- 超级个体:去掉首位特例;列表仅展示有头像且非微信默认昵称(vip.go) - 个人资料:居中头像、低调联系方式、点头像优先走存客宝 lead(ckbLeadToken) - 阅读页分享朋友圈复制与 toast 去重 - soul-api: miniprogram users 带 ckbLeadToken;其它 handler 与路由调整 - 脚本:content_upload、miniprogram 上传辅助等 Made-with: Cursor
82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
/**
|
||
* 卡若创业派对 - 开发登录页(仅本地调试)
|
||
* 勿写入 app.json pages:提审包不得注册本页。
|
||
* 需要用时在 app.json 的 pages 数组末尾临时加入 "pages/dev-login/dev-login"。
|
||
*/
|
||
const app = getApp()
|
||
const { checkAndExecute } = require('../../utils/ruleEngine.js')
|
||
|
||
Page({
|
||
data: {
|
||
statusBarHeight: 44,
|
||
account: '',
|
||
password: '',
|
||
loading: false
|
||
},
|
||
|
||
onLoad() {
|
||
this.setData({
|
||
statusBarHeight: app.globalData.statusBarHeight || 44
|
||
})
|
||
},
|
||
|
||
onAccountInput(e) {
|
||
this.setData({ account: (e.detail.value || '').trim() })
|
||
},
|
||
|
||
onPasswordInput(e) {
|
||
this.setData({ password: e.detail.value || '' })
|
||
},
|
||
|
||
goBack() {
|
||
app.goBackOrToHome()
|
||
},
|
||
|
||
async handleLogin() {
|
||
const { account, password, loading } = this.data
|
||
if (!account || loading) return
|
||
|
||
const phone = account.replace(/\s/g, '')
|
||
if (phone.length < 11) {
|
||
wx.showToast({ title: '请输入11位手机号', icon: 'none' })
|
||
return
|
||
}
|
||
|
||
this.setData({ loading: true })
|
||
try {
|
||
const res = await app.request('/api/miniprogram/dev/login-by-phone', {
|
||
method: 'POST',
|
||
data: { phone, password: password || '' }
|
||
})
|
||
|
||
if (res.success && res.data) {
|
||
const user = res.data.user
|
||
app.globalData.userInfo = user
|
||
app.globalData.isLoggedIn = true
|
||
app.globalData.purchasedSections = user.purchasedSections || []
|
||
app.globalData.hasFullBook = user.hasFullBook || false
|
||
app.globalData.isVip = user.isVip || false
|
||
app.globalData.vipExpireDate = user.vipExpireDate || ''
|
||
|
||
wx.setStorageSync('userInfo', user)
|
||
wx.setStorageSync('token', res.data.token)
|
||
|
||
const pendingRef = wx.getStorageSync('pendingReferralCode') || app.globalData.pendingReferralCode
|
||
if (pendingRef) {
|
||
app.bindReferralCode(pendingRef)
|
||
}
|
||
|
||
checkAndExecute('after_login', null)
|
||
setTimeout(() => app.checkVipContactRequiredAndGuide(), 1200)
|
||
|
||
wx.showToast({ title: '登录成功', icon: 'success' })
|
||
setTimeout(() => wx.switchTab({ url: '/pages/index/index' }), 800)
|
||
}
|
||
} catch (e) {
|
||
wx.showToast({ title: e.message || '登录失败', icon: 'none' })
|
||
} finally {
|
||
this.setData({ loading: false })
|
||
}
|
||
}
|
||
})
|