更新小程序配置,重构页面结构,删除不再使用的地址管理和章节页面,优化项目结构以提升可维护性;调整全局样式,增强组件的可复用性和一致性。
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88,
|
||||
user: null,
|
||||
showBindModal: false,
|
||||
bindType: 'phone',
|
||||
bindValue: '',
|
||||
isBinding: false,
|
||||
bindError: ''
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const statusBarHeight = app.globalData.statusBarHeight || 44
|
||||
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
|
||||
this.setData({ statusBarHeight, navBarHeight })
|
||||
this.syncUser()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.syncUser()
|
||||
},
|
||||
|
||||
syncUser() {
|
||||
const user = app.globalData.userInfo || null
|
||||
this.setData({ user })
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack({ fail: () => wx.switchTab({ url: '/pages/my/my' }) })
|
||||
},
|
||||
|
||||
goAddresses() {
|
||||
wx.navigateTo({ url: '/pages/address-list/address-list' })
|
||||
},
|
||||
|
||||
openBindModal(e) {
|
||||
const type = e.currentTarget.dataset.type
|
||||
const user = this.data.user
|
||||
let bindValue = ''
|
||||
if (type === 'phone' && user && user.phone) bindValue = user.phone
|
||||
if (type === 'wechat' && user && user.wechat) bindValue = user.wechat
|
||||
if (type === 'alipay' && user && user.alipay) bindValue = user.alipay
|
||||
this.setData({
|
||||
showBindModal: true,
|
||||
bindType: type,
|
||||
bindValue,
|
||||
bindError: ''
|
||||
})
|
||||
},
|
||||
|
||||
closeBindModal() {
|
||||
if (!this.data.isBinding) this.setData({ showBindModal: false, bindValue: '', bindError: '' })
|
||||
},
|
||||
|
||||
onBindInput(e) {
|
||||
this.setData({ bindValue: (e.detail && e.detail.value) || '', bindError: '' })
|
||||
},
|
||||
|
||||
submitBind() {
|
||||
const { bindType, bindValue, user } = this.data
|
||||
if (!bindValue || !bindValue.trim()) {
|
||||
this.setData({ bindError: '请输入内容' })
|
||||
return
|
||||
}
|
||||
if (bindType === 'phone' && !/^1[3-9]\d{9}$/.test(bindValue)) {
|
||||
this.setData({ bindError: '请输入正确的手机号' })
|
||||
return
|
||||
}
|
||||
if (bindType === 'wechat' && bindValue.length < 6) {
|
||||
this.setData({ bindError: '微信号至少6位' })
|
||||
return
|
||||
}
|
||||
if (bindType === 'alipay' && !bindValue.includes('@') && !/^1[3-9]\d{9}$/.test(bindValue)) {
|
||||
this.setData({ bindError: '请输入正确的支付宝账号' })
|
||||
return
|
||||
}
|
||||
this.setData({ isBinding: true, bindError: '' })
|
||||
app.request('/api/user/update', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
userId: user && user.id,
|
||||
[bindType]: bindValue
|
||||
}
|
||||
}).then(() => {
|
||||
const newUser = { ...user, [bindType]: bindValue }
|
||||
app.globalData.userInfo = newUser
|
||||
wx.setStorageSync('userInfo', newUser)
|
||||
this.setData({
|
||||
user: newUser,
|
||||
showBindModal: false,
|
||||
bindValue: '',
|
||||
isBinding: false
|
||||
})
|
||||
wx.showToast({ title: '绑定成功', icon: 'success' })
|
||||
}).catch(() => {
|
||||
this.setData({ bindError: '绑定失败,请重试', isBinding: false })
|
||||
})
|
||||
},
|
||||
|
||||
logout() {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
app.globalData.userInfo = null
|
||||
app.globalData.isLoggedIn = false
|
||||
app.globalData.purchasedSections = []
|
||||
app.globalData.hasFullBook = false
|
||||
wx.removeStorageSync('userInfo')
|
||||
wx.removeStorageSync('token')
|
||||
wx.switchTab({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "设置",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<view class="page">
|
||||
<view class="nav-placeholder" style="height: {{navBarHeight || (statusBarHeight + 44)}}px;"></view>
|
||||
<view class="header safe-header-right">
|
||||
<view class="nav-back" bindtap="goBack">← 返回</view>
|
||||
<text class="header-title">设置</text>
|
||||
</view>
|
||||
|
||||
<view class="main">
|
||||
<view class="card">
|
||||
<view class="card-head">
|
||||
<text class="card-icon">🛡</text>
|
||||
<view>
|
||||
<text class="card-title">账号绑定</text>
|
||||
<text class="card-desc">绑定后可用于提现和找伙伴功能</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="bind-item" data-type="phone" bindtap="openBindModal">
|
||||
<view class="bind-left">
|
||||
<view class="bind-icon {{user.phone ? 'bound' : ''}}">📱</view>
|
||||
<view>
|
||||
<text class="bind-label">手机号</text>
|
||||
<text class="bind-value">{{user.phone || '未绑定'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="bind-action" wx:if="{{user.phone}}">✓</text>
|
||||
<text class="bind-action brand" wx:else>去绑定</text>
|
||||
</view>
|
||||
|
||||
<view class="bind-item" data-type="wechat" bindtap="openBindModal">
|
||||
<view class="bind-left">
|
||||
<view class="bind-icon wechat {{user.wechat ? 'bound' : ''}}">💬</view>
|
||||
<view>
|
||||
<text class="bind-label">微信号</text>
|
||||
<text class="bind-value">{{user.wechat || '未绑定'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="bind-action" wx:if="{{user.wechat}}">✓</text>
|
||||
<text class="bind-action green" wx:else>去绑定</text>
|
||||
</view>
|
||||
|
||||
<view class="bind-item" data-type="alipay" bindtap="openBindModal">
|
||||
<view class="bind-left">
|
||||
<view class="bind-icon alipay {{user.alipay ? 'bound' : ''}}">💳</view>
|
||||
<view>
|
||||
<text class="bind-label">支付宝</text>
|
||||
<text class="bind-value">{{user.alipay || '未绑定'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="bind-action" wx:if="{{user.alipay}}">✓</text>
|
||||
<text class="bind-action blue" wx:else>去绑定</text>
|
||||
</view>
|
||||
|
||||
<view class="bind-item" bindtap="goAddresses">
|
||||
<view class="bind-left">
|
||||
<view class="bind-icon addr">📍</view>
|
||||
<view>
|
||||
<text class="bind-label">收货地址</text>
|
||||
<text class="bind-value">管理收货地址,用于发货与邮寄</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="bind-action brand">管理</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="hint" wx:if="{{!user.wechat && !user.alipay}}">
|
||||
<text>提示:绑定至少一个支付方式(微信或支付宝)才能使用提现功能</text>
|
||||
</view>
|
||||
|
||||
<view class="btn-logout" bindtap="logout">退出登录</view>
|
||||
</view>
|
||||
|
||||
<view class="mask" wx:if="{{showBindModal}}" catchtap="closeBindModal">
|
||||
<view class="modal" catchtap="">
|
||||
<view class="modal-head">
|
||||
<text class="modal-title">绑定{{bindType === 'phone' ? '手机号' : (bindType === 'wechat' ? '微信号' : '支付宝')}}</text>
|
||||
<view class="modal-close" bindtap="closeBindModal">×</view>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<input
|
||||
class="bind-input"
|
||||
placeholder="{{bindType === 'phone' ? '请输入11位手机号' : (bindType === 'wechat' ? '请输入微信号' : '请输入支付宝账号')}}"
|
||||
value="{{bindValue}}"
|
||||
bindinput="onBindInput"
|
||||
/>
|
||||
<text class="bind-err" wx:if="{{bindError}}">{{bindError}}</text>
|
||||
<view class="btn-primary {{!bindValue || isBinding ? 'disabled' : ''}}" bindtap="submitBind">
|
||||
{{isBinding ? '绑定中...' : '确认绑定'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,44 +0,0 @@
|
||||
page { background: #000; color: #fff; }
|
||||
.page { min-height: 100vh; padding-bottom: 80rpx; box-sizing: border-box; }
|
||||
.nav-placeholder { width: 100%; }
|
||||
.header { display: flex; align-items: center; padding: 24rpx 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.nav-back { font-size: 32rpx; color: #00CED1; margin-right: 24rpx; }
|
||||
.header-title { flex: 1; text-align: center; font-size: 34rpx; color: #00CED1; }
|
||||
|
||||
.main { padding: 32rpx; }
|
||||
.card { border-radius: 32rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.05); overflow: hidden; margin-bottom: 24rpx; }
|
||||
.card-head { display: flex; align-items: flex-start; gap: 24rpx; padding: 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.card-icon { font-size: 36rpx; }
|
||||
.card-title { font-size: 30rpx; color: #fff; font-weight: 500; display: block; }
|
||||
.card-desc { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; margin-top: 8rpx; }
|
||||
|
||||
.bind-item { display: flex; align-items: center; justify-content: space-between; padding: 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.bind-item:last-child { border-bottom: none; }
|
||||
.bind-left { display: flex; align-items: center; gap: 24rpx; flex: 1; min-width: 0; }
|
||||
.bind-icon { width: 64rpx; height: 64rpx; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 32rpx; flex-shrink: 0; }
|
||||
.bind-icon.bound { background: rgba(0,206,209,0.2); }
|
||||
.bind-icon.wechat.bound { background: rgba(7,193,96,0.2); }
|
||||
.bind-icon.alipay.bound { background: rgba(22,119,255,0.2); }
|
||||
.bind-icon.addr { background: rgba(249,115,22,0.2); }
|
||||
.bind-label { font-size: 28rpx; color: #fff; display: block; }
|
||||
.bind-value { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; margin-top: 4rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.bind-action { font-size: 24rpx; color: rgba(255,255,255,0.5); }
|
||||
.bind-action.brand { color: #00CED1; }
|
||||
.bind-action.green { color: #07C160; }
|
||||
.bind-action.blue { color: #1677FF; }
|
||||
|
||||
.hint { padding: 24rpx 32rpx; border-radius: 24rpx; background: rgba(249,115,22,0.1); border: 2rpx solid rgba(249,115,22,0.2); margin-bottom: 24rpx; }
|
||||
.hint text { font-size: 24rpx; color: rgba(249,115,22,0.9); }
|
||||
|
||||
.btn-logout { width: 100%; padding: 28rpx; border-radius: 24rpx; background: #1c1c1e; border: 2rpx solid rgba(248,113,113,0.4); color: #f87171; font-size: 30rpx; font-weight: 500; text-align: center; }
|
||||
|
||||
.mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 48rpx; box-sizing: border-box; }
|
||||
.modal { width: 100%; max-width: 600rpx; background: #1c1c1e; border-radius: 32rpx; overflow: hidden; }
|
||||
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.1); }
|
||||
.modal-title { font-size: 36rpx; font-weight: 600; color: #fff; }
|
||||
.modal-close { width: 64rpx; height: 64rpx; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 40rpx; color: rgba(255,255,255,0.6); }
|
||||
.modal-body { padding: 32rpx; }
|
||||
.bind-input { width: 100%; padding: 24rpx 32rpx; border-radius: 24rpx; background: rgba(0,0,0,0.3); border: 2rpx solid rgba(255,255,255,0.1); color: #fff; font-size: 28rpx; box-sizing: border-box; margin-bottom: 24rpx; }
|
||||
.bind-err { font-size: 24rpx; color: #f87171; display: block; margin-bottom: 16rpx; }
|
||||
.btn-primary { width: 100%; padding: 24rpx; border-radius: 24rpx; background: #00CED1; color: #000; font-size: 30rpx; font-weight: 500; text-align: center; }
|
||||
.btn-primary.disabled { opacity: 0.5; }
|
||||
Reference in New Issue
Block a user