386 lines
8.3 KiB
Vue
386 lines
8.3 KiB
Vue
|
|
<template>
|
||
|
|
<view class="container safe-area-inset-bottom">
|
||
|
|
<view class="none">
|
||
|
|
<!-- 授权登录 -->
|
||
|
|
<view class="conter">
|
||
|
|
<view class="title">
|
||
|
|
欢迎登录
|
||
|
|
</view>
|
||
|
|
<image src="@/static/empty/login.png" mode="aspectFit"></image>
|
||
|
|
<button class="btn" :class="form['check']?'':'bg'" :disabled="!form['check']" open-type="getPhoneNumber"
|
||
|
|
@getphonenumber="getPhoneNumber">手机号一键注册</button>
|
||
|
|
|
||
|
|
<view class="word">
|
||
|
|
<u-icon size="35" :color="form['check']?'#2979FF':'#E5E5E5'" name="checkmark-circle-fill"
|
||
|
|
@click="form['check']=!form['check']"></u-icon>
|
||
|
|
<view class="agreement">
|
||
|
|
我已阅读并同意
|
||
|
|
<text @click="getInfo(1)">《用户服务协议》</text>
|
||
|
|
和
|
||
|
|
<text @click="getInfo(2)">《隐私政策》</text>
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
<view class="text" @click="back">取消登录</view>
|
||
|
|
|
||
|
|
<!-- <view class="footer" @click="toLogon">
|
||
|
|
输入其他手机号码注册
|
||
|
|
</view> -->
|
||
|
|
</view>
|
||
|
|
</view>
|
||
|
|
|
||
|
|
<u-popup v-model="show" :safe-area-inset-bottom="true" mode="bottom" height="88%" border-radius="20"
|
||
|
|
:closeable="true">
|
||
|
|
<view class="agreen">
|
||
|
|
<u-parse :html="content"></u-parse>
|
||
|
|
</view>
|
||
|
|
</u-popup>
|
||
|
|
|
||
|
|
<u-toast ref="uToast" />
|
||
|
|
</view>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import {
|
||
|
|
getAgreem,
|
||
|
|
getLogin,
|
||
|
|
getsLogin
|
||
|
|
} from '../../request/api/api.js'
|
||
|
|
|
||
|
|
export default {
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
code: "",
|
||
|
|
form: {
|
||
|
|
check: false
|
||
|
|
},
|
||
|
|
encryptedData: "",
|
||
|
|
iv: "",
|
||
|
|
session_key: "",
|
||
|
|
show: false,
|
||
|
|
content: ``,
|
||
|
|
type: 1,
|
||
|
|
id: 1,
|
||
|
|
isShow_envVersion: uni.getStorageSync('isShow_envVersion')
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onLoad(e) {
|
||
|
|
this.type = e.type
|
||
|
|
this.id = e.id
|
||
|
|
uni.removeStorageSync('token')
|
||
|
|
uni.removeStorageSync('userinfo')
|
||
|
|
},
|
||
|
|
created() {
|
||
|
|
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
back() {
|
||
|
|
uni.navigateBack({ delta: 1 })
|
||
|
|
},
|
||
|
|
getPhoneNumber(e) {
|
||
|
|
uni.showLoading({
|
||
|
|
title: "加载中"
|
||
|
|
});
|
||
|
|
|
||
|
|
if (!this.form['check']) {
|
||
|
|
uni.showToast({
|
||
|
|
icon: "error",
|
||
|
|
title: '请勾选协议'
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if (e.detail.errMsg && e.detail.errMsg == 'getPhoneNumber:fail user deny') {
|
||
|
|
// uni.showToast({
|
||
|
|
// icon: "error",
|
||
|
|
// title: '未获取手机号码'
|
||
|
|
// })
|
||
|
|
this.$refs.uToast.show({
|
||
|
|
title: '未获取手机号码',
|
||
|
|
type: 'default',
|
||
|
|
icon: false
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
this.encryptedData = e.detail.encryptedData; //需要解密的内容
|
||
|
|
this.iv = e.detail.iv; //偏移量
|
||
|
|
this.code = e.detail.code
|
||
|
|
// console.log(e);
|
||
|
|
|
||
|
|
let data = {
|
||
|
|
iv: this.iv,
|
||
|
|
encryptedData: this.encryptedData,
|
||
|
|
code: this.code,
|
||
|
|
store_id: '11001'
|
||
|
|
}
|
||
|
|
getLogin({
|
||
|
|
method: 'post',
|
||
|
|
data: data
|
||
|
|
}).then((res) => {
|
||
|
|
// console.log(res, 'login');
|
||
|
|
if (res.data.errcode == 0) {
|
||
|
|
if (this.type == 1) {
|
||
|
|
uni.navigateTo({
|
||
|
|
url: "/pages/home/index-list?id=" + this.id,
|
||
|
|
fail: (e) => {
|
||
|
|
// console.log(e);
|
||
|
|
},
|
||
|
|
success() {
|
||
|
|
uni.showToast({
|
||
|
|
title: '登陆成功',
|
||
|
|
duration: 2000
|
||
|
|
});
|
||
|
|
uni.hideLoading();
|
||
|
|
}
|
||
|
|
})
|
||
|
|
return
|
||
|
|
}
|
||
|
|
// 进入h5 token是登录返回的platform_token user_id是萧康的用户id
|
||
|
|
uni.setStorageSync('token_h5', res.data.data.plate_token)
|
||
|
|
|
||
|
|
// setTimeout(() => {
|
||
|
|
// this.getH5();
|
||
|
|
// }, 100)
|
||
|
|
uni.reLaunch({
|
||
|
|
url: "/pages/home/home",
|
||
|
|
fail: (e) => {
|
||
|
|
// console.log(e);
|
||
|
|
},
|
||
|
|
success() {
|
||
|
|
uni.showToast({
|
||
|
|
title: '登陆成功',
|
||
|
|
duration: 2000
|
||
|
|
});
|
||
|
|
uni.hideLoading();
|
||
|
|
}
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
uni.showToast({
|
||
|
|
icon: "error",
|
||
|
|
title: res.data.msg
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
toLogon() {
|
||
|
|
uni.navigateTo({
|
||
|
|
url: '/pages/login/logon',
|
||
|
|
fail: function(res) {
|
||
|
|
// console.log(res);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
// 协议
|
||
|
|
getInfo(e) {
|
||
|
|
this.show = true
|
||
|
|
|
||
|
|
getAgreem({
|
||
|
|
method: "post",
|
||
|
|
data: {
|
||
|
|
end: 1,
|
||
|
|
store_id: uni.getStorageSync('store_id') || '11001',
|
||
|
|
}
|
||
|
|
}).then((res) => {
|
||
|
|
// console.log(res);
|
||
|
|
|
||
|
|
if (e == 1) {
|
||
|
|
this.content = res.data.data[0].content
|
||
|
|
} else {
|
||
|
|
this.content = res.data.data[1].content
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
getToLogin() {
|
||
|
|
uni.login({
|
||
|
|
provider: 'weixin',
|
||
|
|
success: (loginRes) => {
|
||
|
|
this.code = loginRes.code
|
||
|
|
// console.log(loginRes.code);
|
||
|
|
getsLogin({
|
||
|
|
method: "post",
|
||
|
|
data: {
|
||
|
|
code: this.code,
|
||
|
|
status: 1
|
||
|
|
}
|
||
|
|
}).then((res) => {
|
||
|
|
// console.log(res, "res");
|
||
|
|
if (res.data.errcode == 0) {
|
||
|
|
uni.setStorageSync('token', res.data.data.token) //存储token
|
||
|
|
uni.setStorageSync('user_id', res.data.data.data.user.id)
|
||
|
|
uni.setStorageSync('userinfo', res.data.data.data['user'])
|
||
|
|
|
||
|
|
} else if (res.data.errcode != 0) {
|
||
|
|
// uni.showToast({
|
||
|
|
// icon: "error",
|
||
|
|
// title: res.data.msg
|
||
|
|
// })
|
||
|
|
this.$refs.uToast.show({
|
||
|
|
title: res.data.msg,
|
||
|
|
type: 'default',
|
||
|
|
icon: false
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
// subScriptionMessage() {
|
||
|
|
|
||
|
|
// },
|
||
|
|
|
||
|
|
// getH5() {
|
||
|
|
// // 进入token
|
||
|
|
// uni.request({
|
||
|
|
// url: 'https://hy.api.ctkj88.com/platform/v1/user/login',
|
||
|
|
// header: {
|
||
|
|
// "authorization": uni.getStorageSync(
|
||
|
|
// "token_h5"),
|
||
|
|
// "Content-Type": "application/x-www-form-urlencoded"
|
||
|
|
// },
|
||
|
|
// method: 'POST',
|
||
|
|
// timeout: 10000,
|
||
|
|
// data: {
|
||
|
|
// user_id: uni.getStorageSync('user_id')
|
||
|
|
// },
|
||
|
|
// success: (res) => {
|
||
|
|
// // console.log(res, 'h5-token');
|
||
|
|
// // uni.setStorageSync('platform_id', res.data.data.platform_id)
|
||
|
|
// uni.setStorageSync('token_platform_id', res.data.data.token)
|
||
|
|
// },
|
||
|
|
// fail(res) {
|
||
|
|
// // console.log(res, 'fail-h5');
|
||
|
|
// }
|
||
|
|
// })
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
mounted() {
|
||
|
|
const token = uni.getStorageSync('token')
|
||
|
|
const user_id = uni.getStorageSync('user_id')
|
||
|
|
const userInfo = uni.getStorageSync('userinfo')
|
||
|
|
const token_h5 = uni.getStorageSync('token_h5')
|
||
|
|
if (token && user_id && userInfo && token_h5) {
|
||
|
|
uni.reLaunch({
|
||
|
|
url: "/pages/home/home",
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
uni.removeStorageSync('token')
|
||
|
|
uni.removeStorageSync('user_id')
|
||
|
|
this.getToLogin();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.text {
|
||
|
|
margin-top: 20rpx;
|
||
|
|
color: #666;
|
||
|
|
}
|
||
|
|
.container {
|
||
|
|
width: 100vw;
|
||
|
|
height: 100vh;
|
||
|
|
padding-bottom: env(safe-area-inset-bottom);
|
||
|
|
|
||
|
|
.none {
|
||
|
|
width: 750rpx;
|
||
|
|
padding-top: 100rpx;
|
||
|
|
background: linear-gradient(180deg, #EAF2FF 0%, #FFFFFF 100%);
|
||
|
|
|
||
|
|
.conter {
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: center;
|
||
|
|
margin: 0rpx auto 380rpx;
|
||
|
|
|
||
|
|
image {
|
||
|
|
width: 431rpx;
|
||
|
|
height: 339rpx;
|
||
|
|
vertical-align: middle;
|
||
|
|
margin-bottom: 110rpx;
|
||
|
|
}
|
||
|
|
|
||
|
|
.title {
|
||
|
|
font-size: 48rpx;
|
||
|
|
font-family: PingFang SC-Regular, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
color: #232323;
|
||
|
|
margin-bottom: 114rpx;
|
||
|
|
}
|
||
|
|
|
||
|
|
.word {
|
||
|
|
display: flex;
|
||
|
|
flex-direction: row;
|
||
|
|
color: #475569;
|
||
|
|
font-size: 28rpx;
|
||
|
|
font-family: PingFang SC-Regular, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
margin-top: 34rpx;
|
||
|
|
|
||
|
|
.agreement {
|
||
|
|
font-size: 24rpx;
|
||
|
|
font-family: PingFang SC-Regular, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
color: #6C7380;
|
||
|
|
margin-left: 16rpx;
|
||
|
|
|
||
|
|
text {
|
||
|
|
color: #2979FF;
|
||
|
|
size: 24rpx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.footer {
|
||
|
|
width: 710rpx;
|
||
|
|
height: 90rpx;
|
||
|
|
line-height: 90rpx;
|
||
|
|
position: fixed;
|
||
|
|
bottom: 60rpx;
|
||
|
|
left: 0;
|
||
|
|
text-align: center;
|
||
|
|
font-size: 26rpx;
|
||
|
|
font-family: PingFang SC-Regular, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
color: #232323;
|
||
|
|
margin: 0 auto;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn {
|
||
|
|
width: 648rpx;
|
||
|
|
height: 88rpx;
|
||
|
|
background: #4175EE;
|
||
|
|
line-height: 88rpx;
|
||
|
|
font-size: 32rpx;
|
||
|
|
text-align: center;
|
||
|
|
font-family: PingFang SC-Medium, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
color: #FFFFFF;
|
||
|
|
border-radius: 64rpx;
|
||
|
|
}
|
||
|
|
|
||
|
|
.bg {
|
||
|
|
width: 648rpx;
|
||
|
|
height: 88rpx;
|
||
|
|
background: #8ABAFF;
|
||
|
|
line-height: 88rpx;
|
||
|
|
font-size: 32rpx;
|
||
|
|
text-align: center;
|
||
|
|
font-family: PingFang SC-Medium, PingFang SC;
|
||
|
|
font-weight: 400;
|
||
|
|
color: #FFFFFF;
|
||
|
|
border-radius: 64rpx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
.agreen {
|
||
|
|
padding: 60rpx 50rpx 20rpx;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|