Browse Source

短信验证码登录

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

90
pages/login/loginsms.vue

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

Loading…
Cancel
Save