You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
398 lines
9.6 KiB
398 lines
9.6 KiB
<template>
|
|
<view class="container flex-items-plus flex-column">
|
|
<global-loading />
|
|
<view class="login-logoBox">
|
|
<image class="login-logo" src="http://36.138.125.206:8081/ceres-local-file/image/logo_http://36.138.125.206:8081/ceres-local-filepng"></image>
|
|
</view>
|
|
<view class="lang-switch-fix">
|
|
<view class="lang-switch-box" @click="onLocaleChange">
|
|
<view class="txt">{{ applicationLocale == 'en' ? $t('navbar.english') : $t('navbar.chinese')}}</view>
|
|
<image src="@/static/images/temp/lang_label.png"/>
|
|
</view>
|
|
</view>
|
|
<view class="loginTitle-text flex-column-plus flex-items font-color-666 fs26">
|
|
<text class="fs28 font-color-252744">{{ $t('client.logindesc')}}</text>
|
|
<text class="fs28 font-color-252744 mar-top-5">{{ $t('client.logindesc1')}}</text>
|
|
</view>
|
|
<view>
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
<button class="loginWxBut fs28" @click="GetUserInfo">{{ $t('client.loginbywx')}}</button>
|
|
<button class="goToHome fs28" @click="goToHome">{{ $t('client.gotohomepage')}}</button>
|
|
<!-- #endif -->
|
|
<!-- #ifdef MP-ALIPAY -->
|
|
<button class="loginWxBut fs28" @click="GetAliPayUserInfo">{{ $t('client.loginbyzfb')}}</button>
|
|
<!-- #endif -->
|
|
<!-- #ifndef MP-ALIPAY -->
|
|
<view class="loginBut" v-if="noMp" @click="goLogin">{{ $t('client.loginbyphone')}}</view>
|
|
<!-- #endif -->
|
|
</view>
|
|
<view class="flex-row-plus mar-top-30" v-if="noMp">
|
|
<text class="fs28 font-color-252744">{{ $t('client.noaccount')}},</text>
|
|
<view class="fs28 font-color-f5be51" @click="goRegister">{{ $t('client.gotoregister')}}</view>
|
|
</view>
|
|
<!-- <view class="language" @click="onLocaleChange">{{ applicationLocale == 'en' ? $t('navbar.english') : $t('navbar.chinese')}}</view>-->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
const NET = require('../../utils/request')
|
|
const API = require('../../config/api')
|
|
export default {
|
|
data() {
|
|
return {
|
|
WXloginQuery: {
|
|
"code": "",
|
|
"salesId": 0,
|
|
"headImage": '',
|
|
"terminal":1
|
|
},
|
|
noMp: false,
|
|
applicationLocale: ''
|
|
// beforePage: undefined,
|
|
// doubleBeforePage: undefined
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
|
|
// #ifndef MP
|
|
this.noMp = true
|
|
// #endif
|
|
const pages = getCurrentPages()
|
|
if(pages.length > 2){
|
|
uni.setStorageSync('last_page', pages[pages.length - 2].route);
|
|
if (pages[pages.length - 2].options) {
|
|
uni.setStorageSync('last_page_options', pages[pages.length - 2].options);
|
|
}
|
|
}
|
|
this.applicationLocale = uni.getLocale();
|
|
uni.onLocaleChange((e) => {
|
|
this.applicationLocale = e.locale;
|
|
})
|
|
},
|
|
onShow() {
|
|
// 所有需要授权页面进登录页面取消loading
|
|
uni.hideLoading()
|
|
},
|
|
onBackPress() {
|
|
uni.switchTab({
|
|
url: '../../pages/tabbar/index/index'
|
|
})
|
|
return true;
|
|
},
|
|
methods: {
|
|
onLocaleChange() {
|
|
var that = this
|
|
uni.showActionSheet({
|
|
itemList: [that.$t('navbar.chinese'), that.$t('navbar.english')],
|
|
success: function (res) {
|
|
if(res.tapIndex == 1){
|
|
uni.setLocale('en');
|
|
that.$i18n.locale = 'en';
|
|
}else {
|
|
uni.setLocale('zh-Hans');
|
|
that.$i18n.locale = 'zh-Hans';
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res.errMsg);
|
|
}
|
|
});
|
|
|
|
},
|
|
back() {
|
|
uni.switchTab({
|
|
url: '../../pages/tabbar/index/index'
|
|
});
|
|
},
|
|
goLogin() {
|
|
uni.navigateTo({
|
|
url: 'accountLogin'
|
|
})
|
|
},
|
|
goRegister() {
|
|
uni.navigateTo({
|
|
url: 'register'
|
|
})
|
|
},
|
|
// 微信登录
|
|
GetUserInfo() {
|
|
// uni.showLoading({
|
|
// title: '正在加载...',
|
|
// mask: true
|
|
// });
|
|
|
|
const that = this
|
|
// // #ifdef APP-PLUS
|
|
// uni.login({
|
|
// provider: 'weixin',
|
|
// success: function(loginRes) {
|
|
// // 获取用户信息
|
|
// uni.getUserInfo({
|
|
// provider: 'weixin',
|
|
// success: function(infoRes) {
|
|
// let wechatOpenId = infoRes.userInfo.openId
|
|
// let avatarUrl = infoRes.userInfo.avatarUrl
|
|
// NET.request(API.WxAppLogin, {
|
|
// 'wechatOpenId': wechatOpenId
|
|
// }, 'POST').then(res => {
|
|
// let data = {
|
|
// wechatOpenId: wechatOpenId,
|
|
// headImage: avatarUrl
|
|
// }
|
|
// that.loginSuc(res.data, data)
|
|
// }).catch(res => {
|
|
// console.log('WxAppLogin failed: ', res)
|
|
// })
|
|
// },
|
|
// fail: () => {
|
|
// uni.showToast({
|
|
// title: "微信登录授权失败",
|
|
// icon: "none"
|
|
// });
|
|
// }
|
|
// });
|
|
// }
|
|
// });
|
|
// // #endif
|
|
|
|
// #ifdef MP-WEIXIN
|
|
uni.login({
|
|
provider: 'weixin',
|
|
success: (res2) => {
|
|
uni.hideLoading()
|
|
that.WXloginQuery.code = res2.code
|
|
},
|
|
fail: () => {
|
|
uni.showToast({
|
|
title: "微信登录授权失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
})
|
|
|
|
uni.getUserProfile({
|
|
desc: '正在获取', //不写不弹提示框
|
|
success: function(res) {
|
|
that.WXloginQuery.headImage = res.userInfo.avatarUrl
|
|
NET.request(API.WxLogin, that.WXloginQuery, 'POST').then(res => {
|
|
let data = {
|
|
wechatOpenId: res.data.wechatOpenId,
|
|
headImage: res.data.headImage
|
|
}
|
|
that.loginSuc(res.data, data)
|
|
}).catch(err => {
|
|
})
|
|
},
|
|
fail: function(err) {
|
|
uni.showToast({
|
|
title: "微信登录授权失败",
|
|
icon: "none"
|
|
});
|
|
},
|
|
});
|
|
/* uni.getUserInfo({
|
|
provider: 'weixin',
|
|
success: function(infoRes) {
|
|
},
|
|
fail: () => {
|
|
uni.showToast({
|
|
title: "微信登录授权失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
}); */
|
|
/* uni.getUserProfile({
|
|
desc: '正在获取', //不写不弹提示框
|
|
success: function(res) {
|
|
console.dir(res)
|
|
that.WXloginQuery.headImg = res.userInfo.avatarUrl
|
|
// that.loginSuc({'ifFirst': 1}, {'headImg': res.userInfo.avatarUrl})
|
|
},
|
|
fail: function(err) {
|
|
uni.showToast({
|
|
title: "微信登录授权失败",
|
|
icon: "none"
|
|
});
|
|
}
|
|
}) */
|
|
// #endif
|
|
},
|
|
GetAliPayUserInfo() {
|
|
const that = this
|
|
uni.login({
|
|
provider: 'alipay',
|
|
scopes: 'auth_user',
|
|
success: function(loginRes) {
|
|
that.alipayLogin(loginRes.authCode)
|
|
}
|
|
});
|
|
},
|
|
alipayLogin(authCode) {
|
|
NET.request(API.AlipayLogin, {
|
|
'code': authCode
|
|
}, 'POST').then(res => {
|
|
this.loginSuc(res.data, {
|
|
'buyerUserId': res.data.buyerUserId
|
|
})
|
|
}).catch(err => {
|
|
})
|
|
},
|
|
goToHome() {
|
|
uni.switchTab({
|
|
url: '/pages/tabbar/index/index'
|
|
});
|
|
},
|
|
loginSuc(buyerUser, data) {
|
|
if (buyerUser.ifFirst == 0) {
|
|
uni.setStorageSync('storage_key', buyerUser);
|
|
this.bindSalesCustomer()
|
|
/* uni.switchTab({
|
|
url: '/pages/tabbar/user/index',
|
|
success() {
|
|
uni.hideLoading()
|
|
}
|
|
}) */
|
|
|
|
const last_page = uni.getStorageSync('last_page') || ''
|
|
if (last_page) {
|
|
const last_page_options = uni.getStorageSync('last_page_options') || ''
|
|
const str = JSON.stringify(last_page_options).replaceAll('{', '').replaceAll('}', '').replaceAll(
|
|
'"', '').replaceAll(':', '=').replaceAll(',', '&')
|
|
// 保留其他路由,需跳转2下 到最后登录页面
|
|
// uni.navigateBack({
|
|
// delta: 1
|
|
// })
|
|
// uni.redirectTo({
|
|
// url: `/${last_page}?${str}`,
|
|
// // url: `/${last_page}?` + str
|
|
// })
|
|
|
|
// 清空其他路由,直接跳转最后登录页面
|
|
uni.reLaunch({
|
|
url: `/${last_page}?${str}`,
|
|
// url: `/${last_page}?` + str
|
|
})
|
|
return
|
|
} else {
|
|
// #ifdef MP-ALIPAY
|
|
uni.navigateTo({
|
|
url: '/pages/tabbar/user/index'
|
|
})
|
|
// #endif
|
|
// #ifndef MP-ALIPAY
|
|
uni.switchTab({
|
|
url: '/pages/tabbar/user/index'
|
|
})
|
|
// #endif
|
|
}
|
|
} else { // 第一次登录,绑定手机号
|
|
uni.redirectTo({
|
|
url: 'bindPhone?data=' + JSON.stringify(data)
|
|
})
|
|
}
|
|
},
|
|
bindSalesCustomer() {
|
|
const shopId = uni.getStorageSync('shopId')
|
|
const salesId = uni.getStorageSync('salesId')
|
|
if (shopId && salesId && shopId !== '' && salesId !== '') {
|
|
// 多次调用绑定方法,不提示任何信息即可
|
|
NET.request(API.BindSalesCustomer, {
|
|
shopId: shopId,
|
|
distributorId: salesId
|
|
}, 'POST').then(res => {
|
|
uni.removeStorageSync('salesId');
|
|
uni.removeStorageSync('shopId');
|
|
}).catch(err => {
|
|
console.dir(err)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.container {
|
|
background-color: #FFFFFF;
|
|
height: 100vh;
|
|
|
|
.login-logoBox {
|
|
margin-top: -200rpx;
|
|
|
|
.login-logo {
|
|
width: 518rpx;
|
|
height: 100rpx;
|
|
}
|
|
}
|
|
|
|
.loginTitle-text {
|
|
margin-top: 100rpx;
|
|
}
|
|
|
|
.goToHome {
|
|
background: none;
|
|
border: none;
|
|
width: auto;
|
|
margin-top: 50rpx;
|
|
color: #999999;
|
|
text-decoration: underline;
|
|
|
|
&:after {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.loginWxBut {
|
|
background: #252744;
|
|
border-radius: 50rpx;
|
|
color: #FFFFFF;
|
|
height: 98rpx;
|
|
width: 620rpx;
|
|
text-align: center;
|
|
line-height: 98rpx;
|
|
margin-top: 49rpx;
|
|
}
|
|
|
|
.loginBut {
|
|
background-color: #252744;
|
|
border-radius: 50rpx;
|
|
color: #FFFFFF;
|
|
height:98rpx;
|
|
width: 620rpx;
|
|
text-align: center;
|
|
line-height: 98rpx;
|
|
margin-top: 30rpx;
|
|
font-size: 32rpx;
|
|
}
|
|
|
|
.language{
|
|
position: absolute;
|
|
bottom: 5vh;
|
|
}
|
|
}
|
|
|
|
.lang-switch-fix{
|
|
position: fixed;
|
|
right: 90rpx;
|
|
top: 110rpx;
|
|
}
|
|
.lang-switch-box{
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
.txt{
|
|
color: #252744;
|
|
font-size: 28rpx;
|
|
margin-right: 12rpx;
|
|
}
|
|
image{
|
|
width: 20rpx;
|
|
height: 13rpx;
|
|
}
|
|
}
|
|
</style>
|
|
<style scoped>
|
|
.loginWxBut::after {
|
|
border-radius: 0 !important;
|
|
}
|
|
</style>
|