182 lines
4.0 KiB
Vue
182 lines
4.0 KiB
Vue
<template>
|
|
<view class="container">
|
|
<view class="box flex-center">
|
|
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/Logo" mode=""></image>
|
|
</view>
|
|
<view class="top_box">
|
|
<button class="toLogin" open-type="getPhoneNumber" @getphonenumber="userlogin">快速登录 </button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
h: null, //动态高度
|
|
types: '', //判断是否是微信扫码点餐进来
|
|
};
|
|
},
|
|
mounted() {
|
|
this.computed_h();
|
|
this.userlogin() // 静默登录
|
|
},
|
|
methods: {
|
|
// 静默登录
|
|
// userlogin(reslange) {
|
|
// uni.login({
|
|
// provider: 'weixin',
|
|
// success: async (data) => {
|
|
// if (data.errMsg == "login:ok") {
|
|
// console.log(data.code, '调试-code')
|
|
// let res = await this.api.userwxlogins({
|
|
// code: data.code,
|
|
// // rawData: infoRes.rawData,
|
|
// // signature: infoRes.signature,
|
|
// // iv: reslange.detail.iv,
|
|
// // encryptedData: resdataa.detail.encryptedData
|
|
// })
|
|
// if (res.code == 0) {}
|
|
// // if (uni.cache.get('types') == 'types') {
|
|
// // uni.reLaunch({
|
|
// // url: '/pages/order_food/order_food'
|
|
// // });
|
|
// // } else {
|
|
// // uni.pro.switchTab('index/index')
|
|
// // }
|
|
// }
|
|
// }
|
|
// })
|
|
// },
|
|
// 正常登录
|
|
async userlogin(reslange) {
|
|
var resdataa = reslange
|
|
// if (resdataa.detail.iv) {
|
|
uni.login({
|
|
provider: 'weixin',
|
|
success: async (data) => {
|
|
try {
|
|
uni.getUserInfo({
|
|
provider: 'weixin',
|
|
success: async (infoRes) => {
|
|
let res = await this.api.userwxlogin({
|
|
code: data.code, //临时登录凭证
|
|
rawData: infoRes.rawData,
|
|
// signature: infoRes.signature,
|
|
// iv: infoRes.detail.iv,
|
|
// encryptedData: infoRes.detail
|
|
// .encryptedData
|
|
})
|
|
if (res.code == 0) {
|
|
uni.cache.set('token', res.data.token);
|
|
uni.cache.set('miniAppOpenId', res.data.userInfo
|
|
.miniAppOpenId)
|
|
uni.cache.set('userInfo', res.data.userInfo);
|
|
if (uni.cache.get('types') == 'types') {
|
|
uni.reLaunch({
|
|
url: '/pages/order_food/order_food'
|
|
});
|
|
} else {
|
|
uni.pro.switchTab('index/index')
|
|
}
|
|
}
|
|
},
|
|
fail: (err) => {}
|
|
});
|
|
} catch (e) {}
|
|
}
|
|
});
|
|
// } else {
|
|
// uni.showToast({
|
|
// title: '获取手机号失败!请重新获取',
|
|
// icon: 'none'
|
|
// });
|
|
// }
|
|
},
|
|
async computed_h() {
|
|
//获取div宽度
|
|
let content_Icon = await uni.utils.info_distance('box');
|
|
let system_info = await uni.getSystemInfo();
|
|
let h = null;
|
|
h = system_info.windowHeight - content_Icon.height + 'px';
|
|
this.h = {
|
|
height: h
|
|
};
|
|
},
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: #FFFFFF;
|
|
}
|
|
|
|
.container {
|
|
// position: relative;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
|
|
.box {
|
|
// padding-top: 110rpx;
|
|
position: fixed;
|
|
top: 110rpx;
|
|
left: 50%;
|
|
z-index: 22;
|
|
transform: translateX(-50%);
|
|
|
|
image {
|
|
width: 128rpx;
|
|
height: 128rpx;
|
|
}
|
|
}
|
|
|
|
.top_box::after {
|
|
position: absolute;
|
|
// content: url(@/static/icon.png);
|
|
width: 282rpx;
|
|
height: 280rpx;
|
|
top: -240rpx;
|
|
right: 32rpx;
|
|
z-index: 2;
|
|
}
|
|
|
|
.top_box {
|
|
z-index: 9;
|
|
padding: 0 64rpx;
|
|
box-sizing: border-box;
|
|
width: 100%;
|
|
position: fixed;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background: #ffffff;
|
|
border-radius: 40rpx 40rpx 0px 0px;
|
|
top: 220rpx;
|
|
|
|
.toLogin {
|
|
margin-top: 212rpx;
|
|
width: 100%;
|
|
background: #F1CB66;
|
|
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
|
font-family: Source Han Sans CN, Source Han Sans CN;
|
|
font-weight: 500;
|
|
font-size: 32rpx;
|
|
color: #333333;
|
|
height: 84rpx;
|
|
line-height: 84rpx;
|
|
text-align: center;
|
|
border: none;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
</style> |