h5AddressToast.vue
11.9 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
<template>
<div class="toast_mask" @touchmove.stop.prevent>
<div class="pointsToast_box">
<div class="title">填写配送地址</div>
<!--地址-->
<div class="address">
<div v-if="addressInfo">
<div class="userinfo_box">
<div class="user_info">
<div v-if="addressInfo.name">
{{ addressInfo.name }}
</div>
<div v-if="addressInfo.phone">
{{ addressInfo.phone }}
</div>
</div>
<div @click="changeAddress()" class="btn">更换</div>
</div>
<div v-if="addressInfo.address" class="info">
{{ addressInfo.address }}
</div>
</div>
<div class="tooltips" v-else @click="changeAddress()">
您未填写地址,去填写
</div>
</div>
<!--商品-->
<!-- <div v-if="itemInfo" class="goods_box">
<img v-if="itemInfo && itemInfo.img" v-lazy="itemInfo.img" />
<div class="goods_info">
<div v-if="itemInfo && itemInfo.title" class="goods_title">
{{ itemInfo.title }}
</div>
</div>
</div> -->
<!--底部按钮-->
<div class="footer">
<div @click="cancel" class="cancel">取消</div>
<div @click="confirm" class="confirm">确认</div>
</div>
</div>
<img @click="$parent.pointsToast_control=false" class="pointsMall_close" src="static/img/addressClose.png" alt=""/>
</div>
</template>
<script>
import { Toast, Indicator } from "mint-ui";
export default {
name: "pointsToast",
data () {
return {
itemInfo: null,
addressInfo: null,
goodsId: this.$route.query.goodsId || null, // 兑换商品ID
orderId: this.$route.query.orderId || null, // 订单ID 先兑换后填地址使用
// drawRecordItemInfo: null // 中奖记录单条信息
};
},
props: ["isBuyLimit"],
created () {
// 判断 安卓还是ios获取回选的地址url地址
let addressId;
if (this.isiPhone.value) {
addressId = this.$route.query.addressId;
} else {
addressId = window.localStorage.getItem("addressId") || this.$route.query.addressId;
}
if (addressId) {
this.getaddressInfo(addressId);
} else {
// 获取我的首选地址
// this.myFirstAddress();
}
//地址之后的回选
var id = this.$route.query.id;
if (id) {
this.luckDrawGift(id);
}
// 兑换商品
// console.log(this.itemInfo)
},
methods: {
// 父组件点击兑换调用子组件传值商品商品信息
getItemInfo (content, orderId) {
this.itemInfo = content;
if (orderId) {
this.orderId = orderId
} else {
this.goodsId = content.id; // 获取需要兑换商品的ID
}
// 获取商品信息接口
this.luckDrawGift(content.id);
// 获取首选地址接口
this.myFirstAddress();
// 存取抽奖记录选中的列表数据
// this.$set(this, "drawRecordItemInfo", content.drawRecordItemInfo);
},
// 我的首选地址
/**
* 我的首选地址
* * @param {string} uid [用户id]
*/
myFirstAddress () {
// 加载中提示
// Indicator.open('加载中...');
// 请求接口
this.http(
"/Api/" + this.getApiVersion().index + "/myFirstAddress",
{
uid: this.getStore("uid")
},
this.myFirstAddressCallback,
{
method: "POST"
}
);
},
/**
* 我的首选地址信息
* @param {object} res [服务器返回数据]
* @param {object} ext [扩展参数]
*/
myFirstAddressCallback (res, ext) {
// 加载完成
// Indicator.close();
// 返回处理
if (res.code == 200) {
// 解构数据
let { data: datas } = res;
this.addressInfo = datas;
/* 我的首选地址信息 开始 */
} else if (res.code == 400) {
// 获取积分商场首页信息失败
// Toast(res.message);
} else {
// 获取积分商场首页信息失败
// Toast("获取我的首选地址失败");
}
},
/**
* 选中的地址
* * @param {string} uid [用户id]
*/
getaddressInfo (addressId) {
// 加载中提示
// Indicator.open('加载中...');
// 请求接口
this.http(
"/Api/" + this.getApiVersion().index + "/addressInfo",
{
id: addressId
},
this.getaddressInfoCallback,
{
method: "POST"
}
);
},
/**
* 选中的地址
* @param {object} res [服务器返回数据]
* @param {object} ext [扩展参数]
*/
getaddressInfoCallback (res, ext) {
// 加载完成
// Indicator.close();
// 返回处理
if (res.code == 200) {
// 解构数据
let { data: datas } = res;
this.addressInfo = datas;
/* 获取选中的地址失败 开始 */
} else if (res.code == 400) {
// 获取选中的地址失败
Toast(res.message);
} else {
// 获取选中的地址失败
Toast("获取选中的地址失败");
}
},
/**
* 选中的商品信息
* * @param {string} uid [用户id]
*/
luckDrawGift (id) {
// 加载中提示
// Indicator.open('加载中...');
// 请求接口
this.http(
"/Api/" + this.getApiVersion().LuckDraw + "/luckDrawGift",
{
uid: this.getStore("uid"),
id: id
},
this.luckDrawGiftCallback,
{
method: "POST"
}
);
},
/**
* 选中的兑换商品信息
* @param {object} res [服务器返回数据]
* @param {object} ext [扩展参数]
*/
luckDrawGiftCallback (res, ext) {
// 加载完成
// Indicator.close();
// 返回处理
if (res.code == 200) {
// 解构数据
let { data: datas } = res;
this.itemInfo = datas;
// console.log(this.itemInfo)
/* 获取选中的地址失败 开始 */
} else if (res.code == 400) {
// 获取选中的兑换商品信息失败
Toast(res.message);
} else {
// 获取选中的兑换商品信息失败
Toast("获取选中的兑换商品信息失败");
}
},
/**
* 取消
*/
cancel () {
// 隐藏弹框
this.$parent.pointsToast_control = false;
// 安卓手机下特殊处理
if (this.isAndroid.value) {
// 安卓下清除locaStroe的ext和addressId数据
window.localStorage.removeItem("ext");
window.localStorage.removeItem("addressId");
}
// 清除URL数据pointsToast_control
window.location.href =
window.location.href.split("?")[0] +
"?uid=" +
this.getStore("uid") + "&goodsId=" + this.$route.query.goodsId
},
/**
* 确定
*/
confirm () {
debugger
// 兑换商品的ID分两种一种是订单ID填写地址;一种是有商品地址填写地址
let orderInfo = {
addressId: null,
id: null, // 兑换商品ID
};
if (this.$route.query.orderId || this.orderId) {
orderInfo = {
addressId: this.$route.query.addressId || this.addressInfo.id,
id: this.$route.query.orderId || this.orderId, // 兑换商品ID
};
} else if (this.$route.query.goodsId || this.goodsId) {
orderInfo = {
addressId: this.$route.query.addressId || this.addressInfo.id,
id: this.$route.query.goodsId || this.goodsId, // 兑换商品ID
};
}
// 安卓手机下特殊处理
if (this.isAndroid.value) {
// 兑换商品的ID分两种一种是订单ID填写地址;一种是有商品地址填写地址
if (this.getParameterByName("orderId") || this.orderId) {
orderInfo.id = this.getParameterByName("orderId") || this.orderId
} else if (this.getParameterByName("goodsId") || this.goodsId) {
orderInfo.id = this.getParameterByName("goodsId") || this.goodsId
}
orderInfo.addressId = window.localStorage.getItem("addressId") || this.addressInfo.id
orderInfo.pointsToast_control = this.getParameterByName("pointsToast_control")
// 安卓下清除locaStroe的ext和addressId数据
window.localStorage.removeItem("ext");
window.localStorage.removeItem("addressId");
} else {
window.location.href =
window.location.href.split("?")[0] +
"?uid=" +
this.getStore("uid") + "&goodsId=" + this.$route.query.goodsId || this.goodsId
}
// 最新地址信息回传给父组件
this.$parent.addressInfo = this.addressInfo;
this.addLuckDrawAddress(orderInfo);
// 隐藏弹框
this.$parent.pointsToast_control = false;
},
// 更改地址
changeAddress () {
// 安卓手机两次更改地址goodsId没拿到从
if (this.isAndroid.value) {
// 处理商品ID问题
if (!this.goodsId) {
let ext = "&" + window.localStorage.getItem("ext")
this.goodsId = this.getParameterByName(
"goodsId",
ext
);
}
// 处理商品ID问题
if (!this.orderId) {
let ext = "&" + window.localStorage.getItem("ext")
this.orderId = this.getParameterByName(
"orderId",
ext
);
}
// 处理填写地址弹框显示记录
// let storageExt = "&pointsToast_control=true"
// window.localStorage.setItem("ext", storageExt)
}
// 测试环境
window.location.href =
this.getApiVersion().addAddresss +
"html/mall/1/#/pages/users/addressList/addressList" +
"?uid=" +
this.getStore("uid") +
"&ext=" +
encodeURIComponent(
"goodsId=" +
this.goodsId +
"&orderId=" +
this.orderId +
"&pointsToast_control=" +
this.$parent.pointsToast_control
) +
"&from=redirect&redirect=" +
encodeURIComponent(window.location.href.split("?")[0]);
},
// 提交中奖的商品信息
/**
* 提交中奖的商品信息
* * @param {string} addressId [地址id]
* *@param {string} id [商品id]
* *@param {string} id_card [身份证id]
*/
addLuckDrawAddress (orderInfo) {
// 加载中提示
Indicator.open("加载中...");
// 请求接口
this.http(
"/Api/" + this.getApiVersion().LuckDraw + "/addLuckIntegralAddress",
{
uid: this.getStore("uid"),
addressId: orderInfo.addressId,
id: orderInfo.id // 商品ID
},
this.addLuckDrawAddressCallback,
{
method: "POST",
ext: orderInfo
}
);
},
/**
* 提交中奖的商品信息
* @param {object} res [服务器返回数据]
* @param {object} ext [扩展参数]
*/
addLuckDrawAddressCallback (res, ext) {
// 加载完成
Indicator.close();
// 返回处理
if (res.code == 200) {
Toast("提交成功等待发货");
this.$emit("toUpdate", ext.ext, this.addressInfo);
} else {
// 兑换礼品失败
Toast(res.message);
}
}
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less">
@import './h5AddressToast';
</style>