Showing
3 changed files
with
94 additions
and
55 deletions
@@ -23,6 +23,8 @@ const yoho = { | @@ -23,6 +23,8 @@ const yoho = { | ||
23 | * 判断是否是 APP | 23 | * 判断是否是 APP |
24 | */ | 24 | */ |
25 | isApp: /yh_blk/i.test(navigator.userAgent || ''), | 25 | isApp: /yh_blk/i.test(navigator.userAgent || ''), |
26 | + isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''), | ||
27 | + isAndroid: /Android/i.test(navigator.userAgent || ''), | ||
26 | 28 | ||
27 | /** | 29 | /** |
28 | * store | 30 | * store |
@@ -362,4 +364,4 @@ const yoho = { | @@ -362,4 +364,4 @@ const yoho = { | ||
362 | } | 364 | } |
363 | }; | 365 | }; |
364 | 366 | ||
365 | -module.exports = yoho; | 367 | +module.exports = yoho; |
@@ -56,7 +56,7 @@ | @@ -56,7 +56,7 @@ | ||
56 | <button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button> | 56 | <button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button> |
57 | </template> | 57 | </template> |
58 | </div> | 58 | </div> |
59 | - <select id="cancel-reason" class="cancel-reason" @blur="reasonChange" @change="reasonChange" v-model="selected"> | 59 | + <select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected"> |
60 | <option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option> | 60 | <option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option> |
61 | </select> | 61 | </select> |
62 | </template> | 62 | </template> |
@@ -79,8 +79,7 @@ | @@ -79,8 +79,7 @@ | ||
79 | order: {}, | 79 | order: {}, |
80 | options: [], | 80 | options: [], |
81 | selected: {}, | 81 | selected: {}, |
82 | - genderSel: {}, | ||
83 | - cancelbusy: false | 82 | + genderSel: {} |
84 | }; | 83 | }; |
85 | }, | 84 | }, |
86 | created() { | 85 | created() { |
@@ -113,7 +112,6 @@ | @@ -113,7 +112,6 @@ | ||
113 | this.show = false; | 112 | this.show = false; |
114 | this.order = {}; | 113 | this.order = {}; |
115 | this.selected = {}; | 114 | this.selected = {}; |
116 | - this.cancelbusy = false; | ||
117 | 115 | ||
118 | this.getOrderData(); | 116 | this.getOrderData(); |
119 | }, | 117 | }, |
@@ -158,31 +156,34 @@ | @@ -158,31 +156,34 @@ | ||
158 | }); | 156 | }); |
159 | }, | 157 | }, |
160 | reasonChange() { | 158 | reasonChange() { |
161 | - if (this.cancelbusy) { | ||
162 | - return false; | ||
163 | - } | 159 | + setTimeout(() => { |
160 | + if (!this.selected.id || document.hidden) { | ||
161 | + return false; | ||
162 | + } | ||
164 | 163 | ||
165 | - this.cancelbusy = true; | ||
166 | - this.orderDetail().cancel({ | ||
167 | - orderCode: this.order.orderCode, | ||
168 | - reasonId: this.selected.id || this.options[0].id, | ||
169 | - reason: this.selected.reason || this.options[0].reason | ||
170 | - }, (result) => { | ||
171 | - if (result.code === 200) { | ||
172 | - tip('取消成功'); | 164 | + this.orderDetail().cancel({ |
165 | + orderCode: this.order.orderCode, | ||
166 | + reasonId: this.selected.id, | ||
167 | + reason: this.selected.reason | ||
168 | + }, (result) => { | ||
169 | + if (result.code === 200) { | ||
170 | + tip({ | ||
171 | + delay: 500, | ||
172 | + txt: '取消成功' | ||
173 | + }); | ||
173 | 174 | ||
174 | - setTimeout(() => { | ||
175 | - this.reload(); | ||
176 | - }, 1000); | 175 | + setTimeout(() => { |
176 | + this.reload(); | ||
177 | + }, 300); | ||
177 | 178 | ||
178 | - yoho.store.set('orderReload', true); | ||
179 | - } else if (result.code !== 500) { | ||
180 | - tip(result.message); | ||
181 | - } | ||
182 | - this.cancelbusy = false; | ||
183 | - }, () => { | ||
184 | - tip('操作失败'); | ||
185 | - }); | 179 | + yoho.store.set('orderReload', true); |
180 | + } else if (result.code !== 500) { | ||
181 | + tip(result.message); | ||
182 | + } | ||
183 | + }, () => { | ||
184 | + tip('操作失败'); | ||
185 | + }); | ||
186 | + }, 700); | ||
186 | }, | 187 | }, |
187 | getCancelReason() { | 188 | getCancelReason() { |
188 | $.ajax({ | 189 | $.ajax({ |
@@ -190,6 +191,12 @@ | @@ -190,6 +191,12 @@ | ||
190 | }).then(result => { | 191 | }).then(result => { |
191 | if (result.data.length > 0) { | 192 | if (result.data.length > 0) { |
192 | this.options = result.data; | 193 | this.options = result.data; |
194 | + if (yoho.isiOS) { | ||
195 | + this.options.unshift({ | ||
196 | + id: 0, | ||
197 | + reason: '请选择' | ||
198 | + }) | ||
199 | + } | ||
193 | } | 200 | } |
194 | }).fail(() => { | 201 | }).fail(() => { |
195 | tip('操作失败'); | 202 | tip('操作失败'); |
@@ -208,10 +215,21 @@ | @@ -208,10 +215,21 @@ | ||
208 | }, | 215 | }, |
209 | autoCancel(code) { | 216 | autoCancel(code) { |
210 | return () => { | 217 | return () => { |
218 | + let reasonId; | ||
219 | + let reason; | ||
220 | + | ||
221 | + if (yoho.isiOS && this.options.length > 1) { | ||
222 | + reasonId = this.options[1].id; | ||
223 | + reason = this.options[1].reason; | ||
224 | + } else if (this.options.length) { | ||
225 | + reasonId = this.options[0].id; | ||
226 | + reason = this.options[0].reason; | ||
227 | + } | ||
228 | + | ||
211 | this.orderDetail().cancel({ | 229 | this.orderDetail().cancel({ |
212 | orderCode: code, | 230 | orderCode: code, |
213 | - reasonId: this.options.length ? this.options[0].id : null, | ||
214 | - reason: this.options.length ? this.options[0].reason : null | 231 | + reasonId: reasonId, |
232 | + reason: reason | ||
215 | }, (result) => { | 233 | }, (result) => { |
216 | if (result.code === 200) { | 234 | if (result.code === 200) { |
217 | this.reload(); | 235 | this.reload(); |
@@ -54,7 +54,7 @@ | @@ -54,7 +54,7 @@ | ||
54 | <p>Your do not have an order <br>for the time being</p> | 54 | <p>Your do not have an order <br>for the time being</p> |
55 | <a href="/product/new">随便逛逛</a> | 55 | <a href="/product/new">随便逛逛</a> |
56 | </div> | 56 | </div> |
57 | - <select id="cancel-reason" class="cancel-reason" @blur="reasonChange" @change="reasonChange" v-model="selected"> | 57 | + <select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected"> |
58 | <option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option> | 58 | <option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option> |
59 | </select> | 59 | </select> |
60 | </template> | 60 | </template> |
@@ -75,7 +75,6 @@ | @@ -75,7 +75,6 @@ | ||
75 | pageTotal: 1, | 75 | pageTotal: 1, |
76 | type: this.$parent.$data.type, | 76 | type: this.$parent.$data.type, |
77 | busy: false, | 77 | busy: false, |
78 | - cancelbusy: false, | ||
79 | emptybox: 'hide', | 78 | emptybox: 'hide', |
80 | currentCode: '', | 79 | currentCode: '', |
81 | selected: {}, | 80 | selected: {}, |
@@ -98,7 +97,6 @@ | @@ -98,7 +97,6 @@ | ||
98 | this.page = 0; | 97 | this.page = 0; |
99 | this.pageTotal = 1; | 98 | this.pageTotal = 1; |
100 | this.busy = false; | 99 | this.busy = false; |
101 | - this.cancelbusy = false; | ||
102 | this.emptybox = 'hide'; | 100 | this.emptybox = 'hide'; |
103 | this.currentCode = ''; | 101 | this.currentCode = ''; |
104 | this.selected = {}; | 102 | this.selected = {}; |
@@ -135,28 +133,31 @@ | @@ -135,28 +133,31 @@ | ||
135 | }); | 133 | }); |
136 | }, | 134 | }, |
137 | reasonChange() { | 135 | reasonChange() { |
138 | - if (this.cancelbusy) { | ||
139 | - return false; | ||
140 | - } | ||
141 | - | ||
142 | - this.cancelbusy = true; | ||
143 | - this.order().cancel({ | ||
144 | - orderCode: this.currentCode, | ||
145 | - reasonId: this.selected.id || this.options[0].id, | ||
146 | - reason: this.selected.reason || this.options[0].reason | ||
147 | - }, (result) => { | ||
148 | - if (result.code === 200) { | ||
149 | - tip('取消成功'); | ||
150 | - setTimeout(() => { | ||
151 | - this.reload(); | ||
152 | - }, 1000); | ||
153 | - } else if (result.code !== 500) { | ||
154 | - tip(result.message); | 136 | + setTimeout(() => { |
137 | + if (!this.selected.id || document.hidden) { | ||
138 | + return false; | ||
155 | } | 139 | } |
156 | - this.cancelbusy = false; | ||
157 | - }, () => { | ||
158 | - tip('操作失败'); | ||
159 | - }); | 140 | + |
141 | + this.order().cancel({ | ||
142 | + orderCode: this.currentCode, | ||
143 | + reasonId: this.selected.id, | ||
144 | + reason: this.selected.reason | ||
145 | + }, (result) => { | ||
146 | + if (result.code === 200) { | ||
147 | + tip({ | ||
148 | + delay: 500, | ||
149 | + txt: '取消成功' | ||
150 | + }); | ||
151 | + setTimeout(() => { | ||
152 | + this.reload(); | ||
153 | + }, 300); | ||
154 | + } else if (result.code !== 500) { | ||
155 | + tip(result.message); | ||
156 | + } | ||
157 | + }, () => { | ||
158 | + tip('操作失败'); | ||
159 | + }); | ||
160 | + }, 700); | ||
160 | }, | 161 | }, |
161 | getCancelReason() { | 162 | getCancelReason() { |
162 | $.ajax({ | 163 | $.ajax({ |
@@ -164,6 +165,13 @@ | @@ -164,6 +165,13 @@ | ||
164 | }).then(result => { | 165 | }).then(result => { |
165 | if (result && result.data) { | 166 | if (result && result.data) { |
166 | this.options = result.data; | 167 | this.options = result.data; |
168 | + | ||
169 | + if (yoho.isiOS) { | ||
170 | + this.options.unshift({ | ||
171 | + id: 0, | ||
172 | + reason: '请选择' | ||
173 | + }) | ||
174 | + } | ||
167 | } | 175 | } |
168 | }).fail(() => { | 176 | }).fail(() => { |
169 | tip('操作失败'); | 177 | tip('操作失败'); |
@@ -171,10 +179,21 @@ | @@ -171,10 +179,21 @@ | ||
171 | }, | 179 | }, |
172 | autoCancel(code) { | 180 | autoCancel(code) { |
173 | return () => { | 181 | return () => { |
182 | + let reasonId; | ||
183 | + let reason; | ||
184 | + | ||
185 | + if (yoho.isiOS && this.options.length > 1) { | ||
186 | + reasonId = this.options[1].id; | ||
187 | + reason = this.options[1].reason; | ||
188 | + } else if (this.options.length) { | ||
189 | + reasonId = this.options[0].id; | ||
190 | + reason = this.options[0].reason; | ||
191 | + } | ||
192 | + | ||
174 | this.order().cancel({ | 193 | this.order().cancel({ |
175 | orderCode: code, | 194 | orderCode: code, |
176 | - reasonId: this.options.length ? this.options[0].id : null, | ||
177 | - reason: this.options.length ? this.options[0].reason : null | 195 | + reasonId: reasonId, |
196 | + reason: reason | ||
178 | }, (result) => { | 197 | }, (result) => { |
179 | if (result.code === 200) { | 198 | if (result.code === 200) { |
180 | this.reload(); | 199 | this.reload(); |
-
Please register or login to post a comment