优化数据库初始化,新增用户收货地址表以支持多地址管理;更新章节页面和我的页面,整合底部导航组件,提升用户体验;调整小程序设置页面,增加收货地址管理功能,优化样式与布局。
This commit is contained in:
136
miniprogram/pages/address-edit/address-edit.js
Normal file
136
miniprogram/pages/address-edit/address-edit.js
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Soul创业派对 - 收货地址新建/编辑
|
||||
*/
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
id: '',
|
||||
isEdit: false,
|
||||
name: '',
|
||||
phone: '',
|
||||
region: ['广东省', '广州市', '天河区'],
|
||||
province: '广东省',
|
||||
city: '广州市',
|
||||
district: '天河区',
|
||||
detail: '',
|
||||
isDefault: false,
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
if (options.id) {
|
||||
this.setData({ id: options.id, isEdit: true })
|
||||
this.loadItem(options.id)
|
||||
}
|
||||
},
|
||||
|
||||
async loadItem(id) {
|
||||
wx.showLoading({ title: '加载中...' })
|
||||
try {
|
||||
const res = await app.request('/api/user/addresses/' + id)
|
||||
wx.hideLoading()
|
||||
if (res.success && res.item) {
|
||||
const item = res.item
|
||||
this.setData({
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
province: item.province || '',
|
||||
city: item.city || '',
|
||||
district: item.district || '',
|
||||
region: [item.province || '', item.city || '', item.district || ''],
|
||||
detail: item.detail,
|
||||
isDefault: item.isDefault
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '加载失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
onNameInput(e) {
|
||||
this.setData({ name: e.detail.value.trim() })
|
||||
},
|
||||
|
||||
onPhoneInput(e) {
|
||||
this.setData({ phone: e.detail.value.replace(/\D/g, '').slice(0, 11) })
|
||||
},
|
||||
|
||||
onRegionChange(e) {
|
||||
const region = e.detail.value
|
||||
this.setData({
|
||||
region,
|
||||
province: region[0] || '',
|
||||
city: region[1] || '',
|
||||
district: region[2] || ''
|
||||
})
|
||||
},
|
||||
|
||||
onDetailInput(e) {
|
||||
this.setData({ detail: e.detail.value.trim() })
|
||||
},
|
||||
|
||||
onDefaultChange(e) {
|
||||
this.setData({ isDefault: e.detail.value })
|
||||
},
|
||||
|
||||
async save() {
|
||||
const { id, isEdit, name, phone, province, city, district, detail, isDefault } = this.data
|
||||
if (!name) {
|
||||
wx.showToast({ title: '请输入收货人姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!phone || !/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 省/市/区为选填,不校验
|
||||
if (!detail) {
|
||||
wx.showToast({ title: '请输入详细地址', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const userId = app.globalData.userInfo?.id
|
||||
if (!userId) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
if (isEdit && id) {
|
||||
const res = await app.request('/api/user/addresses/' + id, {
|
||||
method: 'PUT',
|
||||
data: { name, phone, province, city, district, detail, isDefault }
|
||||
})
|
||||
if (res.success) {
|
||||
wx.showToast({ title: '保存成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 1500)
|
||||
} else {
|
||||
wx.showToast({ title: res.message || '保存失败', icon: 'none' })
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
} else {
|
||||
const res = await app.request('/api/user/addresses', {
|
||||
method: 'POST',
|
||||
data: { userId, name, phone, province, city, district, detail, isDefault }
|
||||
})
|
||||
if (res.success) {
|
||||
wx.showToast({ title: '添加成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 1500)
|
||||
} else {
|
||||
wx.showToast({ title: res.message || '添加失败', icon: 'none' })
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.setData({ loading: false })
|
||||
wx.showToast({ title: '保存失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
4
miniprogram/pages/address-edit/address-edit.json
Normal file
4
miniprogram/pages/address-edit/address-edit.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "编辑地址",
|
||||
"usingComponents": {}
|
||||
}
|
||||
40
miniprogram/pages/address-edit/address-edit.wxml
Normal file
40
miniprogram/pages/address-edit/address-edit.wxml
Normal file
@@ -0,0 +1,40 @@
|
||||
<!-- 收货地址 新建/编辑 -->
|
||||
<view class="page">
|
||||
<view class="nav-bar" style="padding-top: {{statusBarHeight}}px;">
|
||||
<view class="nav-back" bindtap="goBack">
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
<text class="nav-title">{{isEdit ? '编辑地址' : '新增地址'}}</text>
|
||||
<view class="nav-placeholder"></view>
|
||||
</view>
|
||||
<view style="height: {{statusBarHeight + 44}}px;"></view>
|
||||
|
||||
<view class="form">
|
||||
<view class="form-item">
|
||||
<text class="label">收货人</text>
|
||||
<input class="input" placeholder="请输入收货人姓名" value="{{name}}" bindinput="onNameInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="label">手机号码</text>
|
||||
<input class="input" type="number" maxlength="11" placeholder="请输入手机号" value="{{phone}}" bindinput="onPhoneInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="label">所在地区(选填)</text>
|
||||
<picker mode="region" value="{{region}}" bindchange="onRegionChange">
|
||||
<view class="picker-value">
|
||||
{{region[0] && region[1] && region[2] ? region[0] + ' ' + region[1] + ' ' + region[2] : '选填,可不选'}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="form-item detail">
|
||||
<text class="label">详细地址</text>
|
||||
<textarea class="textarea" placeholder="街道、楼栋、门牌号等" value="{{detail}}" bindinput="onDetailInput" maxlength="200" />
|
||||
</view>
|
||||
<view class="form-item switch-row">
|
||||
<text class="label">设为默认地址</text>
|
||||
<switch checked="{{isDefault}}" bindchange="onDefaultChange" color="#00CED1" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-save {{loading ? 'disabled' : ''}}" bindtap="save">保存</view>
|
||||
</view>
|
||||
21
miniprogram/pages/address-edit/address-edit.wxss
Normal file
21
miniprogram/pages/address-edit/address-edit.wxss
Normal file
@@ -0,0 +1,21 @@
|
||||
.page { min-height: 100vh; background: #000; padding-bottom: 120rpx; }
|
||||
.nav-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: rgba(0,0,0,0.9); backdrop-filter: blur(40rpx); display: flex; align-items: center; justify-content: space-between; padding: 0 32rpx; height: 88rpx; }
|
||||
.nav-back { width: 64rpx; height: 64rpx; display: flex; align-items: center; justify-content: center; }
|
||||
.back-icon { font-size: 40rpx; color: rgba(255,255,255,0.6); }
|
||||
.nav-title { font-size: 34rpx; font-weight: 600; color: #fff; }
|
||||
.nav-placeholder { width: 64rpx; }
|
||||
|
||||
.form { margin: 24rpx; background: #1c1c1e; border-radius: 24rpx; overflow: hidden; border: 2rpx solid rgba(0,206,209,0.2); }
|
||||
.form-item { display: flex; align-items: center; padding: 28rpx 24rpx; border-bottom: 2rpx solid rgba(255,255,255,0.06); }
|
||||
.form-item:last-child { border-bottom: none; }
|
||||
.form-item.detail { align-items: flex-start; }
|
||||
.form-item .label { width: 160rpx; font-size: 28rpx; color: rgba(255,255,255,0.8); flex-shrink: 0; }
|
||||
.form-item .input { flex: 1; font-size: 28rpx; color: #fff; }
|
||||
.form-item .picker-value { flex: 1; font-size: 28rpx; color: #fff; }
|
||||
.form-item .picker-value:empty:before { content: '请选择省市区'; color: rgba(255,255,255,0.4); }
|
||||
.form-item .textarea { flex: 1; font-size: 28rpx; color: #fff; min-height: 120rpx; }
|
||||
.form-item.switch-row { justify-content: space-between; }
|
||||
.form-item switch { transform: scale(0.9); }
|
||||
|
||||
.btn-save { margin: 48rpx 24rpx 0; height: 88rpx; line-height: 88rpx; text-align: center; background: #00CED1; color: #000; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; }
|
||||
.btn-save.disabled { opacity: 0.6; }
|
||||
83
miniprogram/pages/address-list/address-list.js
Normal file
83
miniprogram/pages/address-list/address-list.js
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Soul创业派对 - 收货地址列表(增删改查)
|
||||
*/
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
list: [],
|
||||
loading: true
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
||||
this.loadList()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadList()
|
||||
},
|
||||
|
||||
async loadList() {
|
||||
const userId = app.globalData.userInfo?.id
|
||||
if (!userId) {
|
||||
this.setData({ list: [], loading: false })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const res = await app.request('/api/user/addresses', { data: { userId } })
|
||||
if (res.success && res.list) {
|
||||
this.setData({ list: res.list, loading: false })
|
||||
} else {
|
||||
this.setData({ list: [], loading: false })
|
||||
}
|
||||
} catch (e) {
|
||||
this.setData({ list: [], loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
goAdd() {
|
||||
wx.navigateTo({ url: '/pages/address-edit/address-edit' })
|
||||
},
|
||||
|
||||
goEdit(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
wx.navigateTo({ url: '/pages/address-edit/address-edit?id=' + id })
|
||||
},
|
||||
|
||||
async deleteAddress(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
const that = this
|
||||
wx.showModal({
|
||||
title: '删除地址',
|
||||
content: '确定要删除该收货地址吗?',
|
||||
success(res) {
|
||||
if (!res.confirm) return
|
||||
that.doDelete(id)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async doDelete(id) {
|
||||
wx.showLoading({ title: '删除中...' })
|
||||
try {
|
||||
const res = await app.request('/api/user/addresses/' + id, { method: 'DELETE' })
|
||||
wx.hideLoading()
|
||||
if (res.success) {
|
||||
wx.showToast({ title: '已删除', icon: 'success' })
|
||||
this.loadList()
|
||||
} else {
|
||||
wx.showToast({ title: res.message || '删除失败', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '删除失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
4
miniprogram/pages/address-list/address-list.json
Normal file
4
miniprogram/pages/address-list/address-list.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "收货地址",
|
||||
"usingComponents": {}
|
||||
}
|
||||
46
miniprogram/pages/address-list/address-list.wxml
Normal file
46
miniprogram/pages/address-list/address-list.wxml
Normal file
@@ -0,0 +1,46 @@
|
||||
<!-- 收货地址列表 - 类似淘宝 -->
|
||||
<view class="page">
|
||||
<view class="nav-bar" style="padding-top: {{statusBarHeight}}px;">
|
||||
<view class="nav-back" bindtap="goBack">
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
<text class="nav-title">收货地址</text>
|
||||
<view class="nav-placeholder"></view>
|
||||
</view>
|
||||
<view style="height: {{statusBarHeight + 44}}px;"></view>
|
||||
|
||||
<view class="content">
|
||||
<view wx:if="{{loading}}" class="loading-wrap">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{list.length === 0}}" class="empty-wrap">
|
||||
<text class="empty-icon">📍</text>
|
||||
<text class="empty-text">暂无收货地址</text>
|
||||
<text class="empty-tip">点击下方按钮添加</text>
|
||||
</view>
|
||||
|
||||
<view wx:else class="address-list">
|
||||
<view
|
||||
class="address-card"
|
||||
wx:for="{{list}}"
|
||||
wx:key="id"
|
||||
data-id="{{item.id}}"
|
||||
bindtap="goEdit"
|
||||
>
|
||||
<view class="card-header">
|
||||
<text class="name">{{item.name}}</text>
|
||||
<text class="phone">{{item.phone}}</text>
|
||||
<view class="default-tag" wx:if="{{item.isDefault}}">默认</view>
|
||||
</view>
|
||||
<view class="card-address">{{item.fullAddress}}</view>
|
||||
<view class="card-actions">
|
||||
<view class="action-btn" catchtap="goEdit" data-id="{{item.id}}">编辑</view>
|
||||
<view class="action-btn delete" catchtap="deleteAddress" data-id="{{item.id}}">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-add" bindtap="goAdd">+ 新增收货地址</view>
|
||||
</view>
|
||||
</view>
|
||||
44
miniprogram/pages/address-list/address-list.wxss
Normal file
44
miniprogram/pages/address-list/address-list.wxss
Normal file
@@ -0,0 +1,44 @@
|
||||
.page { min-height: 100vh; background: #000; padding-bottom: 120rpx; }
|
||||
.nav-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: rgba(0,0,0,0.9); backdrop-filter: blur(40rpx); display: flex; align-items: center; justify-content: space-between; padding: 0 32rpx; height: 88rpx; }
|
||||
.nav-back { width: 64rpx; height: 64rpx; display: flex; align-items: center; justify-content: center; }
|
||||
.back-icon { font-size: 40rpx; color: rgba(255,255,255,0.6); }
|
||||
.nav-title { font-size: 34rpx; font-weight: 600; color: #fff; }
|
||||
.nav-placeholder { width: 64rpx; }
|
||||
|
||||
.content { padding: 24rpx; }
|
||||
.loading-wrap, .empty-wrap { text-align: center; padding: 80rpx 0; }
|
||||
.loading-text { color: rgba(255,255,255,0.5); font-size: 28rpx; }
|
||||
.empty-icon { font-size: 80rpx; display: block; margin-bottom: 24rpx; opacity: 0.6; }
|
||||
.empty-text { color: #fff; font-size: 30rpx; display: block; }
|
||||
.empty-tip { color: rgba(255,255,255,0.4); font-size: 26rpx; display: block; margin-top: 8rpx; }
|
||||
|
||||
.address-list { display: flex; flex-direction: column; gap: 24rpx; }
|
||||
.address-card {
|
||||
background: #1c1c1e;
|
||||
border-radius: 24rpx;
|
||||
padding: 28rpx;
|
||||
border: 2rpx solid rgba(0,206,209,0.2);
|
||||
}
|
||||
.card-header { display: flex; align-items: center; gap: 16rpx; margin-bottom: 16rpx; }
|
||||
.card-header .name { font-size: 30rpx; font-weight: 600; color: #fff; }
|
||||
.card-header .phone { font-size: 26rpx; color: rgba(255,255,255,0.6); }
|
||||
.default-tag { margin-left: auto; padding: 4rpx 12rpx; background: rgba(0,206,209,0.25); color: #00CED1; font-size: 22rpx; border-radius: 8rpx; }
|
||||
.card-address { font-size: 26rpx; color: rgba(255,255,255,0.7); line-height: 1.5; margin-bottom: 20rpx; }
|
||||
.card-actions { display: flex; justify-content: flex-end; gap: 24rpx; }
|
||||
.action-btn { font-size: 26rpx; color: #00CED1; }
|
||||
.action-btn.delete { color: rgba(255,107,107,0.9); }
|
||||
|
||||
.btn-add {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 24rpx;
|
||||
right: 24rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
text-align: center;
|
||||
background: #00CED1;
|
||||
color: #000;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
@@ -32,13 +32,13 @@ Page({
|
||||
latestSection: null,
|
||||
latestLabel: '最新更新',
|
||||
|
||||
// 内容概览
|
||||
// 内容概览(与 Web lib/book-data.ts 一致)
|
||||
partsList: [
|
||||
{ id: 'part-1', number: '一', title: '真实的人', subtitle: '人与人之间的底层逻辑' },
|
||||
{ id: 'part-2', number: '二', title: '真实的行业', subtitle: '电商、内容、传统行业解析' },
|
||||
{ id: 'part-3', number: '三', title: '真实的错误', subtitle: '我和别人犯过的错' },
|
||||
{ id: 'part-4', number: '四', title: '真实的赚钱', subtitle: '底层结构与真实案例' },
|
||||
{ id: 'part-5', number: '五', title: '真实的社会', subtitle: '未来职业与商业生态' }
|
||||
{ id: 'part-1', number: '01', title: '真实的人', subtitle: '人性观察与社交逻辑' },
|
||||
{ id: 'part-2', number: '02', title: '真实的行业', subtitle: '社会运作的底层规则' },
|
||||
{ id: 'part-3', number: '03', title: '真实的错误', subtitle: '错过机会比失败更贵' },
|
||||
{ id: 'part-4', number: '04', title: '真实的赚钱', subtitle: '所有行业的杠杆结构' },
|
||||
{ id: 'part-5', number: '05', title: '真实的未来', subtitle: '人与系统的关系' }
|
||||
],
|
||||
|
||||
// 加载状态
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<view class="search-circle"></view>
|
||||
<view class="search-handle"></view>
|
||||
</view>
|
||||
<text class="search-placeholder">搜索章节标题或内容...</text>
|
||||
<text class="search-placeholder">搜索章节...</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Page({
|
||||
phoneNumber: '',
|
||||
wechatId: '',
|
||||
alipayAccount: '',
|
||||
address: '',
|
||||
addressSummary: '管理收货地址',
|
||||
|
||||
// 自动提现(默认开启)
|
||||
autoWithdrawEnabled: true,
|
||||
@@ -47,7 +47,6 @@ 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 address = wx.getStorageSync('user_address') || userInfo.address || ''
|
||||
// 默认开启自动提现
|
||||
const autoWithdrawEnabled = wx.getStorageSync('auto_withdraw_enabled') !== false
|
||||
|
||||
@@ -57,73 +56,37 @@ Page({
|
||||
phoneNumber,
|
||||
wechatId,
|
||||
alipayAccount,
|
||||
address,
|
||||
autoWithdrawEnabled
|
||||
})
|
||||
this.loadAddressSummary()
|
||||
}
|
||||
},
|
||||
|
||||
// 一键获取收货地址
|
||||
getAddress() {
|
||||
wx.chooseAddress({
|
||||
success: (res) => {
|
||||
console.log('[Settings] 获取地址成功:', res)
|
||||
const fullAddress = `${res.provinceName || ''}${res.cityName || ''}${res.countyName || ''}${res.detailInfo || ''}`
|
||||
|
||||
if (fullAddress.trim()) {
|
||||
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.syncAddressToServer(fullAddress)
|
||||
|
||||
wx.showToast({ title: '地址已获取', icon: 'success' })
|
||||
}
|
||||
},
|
||||
fail: (e) => {
|
||||
console.log('[Settings] 获取地址失败:', e)
|
||||
if (e.errMsg?.includes('cancel')) {
|
||||
// 用户取消,不提示
|
||||
return
|
||||
}
|
||||
if (e.errMsg?.includes('auth deny') || e.errMsg?.includes('authorize')) {
|
||||
wx.showModal({
|
||||
title: '需要授权',
|
||||
content: '请在设置中允许获取收货地址',
|
||||
confirmText: '去设置',
|
||||
success: (res) => {
|
||||
if (res.confirm) wx.openSetting()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showToast({ title: '获取失败,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 同步地址到服务器
|
||||
async syncAddressToServer(address) {
|
||||
// 加载地址摘要(共 N 个地址)
|
||||
async loadAddressSummary() {
|
||||
try {
|
||||
const userId = app.globalData.userInfo?.id
|
||||
if (!userId) return
|
||||
|
||||
await app.request('/api/user/update', {
|
||||
method: 'POST',
|
||||
data: { userId, address }
|
||||
})
|
||||
console.log('[Settings] 地址已同步到服务器')
|
||||
const res = await app.request('/api/user/addresses', { data: { userId } })
|
||||
if (res.success && res.list && res.list.length > 0) {
|
||||
this.setData({ addressSummary: `共${res.list.length}个收货地址` })
|
||||
} else {
|
||||
this.setData({ addressSummary: '管理收货地址' })
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('[Settings] 同步地址失败:', e)
|
||||
this.setData({ addressSummary: '管理收货地址' })
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// 跳转收货地址列表(增删改查),未登录时提示先登录
|
||||
goToAddressList() {
|
||||
if (!app.globalData.isLoggedIn || !app.globalData.userInfo) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/address-list/address-list' })
|
||||
},
|
||||
|
||||
// 切换自动提现
|
||||
async toggleAutoWithdraw(e) {
|
||||
const enabled = e.detail.value
|
||||
|
||||
@@ -58,20 +58,22 @@
|
||||
</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 class="bind-card address-card">
|
||||
<view class="bind-item" bindtap="goToAddressList">
|
||||
<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">{{isLoggedIn ? (addressSummary || '管理收货地址') : '点击登录后管理'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bind-right">
|
||||
<text class="bind-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
.bind-right { display: flex; align-items: center; }
|
||||
.bind-check { color: #00CED1; font-size: 32rpx; }
|
||||
.bind-btn { color: #00CED1; font-size: 26rpx; }
|
||||
.bind-arrow { color: rgba(255,255,255,0.4); font-size: 36rpx; }
|
||||
|
||||
/* 一键获取手机号按钮 */
|
||||
.get-phone-btn {
|
||||
@@ -48,6 +49,9 @@
|
||||
}
|
||||
.get-phone-btn::after { border: none; }
|
||||
|
||||
/* 收货地址独立卡片(始终显示) */
|
||||
.address-card { margin-top: 24rpx; }
|
||||
|
||||
/* 自动提现卡片 */
|
||||
.auto-withdraw-card { margin-top: 24rpx; }
|
||||
.auto-withdraw-content { padding-top: 16rpx; }
|
||||
|
||||
Reference in New Issue
Block a user