Commit 63e878a7 by LinChengbiao

对接PC端,修改登录页逻辑

parent c44078ce
......@@ -29,7 +29,8 @@ export default class extends wepy.app {
}
globalData = {
userInfo: null
userInfo: null,
loginRes: null
}
constructor () {
......
<template>
<view class="homeHeaderWpy">
携程品牌事件库
{{ loginRes.sourceName }}品牌事件库
</view>
</template>
......@@ -11,6 +11,12 @@ export default class homeHeader extends wepy.component {
onLoad () {
// console.log('homeHeader')
}
computed = {
loginRes () {
return this.$parent.$parent.globalData.loginRes
}
}
}
</script>
......
......@@ -90,6 +90,12 @@ export default class home extends wepy.page {
})
}
computed = {
userInfo () {
return this.$parent.globalData.userInfo
}
}
events = {
toSearch () {
// console.log(this.searchWord)
......
......@@ -10,10 +10,10 @@
<image class="logo" src="../static/img/logo.png" />
<!-- 点击按钮的时候弹出授权弹窗,已经授权过的不会弹出弹窗 -->
<button class="btn" wx:if="{{ !userInfo }}" open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button>
<view class="btn" wx:if="{{ userInfo }}" @tap="bindZhiWei">绑定</view>
<button class="btn" wx:if="{{ !userInfo }}" open-type="getUserInfo" @getuserinfo="getUserInfo" @tap="loginBtn">登录</button>
<view class="btn" wx:if="{{ userInfo && wait }}" @tap="bindZhiWei">绑定</view>
<view class="bindIpts" wx:if="{{ userInfo }}">
<view class="bindIpts" wx:if="{{ userInfo && wait }}">
<view class="text">绑定已有帐号</view>
<view class="input">
<image src="../static/img/i_icon_username.png" />
......@@ -50,12 +50,12 @@ export default class login extends wepy.page {
password: ''
},
alertData: {},
autoLogin: true
autoLogin: true,
wait: true
}
onLoad () {
// console.log('login')
this.loginBrandSmall()
}
methods = {
......@@ -72,6 +72,9 @@ export default class login extends wepy.page {
} else {
this.zhiweiBind()
}
},
loginBtn () {
this.wait = false
}
}
......@@ -158,14 +161,15 @@ export default class login extends wepy.page {
url: 'base/loginBrandSmall.do',
method: 'POST',
data: {
code: await this.getCode()
code: await this.getCode(),
wxUserInfo: this.userInfo
}
}).then(res => {
// console.log(res)
if (res.data.state) {
let data = res.data.data
console.log('loginBrandSmall: ', data)
if (!this.autoLogin) {
if (this.autoLogin) {
this.alertData = {
show: true,
type: 'success',
......@@ -173,6 +177,7 @@ export default class login extends wepy.page {
duration: 2,
callback: () => {
// console.log('页面跳转到首页')
this.$parent.globalData.loginRes = data
wepy.setStorageSync('JSESSIONID', data.JSESSIONID)
wepy.redirectTo({
url: `/pages/home`
......@@ -180,6 +185,7 @@ export default class login extends wepy.page {
}
}
} else {
this.$parent.globalData.loginRes = data
wepy.setStorageSync('JSESSIONID', data.JSESSIONID)
wepy.redirectTo({
url: `/pages/home`
......@@ -196,6 +202,7 @@ export default class login extends wepy.page {
}
}
}
this.wait = true
this.$apply()
}).catch(err => {
if (!this.autoLogin) {
......@@ -221,6 +228,12 @@ export default class login extends wepy.page {
return this.$parent.globalData.userInfo
}
}
watch = {
userInfo (val) {
this.loginBrandSmall()
}
}
}
</script>
......
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