105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
const app = getApp()
|
||
|
||
Page({
|
||
data: {
|
||
statusBarHeight: 44,
|
||
navBarHeight: 88,
|
||
isLoggedIn: false,
|
||
user: null,
|
||
totalEarnings: '0.00',
|
||
pendingEarnings: '0.00',
|
||
referralCode: '',
|
||
distributorShare: 90,
|
||
canWithdraw: false
|
||
},
|
||
|
||
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' }) })
|
||
},
|
||
|
||
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' })
|
||
})
|
||
},
|
||
|
||
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' })
|
||
})
|
||
},
|
||
|
||
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
|
||
})
|
||
}
|
||
})
|