Commit 2ea31414 authored by 罗超's avatar 罗超

2

parent 1e6ff93a
......@@ -31,7 +31,7 @@
.Order_Number {
color: #0000ff;
font-size: 28rpx;
font-size: 24rpx;
}
.courseName {
......
<template>
<view class="indexassembly">
<view class="indexassembly" :style="{width:width,height:height}">
<view>
<slot>
登录
</slot>
<button class="hotsopt" style="" open-type="getUserInfo" @tap="getUserProfile()" @click="getCode"></button>
<button class="hotsopt" :style="{width:width,height:height}" open-type="getUserInfo" @tap="getUserProfile()"
@click="getCode"></button>
</view>
<van-popup :show="showPhone">
<view
style="width: 70vw;background: #FFF;display: flex;flex-direction: column;align-items: center;padding-bottom: 20px;border-radius: 8px;">
......@@ -19,7 +19,7 @@
<text style="margin-top: 15px;font-size: 18px;font-weight: bold;color: #111111;">{{obj.Name}}</text>
<text style="margin-top: 5px;font-size: 13px;color: #111111;">申请获取您微信绑定的手机号码</text>
<view class="btn">获取手机号
<button type="default" open-type="getPhoneNumber" v-if="showLogin == true"
<button type="default" open-type="getPhoneNumber" v-if="showLogin == true"
style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;"
@getphonenumber=" decryptPhoneNumber"></button>
</view>
......@@ -33,34 +33,46 @@
reactive,
toRefs,
onMounted,
getCurrentInstance,
getCurrentInstance,
inject
} from "vue";
import {
login,
phoneLogin,
parsePhone
} from "../../../api/index";
} from "../../../api/index";
export default {
name: "",
props: {
state: String,
width: {
type: String,
default: '100rpx'
},
height: {
type: String,
default: '100rpx'
},
},
components: {},
setup(props,{attrs,slots,emit}) {
setup(props, {
attrs,
slots,
emit
}) {
const pages = getCurrentPages() // 获取栈实例
const currentRoute = pages[pages.length-1].route; // 获取当前页面路由
const currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
let Toast = inject("$toast");
let data = reactive({
obj: {
Name: '',
Photo: '',
},
showPhone: false,
showLogin:true,//多次点击
showPhone: false,
showLogin: true, //多次点击
});
let methods = {
getUserProfile() {
......@@ -72,9 +84,9 @@
data.obj.Name = info.userInfo.nickName;
data.obj.Photo = info.userInfo.avatarUrl;
data.showPhone = true; //显示获取手机号码弹窗
if(currentRoute=="pages/index/index"){
uni.hideTabBar()//手机授权弹窗出现 隐藏tabbar
}
if (currentRoute == "pages/index/index") {
uni.hideTabBar() //手机授权弹窗出现 隐藏tabbar
}
},
fail: () => {
uni.showToast({
......@@ -95,7 +107,7 @@
data.obj.iv = e.detail.iv
data.obj.encryptedData = e.detail.encryptedData
// that.getCode()
that.parsePhoneNum(data.obj.encryptedData, data.obj.iv,data.obj.code)
that.parsePhoneNum(data.obj.encryptedData, data.obj.iv, data.obj.code)
}
},
getCode() { //获取code
......@@ -108,7 +120,7 @@
success: (res) => {
//获取code
data.obj.code = res.code
},
fail: () => {
uni.showToast({
......@@ -127,10 +139,10 @@
});
},
//解密手机号
async parsePhoneNum(encryptedData, iv, code) {
uni.showLoading({
title: "登录中",
});
async parsePhoneNum(encryptedData, iv, code) {
uni.showLoading({
title: "登录中",
});
data.showLogin = false; //防止多次点击登录
let res = await parsePhone({
encryptedData,
......@@ -138,27 +150,27 @@
code
})
if (res && res.Data.phoneNumber) {
data.obj.phoneNum = res.Data.phoneNumber
data.obj.phoneNum = res.Data.phoneNumber
// data.obj.phoneNum = '18328620563'
data.obj.openid = res.Data.openid
data.obj.unionid = res.Data.unionid
that.phoneNumLogin()
let obj = {
Account :data.obj.phoneNum,
WeChatName :data.obj.Name,
WeChatPhoto :data.obj.Photo,
OpenId: data.obj.openid,
unionid: data.obj.unionid,
}
try {
uni.setStorageSync("temporarydh", obj);
} catch (e) {
console.log(e,'eeeeeee')
}
that.phoneNumLogin()
let obj = {
Account: data.obj.phoneNum,
WeChatName: data.obj.Name,
WeChatPhoto: data.obj.Photo,
OpenId: data.obj.openid,
unionid: data.obj.unionid,
}
try {
uni.setStorageSync("temporarydh", obj);
} catch (e) {
console.log(e, 'eeeeeee')
}
} else {
Toast.fail("授权失败,请重新授权")
data.showLogin = true; //防止多次点击登录
Toast.fail("授权失败,请重新授权")
data.showLogin = true; //防止多次点击登录
uni.hideLoading();
}
},
......@@ -169,32 +181,32 @@
OpenId: data.obj.openid,
unionid: data.obj.unionid,
})
if (res.Code==1) {
uni.hideLoading();
if (res.Code == 1) {
uni.hideLoading();
data.showLogin = true; //防止多次点击登录
res.Data.Account = data.obj.phoneNum;
uni.setStorageSync("userInfo", res.Data);
Toast.success("登录成功");
emit('success')
data.showPhone = false
Toast.success("登录成功");
emit('success')
data.showPhone = false
uni.showTabBar()
}else{
data.showLogin = true; //防止多次点击登录
} else {
data.showLogin = true; //防止多次点击登录
data.showPhone = false
if(currentRoute=="pages/index/index"){
uni.showTabBar()//手机授权弹窗出现 隐藏tabbar
}
uni.hideLoading();
if(res.Data.Error==-1){//如果没找到电话号码 就跳入登录
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/login/login'
// });
// }, 1000);
}
if (currentRoute == "pages/index/index") {
uni.showTabBar() //手机授权弹窗出现 隐藏tabbar
}
uni.hideLoading();
if (res.Data.Error == -1) { //如果没找到电话号码 就跳入登录
// setTimeout(() => {
// uni.reLaunch({
// url: '/pages/login/login'
// });
// }, 1000);
}
}
}
};
......@@ -212,8 +224,6 @@
</script>
<style scoped>
.indexassembly {
width: 110rpx;
height: 90rpx;
line-height: 90rpx;
position: relative;
}
......@@ -226,9 +236,6 @@
opacity: 0;
left: 0;
top: 0;
width: 280rpx;
height: 90rpx;
}
.btn {
......
......@@ -18,21 +18,22 @@
</van-field>
</van-cell-group>
</view>
<view class="flex flex_between_center btnBox">
<view class="loginBtn flex flex_center_center" @click="login">账号登录</view>
<view class="phoneBtn flex flex_center_center" @click="show=true">游客登录</view>
<!-- <button class="phoneBtn flex flex_center_center" open-type="getPhoneNumber" @getphonenumber="getphonenumber" @click="login2">手机号一键登录</button> -->
<view class="btnBox" @click="login">
账号登录
</view>
<view class="btnBox" style="margin:20rpx auto 0;">
<indexassembly @success='againdata' >
<view class="loginBtn flex flex_center_center" style="background-color:#4C50E7;">授权登录</view>
<view class="flex_center_center">
<indexassembly width="440rpx" height="90rpx" @success='againdata' >
<view class="btnBox authBtn" >
授权登录
</view>
</indexassembly>
</view>
<view class="visitor" @click="show=true">
游客登录
</view>
<van-toast id="van-toast" />
<van-dialog :show='show' title="提示" message='游客登录,不能使用全部功能!' show-cancel-button @cancel='show = false'
@confirm='login3'>
</van-dialog>
</view>
</template>
......@@ -304,14 +305,30 @@
}
.btnBox {
width: 600rpx;
width: 440rpx;
height: 90rpx;
border-radius: 12rpx;
border-radius: 45rpx;
overflow: hidden;
margin: 0 auto;
font-size: 32rpx;
margin-bottom: 55rpx;
background-color: #4C50E8;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: #ffffff;
color: #FFFFFF;
text-align: center;
line-height: 88rpx;
}
.authBtn{
background-color: #EDEDFD !important;
color: #4C50E8 !important;
}
.visitor{
text-align: center;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 500;
color: #BEBEBE;
margin-top: 55rpx;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment