瀏覽代碼

Merge remote-tracking branch 'origin/master'

Kirin 3 年之前
父節點
當前提交
c3b9a0d25b
共有 1 個文件被更改,包括 38 次插入19 次删除
  1. 38 19
      app/admin/view/store/placeorder/index.php

+ 38 - 19
app/admin/view/store/placeorder/index.php

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