helpPlaceAnOrder.vue
9.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
<template>
<view class="container">
<Navbar title="帮助下单" canBack></Navbar>
<!-- <u-navbar title="确认订单" autoBack :safeAreaInsetTop="true" placeholder fixed></u-navbar> -->
<view class="orderCss">
<view class="addressBarCss" @click="selectAddress">
<view class="leftCss">
<u-icon name="map" size="25"></u-icon>
</view>
<view class="centerCss w50" v-if="hasAds">
<view class="margin-top">
联系人:{{khxx.khmc || ""}}
</view>
<view class="text-gray margin-top-sm text-sm w100 overflow-one-lines">
详细地址:{{khxx.khlxdzsf }}{{khxx.khlxdzs }}{{khxx.khlxdzq }}{{khxx.khlxdzjd }}{{khxx.khlxdzxxdz }}
</view>
</view>
<view class="centerCss" v-else>
请选择地址
</view>
<view class="rightCss">
<u-icon name="arrow-right" size="20"></u-icon>
</view>
</view>
<view class="shopCardCss">
<view class="flex align-center">
<u-icon name="/static/images/home/shopTitle.png" size="20"></u-icon>
<view class="margin-left-xs">
{{userInfo && userInfo.fssczmc || ""}}
<!-- 利民液化气供应站 -->
</view>
</view>
<view class="flex justify-between align-center">
<view class="flex flex-direction w100" v-if="hasShop">
<view class="flex justify-between margin-top">
<view class="">
<u-image width="80px" height="80px" :src="gasDetail.image"></u-image>
</view>
<view class="flex flex-direction justify-between margin-left-sm w50">
<view class="">
{{gasDetail.fMc}}
</view>
<view class="text-sm text-gray">
{{gasDetail.fMs || ""}}
</view>
<view class="themeColor text-lg text-bold">
¥{{gasDetail.fJg}}
</view>
</view>
<view class="flex flex-direction justify-between align-end">
<view class="margin-top-xs" @click="openPopup('edit')">
<u-icon name="arrow-right" size="20"></u-icon>
</view>
<u-number-box v-model="gasDetail.num" max="100"
@change="gasNumberChange"></u-number-box>
</view>
</view>
<view class="flex justify-between align-center margin-top">
<view class="">
订单备注
</view>
<view class="text-gray">
<u-input inputAlign="right" maxlength="30" v-model="gasDetail.ddbz" border="none"
clearable placeholder="请填写您的备注信息"></u-input>
</view>
</view>
</view>
<view class="flex justify-between align-center w100 margin-top" v-else>
<view class="w100">
<view class="text-center">
请添加气瓶
</view>
</view>
<view class="margin-top-xs" @click="openPopup('add')">
<u-icon name="plus-circle-fill" color="#EA5504" size="20"></u-icon>
</view>
</view>
</view>
</view>
<view class="moneyCardCss">
<view class="flex justify-between flex-direction">
<view class="flex">
提取方式<text class="text-gray">(必选)</text>
</view>
<view class="flex justify-between margin-top">
<view class="">
{{psfs || ""}}
</view>
<view class="" @click="openExtract">
<u-icon name="arrow-right"></u-icon>
</view>
</view>
</view>
</view>
<view class="moneyCardCss">
<view class="flex justify-between">
<view class="">
商品总金额
</view>
<view class="themeColor">
¥{{gasDetail.total}}
</view>
</view>
<view class="flex justify-between margin-top">
<view class="text-gray">
商品金额
</view>
<view class="">
¥{{gasDetail.fJg || 0}}
</view>
</view>
<!-- <view class="flex justify-between margin-top">
<view class="text-gray">
气瓶押金
</view>
<view class="">
¥0.00
</view>
</view> -->
</view>
<view class="bomBarCss">
<view class="themeColor themeFs">
¥{{gasDetail.total || 0}}
</view>
<view class="" @click="submitOrder">
<u-button color="#EA5504">立即下单</u-button>
</view>
</view>
</view>
<u-picker :show="extractShow" :columns="columns" @confirm="handleExtract" @cancel="extractShow = false"
closeOnClickOverlay @close="extractShow = false"></u-picker>
<popupShop ref="popupShopRef" :hxData="gasDetail" @shopData="getShopdata"></popupShop>
</view>
</template>
<script>
import {
mergeRecursive
} from "@/utils/ruoyi";
import storage from '@/utils/storage'
import {
mapGetters
} from 'vuex'
import popupShop from './components/popupShop.vue'
export default {
components: {
popupShop
},
props: {
},
data() {
return {
gasDetail: {
num: 1,
total: 0,
ddbz: ""
},
gasNumber: 1,
hasAds: false,
hasShop: false,
khxx: {},
columns: [
['配送', '自提']
],
psfs: '配送',
extractShow: false,
}
},
computed: {
},
onLoad(data) {
uni.$on('khxxData', (khxx) => {
this.hasAds = true;
this.khxx = khxx;
console.log("获取客户信息", JSON.stringify(this.khxx));
});
this.getStaffQplxPage()
},
onUnload() {
uni.$off('khxxData')
},
async onShow() {
console.log("userInfo", this.userInfo);
// console.log('this.$store',JSON.parse(JSON.stringify(this.$store.state.user.userInfo)));
// await this.getGasDetail();
// this.$store.dispatch('GetDefaultAds').then(async (res) => {
// console.log("是否默认地址",res);
// if(res === 'Default'){
// await this.getAdsDetail();
// }
// }).catch(e => {
// console.log("查询地址错误", e);
// });
},
computed: {
...mapGetters({
adsId: 'adsId'
}),
...mapGetters({
userInfo: 'userInfo'
})
},
methods: {
// 查询气瓶类型列表 默认第一个为当前气瓶
getStaffQplxPage() {
this.$api.orderApi.getStaffQplxPage().then(async res => {
if (res.code === 200) {
let data = res.value;
console.log("气瓶类型列表", data);
let currentGas = data.fqplxList[0];
let JsonParse = JSON.parse(currentGas.fTp);
let images = await this.$getPhotoUrl(JsonParse[0].response.fileId);
this.hasShop = true;
this.gasDetail.qplxID = currentGas.id;
this.gasDetail.fMc = currentGas.fMc;
this.gasDetail.fMs = currentGas.fMs;
this.gasDetail.fJg = currentGas.fJg;
this.gasDetail.total = currentGas.fJg;
this.gasDetail.image = images;
console.log("热销气瓶", currentGas);
}
})
},
openPopup(type) {
console.log(type);
if (type === 'add') {
this.$refs.popupShopRef.open();
} else {
this.$refs.popupShopRef.edit(this.gasDetail);
}
},
openExtract() {
this.extractShow = true;
},
// 选择提取方式
handleExtract(e) {
console.log(e);
let value = e.value[0];
this.psfs = value;
this.extractShow = false;
},
getShopdata(data) {
console.log("获取shopData", data);
this.hasShop = true;
this.gasDetail = {
...data
};
},
gasNumberChange(e) {
let number = e.value;
let price = this.gasDetail.fJg;
// this.qplist.sl = number;
this.gasDetail.total = this.$calcUtil.ride(price, number)
},
selectAddress() {
let adsData = JSON.stringify(this.khxx);
uni.navigateTo({
url: 'improveCustomer?adsData=' + adsData
})
},
async submitOrder() {
if (Object.keys(this.khxx).length == 0) {
uni.$u.toast('未选择配送地址');
return false
}
if (!this.hasShop) {
uni.$u.toast('未选择气瓶');
return false
}
if (!this.psfs) {
uni.$u.toast('未选择配送方式');
return false
}
// 组装提交数据
let helpData = {
khxx: this.khxx, //客户信息
spxx: {
qplxID: this.gasDetail.qplxID,
ddbz: this.gasDetail.ddbz,
num: this.gasDetail.num
},
psfs: this.psfs
}
console.log('待提交数据', JSON.parse(JSON.stringify(helpData)));
this.$modal.confirm('确认提交订单?', '提示').then(async () => {
const result = await this.$api.orderApi.helpCreateOrder(helpData);
let {
code,
value
} = result;
if (code === 200) {
uni.$u.toast('下单成功');
setTimeout(() => {
uni.navigateTo({
url: "/pages/home/appList/helpPlaceAnOrder/orderSuccessful?datas=" +
JSON.stringify(value)
})
}, 500)
console.log("result", result);
}
}).catch(() => {
console.log("取消");
});
}
}
}
</script>
<style lang="scss" scoped>
.orderCss {
margin: 10px;
.orderTopBarCss {
background: #EA5504;
height: 40px;
border-radius: 10px 10px 0 0;
display: flex;
justify-content: center;
align-items: center;
}
.addressBarCss {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 10px;
background: #ffffff;
padding: 10px 10px 20px 10px;
.leftCss {
width: 10%;
}
.centerCss {
width: 80%;
min-height: 50px;
margin-left: 5px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
.rightCss {
width: 10%;
}
}
.addressBarCss {
background-color: #fff;
position: relative;
}
.addressBarCss:before {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 5px;
background: repeating-linear-gradient(-45deg, #A82831, #A82831 20%, transparent 0, transparent 25%, #254A81 0, #254A81 45%, transparent 0, transparent 50%);
background-size: 200px;
content: "";
}
.shopCardCss {
margin-top: 10px;
padding: 20px 10px;
border-radius: 15px;
background: #ffffff;
}
.moneyCardCss {
margin-top: 10px;
padding: 20px 10px;
border-radius: 15px;
background: #ffffff;
}
.bomBarCss {
position: absolute;
width: 100%;
bottom: 0;
left: 0;
padding: 0 20px;
background: #fff;
height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
}
/deep/.bomBarCss .u-button {
border-radius: 10px !important;
width: 120px;
}
}
</style>