【订单详情】

1. 购物车数量、添加
2. 提交订单
pull/1/MERGE
YunaiV 2023-06-07 20:23:44 +08:00
parent c9f3f7f6ff
commit dcbe6241f0
4 changed files with 137 additions and 187 deletions

View File

@ -438,23 +438,3 @@ export function extractUser() {
export function spreadPeoCount() {
return request.get("spread/people/count");
}
/*
统计
*
*/
export function computeUser(){
uni.request({
url: document.location.protocol + '//shop.crmeb.net/index.php/admin/server.upgrade_api/updatewebinfo',
method:'POST',
data: {
host:window.location.host,
https:document.location.protocol,
version:'CRMEB-JAVA-KY-V1.3.4',
version_code:'gitee',
ip:Cache.has('Ip') ? Cache.get('Ip') : ''
},
dataType:'json',
success: (res) => {}
});
}

View File

@ -53,13 +53,16 @@
</view>
</view>
</view>
<!-- TODO 芋艿拼团 -->
<view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock > 0 && attr.productSelect.quota > 0"
@click="goCat">我要参团</view>
<view class="joinBnt on"
v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
<view class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock" @click="goCat"></view>
<!-- <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock && attr.productSelect.quota" @click="goCat"></view> -->
<view class="joinBnt on" v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
<!-- TODO 芋艿购物车 -->
<view class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock"
@click="goCat">确定</view>
<view class="joinBnt on"
v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
</view>
<view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
</view>
@ -80,15 +83,15 @@
type: Number,
value: 0
},
iSbnt: {
iSbnt: { //
type: Number,
value: 0
},
iSplus: {
iSplus: { // + -
type: Number,
value: 0
},
iScart: {
iScart: { //
type: Number,
value: 0
}
@ -105,15 +108,18 @@
* 购物车手动输入数量
*/
bindCode: function(e) {
// TODO
this.$emit('iptCartNum', this.attr.productSelect.cart_num);
},
closeAttr: function() {
this.$emit('myevent');
this.attr.cartAttr = false
},
CartNumDes: function() {
// TODO
this.$emit('ChangeCartNum', false);
},
CartNumAdd: function() {
// TODO
this.$emit('ChangeCartNum', true);
},
/**
@ -125,6 +131,7 @@
clickProperty: function(indexw, indexn) {
this.$set(this.attr.properties[indexw], 'index', this.attr.properties[indexw].values[indexn].name);
let newSkuKey = this.getCheckedValueNames().join(",");
// TODO ChangeAttr selectSku
this.$emit("ChangeAttr", newSkuKey);
},
/**

View File

@ -178,10 +178,10 @@
<view class='iconfont icon-shoucang' v-else></view>
<view>收藏</view>
</view>
<navigator open-type='switchTab' class="animated item" :class="animated ? 'bounceIn':''"
<navigator open-type='switchTab' class="animated item" :class="cartAnimated ? 'bounceIn':''"
url='/pages/order_addcart/order_addcart' hover-class="none">
<view class='iconfont icon-gouwuche1'>
<text v-if="CartCount > 0" class='num bg-color'>{{CartCount}}</text>
<text v-if="cartCount > 0" class='num bg-color'>{{ cartCount }}</text>
</view>
<view>购物车</view>
</navigator>
@ -224,7 +224,6 @@
:attr="attr"
:isShow='1'
:iSplus='1'
@myevent="onMyEvent"
@ChangeAttr="ChangeAttr"
@ChangeCartNum="ChangeCartNum"
@iptCartNum="iptCartNum"
@ -285,7 +284,6 @@
import {
collectAdd,
collectDel,
postCartAdd,
getReplyConfig,
getProductGood,
getReplyProduct
@ -294,13 +292,9 @@
import {
getCoupons
} from '@/api/api.js';
import {
getCartCounts
} from '@/api/order.js';
import {
toLogin
} from '@/libs/login.js';
import {computeUser} from "@/api/user.js";
import {
mapGetters
} from "vuex";
@ -315,6 +309,7 @@
import home from '@/components/home';
import parser from "@/components/jyf-parser/jyf-parser";
import * as ProductSpuApi from '@/api/product/spu.js';
import * as TradeCartApi from '@/api/trade/cart.js';
import * as Util from '@/utils/util.js';
import * as ProductUtil from '@/utils/product.js';
// #ifdef MP
@ -360,8 +355,8 @@
properties: [],
productSelect: {} // SKU
},
CartCount: 0, //
animated: false, //
cartCount: 0, //
cartAnimated: false, //
replyCount: 0, // TODO
reply: [], //
replyChance: 0, // TODO
@ -370,7 +365,6 @@
cart_num: 1, // TODO
isAuto: false, // TODO
isShowAuth: false, // TODO
isOpen: false, // TODO attr.cartAttr
actionSheetHidden: true, // TODO
storeImage: '', // // TODO
PromotionCode: '', // // TODO
@ -439,11 +433,9 @@
that.retunTop = false
}
that.navH = app.globalData.navHeight;
// #ifdef H5
computeUser();
// #endif
// #ifdef MP || APP-PLUS
// id
// TODO
setTimeout(()=>{
if(options.spread){
app.globalData.spread = options.spread;
@ -457,7 +449,6 @@
},
});
if (!options.scene && !options.id) {
this.showSkeleton = false;
this.$util.Tips({
title: '缺少参数无法查看商品'
}, {
@ -474,7 +465,6 @@
setTimeout(()=>{
spread(mapeMpQrCodeValue.spread).then(res => {}).catch(res => {})
},2000)
} else {
this.id = options.id;
}
@ -569,9 +559,10 @@
/**
* 购物车手动填写
*
* @param number 数量
*/
iptCartNum: function(e) {
this.$set(this.attr.productSelect, 'cart_num', e ? e : 1);
iptCartNum: function(number) {
this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
},
// 退
returns: function() {
@ -579,7 +570,6 @@
},
tap: function(index) {
var id = "past" + index;
var index = index;
var that = this;
this.$set(this, 'toView', id);
this.$set(this, 'navActive', index);
@ -653,27 +643,27 @@
},
/**
* 购物车数量加和数量减
*
* @param changeValue true 增加false 减少
*/
ChangeCartNum: function(changeValue) {
//changeValue: |
//
let productSelect = this.skuMap[this.attrValue];
//,
if (productSelect === undefined && !this.attr.properties.length)
productSelect = this.attr.productSelect;
//0
if (productSelect === undefined) return;
let stock = productSelect.stock || 0;
let num = this.attr.productSelect;
// sku
let sku = this.attr.productSelect;
if (!sku) {
return;
}
//
let stock = sku.stock || 0;
if (changeValue) {
num.cart_num++;
if (num.cart_num > stock) {
sku.cart_num++;
if (sku.cart_num > stock) {
this.$set(this.attr.productSelect, "cart_num", stock);
this.$set(this, "cart_num", stock);
}
} else {
num.cart_num--;
if (num.cart_num < 1) {
sku.cart_num--;
if (sku.cart_num < 1) {
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "cart_num", 1);
}
@ -739,7 +729,7 @@
this.$nextTick(() => {
if (good_list.length) {
this.setClientHeight();
};
}
})
});
},
@ -758,7 +748,7 @@
that.$set(that, 'userCollect', res.data.userCollect); // TODO
that.$set(that.attr, 'properties', ProductUtil.convertProductPropertyList(skus));
that.$set(that, 'skuMap', ProductUtil.convertProductSkuMap(skus));
that.$set(that.sharePacket, 'priceName', res.data.priceName);
that.$set(that.sharePacket, 'priceName', res.data.priceName); // TODO share packet
that.$set(that.sharePacket, 'isState', Math.floor(res.data.priceName) === 0);
that.$set(that, 'activityH5', res.data.activityAllH5 ? res.data.activityAllH5 : []);
//
@ -828,7 +818,7 @@
that.$set(that, 'topArr', topArr);
that.$set(that, 'heightArr', heightArr);
});
};
}
},
/**
* 拨打电话
@ -924,8 +914,6 @@
that.$set(that.coupon, 'coupon', false);
},
/**
*
*
* 收藏商品
*/
setCollect: function() {
@ -949,7 +937,6 @@
*/
openAttr: function() {
this.$set(this.attr, 'cartAttr', true);
this.$set(this, 'isOpen', true);
},
/**
* 打开优惠券插件
@ -963,75 +950,50 @@
that.$set(that.coupon, 'coupon', true);
}
},
onMyEvent: function() {
this.$set(this.attr, 'cartAttr', false);
this.$set(this, 'isOpen', false);
},
/**
* 打开属性加入购物车
*
*/
joinCart: function(e) {
//
if (this.isLogin === false) {
joinCart: function() {
//
if (!this.isLogin) {
toLogin();
} else {
this.goCat(1);
return;
}
},
/*
* 加入购物车
*/
goCat: function(num) {
let that = this,
productSelect = that.skuMap[this.attrValue];
//
if (that.attrValue) {
//
that.attr.cartAttr = !that.isOpen ? true : false;
} else {
if (that.isOpen) that.attr.cartAttr = true;
else that.attr.cartAttr = !that.attr.cartAttr;
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return
}
//
if (that.attr.cartAttr === true && that.isOpen === false)
return (that.isOpen = true);
//,,
if (
that.attr.properties.length &&
productSelect.stock === 0 &&
that.isOpen === true
)
//
let sku = this.attr.productSelect;
if (sku.stock === 0) {
return that.$util.Tips({
title: "产品库存不足,请选择其它"
});
if (num === 1) {
let q = {
productId: parseFloat(that.id),
cartNum: parseFloat(that.attr.productSelect.cart_num),
isNew: false,
propertiesUnique: that.attr.productSelect !== undefined ?
that.attr.productSelect.unique : that.productInfo.id
};
postCartAdd(q).then(function(res) {
that.isOpen = false;
that.attr.cartAttr = false;
that.$util.Tips({
}
//
TradeCartApi.addCart({
count: sku.cart_num,
skuId: sku.id,
addStatus: true // TODO addStatus
}).then(res => {
// attr
this.attr.cartAttr = false;
//
this.$util.Tips({
title: "添加购物车成功",
success: () => {
that.getCartCount(true);
this.getCartCount(true);
}
});
})
.catch(res => {
that.isOpen = false;
return that.$util.Tips({
}).catch(res => {
this.$util.Tips({
title: res
});
});
} else {
this.getPreOrder();
}
},
/**
* 获取购物车数量
@ -1039,40 +1001,42 @@
* @param isAnima 是否展示购物车动画和重置属性
*/
getCartCount: function(isAnima) {
let that = this;
const isLogin = that.isLogin;
if (isLogin) {
getCartCounts(true, 'total').then(res => {
that.CartCount = res.data.count;
const isLogin = this.isLogin;
if (!isLogin) {
return
}
TradeCartApi.getCartCount().then(res => {
this.cartCount = res.data;
//
if (isAnima) {
that.animated = true;
setTimeout(function() {
that.animated = false;
this.cartAnimated = true;
setTimeout(() => {
this.cartAnimated = false;
}, 500);
}
});
}
},
/**
* 立即购买
*/
goBuy: function(e) {
if (this.isLogin === false) {
goBuy: function() {
//
if (!this.isLogin) {
toLogin();
} else {
this.goCat(0);
return;
}
},
/**
* 预下单
*/
getPreOrder: function() {
this.$Order.getPreOrder(this.type === 'normal' ? 'buyNow' : 'video', [{
"attrValueId": parseFloat(this.attr.productSelect.unique),
"productId": parseFloat(this.id),
"productNum": parseFloat(this.attr.productSelect.cart_num)
}]);
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return;
}
//
let sku = this.attr.productSelect;
uni.navigateTo({
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
});
},
//
authColse: function(e) {
@ -1080,7 +1044,6 @@
},
/**
* 分享打开
*
*/
listenerActionSheet: function() {
if (this.isLogin === false) {

View File

@ -19,5 +19,5 @@ export function base64src(base64data, cb) {
return (new Error('ERROR_BASE64SRC_WRITE'));
},
});
};
}
//module.exports = base64src;