同步数据
This commit is contained in:
@@ -1,68 +1,117 @@
|
||||
// pages/address-edit/address-edit.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88
|
||||
navBarHeight: 88,
|
||||
id: '',
|
||||
isEdit: false,
|
||||
name: '',
|
||||
phone: '',
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
detail: '',
|
||||
isDefault: false,
|
||||
loading: false,
|
||||
saving: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const statusBarHeight = app.globalData.statusBarHeight || 44
|
||||
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
|
||||
this.setData({ statusBarHeight, navBarHeight })
|
||||
const id = (options && options.id) ? decodeURIComponent(options.id) : ''
|
||||
this.setData({ statusBarHeight, navBarHeight, id, isEdit: !!id })
|
||||
if (id) this.loadAddress(id)
|
||||
},
|
||||
|
||||
loadAddress(id) {
|
||||
this.setData({ loading: true })
|
||||
app.request('/api/user/addresses/' + encodeURIComponent(id))
|
||||
.then(res => {
|
||||
const item = res && res.item ? res.item : null
|
||||
if (!item) {
|
||||
this.setData({ loading: false })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
loading: false,
|
||||
name: item.name || '',
|
||||
phone: item.phone || '',
|
||||
province: item.province || '',
|
||||
city: item.city || '',
|
||||
district: item.district || '',
|
||||
detail: item.detail || '',
|
||||
isDefault: !!item.isDefault
|
||||
})
|
||||
})
|
||||
.catch(() => this.setData({ loading: false }))
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack({ fail: () => wx.switchTab({ url: '/pages/my/my' }) })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
onNameInput(e) { this.setData({ name: (e.detail && e.detail.value) || '' }) },
|
||||
onPhoneInput(e) { this.setData({ phone: (e.detail && e.detail.value) || '' }) },
|
||||
onProvinceInput(e) { this.setData({ province: (e.detail && e.detail.value) || '' }) },
|
||||
onCityInput(e) { this.setData({ city: (e.detail && e.detail.value) || '' }) },
|
||||
onDistrictInput(e) { this.setData({ district: (e.detail && e.detail.value) || '' }) },
|
||||
onDetailInput(e) { this.setData({ detail: (e.detail && e.detail.value) || '' }) },
|
||||
onDefaultChange(e) { this.setData({ isDefault: !!e.detail.value }) },
|
||||
|
||||
submit() {
|
||||
const { id, isEdit, name, phone, province, city, district, detail, isDefault } = this.data
|
||||
const user = app.globalData.userInfo
|
||||
if (!user || !user.id) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!name || !name.trim()) {
|
||||
wx.showToast({ title: '请输入姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!phone || !phone.trim()) {
|
||||
wx.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone.trim())) {
|
||||
wx.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!detail || !detail.trim()) {
|
||||
wx.showToast({ title: '请输入详细地址', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ saving: true })
|
||||
const body = {
|
||||
userId: user.id,
|
||||
name: name.trim(),
|
||||
phone: phone.trim(),
|
||||
province: (province || '').trim(),
|
||||
city: (city || '').trim(),
|
||||
district: (district || '').trim(),
|
||||
detail: detail.trim(),
|
||||
isDefault: !!isDefault
|
||||
}
|
||||
if (isEdit && id) {
|
||||
app.request('/api/user/addresses/' + encodeURIComponent(id), {
|
||||
method: 'PUT',
|
||||
data: body
|
||||
}).then(() => {
|
||||
this.setData({ saving: false })
|
||||
wx.showToast({ title: '保存成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 1500)
|
||||
}).catch(() => this.setData({ saving: false }))
|
||||
} else {
|
||||
app.request('/api/user/addresses', {
|
||||
method: 'POST',
|
||||
data: body
|
||||
}).then(() => {
|
||||
this.setData({ saving: false })
|
||||
wx.showToast({ title: '添加成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 1500)
|
||||
}).catch(() => this.setData({ saving: false }))
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,49 @@
|
||||
<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>
|
||||
<text class="header-title">{{isEdit ? '编辑地址' : '新增地址'}}</text>
|
||||
</view>
|
||||
<view class="placeholder-body">待开发</view>
|
||||
|
||||
<block wx:if="{{loading}}">
|
||||
<view class="empty-wrap">
|
||||
<text class="empty-desc">加载中...</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:else>
|
||||
<view class="form">
|
||||
<view class="form-item">
|
||||
<text class="form-label">姓名</text>
|
||||
<input class="form-input" placeholder="请输入姓名" value="{{name}}" bindinput="onNameInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">手机号</text>
|
||||
<input class="form-input" type="number" maxlength="11" placeholder="请输入11位手机号" value="{{phone}}" bindinput="onPhoneInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">省份</text>
|
||||
<input class="form-input" placeholder="选填" value="{{province}}" bindinput="onProvinceInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">城市</text>
|
||||
<input class="form-input" placeholder="选填" value="{{city}}" bindinput="onCityInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">区/县</text>
|
||||
<input class="form-input" placeholder="选填" value="{{district}}" bindinput="onDistrictInput" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="form-label">详细地址</text>
|
||||
<textarea class="form-textarea" placeholder="街道、门牌号等" value="{{detail}}" bindinput="onDetailInput" />
|
||||
</view>
|
||||
<view class="form-item row">
|
||||
<text class="form-label">设为默认地址</text>
|
||||
<switch checked="{{isDefault}}" bindchange="onDefaultChange" color="#00CED1" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-save {{saving ? 'disabled' : ''}}" bindtap="submit">
|
||||
{{saving ? '保存中...' : '保存'}}
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
page { background: #000; color: #fff; }
|
||||
.page { min-height: 100vh; }
|
||||
.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; }
|
||||
.placeholder-body { padding: 48rpx; text-align: center; color: rgba(255,255,255,0.4); font-size: 28rpx; }
|
||||
.container { padding: 32rpx; }
|
||||
|
||||
.empty-wrap { padding: 80rpx 48rpx; text-align: center; }
|
||||
.empty-desc { font-size: 28rpx; color: rgba(255,255,255,0.5); }
|
||||
|
||||
.form { padding: 32rpx; }
|
||||
.form-item { margin-bottom: 32rpx; }
|
||||
.form-item.row { display: flex; align-items: center; justify-content: space-between; }
|
||||
.form-label { font-size: 28rpx; color: rgba(255,255,255,0.6); display: block; margin-bottom: 16rpx; }
|
||||
.form-item.row .form-label { margin-bottom: 0; }
|
||||
.form-input { width: 100%; padding: 24rpx 32rpx; border-radius: 16rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.1); color: #fff; font-size: 28rpx; box-sizing: border-box; }
|
||||
.form-textarea { width: 100%; min-height: 160rpx; padding: 24rpx 32rpx; border-radius: 16rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.1); color: #fff; font-size: 28rpx; box-sizing: border-box; }
|
||||
|
||||
.btn-save { margin: 32rpx; padding: 28rpx; border-radius: 24rpx; background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%); color: #000; font-size: 30rpx; font-weight: 600; text-align: center; box-sizing: border-box; }
|
||||
.btn-save.disabled { opacity: 0.5; }
|
||||
|
||||
@@ -1,68 +1,80 @@
|
||||
// pages/address-list/address-list.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88
|
||||
navBarHeight: 88,
|
||||
user: null,
|
||||
list: [],
|
||||
loading: true
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
onLoad() {
|
||||
const statusBarHeight = app.globalData.statusBarHeight || 44
|
||||
const navBarHeight = app.globalData.navBarHeight || (statusBarHeight + 44)
|
||||
this.setData({ statusBarHeight, navBarHeight })
|
||||
this.syncUser()
|
||||
this.loadList()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadList()
|
||||
},
|
||||
|
||||
syncUser() {
|
||||
const user = app.globalData.userInfo || null
|
||||
this.setData({ user })
|
||||
},
|
||||
|
||||
loadList() {
|
||||
const user = app.globalData.userInfo
|
||||
if (!user || !user.id) {
|
||||
this.setData({ list: [], loading: false })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
app.request('/api/user/addresses?userId=' + encodeURIComponent(user.id))
|
||||
.then(res => {
|
||||
const list = (res && res.list) ? res.list : []
|
||||
this.setData({ list, loading: false })
|
||||
})
|
||||
.catch(() => this.setData({ loading: false }))
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack({ fail: () => wx.switchTab({ url: '/pages/my/my' }) })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
goAdd() {
|
||||
wx.navigateTo({ url: '/pages/address-edit/address-edit' })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
goEdit(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
if (id) wx.navigateTo({ url: '/pages/address-edit/address-edit?id=' + encodeURIComponent(id) })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
deleteAddr(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
if (!id) return
|
||||
const that = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该收货地址吗?',
|
||||
success(res) {
|
||||
if (!res.confirm) return
|
||||
app.request('/api/user/addresses/' + encodeURIComponent(id), { method: 'DELETE' })
|
||||
.then(data => {
|
||||
if (data && data.success) {
|
||||
const list = that.data.list.filter(item => item.id !== id)
|
||||
that.setData({ list })
|
||||
wx.showToast({ title: '已删除', icon: 'success' })
|
||||
} else {
|
||||
wx.showToast({ title: (data && data.message) ? data.message : '删除失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
.catch(() => wx.showToast({ title: '删除失败', icon: 'none' }))
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,50 @@
|
||||
<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>
|
||||
<text class="header-title">收货地址</text>
|
||||
</view>
|
||||
<view class="placeholder-body">待开发</view>
|
||||
|
||||
<block wx:if="{{!user}}">
|
||||
<view class="empty-wrap">
|
||||
<text class="empty-desc">请先登录</text>
|
||||
<view class="btn-primary" bindtap="goBack">去登录</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{loading}}">
|
||||
<view class="empty-wrap">
|
||||
<text class="empty-desc">加载中...</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{list.length === 0}}">
|
||||
<view class="empty-wrap">
|
||||
<text class="empty-icon">📍</text>
|
||||
<text class="empty-desc">暂无收货地址</text>
|
||||
<text class="empty-hint">点击下方按钮添加</text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:else>
|
||||
<view class="addr-list">
|
||||
<view
|
||||
class="addr-card"
|
||||
wx:for="{{list}}"
|
||||
wx:key="id"
|
||||
>
|
||||
<view class="addr-row">
|
||||
<text class="addr-name">{{item.name}}</text>
|
||||
<text class="addr-phone">{{item.phone}}</text>
|
||||
<text class="addr-default" wx:if="{{item.isDefault}}">默认</text>
|
||||
</view>
|
||||
<text class="addr-full">{{item.fullAddress}}</text>
|
||||
<view class="addr-actions">
|
||||
<view class="addr-btn" data-id="{{item.id}}" bindtap="goEdit">编辑</view>
|
||||
<view class="addr-btn danger" data-id="{{item.id}}" bindtap="deleteAddr">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view class="btn-add" wx:if="{{user}}" bindtap="goAdd">➕ 新增收货地址</view>
|
||||
</view>
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
page { background: #000; color: #fff; }
|
||||
.page { min-height: 100vh; }
|
||||
.page { min-height: 100vh; padding-bottom: 160rpx; 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; }
|
||||
.placeholder-body { padding: 48rpx; text-align: center; color: rgba(255,255,255,0.4); font-size: 28rpx; }
|
||||
.container { padding: 32rpx; }
|
||||
|
||||
.empty-wrap { padding: 80rpx 48rpx; text-align: center; }
|
||||
.empty-icon { font-size: 96rpx; display: block; margin-bottom: 24rpx; opacity: 0.5; }
|
||||
.empty-desc { font-size: 28rpx; color: rgba(255,255,255,0.5); display: block; margin-bottom: 16rpx; }
|
||||
.empty-hint { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; }
|
||||
.btn-primary { display: inline-block; padding: 24rpx 64rpx; border-radius: 48rpx; background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%); color: #000; font-size: 30rpx; font-weight: 600; }
|
||||
|
||||
.addr-list { padding: 32rpx; }
|
||||
.addr-card { padding: 32rpx; border-radius: 24rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.05); margin-bottom: 24rpx; box-sizing: border-box; }
|
||||
.addr-row { display: flex; align-items: center; gap: 16rpx; margin-bottom: 16rpx; flex-wrap: wrap; }
|
||||
.addr-name { font-size: 30rpx; color: #fff; font-weight: 500; }
|
||||
.addr-phone { font-size: 26rpx; color: rgba(255,255,255,0.5); }
|
||||
.addr-default { font-size: 22rpx; padding: 4rpx 16rpx; border-radius: 8rpx; background: rgba(0,206,209,0.2); color: #00CED1; }
|
||||
.addr-full { font-size: 26rpx; color: rgba(255,255,255,0.6); line-height: 1.5; display: block; margin-bottom: 24rpx; }
|
||||
.addr-actions { display: flex; justify-content: flex-end; gap: 32rpx; padding-top: 24rpx; border-top: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.addr-btn { font-size: 28rpx; color: #00CED1; }
|
||||
.addr-btn.danger { color: #f87171; }
|
||||
|
||||
.btn-add { position: fixed; bottom: 0; left: 0; right: 0; margin: 32rpx; padding: 28rpx; border-radius: 24rpx; background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%); color: #000; font-size: 30rpx; font-weight: 600; text-align: center; box-sizing: border-box; }
|
||||
|
||||
@@ -1,68 +1,104 @@
|
||||
// pages/referral/referral.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
navBarHeight: 88
|
||||
navBarHeight: 88,
|
||||
isLoggedIn: false,
|
||||
user: null,
|
||||
totalEarnings: '0.00',
|
||||
pendingEarnings: '0.00',
|
||||
referralCode: '',
|
||||
distributorShare: 90,
|
||||
canWithdraw: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
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 isLoggedIn = !!app.globalData.isLoggedIn
|
||||
const user = app.globalData.userInfo || null
|
||||
if (!user) {
|
||||
this.setData({ isLoggedIn: false, user: null })
|
||||
return
|
||||
}
|
||||
const total = Number(user.earnings != null ? user.earnings : 0)
|
||||
const totalEarnings = total.toFixed(2)
|
||||
const pendingEarnings = Number(user.pendingEarnings != null ? user.pendingEarnings : 0).toFixed(2)
|
||||
const referralCode = user.referralCode || ''
|
||||
this.setData({
|
||||
isLoggedIn: true,
|
||||
user,
|
||||
totalEarnings,
|
||||
pendingEarnings,
|
||||
referralCode,
|
||||
canWithdraw: total >= 10
|
||||
})
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack({ fail: () => wx.switchTab({ url: '/pages/my/my' }) })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
copyLink() {
|
||||
const user = app.globalData.userInfo
|
||||
if (!user || !user.referralCode) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const baseUrl = app.globalData.baseUrl || 'https://soul.quwanzhi.com'
|
||||
const link = baseUrl + '?ref=' + user.referralCode
|
||||
wx.setClipboardData({
|
||||
data: link,
|
||||
success: () => wx.showToast({ title: '链接已复制', icon: 'success' })
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
shareToMoments() {
|
||||
const user = app.globalData.userInfo
|
||||
if (!user || !user.referralCode) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const baseUrl = app.globalData.baseUrl || 'https://soul.quwanzhi.com'
|
||||
const link = baseUrl + '?ref=' + user.referralCode
|
||||
const text = `📖 推荐一本好书《一场SOUL的创业实验场》
|
||||
|
||||
这是卡若每天早上6-9点在Soul派对房分享的真实商业故事,55个真实案例,讲透创业的底层逻辑。
|
||||
|
||||
👉 点击阅读: ${link}
|
||||
|
||||
#创业 #商业思维 #Soul派对`
|
||||
wx.setClipboardData({
|
||||
data: text,
|
||||
success: () => wx.showToast({ title: '朋友圈文案已复制', icon: 'success' })
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
applyWithdraw() {
|
||||
const user = app.globalData.userInfo
|
||||
if (!user) {
|
||||
wx.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const total = Number(user.earnings != null ? user.earnings : 0)
|
||||
if (total < 10) {
|
||||
wx.showToast({ title: '满10元可提现', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: '请在小程序内联系客服或使用提现功能',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,5 +4,59 @@
|
||||
<view class="nav-back" bindtap="goBack">← 返回</view>
|
||||
<text class="header-title">推广中心</text>
|
||||
</view>
|
||||
<view class="placeholder-body">待开发</view>
|
||||
|
||||
<block wx:if="{{!isLoggedIn}}">
|
||||
<view class="empty-wrap">
|
||||
<text class="empty-desc">请先登录</text>
|
||||
<view class="btn-primary" bindtap="goBack">返回我的</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:else>
|
||||
<view class="earnings-card">
|
||||
<view class="earnings-head">
|
||||
<view class="earnings-title-row">
|
||||
<text class="earnings-icon">💰</text>
|
||||
<view>
|
||||
<text class="earnings-label">累计收益</text>
|
||||
<text class="earnings-rate">{{distributorShare}}% 返利</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="earnings-right">
|
||||
<text class="earnings-total">¥{{totalEarnings}}</text>
|
||||
<text class="earnings-pending">待结算: ¥{{pendingEarnings}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-withdraw {{canWithdraw ? '' : 'disabled'}}" bindtap="applyWithdraw">
|
||||
{{canWithdraw ? '申请提现' : '满10元可提现'}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="code-card">
|
||||
<view class="code-row">
|
||||
<text class="code-label">我的邀请码</text>
|
||||
<text class="code-value">{{referralCode}}</text>
|
||||
</view>
|
||||
<text class="code-desc">好友通过你的链接购买立省5%,你获得{{distributorShare}}%收益</text>
|
||||
</view>
|
||||
|
||||
<view class="action-list">
|
||||
<view class="action-item" bindtap="copyLink">
|
||||
<view class="action-icon">🔗</view>
|
||||
<view class="action-text">
|
||||
<text class="action-title">复制邀请链接</text>
|
||||
<text class="action-desc">分享给好友购买</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
<view class="action-item" bindtap="shareToMoments">
|
||||
<view class="action-icon wechat">💬</view>
|
||||
<view class="action-text">
|
||||
<text class="action-title">分享到朋友圈</text>
|
||||
<text class="action-desc">复制文案发朋友圈</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
page { background: #000; color: #fff; }
|
||||
.page { min-height: 100vh; }
|
||||
.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; }
|
||||
.placeholder-body { padding: 48rpx; text-align: center; color: rgba(255,255,255,0.4); font-size: 28rpx; }
|
||||
.container { padding: 32rpx; }
|
||||
|
||||
.empty-wrap { padding: 80rpx 48rpx; text-align: center; }
|
||||
.empty-desc { font-size: 28rpx; color: rgba(255,255,255,0.5); display: block; margin-bottom: 32rpx; }
|
||||
.btn-primary { display: inline-block; padding: 24rpx 64rpx; border-radius: 48rpx; background: linear-gradient(135deg, #00CED1 0%, #20B2AA 100%); color: #000; font-size: 30rpx; font-weight: 600; }
|
||||
|
||||
.earnings-card { margin: 32rpx; padding: 32rpx; border-radius: 32rpx; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); border: 2rpx solid rgba(0,206,209,0.2); box-sizing: border-box; }
|
||||
.earnings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24rpx; gap: 24rpx; min-width: 0; }
|
||||
.earnings-title-row { display: flex; align-items: center; gap: 16rpx; min-width: 0; }
|
||||
.earnings-icon { font-size: 40rpx; flex-shrink: 0; }
|
||||
.earnings-label { font-size: 24rpx; color: rgba(255,255,255,0.5); display: block; }
|
||||
.earnings-rate { font-size: 24rpx; color: #00CED1; display: block; margin-top: 4rpx; }
|
||||
.earnings-right { text-align: right; flex-shrink: 0; }
|
||||
.earnings-total { font-size: 56rpx; font-weight: 700; color: #fff; display: block; }
|
||||
.earnings-pending { font-size: 24rpx; color: rgba(255,255,255,0.5); }
|
||||
.btn-withdraw { width: 100%; padding: 24rpx; border-radius: 24rpx; background: linear-gradient(90deg, #00CED1 0%, #20B2AA 100%); color: #000; font-size: 30rpx; font-weight: 600; text-align: center; margin-top: 16rpx; box-sizing: border-box; }
|
||||
.btn-withdraw.disabled { opacity: 0.5; background: #2c2c2e; color: rgba(255,255,255,0.5); }
|
||||
|
||||
.code-card { margin: 32rpx; padding: 32rpx; border-radius: 24rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.code-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16rpx; }
|
||||
.code-label { font-size: 30rpx; color: #fff; font-weight: 500; }
|
||||
.code-value { font-size: 28rpx; color: #00CED1; font-family: monospace; background: rgba(0,206,209,0.1); padding: 12rpx 24rpx; border-radius: 16rpx; }
|
||||
.code-desc { font-size: 24rpx; color: rgba(255,255,255,0.5); }
|
||||
|
||||
.action-list { margin: 32rpx; border-radius: 24rpx; background: #1c1c1e; border: 2rpx solid rgba(255,255,255,0.05); overflow: hidden; }
|
||||
.action-item { display: flex; align-items: center; padding: 32rpx; border-bottom: 2rpx solid rgba(255,255,255,0.05); }
|
||||
.action-item:last-child { border-bottom: none; }
|
||||
.action-icon { width: 80rpx; height: 80rpx; border-radius: 20rpx; background: rgba(0,206,209,0.15); display: flex; align-items: center; justify-content: center; font-size: 40rpx; margin-right: 24rpx; flex-shrink: 0; }
|
||||
.action-icon.wechat { background: rgba(7,193,96,0.15); }
|
||||
.action-text { flex: 1; min-width: 0; }
|
||||
.action-title { font-size: 30rpx; color: #fff; font-weight: 500; display: block; }
|
||||
.action-desc { font-size: 24rpx; color: rgba(255,255,255,0.4); display: block; margin-top: 8rpx; }
|
||||
.action-arrow { font-size: 32rpx; color: rgba(255,255,255,0.3); }
|
||||
|
||||
Reference in New Issue
Block a user