Commit 4269c4cd by 张立顺

合并代码

1 parent 11cbfab2
const navStyle = "background-color: transparent;"; const navStyle = 'background-color: transparent;'
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import WxValidate from '~/utils/WxValidate' import WxValidate from '~/utils/wxValidate'
import { import { selectAccountLogin, setLoginInfo } from '../lib/index'
selectAccountLogin,
setLoginInfo
} from '../lib/index'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
navStyle, navStyle,
padHeight:0, padHeight: 0,
headerHeight: 0, headerHeight: 0,
loginMethod: 0, loginMethod: 0,
formData:{ formData: {
phone:'', phone: '',
code:'' code: ''
}, },
authorized: false, authorized: false,
phoneReady: false, phoneReady: false,
disabled: true disabled: true
}, },
navbarReady(e) { navbarReady(e) {
let { let { height } = e.detail
height
} = e.detail;
this.setData({ this.setData({
headerHeight: height, headerHeight: height
}); })
}, },
/** /**
...@@ -44,18 +38,12 @@ Page({ ...@@ -44,18 +38,12 @@ Page({
async init() { async init() {
try { try {
const { const { data, code, message } = await USERAPI.wxCodeLogin()
data,
code,
message
} = await USERAPI.wxCodeLogin()
if (code == '0') { if (code == '0') {
this.loginToken = data this.loginToken = data
} else this.reLogin(message) } else this.reLogin(message)
wx.hideLoading() wx.hideLoading()
} catch ({ } catch ({ errMsg }) {
errMsg
}) {
console.error(errMsg) console.error(errMsg)
this.reLogin() this.reLogin()
} }
...@@ -66,9 +54,7 @@ Page({ ...@@ -66,9 +54,7 @@ Page({
content: message || '获取loginToken失败', content: message || '获取loginToken失败',
confirmText: '重试', confirmText: '重试',
confirmColor: '#3666FE' confirmColor: '#3666FE'
}).then(({ }).then(({ confirm }) => {
confirm
}) => {
if (confirm) this.init() if (confirm) this.init()
}) })
}, },
...@@ -85,7 +71,7 @@ Page({ ...@@ -85,7 +71,7 @@ Page({
// padHeight: 0 // padHeight: 0
// }) // })
// }, // },
// pageScrollToBottom() { // pageScrollToBottom() {
// wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) { // wx.createSelectorQuery().select('.container').boundingClientRect(function(rect) {
// // 使页面滚动到底部 // // 使页面滚动到底部
// wx.pageScrollTo({ // wx.pageScrollTo({
...@@ -93,197 +79,166 @@ Page({ ...@@ -93,197 +79,166 @@ Page({
// }) // })
// }).exec() // }).exec()
// }, // },
handleLogin(){ handleLogin() {
const { const { formData } = this.data,
formData obj = {
} = this.data, mobile: formData.phone,
obj = { code: formData.code
mobile: formData.phone,
code: formData.code
}
if(this.data.showLoading) return;
this.setShowLoading(true)
USERAPI.phoneSmsLogin(obj).then(({
code,
data,
message,
errId
}) => {
this.setShowLoading(false)
if (code == '0') {
this.checkLoginUserInfo(data)
} else if(errId=='30990103') {
this.setData({
authorized:true
})
}else{
wx.$api.showToast(message || '系统异常')
} }
}).catch(err => { if (this.data.showLoading) return
this.setShowLoading(false) this.setShowLoading(true)
wx.$api.showToast('系统异常') USERAPI.phoneSmsLogin(obj)
}) .then(({ code, data, message, errId }) => {
this.setShowLoading(false)
if (code == '0') {
this.checkLoginUserInfo(data)
} else if (errId == '30990103') {
this.setData({
authorized: true
})
} else {
wx.$api.showToast(message || '系统异常')
}
})
.catch(err => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
}, },
/**手机号&微信登录:是否跳转登录列表页 */ /**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo({ checkLoginUserInfo({ loginUserInfoList, sessionId }) {
loginUserInfoList,
sessionId
}) {
/**多个账号 */ /**多个账号 */
console.log(loginUserInfoList,'loginUserInfoList') console.log(loginUserInfoList, 'loginUserInfoList')
if (loginUserInfoList.length > 1) wx.$router.go('/pages/authentication/accountItems/accountItems', { if (loginUserInfoList.length > 1)
sessionId, wx.$router.go('/pages/authentication/accountItems/accountItems', {
...this.options sessionId,
}) ...this.options
/**只有一个账号 */ })
else selectAccountLogin({ /**只有一个账号 */ else
id: loginUserInfoList[0].uuid, selectAccountLogin({
sessionId id: loginUserInfoList[0].uuid,
}) sessionId
})
}, },
switchLoginMethod(e){ switchLoginMethod(e) {
const {type} = e.target.dataset const { type } = e.target.dataset
this.setData({ this.setData({
loginMethod: type loginMethod: type
}) })
}, },
input(e){ input(e) {
const {value} = e.detail const { value } = e.detail
const {name} = e.target.dataset const { name } = e.target.dataset
console.log(e,this.data.formData,'88') console.log(e, this.data.formData, '88')
this.setData({ this.setData({
[`formData.${name}`] : value [`formData.${name}`]: value
}) })
this.checkInfo() this.checkInfo()
}, },
checkInfo(){ checkInfo() {
this.setData({ this.setData({
phoneReady: this.validate.methods.tel(this.data.formData.phone), phoneReady: this.validate.methods.tel(this.data.formData.phone),
disabled: !this.validate.methods.tel(this.data.formData.phone) || this.data.formData?.code?.length !=4 disabled: !this.validate.methods.tel(this.data.formData.phone) || this.data.formData?.code?.length != 4
}) })
}, },
/**获取验证码 */ /**获取验证码 */
getSmsCode() { getSmsCode() {
const { const { phoneReady, formData, count } = this.data,
phoneReady,
formData,
count
} = this.data,
countDown = 60 countDown = 60
if (count || !this.data.phoneReady) return if (count || !this.data.phoneReady) return
// this.setData({ // this.setData({
// smsLoading: true // smsLoading: true
// }) // })
USERAPI.getSmsCode(formData.phone).then(({ USERAPI.getSmsCode(formData.phone)
code, .then(({ code, message }) => {
message // this.setData({
}) => { // smsLoading: false
// this.setData({ // })
// smsLoading: false if (code == '0') this.countDown(countDown)
// }) else wx.$api.showToast(message || '发送验证码失败')
if (code == '0') this.countDown(countDown) })
else wx.$api.showToast(message || '发送验证码失败') .catch(err => {
}).catch(err => { // this.setData({
// this.setData({ // smsLoading: false
// smsLoading: false // })
// }) wx.$api.showToast(err || '发送验证码失败')
wx.$api.showToast(err || '发送验证码失败') })
})
}, },
/**验证码倒计时 */ /**验证码倒计时 */
countDown(countDown) { countDown(countDown) {
if (countDown) this.setData({ if (countDown)
count: countDown this.setData({
}) count: countDown
})
setTimeout(() => { setTimeout(() => {
let { let { count } = this.data
count
} = this.data
this.setData({ this.setData({
count: --count count: --count
}) })
if (count > 0) this.countDown() if (count > 0) this.countDown()
else this.setData({ else
count: null this.setData({
}) count: null
})
}, 1e3) }, 1e3)
}, },
setShowLoading(val){ setShowLoading(val) {
this.setData({ this.setData({
showLoading: val showLoading: val
}) })
}, },
wxLogin({ wxLogin({ detail }) {
detail
}) {
if (!detail.code || this.data.showLoading) return if (!detail.code || this.data.showLoading) return
this.setShowLoading(true) this.setShowLoading(true)
USERAPI.authUserPhone(detail, this.loginToken).then(({ USERAPI.authUserPhone(detail, this.loginToken)
code, .then(({ code, data, message, errId }) => {
data, this.setShowLoading(false)
message, if (code == '0') {
errId this.checkLoginUserInfo(data)
}) => { } else if (errId == '30990103') {
this.setShowLoading(false) this.setData({
if (code == '0'){ authorized: true
this.checkLoginUserInfo(data) })
}else if(errId=='30990103'){ } else {
this.setData({ wx.$api.showToast(message || '系统异常')
authorized:true }
}) })
}else{ .catch(({ errMsg }) => {
wx.$api.showToast(message || '系统异常') this.setShowLoading(false)
} wx.$api.showToast('系统异常')
}).catch(({ })
errMsg
}) => {
this.setShowLoading(false)
wx.$api.showToast('系统异常')
})
}, },
goServicePage(){ goServicePage() {
wx.$router.go('/pages/authentication/customerService/customerService') wx.$router.go('/pages/authentication/customerService/customerService')
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {},
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() { onHide() {},
},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload() { onUnload() {},
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {},
},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { onReachBottom() {},
},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
onShareAppMessage() {}
})
{ {
"setting": { "setting": {
"compileHotReLoad": false, "compileHotReLoad": false,
"urlCheck": false, "urlCheck": true,
"lazyloadPlaceholderEnable": true "lazyloadPlaceholderEnable": false
},
"condition": {
"miniprogram": {
"list": [
{
"name": "个人中心",
"pathName": "pages/tab/mine/mine",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "编辑",
"pathName": "packageMine/pages/editBasicInfo/index",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/login/login",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/register/register",
"query": "data=%7B%22staffName%22%3A%22%E6%81%92%E6%B2%B3%E7%8C%B4%22%2C%22merchantId%22%3A44184606%2C%22fileUrl%22%3A%22https%3A%2F%2Fimg1.baidu.com%2Fit%2Fu%3D1755961019%2C1690032781%26fm%3D253%26app%3D138%26size%3Dw931%26n%3D0%26f%3DJPEG%26fmt%3Dauto%3Fsec%3D1665766800%26t%3D0b9617eab6fe013e35dc2e491e2e2100%22%7D",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/registerSuccess/registerSuccess",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/registerInfo/registerInfo",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/authentication/customerService/customerService",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/visitor/visitor",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/order/order",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/applyActivity/applyActivity",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/applySuccess/applySuccess",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/taskDetail/taskDetail",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "packageActivity/pages/order/order",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
}, },
"condition": {},
"projectname": "store-assistant", "projectname": "store-assistant",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.26.1" "libVersion": "2.26.1"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!