浏览代码

Merge branch '2.1.0' of http://git.ycjcjy.com/SpaceOfCheng/wechat into 2.1.0

yuantianjiao 6 年前
父节点
当前提交
32042609e6

+ 41
- 1
src/pages/user/placeOrder/index.vue 查看文件

@@ -207,6 +207,7 @@ export default {
207 207
     ...caseTableActions([
208 208
       'getGoodsTypeList',
209 209
       'getGoodsList',
210
+      'toPayBefore',
210 211
       'toPay',
211 212
     ]),
212 213
     ...mapCaseActions([
@@ -215,7 +216,46 @@ export default {
215 216
     toPlaceOrder () { // 下单 
216 217
       if (this.selGoods.length) {
217 218
         if (this.userInfo.customer.MapUser === '' || (this.userInfo.customer.MapUser !== '' && sessionStorage.getItem('from') !== 'sales')) {
218
-          this.$router.push({ name: 'placeOrderDetail', query: { info: JSON.stringify(this.selGoods), caseid: encodeURI(this.caseId), areaid: encodeURI(this.areaId), areaname: encodeURI(this.areaName), areaid: encodeURI(this.areaId), tableid: encodeURI(this.tableId), tableno: encodeURI(this.tableNo) } })
219
+          if (this.ajaxOff) {
220
+            this.ajaxOff = false
221
+            this.postData.info.OrgId = this.orgId
222
+            this.postData.info.UserId = this.userInfo.CustomerId
223
+            this.postData.info.UserName = this.userInfo.customer.CustomerName
224
+            this.postData.info.PayType = 'sys user'
225
+            this.postData.info.Remark = ''
226
+            this.postData.from = sessionStorage.getItem('from') ? sessionStorage.getItem('from') : ''
227
+            var orderInfo = this.selGoods
228
+            this.postData.detail = []
229
+            var amount = 0
230
+            var num = 0
231
+            for (var n = 0; n < orderInfo.length; n++) {
232
+              this.postData.detail.push({
233
+                GoodsId: orderInfo[n].id,
234
+                GoodsName: orderInfo[n].name,
235
+                SpecId: orderInfo[n].spec,
236
+                SpecName: orderInfo[n].specname,
237
+                Number: orderInfo[n].num - 0,
238
+                Price: String(orderInfo[n].price - 0),
239
+              })
240
+              amount += (orderInfo[n].price - 0) * orderInfo[n].num
241
+              num += orderInfo[n].num - 0
242
+            }
243
+            this.postData.info.Amount = String(amount)
244
+            this.postData.info.OrdersNum = num
245
+            // console.log(JSON.stringify(this.postData))
246
+            this.toPayBefore({
247
+              info: JSON.stringify(this.postData.info),
248
+              detail: JSON.stringify(this.postData.detail),
249
+              customercouponid: '',
250
+              from: this.postData.from
251
+            }).then((res) => {
252
+              // console.log(JSON.stringify(res))
253
+              this.ajaxOff = true
254
+              this.$router.push({ name: 'placeOrderDetail', query: { info: JSON.stringify(this.selGoods), caseid: encodeURI(this.caseId), areaid: encodeURI(this.areaId), areaname: encodeURI(this.areaName), areaid: encodeURI(this.areaId), tableid: encodeURI(this.tableId), tableno: encodeURI(this.tableNo), ordersid: res.OrdersId } })
255
+            }).catch(() => {
256
+              this.ajaxOff = true
257
+            })
258
+          }
219 259
         } else {
220 260
           this.showCalcMenu = true
221 261
         }

+ 3
- 27
src/pages/user/placeOrderDetail/index.vue 查看文件

@@ -211,34 +211,10 @@ export default {
211 211
     toPayer () { // 下单
212 212
       if (this.ajaxoff) {
213 213
         this.ajaxoff = false
214
-        this.postData.info.OrgId = this.orgId
215
-        this.postData.info.UserId = this.userInfo.CustomerId
216
-        this.postData.info.UserName = this.userInfo.customer.CustomerName
217
-        this.postData.info.PayType = this.postData.customercouponid === '' ? 'coupon' : 'vip'
218
-        var orderInfo = JSON.parse(this.$route.query.info)
219
-        this.postData.detail = []
220
-        var amount = 0
221
-        var num = 0
222
-        for (var n = 0; n < orderInfo.length; n++) {
223
-          this.postData.detail.push({
224
-            GoodsId: orderInfo[n].id,
225
-            GoodsName: orderInfo[n].name,
226
-            SpecId: orderInfo[n].spec,
227
-            SpecName: orderInfo[n].specname,
228
-            Number: orderInfo[n].num - 0,
229
-            Price: String(orderInfo[n].price - 0),
230
-          })
231
-          amount += (orderInfo[n].price - 0) * orderInfo[n].num
232
-          num += orderInfo[n].num - 0
233
-        }
234
-        this.postData.info.Amount = String(amount)
235
-        this.postData.info.OrdersNum = num
236
-        console.log(JSON.stringify(this.postData))
237 214
         this.toPay({
238
-          info: JSON.stringify(this.postData.info),
239
-          detail: JSON.stringify(this.postData.detail),
240
-          customercouponid: this.postData.customercouponid || '',
241
-          from: ''
215
+          id: this.$route.query.ordersid,
216
+          remark: this.postData.info.Remark,
217
+          customercouponid: this.postData.customercouponid
242 218
         }).then((res) => {
243 219
           this.showSuccessPopup = true
244 220
           // this.$dialog.alert({

+ 21
- 3
src/store/placeOrderForCoffee/index.js 查看文件

@@ -63,10 +63,10 @@ export default {
63 63
         })
64 64
       })
65 65
     },
66
-    toPay (context, { info, detail, customercouponid, from }) { // 下单
66
+    toPayBefore (context, { info, detail, customercouponid, from }) { // 下单
67 67
       return new Promise((resolve, reject) => {
68
-        Ajax(api.caseForCoffee.placeGoodsOrder.url, {
69
-          method: api.caseForCoffee.placeGoodsOrder.method,
68
+        Ajax(api.caseForCoffee.placeGoodsOrderBefore.url, {
69
+          method: api.caseForCoffee.placeGoodsOrderBefore.method,
70 70
           data: {
71 71
             info,
72 72
             detail,
@@ -80,6 +80,24 @@ export default {
80 80
         })
81 81
       })
82 82
     },
83
+    toPay (context, payload) { // 下单
84
+      return new Promise((resolve, reject) => {
85
+        Ajax(api.caseForCoffee.placeGoodsOrder.url, {
86
+          method: api.caseForCoffee.placeGoodsOrder.method,
87
+          urlData: {
88
+            id: payload.id
89
+          },
90
+          data: {
91
+            remark: payload.remark,
92
+            customercouponid: payload.customercouponid
93
+          }
94
+        }).then(res => {
95
+          resolve(res)
96
+        }).catch(() => {
97
+          reject()
98
+        })
99
+      })
100
+    },
83 101
     getCouponList (context) { // 获取优惠券列表
84 102
       return new Promise((resolve) => {
85 103
         Ajax(api.caseForCoffee.getCouponList.url, {

+ 5
- 1
src/util/api.js 查看文件

@@ -47,10 +47,14 @@ const $api = {
47 47
       method: 'get',
48 48
       url: `${baseUrl}${guest}/goods`
49 49
     },
50
-    placeGoodsOrder: { // 商品下单
50
+    placeGoodsOrderBefore: { // 商品下单
51 51
       method: 'post',
52 52
       url: `${baseUrl}${wechat}/order/goods`
53 53
     },
54
+    placeGoodsOrder: { // 商品下单
55
+      method: 'put',
56
+      url: `${baseUrl}${wechat}/order/goods/:id`
57
+    },
54 58
     getCouponList: { // 获取优惠券列表
55 59
       method: 'get',
56 60
       url: `${baseUrl}${wechat}/customer/coupon`