|
|
@@ -217,7 +217,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- selectServiceObjectIndex:-1,
|
|
|
+ selectServiceObjectIndex: -1,
|
|
|
showRemarkId: '',
|
|
|
userInfo: {},
|
|
|
subOrderNo: '',
|
|
|
@@ -297,7 +297,6 @@ export default {
|
|
|
|
|
|
onShow() {
|
|
|
this.userInfo = uni.getStorageSync('userInfo')
|
|
|
- this.listServiceObject()
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
@@ -322,39 +321,46 @@ export default {
|
|
|
},
|
|
|
// 查询服务对像信息列表
|
|
|
listServiceObject() {
|
|
|
- let serviceObjectList = []
|
|
|
- this.$api.listServiceObject(this.reqParm).then((res) => {
|
|
|
+ return this.$api.listServiceObject(this.reqParm).then((res) => {
|
|
|
+ let serviceObjectList = [];
|
|
|
res.data.data.forEach(i => {
|
|
|
if (i.isSelf != 1) {
|
|
|
- serviceObjectList.push(i)
|
|
|
+ serviceObjectList.push(i);
|
|
|
}
|
|
|
- })
|
|
|
- // this.serviceObjectList[0] = serviceObjectList
|
|
|
-
|
|
|
- this.$set(this.serviceObjectList, 0, serviceObjectList)
|
|
|
+ });
|
|
|
+ this.$set(this.serviceObjectList, 0, serviceObjectList);
|
|
|
this.getImgUrlByBannerOssId(this.serviceObjectList[0]);
|
|
|
- console.log('执行了+++++++++++++++++++', this.serviceObjectList)
|
|
|
+ console.log('执行了+++++++++++++++++++', this.serviceObjectList);
|
|
|
|
|
|
- // if (this.isShare) {
|
|
|
if (serviceObjectList.length === 0) {
|
|
|
+ // 无服务对象:执行跳转逻辑,返回 false 表示不继续后续操作
|
|
|
uni.showToast({
|
|
|
- duration: 2500,
|
|
|
+ duration: 1500, // 与 setTimeout 时间一致,避免提示残留
|
|
|
title: '当前账号没有服务对象,即将跳转服务对象绑定',
|
|
|
icon: 'none',
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
uni.hideToast();
|
|
|
- //关闭提示后跳转
|
|
|
uni.navigateTo({
|
|
|
url: '/myPages/serviceObjectFaceAuth/index'
|
|
|
- })
|
|
|
- }, 1500)
|
|
|
+ });
|
|
|
+ }, 1500);
|
|
|
+ return false; // 关键:告诉 beforeCommitOrder 不需要继续执行
|
|
|
}
|
|
|
- // }
|
|
|
|
|
|
- })
|
|
|
+ // 有服务对象:返回 true 表示可以继续后续操作
|
|
|
+ return true;
|
|
|
+ }).catch((err) => {
|
|
|
+ console.error('获取服务对象列表失败', err);
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取服务信息失败,请重试',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ return false; // 接口失败也不继续后续逻辑
|
|
|
+ });
|
|
|
},
|
|
|
- closeSelectServiceObjectPopup(){
|
|
|
+ closeSelectServiceObjectPopup() {
|
|
|
this.selectServiceObjectIndex = -1
|
|
|
this.$refs.popup.close()
|
|
|
},
|
|
|
@@ -387,27 +393,41 @@ export default {
|
|
|
|
|
|
},
|
|
|
|
|
|
- beforeCommitOrder() {
|
|
|
- if (!this.userInfo.phone) {
|
|
|
- uni.showModal({
|
|
|
- title: '温馨提示',
|
|
|
- content: '请先绑定手机号',
|
|
|
- success: res => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.navigateTo({
|
|
|
- url: '/myPages/setting/setting-telphone',
|
|
|
- })
|
|
|
+ async beforeCommitOrder() {
|
|
|
+ try {
|
|
|
+ // 等待 listServiceObject 完全执行(包括数据处理、弹窗提示注册),拿到是否继续的标记
|
|
|
+ const isContinue = await this.listServiceObject();
|
|
|
+
|
|
|
+ // 关键:如果不需要继续(无服务对象/接口失败),直接终止,不执行后续 popup 逻辑
|
|
|
+ if (!isContinue) return;
|
|
|
+
|
|
|
+ // 以下逻辑仅在「有服务对象」时才执行
|
|
|
+ if (!this.userInfo.phone) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '温馨提示',
|
|
|
+ content: '请先绑定手机号',
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/myPages/setting/setting-telphone',
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (this.activity.isAddServiceObject == 1) {
|
|
|
- // this.show = true
|
|
|
- this.$refs.popup.open()
|
|
|
- } else {
|
|
|
- this.commitOrder()
|
|
|
+ if (this.activity.isAddServiceObject == 1) {
|
|
|
+ this.$refs.popup.open(); // 只有有服务对象+手机号已绑定,才打开 popup
|
|
|
+ } else {
|
|
|
+ this.commitOrder();
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '操作失败,请重试',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -415,7 +435,7 @@ export default {
|
|
|
// console.log(e)
|
|
|
// this.serviceObjectId = e.value[0].id
|
|
|
console.log(e)
|
|
|
- if(!e){
|
|
|
+ if (!e) {
|
|
|
uni.showToast({
|
|
|
duration: 2000,
|
|
|
title: '请选择一个服务对象',
|
|
|
@@ -453,8 +473,8 @@ export default {
|
|
|
console.log('++++++++++++++++++订单提交+++++++++++', res)
|
|
|
uni.hideLoading();
|
|
|
this.subOrderNo = res.data.data.orderNo
|
|
|
- if(this.isShare){
|
|
|
- if (this.activity.sharePrice * 1 > 0 ) {
|
|
|
+ if (this.isShare) {
|
|
|
+ if (this.activity.sharePrice * 1 > 0) {
|
|
|
this.$refs.myPay.openPopup()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
@@ -463,8 +483,8 @@ export default {
|
|
|
});
|
|
|
this.isActivityCheck = true
|
|
|
}
|
|
|
- }else {
|
|
|
- if (this.activity.salePrice * 1 > 0 ) {
|
|
|
+ } else {
|
|
|
+ if (this.activity.salePrice * 1 > 0) {
|
|
|
this.$refs.myPay.openPopup()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
@@ -516,8 +536,6 @@ export default {
|
|
|
this.isActivityCheck = res.data.data
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
</script>
|