refactor(支付流程): 优化支付权限检查和弹窗处理逻辑
重构支付权限检查逻辑,将权限验证从onMounted移至useDidShow统一处理 优化支付协议弹窗按钮文案和错误处理逻辑 移除未使用的组件导入和冗余代码
Showing
3 changed files
with
10 additions
and
31 deletions
| ... | @@ -23,10 +23,8 @@ declare module 'vue' { | ... | @@ -23,10 +23,8 @@ declare module 'vue' { |
| 23 | NutEllipsis: typeof import('@nutui/nutui-taro')['Ellipsis'] | 23 | NutEllipsis: typeof import('@nutui/nutui-taro')['Ellipsis'] |
| 24 | NutForm: typeof import('@nutui/nutui-taro')['Form'] | 24 | NutForm: typeof import('@nutui/nutui-taro')['Form'] |
| 25 | NutFormItem: typeof import('@nutui/nutui-taro')['FormItem'] | 25 | NutFormItem: typeof import('@nutui/nutui-taro')['FormItem'] |
| 26 | - NutIcon: typeof import('@nutui/nutui-taro')['Icon'] | ||
| 27 | NutImagePreview: typeof import('@nutui/nutui-taro')['ImagePreview'] | 26 | NutImagePreview: typeof import('@nutui/nutui-taro')['ImagePreview'] |
| 28 | NutInput: typeof import('@nutui/nutui-taro')['Input'] | 27 | NutInput: typeof import('@nutui/nutui-taro')['Input'] |
| 29 | - NutLoading: typeof import('@nutui/nutui-taro')['Loading'] | ||
| 30 | NutMenu: typeof import('@nutui/nutui-taro')['Menu'] | 28 | NutMenu: typeof import('@nutui/nutui-taro')['Menu'] |
| 31 | NutMenuItem: typeof import('@nutui/nutui-taro')['MenuItem'] | 29 | NutMenuItem: typeof import('@nutui/nutui-taro')['MenuItem'] |
| 32 | NutOverlay: typeof import('@nutui/nutui-taro')['Overlay'] | 30 | NutOverlay: typeof import('@nutui/nutui-taro')['Overlay'] | ... | ... |
| ... | @@ -65,7 +65,7 @@ | ... | @@ -65,7 +65,7 @@ |
| 65 | color="orange" | 65 | color="orange" |
| 66 | @click="handleConfirm" | 66 | @click="handleConfirm" |
| 67 | > | 67 | > |
| 68 | - {{ bindStatus.is_finish ? '确认' : '确认并签约' }} | 68 | + {{ bindStatus.is_finish ? '我要发布' : '确认并签约' }} |
| 69 | </nut-button> | 69 | </nut-button> |
| 70 | </div> | 70 | </div> |
| 71 | </div> | 71 | </div> |
| ... | @@ -241,8 +241,6 @@ const handleAgree = async () => { | ... | @@ -241,8 +241,6 @@ const handleAgree = async () => { |
| 241 | 241 | ||
| 242 | // 调用绑定接口 | 242 | // 调用绑定接口 |
| 243 | await handleBindJeePay() | 243 | await handleBindJeePay() |
| 244 | - } else { | ||
| 245 | - console.error('更新协议状态失败:', result.message) | ||
| 246 | } | 244 | } |
| 247 | } catch (error) { | 245 | } catch (error) { |
| 248 | console.error('更新协议状态失败:', error) | 246 | console.error('更新协议状态失败:', error) |
| ... | @@ -329,12 +327,6 @@ const handleBindJeePay = async () => { | ... | @@ -329,12 +327,6 @@ const handleBindJeePay = async () => { |
| 329 | emit('confirm') | 327 | emit('confirm') |
| 330 | return | 328 | return |
| 331 | } | 329 | } |
| 332 | - } else { | ||
| 333 | - console.error('绑定接口调用失败:', result.message) | ||
| 334 | - Taro.showToast({ | ||
| 335 | - title: '绑定失败,请重试', | ||
| 336 | - icon: 'none' | ||
| 337 | - }) | ||
| 338 | } | 330 | } |
| 339 | } catch (error) { | 331 | } catch (error) { |
| 340 | console.error('绑定接口调用失败:', error) | 332 | console.error('绑定接口调用失败:', error) | ... | ... |
| ... | @@ -1171,9 +1171,8 @@ const checkUserPermission = async () => { | ... | @@ -1171,9 +1171,8 @@ const checkUserPermission = async () => { |
| 1171 | url: '/pages/collectionSettings/index?target=sell' | 1171 | url: '/pages/collectionSettings/index?target=sell' |
| 1172 | }) | 1172 | }) |
| 1173 | } | 1173 | } |
| 1174 | - } else { | 1174 | + } else if (res.cancel) { |
| 1175 | - // 用户点击关闭,返回上一页 | 1175 | + console.log('用户点击取消') |
| 1176 | - // Taro.navigateBack() | ||
| 1177 | } | 1176 | } |
| 1178 | } | 1177 | } |
| 1179 | }) | 1178 | }) |
| ... | @@ -1184,15 +1183,6 @@ const checkUserPermission = async () => { | ... | @@ -1184,15 +1183,6 @@ const checkUserPermission = async () => { |
| 1184 | 1183 | ||
| 1185 | // 页面加载时执行 | 1184 | // 页面加载时执行 |
| 1186 | onMounted(async () => { | 1185 | onMounted(async () => { |
| 1187 | - const hasPermission = await checkUserPermission() | ||
| 1188 | - | ||
| 1189 | - if (!hasPermission) { | ||
| 1190 | - return | ||
| 1191 | - } | ||
| 1192 | - | ||
| 1193 | - // 权限验证通过,显示收款说明弹框 | ||
| 1194 | - paymentAgreementVisible.value = true | ||
| 1195 | - | ||
| 1196 | // 加载基础数据 | 1186 | // 加载基础数据 |
| 1197 | await Promise.all([ | 1187 | await Promise.all([ |
| 1198 | loadSchools(), | 1188 | loadSchools(), |
| ... | @@ -1222,17 +1212,16 @@ onMounted(async () => { | ... | @@ -1222,17 +1212,16 @@ onMounted(async () => { |
| 1222 | } | 1212 | } |
| 1223 | }) | 1213 | }) |
| 1224 | 1214 | ||
| 1225 | -// 页面显示时执行(用户从其他页面返回时会触发) | 1215 | +// 页面显示时执行(包括首次加载和从其他页面返回) |
| 1226 | useDidShow(async () => { | 1216 | useDidShow(async () => { |
| 1227 | - // 只有在页面已经初始化后才进行权限检查 | 1217 | + const hasPermission = await checkUserPermission() |
| 1228 | - // 避免与onMounted重复执行 | ||
| 1229 | - const pages = Taro.getCurrentPages() | ||
| 1230 | - const currentPage = pages[pages.length - 1] | ||
| 1231 | 1218 | ||
| 1232 | - // 如果页面已经加载过,则重新检查权限 | 1219 | + if (!hasPermission) { |
| 1233 | - if (currentPage && currentPage.data && Object.keys(currentPage.data).length > 0) { | 1220 | + return |
| 1234 | - await checkUserPermission() | ||
| 1235 | } | 1221 | } |
| 1222 | + | ||
| 1223 | + // 权限验证通过,显示收款说明弹框 | ||
| 1224 | + paymentAgreementVisible.value = true | ||
| 1236 | }) | 1225 | }) |
| 1237 | 1226 | ||
| 1238 | /** | 1227 | /** | ... | ... |
-
Please register or login to post a comment