Browse Source

短信验证码登录

master
453530270@qq.com 3 years ago
parent
commit
d721ab46ee
  1. 88
      pages/login/loginsms.vue

88
pages/login/loginsms.vue

@ -47,7 +47,8 @@
</template>
<script>
import * as LoginApi from '@/api/login'
import store from '@/store'
export default {
components: {
@ -60,67 +61,56 @@
isLoad: false,
//
mobile: '',
//
vpass:"",
}
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
console.log('login onLoad')
//
// await this.setShowUserInfo()
//
this.isLoad = true
console.log('isLoad', true)
},
methods: {
//
handleLogin() {
const app = this
if (!app.isLoading && app.formValidation(SUBMIT_LOGIN)) {
if (!app.isLoading && app.formValidationMobile(app.mobile)) {
app.submitLogin()
}
},
//
formValidationMobile(str){
if (Verify.isEmpty(str)) {
this.$toast('手机号不能为空')
return false
}
return true
},
//
submitLogin() {
const app = this
app.isLoading = true
store.dispatch('Login', {
smsCode: app.smsCode,
mobile: app.mobile,
isParty: app.isParty,
partyData: app.partyData
})
.then(result => {
//
app.$toast(result.message)
// :
uni.$emit('syncRefresh', true)
//
setTimeout(() => app.onNavigateBack(1), 2000)
})
.catch(err => {
//
if (err.result.data.isBack) {
setTimeout(() => app.onNavigateBack(1), 2000)
}
})
.finally(() => app.isLoading = false)
},
/**
* 设置当前是否显示微信小程序授权登录
* - 条件1: 只有微信小程序才显示获取用户信息按钮
* - 条件2: 后台设置是否已开启该选项 [后台-客户端-注册设置]
*/
async setShowUserInfo() {
console.log('setShowUserInfo start')
const app = this
// , getUserProfile
const isMpWeixin = app.platform === 'MP-WEIXIN' && wx.canIUse('getUserProfile')
//
await SettingModel.item(SettingKeyEnum.REGISTER.value, false)
.then(setting => {
app.isMpWeixinAuth = isMpWeixin && setting.isOauthMpweixin
console.log('setShowUserInfo complete')
})
},
//
onGetUserInfoSuccess({ oauth, code, userInfo }) {
//
this.partyData = { oauth, code, userInfo }
//
this.onShowRegister()
},
//
onShowRegister() {
//
this.isMpWeixinAuth = false
//
this.isParty = true
}
}
}
</script>

Loading…
Cancel
Save