许成详 6 yıl önce
ebeveyn
işleme
daa8a9e532

+ 1
- 0
src/pages/sales/coffeeIndex/index.vue Dosyayı Görüntüle

@@ -84,6 +84,7 @@ import caseTableItem from '../../../components/caseTableItem/index'
84 84
 import topCaseInfo from '../../../components/topCaseInfo/index'
85 85
 import myCard from '../../../components/myCard/myCard'
86 86
 import customerCard from '../../../components/customerCard/customerCard'
87
+import { mapState, createNamespacedHelpers } from 'vuex'
87 88
 const { mapActions: actions } = createNamespacedHelpers('app')
88 89
 const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
89 90
 

+ 66
- 110
src/pages/sales/placeOrder/index.vue Dosyayı Görüntüle

@@ -15,7 +15,7 @@
15 15
       <div class="tableInfo flex-h">
16 16
         <div class="flex-item">
17 17
           <div>
18
-            <span>桌号:{{tableNo}}</span>
18
+            <span>桌号:{{postData.info.TableNo}}</span>
19 19
             <!-- <span>本月已用:150杯</span> -->
20 20
           </div>
21 21
         </div>
@@ -66,8 +66,7 @@
66 66
           <i class="iconfont" :class="{'icon-jiantou-up': !showCalcMenu,'icon-jiantou-down': showCalcMenu}" @click="showCalcMenu = true"></i>
67 67
         </div>
68 68
       </div>
69
-      <router-link :to="{name: 'placeOrderDetail', query: {info: JSON.stringify(settlementList), caseid: encodeURI(caseId), areaid: encodeURI(areaId), areaname: encodeURI(areaName), areaid: encodeURI(areaId), tableid: encodeURI(tableId), tableno: encodeURI(tableNo)}}">下单</router-link>
70
-      <!-- <a @click="showCalcMenu = true">下单</a> -->
69
+      <a @click="showCalcMenu = true">下单</a>
71 70
     </div>
72 71
     <orderPopup :show="showPopup" :data="currentSpec" @closePopup="closePopup" @returnData="calcMenus"></orderPopup>
73 72
     <calcMenu :show="showCalcMenu" :totalNum="totalCupNum" :data="settlementList" @returnData="calcMenus" @emptyMenus="emptyMenus" @closeCalcMenu="closeCalcMenu" @placeOrder="placeOrder"></calcMenu>
