Browse Source

Merge pull request '优化提交逻辑:重复提交时自动跳转到审核页面' (#10) from Xfy into Main

Reviewed-on: http://8.137.125.67:4000/SwtTt29/Program-mini/pulls/10
pull/1/head
SwtTt29 3 months ago
parent
commit
f6fdaaab10
  1. 19
      pages/index/index.js
  2. 8
      pages/profile/index.wxml
  3. 4
      pages/seller/index.js
  4. 59
      pages/settlement/index.js
  5. 2
      server-example/test_settlement_api.js

19
pages/index/index.js

@ -155,7 +155,7 @@ Page({
const existingUserId = wx.getStorageSync('userId') const existingUserId = wx.getStorageSync('userId')
const existingUserInfo = wx.getStorageSync('userInfo') const existingUserInfo = wx.getStorageSync('userInfo')
if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber !== '13800138000') { if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber) {
console.log('用户已登录且手机号有效,直接完成身份设置') console.log('用户已登录且手机号有效,直接完成身份设置')
// 直接完成身份设置,跳过重复授权 // 直接完成身份设置,跳过重复授权
const currentUserType = this.data.pendingUserType || this.data.currentUserType || 'buyer' const currentUserType = this.data.pendingUserType || this.data.currentUserType || 'buyer'
@ -268,8 +268,8 @@ Page({
const isNewPhone = phoneRes.isNewPhone || true const isNewPhone = phoneRes.isNewPhone || true
const phoneNumber = phoneRes.phoneNumber || null const phoneNumber = phoneRes.phoneNumber || null
// 如果有手机号冲突且没有返回手机号,使用临时手机号 // 如果有手机号冲突且没有返回手机号,使用实际返回的手机号
const finalPhoneNumber = hasPhoneConflict && !phoneNumber ? '13800138000' : phoneNumber const finalPhoneNumber = phoneNumber
console.log('手机号解密结果:', { console.log('手机号解密结果:', {
phoneNumber: finalPhoneNumber, phoneNumber: finalPhoneNumber,
@ -419,7 +419,7 @@ Page({
wx.setStorageSync('userId', mockUserId) wx.setStorageSync('userId', mockUserId)
// 4. 模拟手机号解密结果 // 4. 模拟手机号解密结果
const mockPhoneNumber = '13800138000' const mockPhoneNumber = null
console.log('模拟手机号解密成功:', mockPhoneNumber) console.log('模拟手机号解密成功:', mockPhoneNumber)
// 5. 创建模拟用户信息 // 5. 创建模拟用户信息
@ -611,12 +611,8 @@ Page({
wx.setStorageSync('userInfo', userInfo) wx.setStorageSync('userInfo', userInfo)
console.log('验证登录状态成功,用户信息已同步:', userInfo) console.log('验证登录状态成功,用户信息已同步:', userInfo)
// 检查是否为临时手机号,如果是则提示用户重新授权 // 如果手机号存在则清除重新授权标志
if (userInfo.phoneNumber === '13800138000') { if (userInfo.phoneNumber) {
console.warn('检测到临时手机号,建议用户重新授权')
// 设置重新授权标志
wx.setStorageSync('needPhoneAuth', true)
} else {
// 清除可能存在的重新授权标志 // 清除可能存在的重新授权标志
wx.removeStorageSync('needPhoneAuth') wx.removeStorageSync('needPhoneAuth')
console.log('手机号验证通过:', userInfo.phoneNumber) console.log('手机号验证通过:', userInfo.phoneNumber)
@ -742,8 +738,7 @@ Page({
const completeUserInfo = { const completeUserInfo = {
...userInfo, ...userInfo,
// 确保包含服务器需要的必要字段 // 确保包含服务器需要的必要字段
nickName: userInfo.nickName || '测试用户', nickName: userInfo.nickName || '测试用户'
phoneNumber: userInfo.phoneNumber || '13800138000'
} }
try { try {

8
pages/profile/index.wxml

@ -8,8 +8,8 @@
<view> <view>
<view style="font-size: 32rpx; font-weight: bold;">{{userInfo.nickName || '未登录'}}</view> <view style="font-size: 32rpx; font-weight: bold;">{{userInfo.nickName || '未登录'}}</view>
<view style="font-size: 26rpx; color: #666;">当前身份: {{userType || '未设置'}}</view> <view style="font-size: 26rpx; color: #666;">当前身份: {{userType || '未设置'}}</view>
<view style="font-size: 26rpx; color: {{userInfo.phoneNumber === '13800138000' ? '#ff4d4f' : '#666'}};"> <view style="font-size: 26rpx; color: #666;">
手机号: {{userInfo.phoneNumber === '13800138000' ? '临时手机号,请重新授权' : (userInfo.phoneNumber || '未绑定')}} 手机号: {{userInfo.phoneNumber || '未绑定'}}
</view> </view>
</view> </view>
</view> </view>
@ -23,14 +23,14 @@
</view> </view>
<!-- 手机号授权按钮 --> <!-- 手机号授权按钮 -->
<view class="card" wx:if="{{!userInfo.phoneNumber || userInfo.phoneNumber === '13800138000'}}"> <view class="card" wx:if="{{!userInfo.phoneNumber}}">
<button <button
open-type="getPhoneNumber" open-type="getPhoneNumber"
bindgetphonenumber="onPhoneNumberResult" bindgetphonenumber="onPhoneNumberResult"
type="primary" type="primary"
style="margin: 20rpx 0;" style="margin: 20rpx 0;"
> >
{{userInfo.phoneNumber === '13800138000' ? '重新授权手机号' : '授权手机号'}} 授权手机号
</button> </button>
</view> </view>

4
pages/seller/index.js

@ -943,7 +943,7 @@ Page({
const existingUserId = wx.getStorageSync('userId') const existingUserId = wx.getStorageSync('userId')
const existingUserInfo = wx.getStorageSync('userInfo') const existingUserInfo = wx.getStorageSync('userInfo')
if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber !== '13800138000') { if (existingOpenid && existingUserId && existingUserInfo && existingUserInfo.phoneNumber) {
console.log('用户已登录且手机号有效,直接完成身份设置') console.log('用户已登录且手机号有效,直接完成身份设置')
// 直接完成身份设置,跳过重复授权 // 直接完成身份设置,跳过重复授权
const currentUserType = this.data.pendingUserType || 'seller' const currentUserType = this.data.pendingUserType || 'seller'
@ -1042,7 +1042,7 @@ Page({
const hasPhoneConflict = phoneRes.phoneNumberConflict || false const hasPhoneConflict = phoneRes.phoneNumberConflict || false
const isNewPhone = phoneRes.isNewPhone || true const isNewPhone = phoneRes.isNewPhone || true
const phoneNumber = phoneRes.phoneNumber || null const phoneNumber = phoneRes.phoneNumber || null
const finalPhoneNumber = hasPhoneConflict && !phoneNumber ? '13800138000' : phoneNumber const finalPhoneNumber = phoneNumber
console.log('手机号解密结果:', { console.log('手机号解密结果:', {
phoneNumber: finalPhoneNumber, phoneNumber: finalPhoneNumber,

59
pages/settlement/index.js

@ -74,6 +74,18 @@ Page({
}); });
} }
// 检查本地保存的settlementStatus
const settlementStatus = wx.getStorageSync('settlementStatus');
if (settlementStatus && (settlementStatus === 'underreview' || settlementStatus === 'approved' || settlementStatus === 'reviewfailed')) {
console.log('检测到本地保存的审核状态:', settlementStatus);
this.setData({
showGuidePage: false,
currentStep: 3,
partnerstatus: settlementStatus
});
return; // 直接返回,不执行后续逻辑
}
// 检查是否是从首页登录返回的 // 检查是否是从首页登录返回的
const pendingReturnPath = wx.getStorageSync('pendingReturnPath'); const pendingReturnPath = wx.getStorageSync('pendingReturnPath');
if (pendingReturnPath === 'settlement') { if (pendingReturnPath === 'settlement') {
@ -774,10 +786,39 @@ Page({
// 清除进度数据,因为已经提交了 // 清除进度数据,因为已经提交了
this.clearSettlementProgress(); this.clearSettlementProgress();
} else { } else {
wx.showToast({ // 检查是否是重复提交错误
title: result.message || '提交失败', if (result.message && result.message.includes('请勿重复提交')) {
icon: 'none' // 已有待审核申请,直接跳转到审核状态页面
}); this.setData({
currentStep: 3, // 设置为第4步(审核状态页面)
partnerstatus: 'underreview' // 审核中状态
});
// 调用API同步最新的用户信息和审核状态
const API = require('../../utils/api.js');
API.getUserInfo().then(userRes => {
console.log('用户完整数据:', userRes.data);
// 更新用户的申请状态
if (userRes.data && userRes.data.partnerstatus) {
this.setData({
partnerstatus: userRes.data.partnerstatus,
applicationId: userRes.data.applicationId
});
// 保存最新状态到本地存储
wx.setStorageSync('settlementStatus', userRes.data.partnerstatus);
if (userRes.data.applicationId) {
wx.setStorageSync('applicationId', userRes.data.applicationId);
}
}
}).catch(err => {
console.error('获取用户数据失败:', err);
});
} else {
// 其他错误情况,显示错误提示
wx.showToast({
title: result.message || '提交失败',
icon: 'none'
});
}
} }
} catch (error) { } catch (error) {
console.error('提交入驻申请失败:', error); console.error('提交入驻申请失败:', error);
@ -888,9 +929,10 @@ Page({
icon: 'success', icon: 'success',
duration: 1500, duration: 1500,
complete: () => { complete: () => {
// 登录成功后继续提交申请 // 登录成功后关闭弹窗,让用户决定是否继续提交
setTimeout(() => { setTimeout(() => {
this.submitApplication(); this.closeOneKeyLoginModal();
this.setData({ showAuthModal: false });
}, 1500); }, 1500);
} }
}); });
@ -963,9 +1005,10 @@ Page({
icon: 'success', icon: 'success',
duration: 1500, duration: 1500,
complete: () => { complete: () => {
// 登录成功后继续提交申请 // 登录成功后关闭弹窗,让用户决定是否继续提交
setTimeout(() => { setTimeout(() => {
this.submitApplication(); this.closeOneKeyLoginModal();
this.setData({ showAuthModal: false });
}, 1500); }, 1500);
} }
}); });

2
server-example/test_settlement_api.js

@ -17,7 +17,7 @@ const testData = {
district: '海淀区', district: '海淀区',
detailedaddress: '中关村科技园区', detailedaddress: '中关村科技园区',
cooperation: 'wholesale', // 合作模式 cooperation: 'wholesale', // 合作模式
phone: '13800138000', phone: null,
applicationId: null // 将在测试过程中设置 applicationId: null // 将在测试过程中设置
}; };

Loading…
Cancel
Save