Commit ba8defe2 authored by 高铭波's avatar 高铭波

Merge branch 'dev'

parents eca1422d a77df364
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
// 授权用户信息 // 授权用户信息
authUserInfo: "", authUserInfo: "",
logout: false,
navHeight: 0, //导航栏高度 navHeight: 0, //导航栏高度
rpxScreenHeight: 0, // 照相视框高度 rpxScreenHeight: 0, // 照相视框高度
safeHeight: 0, // 安全高度 safeHeight: 0, // 安全高度
...@@ -153,6 +153,7 @@ export default { ...@@ -153,6 +153,7 @@ export default {
wxAppNo: that.globalData.wxAppNo, // 自营平台小程序 wxAppNo: that.globalData.wxAppNo, // 自营平台小程序
}; };
let result = await that.$u.api.loginWechatAuth(params); let result = await that.$u.api.loginWechatAuth(params);
console.log("result", result)
if ( if (
result && result &&
result.code == 200 && result.code == 200 &&
...@@ -173,23 +174,24 @@ export default { ...@@ -173,23 +174,24 @@ export default {
} }
}); });
}, },
setUserData(userInfo) { setUserData(userInfo, that) {
let self = that ? that : this
if (userInfo && userInfo.token) { if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息 // 如果已经登录则直接获取相关信息
this.$u.vuex("vuex_token", userInfo.token); self.$u.vuex("vuex_token", userInfo.token);
this.$u.vuex("vuex_user", userInfo); self.$u.vuex("vuex_user", userInfo);
this.$u.vuex("vuex_wx_uid", userInfo.wxopenid); self.$u.vuex("vuex_wx_uid", userInfo.wxopenid);
this.track('auth_login', { this.track('auth_login', {
auth_token: userInfo.token, auth_token: userInfo.token,
auth_user: userInfo, auth_user: userInfo,
auth_wx_uid: userInfo.wxopenid auth_wx_uid: userInfo.wxopenid
}); });
} else { } else {
this.$u.vuex("vuex_token", ""); self.$u.vuex("vuex_token", "");
this.$u.vuex("vuex_user", null); self.$u.vuex("vuex_user", null);
this.$u.vuex("vuex_wx_uid", ""); self.$u.vuex("vuex_wx_uid", "");
} }
this.$u.vuex("vuex_settled", null); self.$u.vuex("vuex_settled", null);
}, },
/* 版本更新 */ /* 版本更新 */
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<text>{{telTip}}</text> <text>{{telTip}}</text>
<u-icon class="tel-arrow-icon" name="arrow-up-fill"></u-icon> <u-icon class="tel-arrow-icon" name="arrow-up-fill"></u-icon>
</view> </view>
</view> </view>
<view v-if="showSuperButton" class="super-button"><u-button@click="handleSuperButton">切换用户</u-button></view> <view v-if="showSuperButton" class="super-button"><u-button@click="handleSuperButton">切换用户</u-button></view>
</view> </view>
...@@ -32,21 +32,20 @@ ...@@ -32,21 +32,20 @@
</u-cell-group> </u-cell-group>
</view> </view>
</view> </view>
<u-modal v-model="show" :content="content" show-cancel-button @confirm="logout"></u-modal>
</view> </view>
</template> </template>
<script> <script>
const app = getApp(); const app = getApp();
import takePhoto from '@/components/take/index.vue'
export default { export default {
components: {
'take-photo': takePhoto
},
data() { data() {
return { return {
qnPath: process.uniEnv.qn_base_url, qnPath: process.uniEnv.qn_base_url,
serviceTel: '18124099271', serviceTel: '18124099271',
showSuperButton: false showSuperButton: false,
show: false,
content: '是否确认退出该账户?'
} }
}, },
computed: { computed: {
...@@ -55,58 +54,58 @@ ...@@ -55,58 +54,58 @@
}, },
avatar() { avatar() {
return this.vuex_settled && this.vuex_settled.avatar return this.vuex_settled && this.vuex_settled.avatar
}, },
name() { name() {
return (this.settled && this.settled.nickname) || (this.vuex_user && (this.vuex_user.name || this.vuex_user.loginName)) return (this.settled && this.settled.nickname) || (this.vuex_user && (this.vuex_user.name || this.vuex_user.loginName))
}, },
mobile() { mobile() {
return (this.settled && this.settled.mobile) || (this.vuex_user && this.vuex_user.mobile) return (this.settled && this.settled.mobile) || (this.vuex_user && this.vuex_user.mobile)
}, },
items() { items() {
return [ return [
{ {
pathName: 'wallet', pathName: 'wallet',
title: '我的钱包', title: '我的钱包',
value: '', value: '',
icon: 'qianbao.png', icon: 'qianbao.png',
imageStyle: 'width:34rpx;height:32rpx' imageStyle: 'width:34rpx;height:32rpx'
}, },
{ {
pathName: 'deposit', pathName: 'deposit',
title: '配件押金', title: '配件押金',
value: '', value: '',
icon: 'yajin.png', icon: 'yajin.png',
imageStyle: 'width:32rpx;height:32rpx' imageStyle: 'width:32rpx;height:32rpx'
}, },
{ {
pathName: 'contract', pathName: 'contract',
title: '我的合同', title: '我的合同',
value: '', value: '',
icon: 'hetong.png', icon: 'hetong.png',
imageStyle: 'width:34rpx;height:32rpx' imageStyle: 'width:34rpx;height:32rpx'
}, },
{ {
pathName: 'cert', pathName: 'cert',
title: '我的证件', title: '我的证件',
value: '', value: '',
icon: 'zhengjian.png', icon: 'zhengjian.png',
imageStyle: 'width:36rpx;height:28rpx' imageStyle: 'width:36rpx;height:28rpx'
}, },
{ {
pathName: 'address', pathName: 'address',
title: '收货地址', title: '收货地址',
value: '', value: '',
icon: 'wddizhi.png', icon: 'wddizhi.png',
imageStyle: 'width:32rpx;height:32rpx' imageStyle: 'width:32rpx;height:32rpx'
}, },
{ {
pathName: 'warehouse', pathName: 'warehouse',
title: '我的仓库', title: '我的仓库',
value: '', value: '',
icon: 'cangku.png', icon: 'cangku.png',
imageStyle: 'width:36rpx;height:32rpx' imageStyle: 'width:36rpx;height:32rpx'
}, },
{ {
pathName: 'customer', pathName: 'customer',
title: '联系客服', title: '联系客服',
value: this.serviceTel, value: this.serviceTel,
...@@ -126,9 +125,9 @@ ...@@ -126,9 +125,9 @@
}, },
placeholderImage() { placeholderImage() {
return this.qnPath + 'touxiang.png' return this.qnPath + 'touxiang.png'
}, },
headImageStyle() { headImageStyle() {
return this.avatar ? 'width:136rpx; height:136rpx;border-radius:68rpx' : 'width:144rpx; height:144rpx;border-radius:72rpx' return this.avatar ? 'width:136rpx; height:136rpx;border-radius:68rpx' : 'width:144rpx; height:144rpx;border-radius:72rpx'
}, },
headSize() { headSize() {
return this.avatar ? 136 : 144 return this.avatar ? 136 : 144
...@@ -136,15 +135,15 @@ ...@@ -136,15 +135,15 @@
}, },
onLoad() { onLoad() {
app.trackPage('我的首页') app.trackPage('我的首页')
if(this.vuex_token ) { if(this.vuex_token ) {
if (!this.showSuperButton) { if (!this.showSuperButton) {
this.allowLogin() this.allowLogin()
} }
if (!this.settled) { if (!this.settled) {
this.getData() this.getData()
} }
} }
}, },
methods: { methods: {
...@@ -159,7 +158,7 @@ ...@@ -159,7 +158,7 @@
}) })
} else { } else {
this.$u.route({url: "pages/login/index"}) this.$u.route({url: "pages/login/index"})
} }
}, },
handleClickName() { handleClickName() {
if(this.vuex_token && this.settled) { if(this.vuex_token && this.settled) {
...@@ -169,20 +168,27 @@ ...@@ -169,20 +168,27 @@
}, },
handleClickTel() { handleClickTel() {
if(this.vuex_token && this.settled && this.mobile) { if(this.vuex_token && this.settled && this.mobile) {
this.show = true
return false return false
} }
this.$u.route({url: "pages/login/index"}) this.$u.route({url: "pages/login/index"})
}, },
async allowLogin() { logout() {
app.setUserData({}, this)
app.globalData.logout = true
},
handleSuperButton() {
this.$u.route({url: 'pages/mine/superLogin/index'})
},
async allowLogin() {
let res = await this.$u.api.allowLogin() let res = await this.$u.api.allowLogin()
console.log(res)
if (res && res.code == 200 && res.data) { if (res && res.code == 200 && res.data) {
this.showSuperButton = res.data.data this.showSuperButton = res.data.data === true
} }
}, },
handleSuperButton() { handleSuperButton() {
this.$u.route({url: 'pages/mine/superLogin/index'}) this.$u.route({url: 'pages/mine/superLogin/index'})
} }
} }
} }
...@@ -205,11 +211,11 @@ ...@@ -205,11 +211,11 @@
color: #FFFFFF; color: #FFFFFF;
font-weight: bold; font-weight: bold;
font-size: 40rpx; font-size: 40rpx;
padding-left: 30rpx; padding-left: 30rpx;
} }
.mine-content { .mine-content {
position: relative; position: relative;
.header-view { .header-view {
padding: 30rpx 30rpx 80rpx 30rpx; padding: 30rpx 30rpx 80rpx 30rpx;
display: flex; display: flex;
...@@ -220,8 +226,8 @@ ...@@ -220,8 +226,8 @@
height: 144rpx; height: 144rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
border-radius: 72rpx; border-radius: 72rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
...@@ -259,9 +265,9 @@ ...@@ -259,9 +265,9 @@
margin-left: 6rpx; margin-left: 6rpx;
} }
} }
} }
.super-button { .super-button {
margin-left: 20rpx; margin-left: 20rpx;
} }
} }
...@@ -292,4 +298,7 @@ ...@@ -292,4 +298,7 @@
} }
} }
</style> .logout {
padding: 20rpx;
}
</style>
...@@ -81,7 +81,12 @@ export default { ...@@ -81,7 +81,12 @@ export default {
title: '授权中..', title: '授权中..',
mask: true mask: true
}); });
that.authLogin() if (getApp().globalData.logout) {
uni.hideLoading()
that.setLoginStatus()
} else {
that.authLogin()
}
}, },
fail: function (res) { fail: function (res) {
uni.showModal({ uni.showModal({
...@@ -112,7 +117,7 @@ export default { ...@@ -112,7 +117,7 @@ export default {
}).then(res => { }).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res && res.code == 200 && res.data && res.data.token) { if (res && res.code == 200 && res.data && res.data.token) {
that.setUserData(res.data) app.setUserData(res.data, that)
that.goBackPage() that.goBackPage()
} else { } else {
that.setLoginStatus() that.setLoginStatus()
...@@ -145,7 +150,8 @@ export default { ...@@ -145,7 +150,8 @@ export default {
}).then(res => { }).then(res => {
uni.hideLoading() uni.hideLoading()
if (res) { if (res) {
that.setUserData(res.data) app.setUserData(res.data, that)
app.getBaseInfo(that)
that.goBackPage() that.goBackPage()
} else { } else {
uni.showToast({ uni.showToast({
...@@ -198,26 +204,8 @@ export default { ...@@ -198,26 +204,8 @@ export default {
} }
}, },
setUserData(userInfo) {
if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息
this.$u.vuex('vuex_token',userInfo.token);
this.$u.vuex('vuex_user', userInfo);
this.$u.vuex('vuex_wx_uid', userInfo.wxopenid);
app.track('auth_login', {
auth_token: userInfo.token,
auth_user: userInfo,
auth_wx_uid: userInfo.wxopenid
});
} else {
this.$u.vuex('vuex_token', '');
this.$u.vuex('vuex_user', null);
this.$u.vuex('vuex_wx_uid', '');
}
this.$u.vuex('vuex_settled', null);
},
setLoginStatus(authed = true) { setLoginStatus(authed = true) {
getApp().globalData.logout = false
if (authed) { if (authed) {
this.needAuth = false this.needAuth = false
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
......
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