Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

Kirin 3 tahun lalu
induk
melakukan
5b49065e1e
1 mengubah file dengan 49 tambahan dan 26 penghapusan
  1. 49 26
      app/admin/view/store/placeorder/index.php

+ 49 - 26
app/admin/view/store/placeorder/index.php

@@ -242,7 +242,7 @@
 				</div>
 			</div>
 		</div>
-		
+
 		<script>
 			mpFrame.start(function(Vue) {
 				new Vue({
@@ -280,6 +280,33 @@
 						}
 					},
 					methods: {
+						// 修复订单
+						async orderContrast() {
+							// 开始处理数据
+							const ind = layer.load(2)
+							const that = this;
+							const userCart = (await $eb.axios.get('{:Url("lst")}' + '?uid=' + that.userId))
+								.data.data.valid; //线上购物车商品
+							const shopList = that.shopList; //本地购物车商品
+							const errorCartList = []; //错误数据保存
+							for (let i = 0; i < userCart.length; i++) {
+								const uObj = userCart[i];
+								for (let s = 0; s < shopList.length; s++) {
+									const sObj = shopList[s];
+									// 判断是否同一个商品
+									if (uObj.cartId == sObj.cartId) {
+										// 判断是否数据不对
+										if (+uObj.cart_num < +sObj.num) {
+											// 处理错误数据
+											await that.changeCartShop(sObj.cartId, sObj.num)
+										}
+										break
+									}
+								}
+							}
+							layer.alert('修复成功')
+							layer.close(ind);
+						},
 						//选中用户卡号
 						checkedUserCard(e) {
 							const that = this;
@@ -349,7 +376,7 @@
 							$eb.axios.post('{:Url("clear_cart")}', {
 								uid: that.userId
 							}).then(function(res) {
-								console.log(res, '购物车删除成功')
+								console.log(res, '购物车清空成功')
 							}).catch(function(err) {
 								console.log(err);
 							})
@@ -402,26 +429,16 @@
 								}
 							});
 						},
-						openLoding() {
-							const loading = this.$loading({
-								lock: true,
-								text: 'Loading',
-								spinner: 'el-icon-loading',
-								background: 'rgba(0, 0, 0, 0.7)'
-							});
-							setTimeout(() => {
-								loading.close();
-							}, 2000);
-						},
 						//处理扫码加入商品时间 
 						async getShopNum() {
 							const that = this;
 							if (that.lodingAddCart) {
+								that.shopId = '';
 								iView.Message.warning('扫码速度过快,加入失败')
 								return
 							}
 							that.lodingAddCart = true;
-							await that.isShopNum().catch(()=>{
+							await that.isShopNum().catch(() => {
 								that.lodingAddCart = false;
 							})
 							that.lodingAddCart = false;
@@ -449,9 +466,9 @@
 								$eb.axios.post('{:Url("getBarCode")}' + (orderId ? '?bar_code=' +
 										orderId : ''))
 									.then(function(res) {
-										console.log(res);
+										// console.log(res);
 										const data = res.data.data;
-										console.log(data, '返回数据')
+										// console.log(data, '返回数据')
 										if (that.is_consumer != data.is_consumer) {
 											if (that.is_consumer == 1) {
 												layer.msg('请选择消费券商品', {
@@ -468,6 +485,7 @@
 											//添加到购物车
 											that.addCart(data, num).then(() => {
 												console.log('购物车加入成功');
+
 												resolve()
 											}).catch((err) => {
 												console.log('购物车加入失败');
@@ -544,7 +562,7 @@
 								price: product.price, //商品价格
 								is_consumer: product.is_consumer //商品类型
 							}]).concat(that.shopList);
-							console.log(this, '初始化后this对象')
+							// console.log(this, '初始化后this对象')
 							//初始化该商品为1
 							that.changeCartShop(cartId, num)
 						},
@@ -567,7 +585,7 @@
 						},
 						submit: async function() {
 							let that = this;
-							console.log(that.form.store_id, '当前门店id')
+							// console.log(that.form.store_id, '当前门店id')
 							//当前门店
 							if (!that.form.store_id) {
 								return layer.msg('请选择门店', {
@@ -597,12 +615,12 @@
 								const orderKey = res.data.data.orderKey;
 								let money = await that.computedOrder(orderKey);
 								layer.confirm('订单总金额:¥' + that.allPayMoney.toFixed(2) + '<br/> vip优惠:¥' + ((
-										that.allPayMoney - money.data.data.result.pay_price) > 0 ? (
-										that.allPayMoney - money.data.data.result.pay_price).toFixed(
-										2) : 0) + '<br/> 实际支付:¥' + money.data.data.result.pay_price
+										that.allPayMoney - money.pay_price) > 0 ? (
+										that.allPayMoney - money.pay_price).toFixed(
+										2) : 0) + '<br/> 实际支付:¥' + money.pay_price
 									.toFixed(2), {
-										btn: ['立即支付', '取消'] //按钮
-									}, async function(index) {
+										btn: ['立即支付', '取消', '修复订单'], //按钮
+										yes: async function(index) {
 											layer.close(index);
 											try {
 												//微信
@@ -637,9 +655,14 @@
 											}
 
 										},
-										function(index) {
+										btn2: function(index) {
 											layer.close(index);
-										});
+										},
+										btn3: function(index) {
+											console.log('对比');
+											that.orderContrast();
+										},
+									});
 								console.log(money, '金额计算');
 							} catch (e) {
 								console.log(e)
@@ -677,7 +700,7 @@
 									uid: that.userId
 								}).then(function(res) {
 									//保存订单key
-									ok(res)
+									ok(res.data.data.result)
 								}).catch(function(err) {
 									erro(err)
 								})