Authored by 沈志敏

fix bug

... ... @@ -23,6 +23,8 @@ const yoho = {
* 判断是否是 APP
*/
isApp: /yh_blk/i.test(navigator.userAgent || ''),
isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''),
isAndroid: /Android/i.test(navigator.userAgent || ''),
/**
* store
... ... @@ -362,4 +364,4 @@ const yoho = {
}
};
module.exports = yoho;
module.exports = yoho;
\ No newline at end of file
... ...
... ... @@ -56,7 +56,7 @@
<button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button>
</template>
</div>
<select id="cancel-reason" class="cancel-reason" @blur="reasonChange" @change="reasonChange" v-model="selected">
<select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected">
<option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option>
</select>
</template>
... ... @@ -79,8 +79,7 @@
order: {},
options: [],
selected: {},
genderSel: {},
cancelbusy: false
genderSel: {}
};
},
created() {
... ... @@ -113,7 +112,6 @@
this.show = false;
this.order = {};
this.selected = {};
this.cancelbusy = false;
this.getOrderData();
},
... ... @@ -158,31 +156,34 @@
});
},
reasonChange() {
if (this.cancelbusy) {
return false;
}
setTimeout(() => {
if (!this.selected.id || document.hidden) {
return false;
}
this.cancelbusy = true;
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: this.selected.id || this.options[0].id,
reason: this.selected.reason || this.options[0].reason
}, (result) => {
if (result.code === 200) {
tip('取消成功');
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: this.selected.id,
reason: this.selected.reason
}, (result) => {
if (result.code === 200) {
tip({
delay: 500,
txt: '取消成功'
});
setTimeout(() => {
this.reload();
}, 1000);
setTimeout(() => {
this.reload();
}, 300);
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
this.cancelbusy = false;
}, () => {
tip('操作失败');
});
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
}, () => {
tip('操作失败');
});
}, 700);
},
getCancelReason() {
$.ajax({
... ... @@ -190,6 +191,12 @@
}).then(result => {
if (result.data.length > 0) {
this.options = result.data;
if (yoho.isiOS) {
this.options.unshift({
id: 0,
reason: '请选择'
})
}
}
}).fail(() => {
tip('操作失败');
... ... @@ -208,10 +215,21 @@
},
autoCancel(code) {
return () => {
let reasonId;
let reason;
if (yoho.isiOS && this.options.length > 1) {
reasonId = this.options[1].id;
reason = this.options[1].reason;
} else if (this.options.length) {
reasonId = this.options[0].id;
reason = this.options[0].reason;
}
this.orderDetail().cancel({
orderCode: code,
reasonId: this.options.length ? this.options[0].id : null,
reason: this.options.length ? this.options[0].reason : null
reasonId: reasonId,
reason: reason
}, (result) => {
if (result.code === 200) {
this.reload();
... ...
... ... @@ -54,7 +54,7 @@
<p>Your do not have an order <br>for the time being</p>
<a href="/product/new">随便逛逛</a>
</div>
<select id="cancel-reason" class="cancel-reason" @blur="reasonChange" @change="reasonChange" v-model="selected">
<select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected">
<option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option>
</select>
</template>
... ... @@ -75,7 +75,6 @@
pageTotal: 1,
type: this.$parent.$data.type,
busy: false,
cancelbusy: false,
emptybox: 'hide',
currentCode: '',
selected: {},
... ... @@ -98,7 +97,6 @@
this.page = 0;
this.pageTotal = 1;
this.busy = false;
this.cancelbusy = false;
this.emptybox = 'hide';
this.currentCode = '';
this.selected = {};
... ... @@ -135,28 +133,31 @@
});
},
reasonChange() {
if (this.cancelbusy) {
return false;
}
this.cancelbusy = true;
this.order().cancel({
orderCode: this.currentCode,
reasonId: this.selected.id || this.options[0].id,
reason: this.selected.reason || this.options[0].reason
}, (result) => {
if (result.code === 200) {
tip('取消成功');
setTimeout(() => {
this.reload();
}, 1000);
} else if (result.code !== 500) {
tip(result.message);
setTimeout(() => {
if (!this.selected.id || document.hidden) {
return false;
}
this.cancelbusy = false;
}, () => {
tip('操作失败');
});
this.order().cancel({
orderCode: this.currentCode,
reasonId: this.selected.id,
reason: this.selected.reason
}, (result) => {
if (result.code === 200) {
tip({
delay: 500,
txt: '取消成功'
});
setTimeout(() => {
this.reload();
}, 300);
} else if (result.code !== 500) {
tip(result.message);
}
}, () => {
tip('操作失败');
});
}, 700);
},
getCancelReason() {
$.ajax({
... ... @@ -164,6 +165,13 @@
}).then(result => {
if (result && result.data) {
this.options = result.data;
if (yoho.isiOS) {
this.options.unshift({
id: 0,
reason: '请选择'
})
}
}
}).fail(() => {
tip('操作失败');
... ... @@ -171,10 +179,21 @@
},
autoCancel(code) {
return () => {
let reasonId;
let reason;
if (yoho.isiOS && this.options.length > 1) {
reasonId = this.options[1].id;
reason = this.options[1].reason;
} else if (this.options.length) {
reasonId = this.options[0].id;
reason = this.options[0].reason;
}
this.order().cancel({
orderCode: code,
reasonId: this.options.length ? this.options[0].id : null,
reason: this.options.length ? this.options[0].reason : null
reasonId: reasonId,
reason: reason
}, (result) => {
if (result.code === 200) {
this.reload();
... ...