<template>
|
<view class="login_page" v-if="isShow">
|
<view class="login_bg"></view>
|
<view class="login_box animated" :class="{ slideInUp: isShow }">
|
<image class="head" src="https://ossacmall.bluedeer.com.cn/app/static/images/app_logo2.png"></image>
|
<view class="title">很高兴遇见您,欢迎您的到来!</view>
|
<view class="input_box">
|
<view class="input_label">*手机号</view>
|
<view class="input">{{ mobile }}</view><button class="input_btn" open-type="getPhoneNumber"
|
@getphonenumber="getphonenumber">手机号快捷登录</button>
|
</view>
|
<view class="submit" @click="submit">确认授权</view>
|
<view class="cancel" @click="skip">暂时跳过</view>
|
</view>
|
</view>
|
</template>
|
<script>
|
const app = getApp();
|
import {
|
silenceBindingSpread
|
} from "@/utils";
|
import Routine from '@/libs/routine';
|
import {
|
bindUserPhone,
|
decryptPhone,
|
getLogo
|
} from '@/api/public';
|
export default {
|
name: 'loginPhone',
|
data() {
|
return {
|
logoUrl: '',
|
isShow: false,
|
mobile: '',
|
info: {},
|
isUpdating:false
|
}
|
},
|
mounted() {},
|
methods: {
|
getphonenumber(e) {
|
console.log(e);
|
if(e.detail&&e.detail.errMsg.indexOf('fail')>=0){
|
return false;
|
}
|
let that = this;
|
this.info = e;
|
uni.showLoading();
|
Routine.getCode()
|
.then(code => {
|
console.log(code);
|
that.decryptPhone(this.info.detail.encryptedData, this.info.detail.iv, code);
|
})
|
.catch(error => {
|
uni.hideLoading();
|
});
|
},
|
decryptPhone(encryptedData, iv, code) {
|
let that = this;
|
uni.showLoading();
|
decryptPhone({
|
encryptedData: encryptedData,
|
iv: iv,
|
code: code,
|
key: that.authKey,
|
type: 'routine'
|
})
|
.then(res => {
|
uni.hideLoading();
|
that.$set(that, 'mobile', res.message);
|
})
|
.catch(res => {
|
uni.hideLoading();
|
});
|
},
|
// 小程序获取手机号码回调
|
getUserPhoneNumber(encryptedData, iv, code) {
|
let that = this;
|
uni.showLoading();
|
bindUserPhone({
|
encryptedData: encryptedData,
|
iv: iv,
|
code: code,
|
key: that.authKey,
|
type: 'routine'
|
})
|
.then(res => {
|
uni.hideLoading();
|
that.$store.commit('UPDATE_LOGINSTATUS', res.data);
|
silenceBindingSpread();
|
that.getUserInfo();
|
})
|
.catch(e => {
|
console.log(e);
|
uni.hideLoading();
|
});
|
},
|
getUserInfo: function() {
|
let that = this;
|
Routine.getLastUserInfo()
|
.then(userInfo => {
|
uni.showLoading();
|
console.log("获取用户信息:", userInfo);
|
uni.$emit('registerSuccess', {});
|
uni.hideLoading();
|
that.$parent.$refs.loginInfo.show();
|
that.hide();
|
})
|
.catch(error => {
|
console.error("获取用户信息错误:", error);
|
// 处理错误情况
|
});
|
|
},
|
submit() {
|
let that = this;
|
if (!that.info.detail) {
|
uni.showToast({
|
title: '请先获取手机号',
|
icon: 'none'
|
});
|
return false;
|
}
|
if(that.isUpdating){
|
return false;
|
}
|
that.isUpdating=true;
|
Routine.getCode()
|
.then(code => {
|
that.isUpdating=false;
|
this.getUserPhoneNumber(this.info.detail ? this.info.detail.encryptedData : '', this.info
|
.detail ? this.info.detail.iv : '', code);
|
})
|
.catch(error => {
|
that.isUpdating=false;
|
uni.hideLoading();
|
});
|
},
|
|
|
show() {
|
let that = this;
|
that.authKey = app.globalData.authKey;
|
this.isShow = true;
|
},
|
skip() {
|
let pages = getCurrentPages(),
|
currPage = pages[pages.length - 1];
|
if (currPage.route.indexOf('pages/zone/') >= 0 ||
|
currPage.route.indexOf('pages/users/user_get_coupon/index') >= 0
|
) {
|
uni.switchTab({
|
'url': '/pages/index/index'
|
})
|
}
|
if (
|
currPage.route.indexOf('pages/users/user_vip/index') >= 0 ||
|
currPage.route.indexOf('pages/users/user_goods_collection/index') >= 0 ||
|
currPage.route.indexOf('pages/users/user_address/index') >= 0 ||
|
currPage.route.indexOf('pages/users/user_address_list/index') >= 0 ||
|
currPage.route.indexOf('pages/users/order_list/index') >= 0
|
) {
|
uni.switchTab({
|
'url': '/pages/user/index'
|
})
|
}
|
this.hide();
|
},
|
hide() {
|
this.isShow = false;
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.login_page {
|
position: fixed;
|
left: 0;
|
top: 0;
|
width: 100%;
|
height: 100%;
|
z-index: 9999;
|
}
|
|
.login_bg {
|
width: 100%;
|
height: 100%;
|
background: rgba(0, 0, 0, .7);
|
}
|
|
.login_box {
|
width: 100%;
|
box-sizing: border-box;
|
padding: 290rpx 60rpx 60rpx 60rpx;
|
position: absolute;
|
left: 0;
|
bottom: 0;
|
background: url("https://ossacmall.bluedeer.com.cn/app/static/images/login_top2.png") center top/100% auto no-repeat;
|
background-color: #FFE20E;
|
border-radius: 40rpx 40rpx 0 0;
|
|
.head {
|
width: 80rpx;
|
height: 80rpx;
|
left: 45rpx;
|
top: 50rpx;
|
position: absolute;
|
border: 1rpx solid #F5F5F5;
|
border-radius: 50%;
|
}
|
|
.title {
|
font-size: 34rpx;
|
line-height: 60rpx;
|
position: absolute;
|
left: 144rpx;
|
top: 60rpx;
|
color: #ffffff;
|
}
|
|
.input_box {
|
padding-left: 110rpx;
|
padding-right: 250rpx;
|
position: relative;
|
font-size: 30rpx;
|
height: 133rpx;
|
line-height: 133rpx;
|
color: #000000;
|
border-bottom: 2rpx solid #000000;
|
|
.input_label {
|
position: absolute;
|
left: 0;
|
top: 0;
|
}
|
|
.input {
|
width: 100%;
|
height: 100%;
|
text-align: center;
|
}
|
|
.input_btn {
|
position: absolute;
|
right: 0;
|
top: 50%;
|
margin-top: -29rpx;
|
width: max-content;
|
font-size: 31rpx;
|
line-height: 57rpx;
|
text-align: center;
|
background-color: unset;
|
color: #016DCC;
|
}
|
}
|
|
.private {
|
padding-left: 50rpx;
|
font-size: 25rpx;
|
color: #000000;
|
position: relative;
|
margin-top: 40rpx;
|
|
.private_icon {
|
width: 90rpx;
|
height: 90rpx;
|
position: absolute;
|
left: -22rpx;
|
top: 50%;
|
margin-top: -45rpx;
|
|
&:before {
|
content: '';
|
display: block;
|
position: absolute;
|
width: 35rpx;
|
height: 35rpx;
|
box-shadow: inset 0 0 0 1rpx #000;
|
border-radius: 50%;
|
left: 50%;
|
top: 50%;
|
margin-left: -18rpx;
|
margin-top: -18rpx;
|
}
|
|
&.active:after {
|
content: '';
|
display: block;
|
position: absolute;
|
width: 18rpx;
|
height: 18rpx;
|
background-color: #000000;
|
border-radius: 50%;
|
left: 50%;
|
top: 50%;
|
margin-left: -9rpx;
|
margin-top: -9rpx;
|
}
|
}
|
|
.private_btn {
|
display: inline-block;
|
border-bottom: 1rpx solid #000000;
|
}
|
}
|
|
.submit {
|
margin-top: 96rpx;
|
font-size: 30rpx;
|
line-height: 84rpx;
|
text-align: center;
|
color: #ffffff;
|
border-radius: 8rpx;
|
background: #016DCC;
|
}
|
|
.cancel {
|
font-size: 30rpx;
|
width: max-content;
|
margin: 24rpx auto 0 auto;
|
color: #000000;
|
}
|
}
|
|
.animated {
|
animation-duration: .4s
|
}
|
</style>
|