xinelu-applet-ui/pages/login/login.vue

122 lines
2.9 KiB
Vue
Raw Normal View History

2023-09-22 11:08:14 +08:00
<template>
<view class="app">
2023-09-22 15:39:13 +08:00
<image src="../../static/logo.png" mode=""></image>
2023-09-26 09:59:01 +08:00
<!-- <view class="text">
2023-09-22 15:39:13 +08:00
新医路健康服务平台
2023-09-26 09:59:01 +08:00
</view> -->
2023-09-22 11:08:14 +08:00
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp">手机号快捷登录</button>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
appLoginpwd,
getWeChatUser,
2023-09-22 11:45:09 +08:00
} from '../../api/pages/login/index.js'
2023-09-22 11:08:14 +08:00
import {
createMobileToken
2023-09-22 11:45:09 +08:00
} from '@/api/pages/login/index.js'
2023-09-22 11:08:14 +08:00
export default {
data() {
return {
phonecode: undefined,
logincode: undefined,
2023-10-10 13:21:23 +08:00
code:undefined,
2023-09-22 11:08:14 +08:00
timer: undefined,
scenenurseStationId: undefined
};
},
onShow() {
this.phonecode = undefined
this.logincode = undefined
2023-10-10 13:21:23 +08:00
this.code = undefined
2023-09-22 11:08:14 +08:00
this.scenenurseStationId = uni.getStorageSync('scenenurseStationId');
},
methods: {
getPhoneNumberp(val) {
let that = this;
if (val.detail.code) {
that.phonecode = val.detail.code
wx.login({
provider: 'weixin',
success: function(loginRes) {
2023-10-10 13:21:23 +08:00
console.log(loginRes)
// uni.$emit('code',loginRes.code)
that.code = loginRes.code
2023-09-22 11:08:14 +08:00
that.pwdlogin();
}
});
}
},
login() {
2023-10-10 13:21:23 +08:00
getWeChatUser(this.code).then(res => {
2023-09-22 11:08:14 +08:00
if (res.code == 200) {
2023-10-10 13:21:23 +08:00
uni.setStorageSync("openid", res.data)
2023-09-22 11:08:14 +08:00
uni.setStorageSync("patientId", res.data.id)
uni.setStorageSync("phone", res.data.phone)
this.$refs.uToast.show({
title: '登录成功',
type: 'success',
duration: '1500'
})
2023-10-10 13:21:23 +08:00
console.log(this.logincode)
2023-09-22 11:08:14 +08:00
this.phonecode = undefined
this.logincode = undefined
uni.setStorageSync("Refresh", 'Refresh')
if (this.timer) {
clearTimeout(this.timer)
}
2023-10-10 13:21:23 +08:00
// this.timer = setTimeout(e => {
// uni.navigateBack({
// delta: 1
// })
// }, 500)
2023-09-22 11:08:14 +08:00
} else {
this.$refs.uToast.show({
title: '登录失败',
type: 'error',
duration: '1500'
})
}
})
},
pwdlogin() {
var that = this
uni.clearStorageSync();
2023-10-10 13:21:23 +08:00
uni.navigateTo({
url:`/pages/register/register?code=${this.logincode}`
2023-09-22 11:08:14 +08:00
})
2023-10-10 13:21:23 +08:00
that.login()
// createMobileToken().then(res => {
// uni.setStorageSync("token", res.data.token)
// if (this.scenenurseStationId) {
// uni.setStorageSync("scenenurseStationId", this.scenenurseStationId)
// }
// that.login()
// })
2023-09-22 11:08:14 +08:00
},
}, //1.分享给朋友
onShareAppMessage(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
2023-09-22 11:45:09 +08:00
title: '新医路健康服务平台',
2023-09-22 11:08:14 +08:00
path: url,
}
},
//2.分享到朋友圈
onShareTimeline(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
2023-09-22 11:45:09 +08:00
title: '新医路健康服务平台',
2023-09-22 11:08:14 +08:00
path: url,
}
},
}
</script>
<style lang="scss">
@import "./login.scss";
2023-09-22 15:39:13 +08:00
</style>