Commit 63e878a7 by LinChengbiao

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

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