nurseWeChatAppletUI/pages/login/login.vue

68 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<view class="app">
<view class="title">
<image src="../../static/logo.png" mode=""></image>
<view class="text">
泉医到家
</view>
</view>
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp">微信一键登录</button>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
appLoginpwd,
getWeChatUser
} from '../../api/login/index.js'
export default {
data() {
return {
phonecode: '',
logincode: '',
timer:null,
};
},
methods: {
getPhoneNumberp(val) {
let that = this;
this.phonecode = val.detail.code
wx.login({
provider: 'weixin',
success: function(loginRes) {
that.logincode = loginRes.code
that.pwdlogin();
}
});
},
pwdlogin() {
getWeChatUser(this.logincode, this.phonecode).then(res => {
if (res.code == 200) {
uni.setStorageSync("openid", res.data.openid)
uni.setStorageSync("patientId", res.data.id)
uni.setStorageSync("phone", res.data.phone)
this.$refs.uToast.show({
title: '登录成功',
type: 'success',
duration: '1500'
})
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(e => {
uni.navigateBack({
delta: 1
})
}, 1500)
}
})
},
},
toLogin() {}
}
</script>
<style lang="scss">
@import "./login.scss";
</style>