修复API + 优化用户体验
## 新增API 1. /api/user/update - 用户信息更新 2. /api/withdraw - 提现功能 ## 我的页面 1. 头像使用微信原生chooseAvatar 2. 昵称使用input type="nickname"一键获取 3. ID点击复制 ## 设置页面 1. 新增收货地址一键获取 2. 自动提现默认开启 ## 找伙伴 1. "创业合伙"改为"找伙伴" 2. 所有匹配类型都从数据库匹配
This commit is contained in:
@@ -15,9 +15,10 @@ Page({
|
||||
phoneNumber: '',
|
||||
wechatId: '',
|
||||
alipayAccount: '',
|
||||
address: '',
|
||||
|
||||
// 自动提现
|
||||
autoWithdrawEnabled: false,
|
||||
// 自动提现(默认开启)
|
||||
autoWithdrawEnabled: true,
|
||||
|
||||
// 绑定弹窗
|
||||
showBindModal: false,
|
||||
@@ -46,7 +47,9 @@ Page({
|
||||
const phoneNumber = wx.getStorageSync('user_phone') || userInfo.phone || ''
|
||||
const wechatId = wx.getStorageSync('user_wechat') || userInfo.wechat || ''
|
||||
const alipayAccount = wx.getStorageSync('user_alipay') || userInfo.alipay || ''
|
||||
const autoWithdrawEnabled = wx.getStorageSync('auto_withdraw_enabled') || false
|
||||
const address = wx.getStorageSync('user_address') || userInfo.address || ''
|
||||
// 默认开启自动提现
|
||||
const autoWithdrawEnabled = wx.getStorageSync('auto_withdraw_enabled') !== false
|
||||
|
||||
this.setData({
|
||||
isLoggedIn: true,
|
||||
@@ -54,11 +57,48 @@ Page({
|
||||
phoneNumber,
|
||||
wechatId,
|
||||
alipayAccount,
|
||||
address,
|
||||
autoWithdrawEnabled
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 一键获取收货地址
|
||||
async getAddress() {
|
||||
try {
|
||||
const res = await wx.chooseAddress()
|
||||
if (res) {
|
||||
const fullAddress = `${res.provinceName}${res.cityName}${res.countyName}${res.detailInfo}`
|
||||
|
||||
wx.setStorageSync('user_address', fullAddress)
|
||||
this.setData({ address: fullAddress })
|
||||
|
||||
// 更新用户信息
|
||||
if (app.globalData.userInfo) {
|
||||
app.globalData.userInfo.address = fullAddress
|
||||
wx.setStorageSync('userInfo', app.globalData.userInfo)
|
||||
}
|
||||
|
||||
// 同步到服务器
|
||||
this.syncProfileToServer()
|
||||
|
||||
wx.showToast({ title: '地址已获取', icon: 'success' })
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Settings] 获取地址失败:', e)
|
||||
if (e.errMsg?.includes('auth deny')) {
|
||||
wx.showModal({
|
||||
title: '需要授权',
|
||||
content: '请允许获取收货地址',
|
||||
confirmText: '去设置',
|
||||
success: (res) => {
|
||||
if (res.confirm) wx.openSetting()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 切换自动提现
|
||||
async toggleAutoWithdraw(e) {
|
||||
const enabled = e.detail.value
|
||||
|
||||
@@ -67,6 +67,21 @@
|
||||
<text class="bind-btn" wx:else>去绑定</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 收货地址 - 微信一键获取 -->
|
||||
<view class="bind-item" bindtap="getAddress">
|
||||
<view class="bind-left">
|
||||
<view class="bind-icon address-icon">📍</view>
|
||||
<view class="bind-info">
|
||||
<text class="bind-label">收货地址</text>
|
||||
<text class="bind-value address-text">{{address || '未绑定'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bind-right">
|
||||
<text class="bind-check" wx:if="{{address}}">✓</text>
|
||||
<text class="bind-btn" wx:else>一键获取</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user