oil-station/gasStation-uni/pagesLogin/login/login.vue
2024-09-21 15:18:24 +08:00

378 lines
8.1 KiB
Vue

<template>
<view class="content">
<view class="container">
<!-- <view class="my-header">
<view class="my-icons"> </view>
<view class="my-text"></view>
<view class="my-icons"></view>
</view> -->
<view class="top-box"></view>
<!-- 顶部区域 -->
<!-- #ifdef MP-WEIXIN -->
<button class="dl-box" open-type='getPhoneNumber' @getphonenumber="getPhone">手机号快捷登录</button>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<!-- <button class="dl-box" open-type="getPhoneNumber" @getphonenumber="getUserLogin">手机号快捷登录</button> -->
<button open-type="getAuthorize" scope='phoneNumber' class="dl-box" hover-class="button-active"
@getAuthorize="getUserLogin">手机号快捷登录</button>
<!-- #endif -->
<button class="kk-box" @click="goback">我再看看</button>
<view class="dbottom">
<view class="quanzi" v-if="qindex == false " @click="qindex =! qindex"></view>
<view class="lanquanzi" v-if="qindex == true" @click="qindex =! qindex"><u-icon name="checkbox-mark"
color="#ffffff" size="14"></u-icon></view>
<text>请仔细阅读</text>
<text class="lan" @click="gopv()">《用户协议》</text>
<text>和</text>
<text class="lan" @click="gopv()">《隐私政策》</text>
</view>
</view>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
title: '',
qindex: false,
baseUrl: this.$baseUrl,
appltType: uni.getStorageSync("appltType"),
}
},
onLoad() {
console.log(this.$baseUrl);
},
components: {},
methods: {
gopv() {
uni.navigateTo({
url: '/pagesLogin/login/webview'
})
},
// 获取支付宝userid
getUserLogin(e) {
if (this.qindex == false) {
uni.showToast({
icon: "none",
title: "请先阅读并勾选用户协议",
duration: 2000
})
return;
}
console.log(e)
let _this = this;
my.getPhoneNumber({
scopes: 'auth_base',
success: res1 => {
let encryptedData = res1.response;
// _this.setData({
// ['userInfo.phone']: "18457621459",
// alertPhone: false,
// })
my.getAuthCode({
scopes: 'auth_base',
success: res => {
const authCode = res.authCode;
console.log(res)
request({
url: "clientApi/sign/alipayLogin/getUserid",
method: 'post',
data: {
authCode: authCode,
storeId: uni.getStorageSync("storeId"),
staffId: "",
// phone: "18457621459",Z
encryptedData: encryptedData,
},
}).then((resp) => {
if (resp.code == 200) {
console.log(uni.getStorageSync("y_type"), uni
.getStorageSync("y_userId"));
if (uni.getStorageSync("y_type") ==
'yaoqingyouli') {
_this.activeRecommendRecords()
}
uni.setStorageSync('App-Token', resp.data.token);
uni.setStorageSync('chainStoreId', resp.data
.chainStoreId);
uni.navigateTo({
url: '/pages/index/index'
})
}
console.log("swq", uni.getStorageSync('App-Token'));
})
},
fail: err => {
console.log('my.getAuthCode 调用失败', err)
}
});
},
fail: err => {
console.log('my.getAuthCode 调用失败', err)
}
});
},
wxlogin() {},
getPhone(e) {
let that = this
if (this.qindex == false) {
uni.showToast({
icon: "none",
title: "请先阅读并勾选用户协议",
duration: 2000
})
return;
}
console.log(e)
uni.login({
provider: 'weixin',
success(res) {
if (res.code) {
uni.setStorageSync('c1', res.code);
console.log('weixin', res.code);
} else {
console.log('登录失败!' + res.errMsg)
}
// console.log(e);
uni.checkSession({
success: () => {
uni.request({
url: that.baseUrl + "clientApi/sign/mpWxLogin",
method: "POST",
data: {
code: uni.getStorageSync('c1'),
encryptedIv: e.detail.iv,
encryptedData: e.detail.encryptedData,
userInfo: {
storeId: uni.getStorageSync("storeId"),
staffId: "",
// phone: '16548796325'
},
type: 'phone',
inviteId: uni.getStorageSync('inviteId') ? uni
.getStorageSync(
'inviteId') : null
},
success: (rex) => {
console.log('请求成功', rex)
if (rex.data.code == 200) {
uni.setStorageSync('App-Token', rex.data.data
.token);
uni.setStorageSync('chainStoreId', rex.data
.data
.chainStoreId);
if (uni.getStorageSync("y_type") ==
'yaoqingyouli') {
that.activeRecommendRecords()
}
uni.navigateTo({
url: '/pages/index/index'
})
}
console.log("swq", uni.getStorageSync(
'App-Token'));
},
fail: (res) => {
console.log("fail", res);
uni.showToast({
icon: "error",
title: "登录失败,请重新点击并授权!",
duration: 2000
})
}
})
},
fail: () => {
uni.showToast({
icon: 'error',
duration: 2000,
title: "登录状态过期,重新登录"
});
}
})
}
})
},
activeRecommendRecords() {
request({
// url: "clientApi/sign/alipayLogin/getUserid",
url: "business/marketingActivity/activeRecommendRecords",
method: 'post',
data: {
storeId: uni.getStorageSync("storeId"),
// storeId: uni.getStorageSync("y_storeId"),
type: uni.getStorageSync("y_type"),
userId: uni.getStorageSync("y_userId"),
},
}).then(res => {})
},
goback() {
uni.reLaunch({
url: '/pages/index/index'
})
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #ffffff;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
// padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
z-index: 99999;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.dl {
height: 40px;
background: #FF9655;
border-radius: 50px;
}
.top-box {
width: 100%;
height: 580px;
background: url('http://47.94.122.58:83/loginBack.png') no-repeat;
background-size: 100% 100%;
margin-bottom: 25px;
}
.dl-box {
width: 80%;
height: 45px;
background: #FF9655;
color: white;
border-radius: 50px;
margin: 0 auto;
}
.kk-box {
width: 80%;
height: 45px;
background: #F0F3FA;
color: #333333;
border-radius: 50px;
border: 1px solid #F0F3FA;
margin: 10px auto;
}
.dbottom {
width: 100%;
text-align: center;
font-size: 12px;
color: #333333;
margin-top: 40px;
position: fixed;
bottom: 45px;
display: flex;
align-items: center;
justify-content: center;
}
.quanzi {
width: 14px;
height: 14px;
border: 1px solid #666666;
border-radius: 50%;
margin-right: 10px;
}
.lanquanzi {
width: 14px;
height: 14px;
border: 1px solid #FF9655;
border-radius: 50%;
margin-right: 10px;
background: #FF9655;
color: white;
}
.lan {
color: #FF9655;
}
.jiuzhong {
width: 90%;
margin: 10px auto;
display: flex;
align-items: center;
}
.dist {
display: flex;
align-items: center;
margin: 0px 10px;
}
.d-zi {
font-size: 14px;
}
.d-qian {
width: 14px;
height: 14px;
margin-right: 5px;
overflow: hidden;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #666666;
color: white;
}
.d-qian-lan {
width: 14px;
height: 14px;
margin-right: 5px;
overflow: hidden;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: #0078FF;
border: 1px solid #0078FF;
color: white;
}
</style>