Commit e88bab69 authored by lijiongliang's avatar lijiongliang

页面修改

parent 28abc381
......@@ -3,383 +3,413 @@
* @Description: 登录
-->
<template>
<view class="appCotent">
<view class="appCotent">
<div class="binding">
<div class="login__logo">
<image src="@/static/binding/logo.png">
</div>
<!-- #ifdef MP-WEIXIN -->
<!-- <view v-if="isCanUse">
<div class="binding">
<div class="login__logo">
<image src="@/static/binding/logo.png">
</div>
<!-- #ifdef MP-WEIXIN -->
<!-- <view v-if="isCanUse">
<view>
<button class="login__btn" hover-class="none" type='primary' @click="getUserProfile">
微信一键登录
</button>
</view>
</view> -->
<view v-if="isCanUse2">
<view>
<button class="login__btn" v-if="!checked" hover-class="none" type='primary'
@click="checkLogin">
微信一键登录
</button>
<button class="login__btn" v-if="checked" hover-class="none" type='primary'
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
微信一键登录
</button>
</view>
</view>
<!-- #endif -->
<div class="login__read">
<u-checkbox-group placement="row">
<u-checkbox :checked='checked' @change="changeBtn"></u-checkbox>
</u-checkbox-group>
已阅读并同意 <span @click="goArticle(1)">《用户注册服务协议》</span><span @click="goArticle(2)">《京东挪车牌隐私权政策》</span>。若您的手机号未注册,将为您直接注册友众账号
</div>
</div>
</view>
<view v-if="isCanUse2">
<view>
<button class="login__btn" v-if="!checked" hover-class="none" type='primary' @click="checkLogin">
微信一键登录
</button>
<button class="login__btn" v-if="checked" hover-class="none" type='primary'
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
微信一键登录
</button>
</view>
</view>
<!-- #endif -->
<div class="login__read">
<u-checkbox-group placement="row">
<u-checkbox :checked='checked' @change="changeBtn"></u-checkbox>
</u-checkbox-group>
已阅读并同意 <span @click="goArticle(1)">《用户注册服务协议》</span><span
@click="goArticle(2)">《京东挪车牌隐私权政策》</span>。若您的手机号未注册,将为您直接注册友众账号
</div>
</div>
</view>
</template>
<script>
export default {
data() {
return {
checked: true,
code: "",
isCanUse: false, //默认为true
isCanUse2: false, //默认为true
openid: '',
nc_protocol: false,
//扫描二维码参数
scene: "",
//检查绑定挪车码
checkCode: {},
//上级url
superiorUrl: '/pages/main',
//上级路径参数
superiorParam: "index",
failure: null
};
},
methods: {
changeBtn() {
this.checked = !this.checked;
},
//登录
checkLogin() {
uni.showToast({
title: "请先阅读并同意《用户注册服务协议》、《京东挪车牌隐私权政策》",
icon: 'none',
duration: 2000,
});
export default {
data() {
return {
checked: true,
code: "",
isCanUse: false, //默认为true
isCanUse2: false, //默认为true
openid: '',
nc_protocol : false,
//扫描二维码参数
scene : "",
//检查绑定挪车码
checkCode: {},
//上级url
superiorUrl: '/pages/main',
//上级路径参数
superiorParam: "index",
failure:null
};
},
methods: {
changeBtn() {
this.checked = !this.checked;
},
//登录
checkLogin() {
uni.showToast({
title: "请先阅读并同意《用户注册服务协议》、《京东挪车牌隐私权政策》",
icon: 'none',
duration: 2000,
});
},
//检查挪车码存在、是否绑定
getCheckMoveCode(){
let opts = { url: '/app/user/check/move/code', method: 'post' };
this.http.httpTokenRequest(opts, {code:this.scene}).then(res => {
if (res.data.code == 200) {
this.checkCode = res.data.data
//未绑定了的情况
if(!this.checkCode.bindFlag){
uni.navigateTo({
url: '/pagesB/pages/move-car/scan?moveCode=' + this.checkCode.code
})
}else if(this.checkCode.selfFlag){
}else{
},
//检查挪车码存在、是否绑定
getCheckMoveCode() {
let opts = {
url: '/app/user/check/move/code',
method: 'post'
};
this.http.httpTokenRequest(opts, {
code: this.scene
}).then(res => {
if (res.data.code == 200) {
this.checkCode = res.data.data
//未绑定了的情况
if (!this.checkCode.bindFlag) {
uni.navigateTo({
url: '/pagesB/pages/move-car/scan?moveCode=' + this.checkCode.code
})
} else if (this.checkCode.selfFlag) {
} else {
}
}
})
},
wechatLogin() {
wx.login({
success: (res) => {
this.code = res.code
this.wechatSession(res.code)
}
})
},
//获取session_key
async wechatSession(code) {
let that = this
let param = {
code: code,
}
}
})
},
wechatLogin() {
wx.login({
success: (res) => {
this.code = res.code
this.wechatSession(res.code)
}
})
},
//获取session_key
async wechatSession(code) {
let that = this
let param = {
code: code,
}
let opts = { url: '/xcx/code/session', method: 'post' }
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
that.openid = res.data.data.openid
uni.setStorageSync('openid', that.openid);
}
})
},
//解析手机号
getPhoneNumber(e) {
uni.showLoading({
title: '加载中',
mask:true
});
let that = this
if (e.detail.errMsg == "getPhoneNumber:ok") {
// uni.hideLoading()
that.decodePhoneLogin(e.detail)
} else {
uni.hideLoading()
console.log("用户点击了拒绝")
}
},
//解密手机号码
async decodePhoneLogin(detail) {
let encryptedData = detail.encryptedData
let iv = detail.iv
let that = this
let param = {
code: detail.code,
openid : that.openid
}
let opts = { url: '/xcx/login', method: 'post' }
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
uni.showToast({
title:'授权成功',
duration:1500
})
uni.setStorageSync('xcxIndexPath', res.data.data.xcxIndexPath);
uni.setStorageSync("userToken", res.data.data.token)
if(this.scene) {
let param = {code : this.scene}
opts = { url: '/app/user/check/move/code', method: 'post' }
that.http.httpTokenRequest(opts, param).then(res => {
if (res.data.code == 200) {
if(res.data.data.bindFlag) {
that.gotoMoveCar();
let opts = {
url: '/xcx/code/session',
method: 'post'
}
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
that.openid = res.data.data.openid
uni.setStorageSync('openid', that.openid);
}
})
},
//解析手机号
getPhoneNumber(e) {
uni.showLoading({
title: '加载中',
mask: true
});
let that = this
if (e.detail.errMsg == "getPhoneNumber:ok") {
// uni.hideLoading()
that.decodePhoneLogin(e.detail)
} else {
that.gotoBindMoveCar();
uni.hideLoading()
console.log("用户点击了拒绝")
}
}
})
} else if(this.failure == 401 ){
uni.navigateBack()
return
} else {
that.gotoIndex()
}
} else {
uni.showToast({
title:'授权失败',
icon:'none',
})
}
})
},
gotoIndex() {
let jumpUrl = this.superiorUrl
if(this.superiorUrl == '/pages/main'){
if(!this.superiorParam){
this.superiorParam = "0"
}
jumpUrl += "?index=" + this.superiorParam
}else{
jumpUrl += "?id=" + this.superiorParam
}
//跳转到绑定页面
uni.reLaunch({ //信息更新成功后跳转到小程序首页
//todo 友众账号绑定界面暂缓
//url: '/pages/binding/binding'
url: jumpUrl
})
// uni.navigateTo({
// url: '/pages/binding/binding'
// });
},
//跳转到挪车页面
gotoMoveCar() {
let that = this;
uni.navigateTo({
url: '/pagesB/pages/move-car/oneMoveCar?scene=' + that.scene
});
},
//跳转到绑定页面
gotoBindMoveCar() {
let that = this;
uni.navigateTo({
url: '/pagesB/pages/move-car/scan?moveCode=' + that.scene
});
},
// 跳转协议政策页面
goArticle(index){
let opts = { url: '', method: 'get' };
if(index == 1){
opts.url = "/app/user/registerAgreement"
}else{
opts.url = "/app/user/ofPrivacy"
}
this.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
let data = res.data.msg
uni.setStorageSync("articelContent",data)
},
//解密手机号码
async decodePhoneLogin(detail) {
let encryptedData = detail.encryptedData
let iv = detail.iv
let that = this
let param = {
code: detail.code,
openid: that.openid
}
let opts = {
url: '/xcx/login',
method: 'post'
}
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
uni.showToast({
title: '授权成功',
duration: 1500
})
uni.setStorageSync('xcxIndexPath', res.data.data.xcxIndexPath);
uni.setStorageSync("userToken", res.data.data.token)
if (this.scene) {
let param = {
code: this.scene
}
opts = {
url: '/app/user/check/move/code',
method: 'post'
}
that.http.httpTokenRequest(opts, param).then(res => {
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar();
} else {
that.gotoBindMoveCar();
}
}
})
} else if (this.failure == 401) {
uni.navigateBack()
return
} else {
that.gotoIndex()
}
} else {
uni.showToast({
title: '授权失败',
icon: 'none',
})
}
})
},
gotoIndex() {
let jumpUrl = this.superiorUrl
if (this.superiorUrl == '/pages/main') {
if (!this.superiorParam) {
this.superiorParam = "0"
}
jumpUrl += "?index=" + this.superiorParam
} else {
jumpUrl += "?id=" + this.superiorParam
}
//跳转到绑定页面
uni.reLaunch({ //信息更新成功后跳转到小程序首页
//todo 友众账号绑定界面暂缓
//url: '/pages/binding/binding'
url: jumpUrl
})
// uni.navigateTo({
// url: '/pages/binding/binding'
// });
},
//跳转到挪车页面
gotoMoveCar() {
let that = this;
uni.navigateTo({
url: '/pagesB/pages/move-car/oneMoveCar?scene=' + that.scene
});
},
//跳转到绑定页面
gotoBindMoveCar() {
let that = this;
uni.navigateTo({
url: '/pages/binding/article'
url: '/pagesB/pages/move-car/scan?moveCode=' + that.scene
});
},
// 跳转协议政策页面
goArticle(index) {
let opts = {
url: '',
method: 'get'
};
if (index == 1) {
opts.url = "/app/user/registerAgreement"
} else {
opts.url = "/app/user/ofPrivacy"
}
this.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
let data = res.data.msg
uni.setStorageSync("articelContent", data)
uni.navigateTo({
url: '/pages/binding/article'
});
}
})
}
},
onLoad(e) { //默认加载
let openid = uni.getStorageSync('openid');
this.failure = e.failure
if (!openid) {
this.wechatLogin()
} else {
this.openid = openid;
}
if (e && e.url) {
this.superiorUrl = e.url
if (e.index) {
this.superiorParam = e.index
}
if (e.id) {
this.superiorParam = e.id
}
}
})
// #ifdef MP-WEIXIN
if (e.scene) {
//获取二维码携带的参数
//扫码后得到的参数
let scene = decodeURIComponent(e.scene)
// scene = scene.split('&')
// let data = {
// //场景值
// scene: e.scene
// }
this.scene = scene;
}
let userToken = uni.getStorageSync('userToken')
if (userToken) {
let that = this
let opts = {
url: '/app/user/info',
method: 'get'
}
that.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
uni.setStorageSync('xcxIndexPath', res.data.data.xcxIndexPath);
if (that.scene) {
let param = {
code: this.scene
}
opts = {
url: '/app/user/check/move/code',
method: 'post'
}
that.http.httpTokenRequest(opts, param).then(res => {
console.info(res);
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar();
} else {
that.gotoBindMoveCar();
}
}
})
} else {
this.gotoIndex()
}
} else {
uni.showToast({
title: '授权失败',
icon: 'none',
})
this.isCanUse2 = true
}
})
} else {
this.isCanUse2 = true
}
// #endif
}
}
},
onLoad(e) { //默认加载
let openid = uni.getStorageSync('openid');
this.failure = e.failure
if(!openid) {
this.wechatLogin()
} else {
this.openid = openid;
}
if(e && e.url){
this.superiorUrl = e.url
if(e.index){
this.superiorParam = e.index
}
if(e.id){
this.superiorParam = e.id
}
}
// #ifdef MP-WEIXIN
if(e.scene) {
//获取二维码携带的参数
//扫码后得到的参数
let scene = decodeURIComponent(e.scene)
// scene = scene.split('&')
// let data = {
// //场景值
// scene: e.scene
// }
this.scene = scene;
}
let userToken = uni.getStorageSync('userToken')
if (userToken) {
let that = this
let opts = { url: '/app/user/info', method: 'get' }
that.http.httpTokenRequest(opts, {}).then(res => {
if (res.data.code == 200) {
uni.setStorageSync('xcxIndexPath', res.data.data.xcxIndexPath);
if(that.scene) {
let param = {code : this.scene}
opts = { url: '/app/user/check/move/code', method: 'post' }
that.http.httpTokenRequest(opts, param).then(res => {
console.info(res);
if (res.data.code == 200) {
if(res.data.data.bindFlag) {
that.gotoMoveCar();
} else {
that.gotoBindMoveCar();
}
}
})
} else {
this.gotoIndex()
}
} else {
uni.showToast({
title:'授权失败',
icon:'none',
})
this.isCanUse2 = true
}
})
} else {
this.isCanUse2 = true
}
// #endif
}
}
</script>
<style lang="scss" scoped>
button::after {
border: none;
}
.appCotent {
display: flex;
align-items: center;
justify-content: center;
}
button::after {
border: none;
}
.appCotent{
display: flex;
align-items: center;
justify-content: center;
}
.binding {
position: relative;
top:-120rpx;
.login__logo {
// padding-top: 206rpx;
text-align: center;
image {
width: 174rpx;
height: 174rpx;
}
}
.u-checkbox-group {
display: inline-block !important;
}
/deep/.u-checkbox-group--row {
display: inline-block !important;
}
.login__btn {
width: 600rpx;
height: 90rpx;
margin: 0 auto;
border-radius: 20rpx;
background: url('@/static/binding/yuan-btn.png') no-repeat;
background-size: contain;
display: flex;
justify-content: center;
align-items: center;
font-family: PingFang SC;
font-weight: bold;
color: #FFFFFF;
opacity: 0.96;
letter-spacing: .5em;
margin-bottom: 32rpx;
margin-top: 100rpx;
}
.login__read {
margin: 0 auto;
width: 600rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 500;
color: #666666;
line-height: 36rpx;
position: fixed;
bottom: 100rpx;
left: 0;
right: 0;
margin: 0 auto;
span {
color: rgb(0, 81, 255);
}
}
}
.binding {
position: relative;
top: -120rpx;
.login__logo {
// padding-top: 206rpx;
text-align: center;
image {
width: 174rpx;
height: 174rpx;
}
}
.u-checkbox-group {
display: inline-block !important;
}
/deep/.u-checkbox-group--row {
display: inline-block !important;
}
.login__btn {
width: 600rpx;
height: 90rpx;
margin: 0 auto;
border-radius: 20rpx;
background: url('@/static/binding/yuan-btn.png') no-repeat;
background-size: contain;
display: flex;
justify-content: center;
align-items: center;
font-family: PingFang SC;
font-weight: bold;
color: #FFFFFF;
opacity: 0.96;
letter-spacing: .5em;
margin-bottom: 32rpx;
margin-top: 100rpx;
}
.login__read {
margin: 0 auto;
width: 600rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 500;
color: #666666;
line-height: 36rpx;
position: fixed;
bottom: 100rpx;
left: 0;
right: 0;
margin: 0 auto;
span {
color: rgb(0, 81, 255);
}
}
}
</style>
......@@ -34,7 +34,8 @@
data() {
return {
tab: "index",
page: 1
page: 1,
scene: null // 二维码携带参数
}
},
computed: {
......@@ -92,18 +93,18 @@
}
let opts = {
url: '/app/user/check/move/code',
method: 'post'
method: 'post'
}
that.http.httpTokenRequest(opts, param).then(
res => {
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar(scene)
} else {
that.gotoBindMoveCar(scene)
res => {
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar(scene)
} else {
that.gotoBindMoveCar(scene)
}
}
}
})
})
} else {
uni.showToast({
title: '扫码失败',
......@@ -150,35 +151,38 @@
});
},
wechatLogin() {
wx.login({
success: (res) => {
this.wechatSession(res.code)
}
})
wx.login({
success: (res) => {
this.wechatSession(res.code)
}
})
},
//获取session_key
async wechatSession(code) {
let that = this
let param = {
code: code,
}
let opts = { url: '/xcx/code/session', method: 'post' }
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
that.openid = res.data.data.openid
uni.setStorageSync('openid', that.openid);
}
})
let that = this
let param = {
code: code,
}
let opts = {
url: '/xcx/code/session',
method: 'post'
}
await that.http.httpRequest(opts, param).then(res => {
if (res.data.code == 200) {
that.openid = res.data.data.openid
uni.setStorageSync('openid', that.openid);
}
})
},
},
onLoad(option) {
// 静默授权获取openid
let openid = uni.getStorageSync('openid');
if(!openid) {
this.wechatLogin()
let openid = uni.getStorageSync('openid');
if (!openid) {
this.wechatLogin()
}
let that = this
if (option && option.index) {
that.$nextTick(() => {
......@@ -190,9 +194,11 @@
that.$refs.myTab.current = i;
});
}
let token = uni.getStorageSync('userToken')
if(!token){
console.log(option,uni.getStorageSync('scene'),22222222222)
let token = uni.getStorageSync('userToken')
if (!token) {
let ptKey = plugin.getPtKey();
if (ptKey) {
uni.showLoading({
......@@ -201,18 +207,21 @@
plugin.isvObfuscator({
url: 'https://wxapplogin2.m.jd.com/cgi-bin/login/isv/isvObfuscator'
}).then(res => {
let {
let {
token,
message
} = res;
if (!token) {
uni.navigateTo({
url:"/pages/login/index/index"
})
uni.hideLoading()
uni.showToast({
title: `京东登录失败:${message}`,
icon: 'none',
duration: 2000
});
// uni.showToast({
// title: `京东登录失败:${message}`,
// icon: 'none',
// duration: 2000
// });
} else {
let opts = {
url: '/xcx/login',
......@@ -221,17 +230,40 @@
let openid = uni.getStorageSync('openid')
that.http.httpTokenRequest(opts, {
token: token,
openid:openid
openid: openid
}).then(res => {
if (res.data.code == 200) {
let token = res.data.data.token
uni.setStorageSync('userToken',token)
uni.setStorageSync('userToken', token)
uni.hideLoading()
uni.showToast({
title: "登录成功",
icon: 'none',
duration: 2000
});
// 判断是否扫码进入
that.scene = uni.getStorageSync('scene')
if (that.scene) {
//获取二维码携带的参数
//扫码后得到的参数
that.http.httpTokenRequest({
url: '/app/user/check/move/code',
method: 'post'
}, {
code: that.scene
}).then(res => {
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar(that.scene);
} else {
that.gotoBindMoveCar(that.scene);
}
uni.removeStorageSync('scene')
}
})
}
}
})
}
......@@ -239,6 +271,35 @@
}).catch(err => {
console.log('err', err)
})
}else{
// 判断是否扫码进入
if (option && option.scene) {
uni.setStorageSync('scene', decodeURIComponent(option.scene))
uni.navigateTo({
url:"/pages/login/index/index"
})
}
}
}else{
// 判断是否扫码进入
if (option && option.scene) {
//获取二维码携带的参数
//扫码后得到的参数
that.scene = decodeURIComponent(option.scene)
that.http.httpTokenRequest({
url: '/app/user/check/move/code',
method: 'post'
}, {
code: that.scene
}).then(res => {
if (res.data.code == 200) {
if (res.data.data.bindFlag) {
that.gotoMoveCar(that.scene);
} else {
that.gotoBindMoveCar(that.scene);
}
}
})
}
}
......
......@@ -62,6 +62,7 @@
</template>
<script>
let plugin = requirePlugin('loginPlugin');
export default {
data() {
return {
......@@ -71,11 +72,12 @@ export default {
icon: require("@/static/my/my01.png"),
title: "我的订单",
url: "/pagesD/pages/personal/myJdOrder"
},{
icon: require("@/static/my/my12.png"),
title: "我的地址",
url: "/pagesD/pages/personal/myAddress"
},
// {
// icon: require("@/static/my/my12.png"),
// title: "我的地址",
// url: "/pagesD/pages/personal/myAddress"
// },
{
icon: require("@/static/my/my8.png"),
title: "使用帮助",
......@@ -133,10 +135,12 @@ export default {
uni.removeStorageSync('userToken')
uni.removeStorageSync('xcxIndexPath')
// uni.removeStorageSync('openid')
uni.reLaunch({
url: '/pages/main'
});
plugin.logout().then((res) => {
console.jdLoginLog(res, 'logoutres');
uni.reLaunch({
url: '/pages/main'
});
});
}
})
......@@ -488,7 +492,7 @@ export default {
background: rgba(0, 0, 0, .1);
}
.list__item:nth-of-type(3) {
.list__item:nth-of-type(2) {
.list__left {
image {
width: 29rpx;
......@@ -498,7 +502,7 @@ export default {
}
}
.list__item:nth-of-type(4) {
.list__item:nth-of-type(3) {
.list__left {
image {
width: 28rpx;
......@@ -508,7 +512,7 @@ export default {
}
}
.list__item:nth-of-type(5) {
.list__item:nth-of-type(4) {
.list__left {
image {
width: 28rpx;
......
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