homeNologin.js
3.3 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
import {
request
} from "../../request/index.js"
const a = getApp()
Page({
data: {
imagesUrl: a.globalData.baseUrl,
swiperList: {},
id: '',
way: 2
},
onShow: function () {},
onLoad: function (options) {
// console.log(options);
this.setData({
id: options.id
})
this.getStoreList()
},
async getStoreList() {
let that = this
try {
const {
data: {
data
}
} = await request({
url: 'api/active/orderDetail',
data: {
id: that.data.id
}
})
// console.log(data);
that.setData({
swiperList: data,
})
} catch (err) {
// console.log(err);
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
cancelRefund(e) { // 取消退款
let that = this
wx.showModal({
title: '提示',
content: '确定要取消退款吗?',
success: async function (res) {
if (res.confirm) {
try {
const {
data
} = await request({
url: 'api/active/qvTui',
data: {
order_no: e.currentTarget.dataset.order_no
}
})
// console.log(data, "取消退款");
if (data.code == 1) {
a.popSuccessTest(data.msg)
setTimeout(() => {
// that.getMyorder()
wx.navigateBack()
}, 800);
}
} catch (err) {
a.popTest(err.msg)
}
} else {
}
}
})
},
async cancelOrder(e) {
let that = this
let id = e.currentTarget.dataset.id
that.Subscribe()
try {
const {
data
} = await request({
url: 'api/active/tuiOrder',
data: {
id: id
}
})
// console.log(data);
that.setData({
msg: data.msg
})
that.popSuccessTest()
// setTimeout(() => {
// wx.navigateBack()
// }, 1500);
} catch (err) {
// console.log(err);
that.setData({
msg: err.msg
})
that.popMaskTest()
}
},
//调起订阅消息 /退款通知
Subscribe() {
return new Promise((resolve, reject) => {
wx.requestSubscribeMessage({
tmplIds: ["dLkIUNEHhOTyzKeh5qWDgecUT8KR11MsC6vZfin8s2o"],
success: (res) => {
if (res['dLkIUNEHhOTyzKeh5qWDgecUT8KR11MsC6vZfin8s2o'] === 'accept') {
wx.showToast({
title: '订阅OK!',
duration: 1000,
success(data) {
//成功
resolve()
},
})
}
wx.navigateBack()
},
fail(err) {
//失败
console.error(err);
wx.navigateBack()
reject()
}
})
})
},
popSuccessTest() {
wx.showToast({
title: this.data.msg,
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
duration: 2000, //停留时间
})
},
popMaskTest() {
wx.showToast({
title: this.data.msg,
duration: 2000,
icon: 'none',
mask: true //是否有透明蒙层,默认为false
//如果有透明蒙层,弹窗的期间不能点击文档内容
})
},
})