Commit 7c0688ca authored by youjie's avatar youjie

绑定

parent c4979ed0
...@@ -7,18 +7,20 @@ ...@@ -7,18 +7,20 @@
</view> </view>
<view class="login-form"> <view class="login-form">
<view class="login-title">同行登录</view> <view class="login-title">同行登录</view>
<view class="login-item"> <template v-if="!ShareLoginstatus">
<input type="text" v-model="msg.account" placeholder="请输入您的同业账号" :class="{'focus':currentFocus=='account'}" @blur="changeCurrentFocus('')" <view class="login-item">
@focus="changeCurrentFocus('account')"> <input type="text" v-model="msg.account" placeholder="请输入您的同业账号" :class="{'focus':currentFocus=='account'}" @blur="changeCurrentFocus('')"
</view> @focus="changeCurrentFocus('account')">
<view class="login-item"> </view>
<input type="password" v-model="msg.password" placeholder="请输入您的登录密码" :class="{'focus':currentFocus=='pwd'}" @blur="changeCurrentFocus('')" <view class="login-item">
@focus="changeCurrentFocus('pwd')"> <input type="password" v-model="msg.password" placeholder="请输入您的登录密码" :class="{'focus':currentFocus=='pwd'}" @blur="changeCurrentFocus('')"
</view> @focus="changeCurrentFocus('pwd')">
<view class="login-item"> </view>
<view @click="loginByAccount" class="login-btn" :class="{'disable':msg.account==''||msg.password==''}">登录</view> <view class="login-item">
</view> <view @click="loginByAccount" class="login-btn" :class="{'disable':msg.account==''||msg.password==''}">登录</view>
</view>
</template>
</view> </view>
</view> </view>
</template> </template>
...@@ -33,13 +35,75 @@ ...@@ -33,13 +35,75 @@
OpenId: '' OpenId: ''
}, },
currentFocus: '', currentFocus: '',
loginLoading: false loginLoading: false,
param:{
OpenId:'',//oDGzz5J3qpVo0j_fU8mKxk-G5bcI
id:'',
createBy:0,
},
ShareLoginstatus: false,
} }
}, },
onLoad(option) {
if (option && option.scene) {
let t = decodeURIComponent(option.scene).split('&')
t.forEach(x => {
let item = x.split('=')
if (item.length === 2) {
if (item[0] === 'id') {
this.param.id = item[1]
} else if (item[0] === 'createBy') {
this.param.createBy = item[1]
}
}
})
console.log(this.param,'------0000')
}
},
mounted() { mounted() {
// let scene = "id=10507&createBy=5"
// console.log(encodeURIComponent(scene),'------')
this.getUserProfileHandler() this.getUserProfileHandler()
}, },
methods: { methods: {
ShareLogin() {
this.apipost("b2b_post_LvXiaoYouBindCustomerByCode",this.param,(res) => {
if (res.resultCode == 1) {
//移除缓存=>跳转到首页重新登录
uni.removeStorageSync('b2b_user')
uni.removeStorageSync('mall_UserInfo')
let tempData = res.data;
if (tempData && tempData.Id && tempData.Id > 0) {
if(tempData.CounponList){
uni.setStorageSync('coupons',tempData.CounponList)
}else{
uni.setStorageSync('coupons',[{Name:tempData.CouponsName,Num:1}])
}
let newUrl = '/pages/index/index';
uni.redirectTo({
url: newUrl
})
} else {
uni.redirectTo({
url: '/pages/index/index'
})
}
}
},(error)=>{
if(error.message=='当前微信已绑定其他同业!'){
if(uni.getStorageSync("mall_UserInfo")||uni.getStorageSync('b2b_user')){
let newUrl = '/pages/index/index';
uni.redirectTo({
url: newUrl
})
}else{
this.ShareLoginstatus = false
}
}
})
},
changeCurrentFocus(val) { changeCurrentFocus(val) {
this.currentFocus = val this.currentFocus = val
}, },
...@@ -108,6 +172,12 @@ ...@@ -108,6 +172,12 @@
}) })
}, },
getUserProfileHandler() { getUserProfileHandler() {
if(this.param.id && this.param.createBy){
uni.showLoading({
title:'绑定中...'
})
this.ShareLoginstatus = true
}
wx.login({ wx.login({
success: (res) => { success: (res) => {
this.getCode(res) this.getCode(res)
...@@ -126,6 +196,11 @@ ...@@ -126,6 +196,11 @@
(res) => { (res) => {
if (res.resultCode == 1) { if (res.resultCode == 1) {
this.msg.OpenId = res.data; this.msg.OpenId = res.data;
if(this.param.id && this.param.createBy){
this.param.OpenId = this.msg.OpenId
this.ShareLogin()
}
} }
} }
); );
......
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