|
@@ -438,10 +438,11 @@
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
that.lodingAddCart = true;
|
|
that.lodingAddCart = true;
|
|
|
- await that.isShopNum().catch(() => {
|
|
|
|
|
|
|
+ await that.isShopNum().then(() => {
|
|
|
|
|
+ that.lodingAddCart = false;
|
|
|
|
|
+ }).catch(() => {
|
|
|
that.lodingAddCart = false;
|
|
that.lodingAddCart = false;
|
|
|
})
|
|
})
|
|
|
- that.lodingAddCart = false;
|
|
|
|
|
// 处理设置允许获得焦点
|
|
// 处理设置允许获得焦点
|
|
|
that.$nextTick(function() {
|
|
that.$nextTick(function() {
|
|
|
that.$refs.code.focus();
|
|
that.$refs.code.focus();
|
|
@@ -485,7 +486,6 @@
|
|
|
//添加到购物车
|
|
//添加到购物车
|
|
|
that.addCart(data, num).then(() => {
|
|
that.addCart(data, num).then(() => {
|
|
|
console.log('购物车加入成功');
|
|
console.log('购物车加入成功');
|
|
|
-
|
|
|
|
|
resolve()
|
|
resolve()
|
|
|
}).catch((err) => {
|
|
}).catch((err) => {
|
|
|
console.log('购物车加入失败');
|
|
console.log('购物车加入失败');
|
|
@@ -529,12 +529,16 @@
|
|
|
if (ind > -1) {
|
|
if (ind > -1) {
|
|
|
that.shopList[ind].num = (+that.shopList[ind].num + (
|
|
that.shopList[ind].num = (+that.shopList[ind].num + (
|
|
|
+num)).toFixed(3);
|
|
+num)).toFixed(3);
|
|
|
-
|
|
|
|
|
|
|
+ resolve(true)
|
|
|
} else {
|
|
} else {
|
|
|
//初始化商品
|
|
//初始化商品
|
|
|
that.initShopData(product, cartId, (+num).toFixed(3))
|
|
that.initShopData(product, cartId, (+num).toFixed(3))
|
|
|
|
|
+ .then((data) => {
|
|
|
|
|
+ resolve(true)
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ reject(err);
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- resolve(true)
|
|
|
|
|
} else {
|
|
} else {
|
|
|
layer.msg(data.msg, {
|
|
layer.msg(data.msg, {
|
|
|
icon: 5
|
|
icon: 5
|
|
@@ -551,20 +555,26 @@
|
|
|
//初始化购物车商品
|
|
//初始化购物车商品
|
|
|
initShopData(product, cartId, num) {
|
|
initShopData(product, cartId, num) {
|
|
|
const that = this;
|
|
const that = this;
|
|
|
- that.shopList = ([{
|
|
|
|
|
- name: product.store_name, //商品
|
|
|
|
|
- num: num, //购物车中的数量
|
|
|
|
|
- id: product.product_id, //当前商品id
|
|
|
|
|
- cartId: cartId, //保存购物车id
|
|
|
|
|
- typeName: product.suk, //商品规格名称
|
|
|
|
|
- unique: product.unique, //商品规格id
|
|
|
|
|
- image: product.image, //商品主图
|
|
|
|
|
- price: product.price, //商品价格
|
|
|
|
|
- is_consumer: product.is_consumer //商品类型
|
|
|
|
|
- }]).concat(that.shopList);
|
|
|
|
|
- // console.log(this, '初始化后this对象')
|
|
|
|
|
- //初始化该商品为1
|
|
|
|
|
- that.changeCartShop(cartId, num)
|
|
|
|
|
|
|
+ return new Promise((resolve, rejact) => {
|
|
|
|
|
+ that.shopList = ([{
|
|
|
|
|
+ name: product.store_name, //商品
|
|
|
|
|
+ num: num, //购物车中的数量
|
|
|
|
|
+ id: product.product_id, //当前商品id
|
|
|
|
|
+ cartId: cartId, //保存购物车id
|
|
|
|
|
+ typeName: product.suk, //商品规格名称
|
|
|
|
|
+ unique: product.unique, //商品规格id
|
|
|
|
|
+ image: product.image, //商品主图
|
|
|
|
|
+ price: product.price, //商品价格
|
|
|
|
|
+ is_consumer: product.is_consumer //商品类型
|
|
|
|
|
+ }]).concat(that.shopList);
|
|
|
|
|
+ // console.log(this, '初始化后this对象')
|
|
|
|
|
+ //初始化该商品为1
|
|
|
|
|
+ that.changeCartShop(cartId, num).then((data) => {
|
|
|
|
|
+ resolve(data);
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ rejact(err);
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
//修改购物车物品数量
|
|
//修改购物车物品数量
|
|
|
changeCartShop(cartId, num) {
|
|
changeCartShop(cartId, num) {
|
|
@@ -578,12 +588,16 @@
|
|
|
console.log(ok)
|
|
console.log(ok)
|
|
|
ok(res)
|
|
ok(res)
|
|
|
}).catch(function(err) {
|
|
}).catch(function(err) {
|
|
|
|
|
+ layer.msg('购物车加入失败请刷新页面', {
|
|
|
|
|
+ icon: 5
|
|
|
|
|
+ })
|
|
|
erro(err)
|
|
erro(err)
|
|
|
console.log(err);
|
|
console.log(err);
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
submit: async function() {
|
|
submit: async function() {
|
|
|
|
|
+ let confirmData;
|
|
|
let that = this;
|
|
let that = this;
|
|
|
// console.log(that.form.store_id, '当前门店id')
|
|
// console.log(that.form.store_id, '当前门店id')
|
|
|
//当前门店
|
|
//当前门店
|
|
@@ -612,6 +626,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let res = await $eb.axios.post('{:Url("confirm")}', pushData);
|
|
let res = await $eb.axios.post('{:Url("confirm")}', pushData);
|
|
|
|
|
+ confirmData = res.data
|
|
|
const orderKey = res.data.data.orderKey;
|
|
const orderKey = res.data.data.orderKey;
|
|
|
let money = await that.computedOrder(orderKey);
|
|
let money = await that.computedOrder(orderKey);
|
|
|
layer.confirm('订单总金额:¥' + that.allPayMoney.toFixed(2) + '<br/> vip优惠:¥' + ((
|
|
layer.confirm('订单总金额:¥' + that.allPayMoney.toFixed(2) + '<br/> vip优惠:¥' + ((
|
|
@@ -665,6 +680,10 @@
|
|
|
});
|
|
});
|
|
|
console.log(money, '金额计算');
|
|
console.log(money, '金额计算');
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
|
|
+ layer.msg(e.message, {
|
|
|
|
|
+ icon: 5
|
|
|
|
|
+ });
|
|
|
|
|
+ layer.alert(`错误返回数据${JSON.stringify(confirmData)}`, {icon: 0});
|
|
|
console.log(e)
|
|
console.log(e)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|