Browse Source

短信验证码登录

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

80
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
},
//
submitLogin() {
const app = this const app = this
// , getUserProfile app.isLoading = true
const isMpWeixin = app.platform === 'MP-WEIXIN' && wx.canIUse('getUserProfile') store.dispatch('Login', {
smsCode: app.smsCode,
// mobile: app.mobile,
await SettingModel.item(SettingKeyEnum.REGISTER.value, false) isParty: app.isParty,
.then(setting => { partyData: app.partyData
app.isMpWeixinAuth = isMpWeixin && setting.isOauthMpweixin
console.log('setShowUserInfo complete')
}) })
.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)
}, },
//
onGetUserInfoSuccess({ oauth, code, userInfo }) {
//
this.partyData = { oauth, code, userInfo }
//
this.onShowRegister()
},
//
onShowRegister() {
//
this.isMpWeixinAuth = false
//
this.isParty = true
}
} }
} }
</script> </script>

Loading…
Cancel
Save