@@ -88,12 +87,7 @@ export default {
88 87
   data () {
89 88
     const _self = this
90 89
     return {
91
-      tableNo: decodeURI(this.$route.query.tableno),
92
-      tableId: decodeURI(this.$route.query.tableid),
93
-      areaId: decodeURI(this.$route.query.areaid),
94
-      areaName: decodeURI(this.$route.query.areaname),
95 90
       caseName: decodeURI(this.$route.query.casename),
96
-      caseId: decodeURI(this.$route.query.caseid),
97 91
       totalCupNum: 0, // 共计使用杯数
98 92
       showCalcMenu: false, // 显隐已点菜单弹窗
99 93
       currentSpec: null, // 当前选择规格
@@ -102,105 +96,21 @@ export default {
102 96
       totalPrice: 0, // 总价格
103 97
       settlementList: [], // 商品选择清单
104 98
       slideMenusActive: 0, // 左侧菜单选中索引值
105
-      menuList: [ // 商品数据
106
-      //   {
107
-      //   value: '咖啡',
108
-      //   eValue: 'Coffee',
109
-      //   id: '1',
110
-      //   status: 1,
111
-      //   list: [{
112
-      //     img: '',
113
-      //     name: '商品名称',
114
-      //     id: '1-1',
115
-      //     status: 1,
116
-      //     spec: [{
117
-      //       value: '去冰',
118
-      //       id: '1-1-1',
119
-      //       num: 0,
120
-      //       status: 0,
121
-      //       price: '10',
122
-      //     }, {
123
-      //       value: '少冰',
124
-      //       id: '1-1-2',
125
-      //       num: 0,
126
-      //       status: 1,
127
-      //       price: '15',
128
-      //     }, {
129
-      //       value: '正常',
130
-      //       id: '1-1-3',
131
-      //       num: 0,
132
-      //       status: 1,
133
-      //       price: '20',
134
-      //     }, {
135
-      //       value: '多冰',
136
-      //       id: '1-1-4',
137
-      //       num: 0,
138
-      //       status: 1,
139
-      //       price: '25',
140
-      //     }],
141
-      //     price: '100',
142
-      //   }, {
143
-      //     img: '',
144
-      //     name: '商品名称',
145
-      //     id: '1-2',
146
-      //     spec: [],
147
-      //     status: 0,
148
-      //     price: '100',
149
-      //   }, {
150
-      //     img: '',
151
-      //     name: '商品名称',
152
-      //     id: '1-3',
153
-      //     spec: [],
154
-      //     status: 1,
155
-      //     price: '100',
156
-      //   }, {
157
-      //     img: '',
158
-      //     name: '商品名称',
159
-      //     id: '1-4',
160
-      //     spec: [],
161
-      //     status: 1,
162
-      //     price: '100',
163
-      //   }, {
164
-      //     img: '',
165
-      //     name: '商品名称',
166
-      //     id: '1-5',
167
-      //     spec: [],
168
-      //     status: 1,
169
-      //     price: '100',
170
-      //   }, {
171
-      //     img: '',
172
-      //     name: '商品名称',
173
-      //     id: '1-6',
174
-      //     spec: [],
175
-      //     status: 1,
176
-      //     price: '100',
177
-      //   }],
178
-      // }, {
179
-      //   value: '咖啡一',
180
-      //   eValue: 'Coffee',
181
-      //   id: '2',
182
-      //   status: 1,
183
-      //   list: [],
184
-      // }, {
185
-      //   value: '咖啡二',
186
-      //   eValue: 'Coffee',
187
-      //   id: '3',
188
-      //   status: 1,
189
-      //   list: [],
190
-      // }, {
191
-      //   value: '咖啡三',
192
-      //   eValue: 'Coffee',
193
-      //   id: '4',
194
-      //   status: 1,
195
-      //   list: [],
196
-      // }, {
197
-      //   value: '咖啡四',
198
-      //   eValue: 'Coffee',
199
-      //   id: '5',
200
-      //   status: 1,
201
-      //   list: [],
202
-      // }
203
-      ],
99
+      menuList: [],
100
+      postData: {
101
+        info: {
102
+          CaseId: decodeURI(_self.$route.query.caseid),
103
+          AreaId: decodeURI(_self.$route.query.areaid),
104
+          AreaName: decodeURI(_self.$route.query.areaname),
105
+          TableId: decodeURI(_self.$route.query.tableid),
106
+          TableNo: decodeURI(_self.$route.query.tableno),
107
+          Amount: 0,// String(_self.returnAmount()[0]), // 订单金额
108
+          OrdersNum: 0, // Number(_self.returnAmount()[1]),
109
+          Remark: '',
110
+        },
111
+        detail: [],
112
+        coupon: [],
113
+      },
204 114
       swiperOption: {
205 115
         observer: true,
206 116
         direction: 'vertical',
@@ -242,11 +152,11 @@ export default {
242 152
   },
243 153
   created () {
244 154
     this.getGoodsTypeList({
245
-      caseid: this.caseId,
155
+      caseid: this.postData.info.CaseId,
246 156
     }).then((res) => {
247 157
       // console.log(JSON.stringify(res))
248 158
       this.getGoodsList({
249
-        caseid: this.caseId,
159
+        caseid: this.postData.info.CaseId,
250 160
       }).then((res) => {
251 161
         // console.log(JSON.stringify(res))
252 162
         this.mapArr()
@@ -257,7 +167,53 @@ export default {
257 167
     ...caseTableActions([
258 168
       'getGoodsTypeList',
259 169
       'getGoodsList',
170
+      'toPay',
260 171
     ]),
172
+    toPayer () { // 下单
173
+      this.postData.info.Amount = String(this.returnAmount()[0])
174
+      this.postData.info.OrdersNum = Number(this.returnAmount()[1])
175
+      this.postData.info.OrgId = this.orgId
176
+      this.postData.info.UserId = this.userInfo.CustomerId
177
+      this.postData.info.UserName = this.userInfo.CustomerName
178
+      this.postData.info.PayType = this.postData.coupon.length ? 'coupon' : 'vip'
179
+      var orderInfo = this.settlementList
180
+      this.postData.detail = []
181
+      for (var n = 0; n < orderInfo.length; n++) {
182
+        this.postData.detail.push({
183
+          GoodsId: orderInfo[n].id,
184
+          GoodsName: orderInfo[n].name,
185
+          SpecId: orderInfo[n].specId,
186
+          SpecName: orderInfo[n].specName,
187
+          Number: orderInfo[n].defaultNum === null ? orderInfo[n].num - 0 : orderInfo[n].defaultNum - 0,
188
+          Price: orderInfo[n].defaultNum === null ? String(orderInfo[n].price) : String(orderInfo[n].defaultPrice),
189
+        })
190
+      }
191
+      console.log(JSON.stringify(this.postData))
192
+      this.toPay({
193
+        info: JSON.stringify(this.postData.info),
194
+        detail: JSON.stringify(this.postData.detail),
195
+        coupon: JSON.stringify(this.postData.coupon)
196
+      }).then((res) => {
197
+        this.$dialog.alert({
198
+          message: '下单成功!'
199
+        }).then(() => {
200
+          window.history.go(-2)
201
+        })
202
+      })
203
+    },
204
+    returnAmount () { // 返回总金额  
205
+      var amount = 0, num = 0
206
+      for (var n = 0; n < this.settlementList.length; n++) {
207
+        if (this.settlementList[n].defaultPrice === null) {
208
+          amount += this.settlementList[n].price * this.settlementList[n].num
209
+          num += this.settlementList[n].num
210
+        } else {
211
+          amount += this.settlementList[n].defaultPrice * this.settlementList[n].defaultNum
212
+          num += this.settlementList[n].defaultNum
213
+        }
214
+      }
215
+      return [amount, num]
216
+    },
261 217
     mapArr () { // 匹配商品规格
262 218
       var aArr = this.goodsTypeList, bArr = this.goodsList
263 219
       for (var n = 0; n < aArr.length; n++) {
@@ -302,7 +258,7 @@ export default {
302 258
       // console.log(JSON.stringify(this.menuList))
303 259
     },
304 260
     placeOrder () { // 下单
305
-      this.$router.push({ name: 'orderList', query: {} })
261
+      this.toPayer()
306 262
     },
307 263
     closeCalcMenu () { // 关闭已选菜单
308 264
       this.showCalcMenu = false