139 lines
3.3 KiB
Vue
139 lines
3.3 KiB
Vue
<template>
|
|
<view class="app">
|
|
<image src="../../static/logo.png" mode=""></image>
|
|
<!-- <view class="text">
|
|
新医路健康服务平台
|
|
</view> -->
|
|
<button class="loginbtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumberp">手机号快捷登录</button>
|
|
<u-toast ref="uToast" />
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
appLoginpwd,
|
|
getWeChatUser,
|
|
isRegistered,
|
|
} from '../../api/pages/login/index.js'
|
|
import {
|
|
getCurrentUser,
|
|
} from '@/api/pages/homepage/homepage.js'
|
|
import {
|
|
createMobileToken
|
|
} from '@/api/pages/login/index.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
phonecode: undefined,
|
|
logincode: undefined,
|
|
code: undefined,
|
|
timer: undefined,
|
|
cityCode: '1',
|
|
openid:'',
|
|
// scenenurseStationId: undefined,
|
|
};
|
|
},
|
|
onShow() {
|
|
this.phonecode = undefined
|
|
this.logincode = undefined
|
|
this.code = undefined
|
|
// 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) {
|
|
that.logincode = loginRes.code
|
|
that.login();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
login() {
|
|
let that = this;
|
|
// getWeChatUser(that.logincode).then(res => {
|
|
// if (res.code == 200) {
|
|
isRegistered(that.logincode, that.phonecode).then(resp => {
|
|
uni.setStorageSync("openid", resp.data.openid)
|
|
that.openid=resp.data.openid
|
|
if (resp.data.code == '0') {
|
|
that.$refs.uToast.show({
|
|
title: '未注册,请先注册',
|
|
type: 'error',
|
|
duration: '1500',
|
|
url: '/pages/register/register',
|
|
})
|
|
} else if (resp.data.code == '1') {
|
|
that.cityCode = '1'
|
|
console.log(that.openid)
|
|
getCurrentUser(that.openid, that.cityCode).then(res => {
|
|
if (res.code == 200) {
|
|
that.$refs.uToast.show({
|
|
title: '登录成功',
|
|
type: 'success',
|
|
duration: '1500'
|
|
})
|
|
uni.setStorageSync('patientId', res.data.id);
|
|
uni.setStorageSync('userinfo', res.data);
|
|
if (this.timer) {
|
|
clearTimeout(this.timer)
|
|
}
|
|
this.timer = setTimeout(e => {
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 500)
|
|
}
|
|
else {
|
|
that.$refs.uToast.show({
|
|
title: '登录失败',
|
|
type: 'error',
|
|
duration: '1500'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
},
|
|
pwdlogin() {
|
|
var that = this
|
|
uni.clearStorageSync();
|
|
|
|
that.login()
|
|
// createMobileToken().then(res => {
|
|
// uni.setStorageSync("token", res.data.token)
|
|
// if (this.scenenurseStationId) {
|
|
// uni.setStorageSync("scenenurseStationId", this.scenenurseStationId)
|
|
// }
|
|
// that.login()
|
|
// })
|
|
},
|
|
}, //1.分享给朋友
|
|
onShareAppMessage(res) {
|
|
let pages = getCurrentPages();
|
|
let url = pages[pages.length - 1].$page.fullPath
|
|
return {
|
|
title: '新医路健康服务平台',
|
|
path: url,
|
|
}
|
|
},
|
|
//2.分享到朋友圈
|
|
onShareTimeline(res) {
|
|
let pages = getCurrentPages();
|
|
let url = pages[pages.length - 1].$page.fullPath
|
|
return {
|
|
title: '新医路健康服务平台',
|
|
path: url,
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import "./login.scss";
|
|
</style> |