Commit e4e6beef authored by Facius's avatar Facius

feat: 登录改造

parent 6df338bc
Pipeline #6606 canceled with stages
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
<script> <script>
import { getLatestVersionNumber } from '@/api/common/index.js'; import { getLatestVersionNumber } from '@/api/common/index.js';
import { version } from '@/utils/config.js'; import { version } from '@/utils/config.js';
import { checkToken } from '@/utils/common.js';
import {
platform,
} from '@/utils/platform'
export default { export default {
onLaunch: function() { onLaunch: function() {
// setToken("eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1bmlvbklkIjoib1gtVEs2VmVTWmNVbUx0cWhodk15NU1mYk9IMCIsIm9wZW5JZCI6Im9aZk5VNUVhSEF3bGdrbm8yQno3Y1Q0X0JRVUUiLCJuYW1lIjoi6Ze7562gIiwibW9iaWxlIjoiMTM0MjM4MzExOTEiLCJ0b2tlbl90eXBlIjoidG9rZW4iLCJ1c2VyaWQiOiIxNTUyNDg2NzEyMzY4NjkzMjQ4IiwiYWNjb3VudCI6IjEzNDIzODMxMTkxIiwiaWF0IjoxNjYwNzA4MzYyLCJuYmYiOjE2NjA3MDgzNjIsImV4cCI6MTY2MjAwNDM2Mn0.9hBVwqmYDxL4Q0S05JXQqteOWI9kda_UXxX5-eNO1LY") // setToken("eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1bmlvbklkIjoib1gtVEs2VmVTWmNVbUx0cWhodk15NU1mYk9IMCIsIm9wZW5JZCI6Im9aZk5VNUVhSEF3bGdrbm8yQno3Y1Q0X0JRVUUiLCJuYW1lIjoi6Ze7562gIiwibW9iaWxlIjoiMTM0MjM4MzExOTEiLCJ0b2tlbl90eXBlIjoidG9rZW4iLCJ1c2VyaWQiOiIxNTUyNDg2NzEyMzY4NjkzMjQ4IiwiYWNjb3VudCI6IjEzNDIzODMxMTkxIiwiaWF0IjoxNjYwNzA4MzYyLCJuYmYiOjE2NjA3MDgzNjIsImV4cCI6MTY2MjAwNDM2Mn0.9hBVwqmYDxL4Q0S05JXQqteOWI9kda_UXxX5-eNO1LY")
...@@ -23,11 +26,25 @@ import { version } from '@/utils/config.js'; ...@@ -23,11 +26,25 @@ import { version } from '@/utils/config.js';
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')
this.autoLogin()
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
}, },
methods:{ methods:{
autoLogin() {
if (platform != '1' || checkToken()) {
return
}
this.$store
.dispatch('Auto_login')
.then(res => {
console.log('登录成功', res);
})
.catch(err => {
console.log('登录失败', err);
});
},
/* 版本更新 */ /* 版本更新 */
updateApp() { updateApp() {
if (uni.canIUse('getUpdateManager')) { if (uni.canIUse('getUpdateManager')) {
......
...@@ -2,7 +2,7 @@ import request from "@/utils/request.js" ...@@ -2,7 +2,7 @@ import request from "@/utils/request.js"
export function userAuthLogin(data) { export function userAuthLogin(data) {
return request({ return request({
url: `/app/unify/authorization`, url: `/app/unify/v2/authorization`,
method: 'POST', method: 'POST',
data, data,
noLoading:true noLoading:true
...@@ -16,3 +16,11 @@ export function sendCode(data) { ...@@ -16,3 +16,11 @@ export function sendCode(data) {
data data
}) })
} }
export function userBindMobile(data) {
return request({
url: `/app/unify/v2/bindMobile`,
method: 'POST',
data,
noLoading:true
})
}
<template>
<button :style="[customStyle]" v-if="userInfo.id && !userInfo.mobile" class="bind-phone-button" :open-type="platform == '1' ? 'getPhoneNumber' : ''"
@getphonenumber="handleClickBindPhone" @click.stop="$u.throttle(handleToBind, 500)">
<view v-if="$slots.content" class="slot-view">
<slot name="content" />
</view>
<view v-else class="bind-phone-view" hover-class="u-hover-class">
<view class="left-view">若您是会员,请绑定手机号恢复权限</view>
<view class="right-view">
<view class="bind-view">立即绑定</view>
<u-icon name="arrow-right" color="#3383FE" :size="28" />
</view>
</view>
</button>
</template>
<script>
import { mapGetters } from 'vuex';
import { wxBindPhone } from '@/utils/bind-mobile.js';
export default {
props: {
customStyle: {
type: Object,
default () {
return {
'background-color': '#ffffff',
padding: '0 28rpx'
}
}
}
},
data () {
return {
show: false,
}
},
computed: {
...mapGetters(['platform', 'userInfo']),
},
watch: {
},
methods: {
handleClickBindPhone (e) {
wxBindPhone(e, () => {
this.getUserInfo();
});
},
handleToBind () {
console.log('-------------', this.platform)
if (this.platform == '4' || this.platform == '3' || this.platform == 'alipay') {
uni.navigateTo({
url: '/pages/login/binding-phone/binding-phone?type=phone'
});
}
},
async getUserInfo () {
try {
await this.$store.dispatch('Get_UserInfo');
this.$emit('bind', this.userInfo)
} catch (e) {
//TODO handle the exception
}
},
},
}
</script>
<style lang="scss" scoped>
.bind-phone-button::after {
border: none;
}
.bind-phone-button {
background-color: #ffffff;
.bind-phone-view {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
border-radius: 16rpx;
min-height: 72rpx;
height: 100%;
.left-view {
font-weight: bold;
color: #333333;
}
.right-view {
color: #3383fe;
display: flex;
align-items: center;
.bind-view {
margin-right: 8rpx;
}
.arrow-right {}
}
}
}
</style>
<template>
<u-popup v-model="show" safe-area-inset-bottom border-radius="24" mode="bottom" :closeable="true" @close="handleClose"
:zoom="false">
<view class="pop-bind-phone">
<view class="title-view">绑定提示</view>
<view class="content-view">享受完整会员权益,请您先绑定手机号码</view>
<button class="bind-phone" open-type="getPhoneNumber" @getphonenumber="handleClickBindPhone">
<view class="buttons-view">
<view class="left-view">
<image class="image-view" :src="imageUrl"></image>
</view>
<view class="right-view">绑定手机号</view>
</view>
</button>
</view>
</u-popup>
</template>
<script>
import { wxBindPhone } from '@/utils/bind-mobile.js';
export default {
props: {
visible: {
type: Boolean,
default: false,
},
},
data () {
return {
show: false,
}
},
watch: {
visible (val) {
this.show = val
},
},
computed: {
baseUrl(){
return process.uniEnv.qn_base_url
},
imageUrl(){
return this.baseUrl+'weixinbangding@3x.png'
},
},
created () { },
methods: {
changeVisibleValue (val) {
this.show = val
this.$emit('update:visible', val)
},
handleClickBindPhone (e) {
wxBindPhone(e, () => {
this.getUserInfo();
this.changeVisibleValue(false)
});
},
handleClose () {
this.changeVisibleValue(false)
},
async getUserInfo () {
try {
await this.$store.dispatch('Get_UserInfo');
this.$emit('bind', this.userInfo)
} catch (e) {
//TODO handle the exception
}
},
},
}
</script>
<style lang="scss" scoped>
.pop-bind-phone {
text-align: center;
padding: 24rpx 32rpx;
background-image: linear-gradient(to bottom, #E9F3FF 0%, #ffffff 50%);
.title-view {
color: #9EA5BB;
font-weight: bold;
font-size: 40rpx;
margin: 32rpx 0 24rpx 0;
}
.content-view {
display: flex;
align-items: center;
justify-content: center;
margin-top: 32rpx;
margin-bottom: 48rpx;
color: #333333;
}
.bind-phone {
background-color: #00C802;
box-shadow: 0 12rpx 24rpx rgba(0, 200, 2, 0.32);
height: 104rpx;
width: 520rpx;
border-radius: 52rpx;
margin-bottom: 32rpx;
padding: 0;
.buttons-view {
display: flex;
justify-content: center;
align-items: center;
height: 104rpx;
.left-view {
margin-right: 16rpx;
display: flex;
justify-content: center;
align-items: center;
.image-view {
width: 38rpx;
height: 32rpx;
}
}
.right-view {
color: #FFFFFF;
font-size: 32rpx;
font-weight: bold;
}
}
}
}
</style>
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
</view> </view>
<slot v-else /> <slot v-else />
</view> </view>
<view v-if="isShare" class="bottom-tip">
<view class="tip-view">{{ bottomTip }}</view>
</view>
<view class="buttons-view"> <view class="buttons-view">
<view v-if="showCancel" class="left-view"> <view v-if="showCancel" class="left-view">
<u-button <u-button
...@@ -61,11 +64,8 @@ ...@@ -61,11 +64,8 @@
</u-button> </u-button>
</view> </view>
</view> </view>
<view v-if="isShare" class="bottom-tip">
<view class="tip-view">{{ bottomTip }}</view>
</view>
<view <view
v-else-if="bottomTip" v-if="bottomTip && !isShare"
:class="['bottom-tip', { select: select }]" :class="['bottom-tip', { select: select }]"
:hover-class="isSelect ? 'u-hover-class' : ''" :hover-class="isSelect ? 'u-hover-class' : ''"
@click="$u.throttle(handleSelect, 500)" @click="$u.throttle(handleSelect, 500)"
...@@ -80,12 +80,18 @@ ...@@ -80,12 +80,18 @@
</view> </view>
<view class="tip-view">{{ bottomTip }}</view> <view class="tip-view">{{ bottomTip }}</view>
</view> </view>
<BindPhone :customStyle="{'background-color': '#f4fffc',margin: '0 -32rpx -24rpx -24rpx',height: '104rpx'}" @bind="changeStatusDisplay"/>
</view> </view>
</u-popup> </u-popup>
</template> </template>
<script> <script>
import BindPhone from '@/components/bind-phone';
export default { export default {
components: {
BindPhone
},
props: { props: {
title: { title: {
type: String, type: String,
...@@ -213,6 +219,9 @@ export default { ...@@ -213,6 +219,9 @@ export default {
handleSelect() { handleSelect() {
this.select = !this.select this.select = !this.select
}, },
changeStatusDisplay() {
this.changeVisibleValue(false)
}
}, },
} }
</script> </script>
...@@ -279,6 +288,7 @@ export default { ...@@ -279,6 +288,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 28rpx; font-size: 28rpx;
margin-bottom: 24rpx;
&.select { &.select {
margin-top: 16rpx; margin-top: 16rpx;
} }
......
...@@ -95,6 +95,7 @@ export default { ...@@ -95,6 +95,7 @@ export default {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 32upx;;
.user-profile { .user-profile {
width: 160upx; width: 160upx;
height: 160upx; height: 160upx;
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.content{ .content{
margin-top: 56upx; margin-top: 24upx;
.my-package{ .my-package{
width: 100%; width: 100%;
height: 112upx; height: 112upx;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<view class="content"> <view class="content">
<view class="mine"> <view class="mine">
<user-header :vipStatus="vipStatus" :vipStatusText="vipStatusText"></user-header> <user-header :vipStatus="vipStatus" :vipStatusText="vipStatusText"></user-header>
<BindPhone @bind="changeStatusDisplay"/>
<!-- 购买会员入口 --> <!-- 购买会员入口 -->
<vip-center v-if="showPayEntrance"></vip-center> <vip-center v-if="showPayEntrance"></vip-center>
<view v-else class="invite-view" hover-class="u-hover-class" @click="$u.throttle(handleClickInvite, 500)"> <view v-else class="invite-view" hover-class="u-hover-class" @click="$u.throttle(handleClickInvite, 500)">
...@@ -21,6 +22,7 @@ import VipCenter from './components/vip-center.vue'; ...@@ -21,6 +22,7 @@ import VipCenter from './components/vip-center.vue';
import MyPackage from './components/my-package.vue'; import MyPackage from './components/my-package.vue';
import UserTotal from './components/user-total.vue'; import UserTotal from './components/user-total.vue';
import MidPopup from '@/components/mid-popup/mid-popup.vue'; import MidPopup from '@/components/mid-popup/mid-popup.vue';
import BindPhone from '@/components/bind-phone';
import { usedOptions } from '@/utils/options/mine/index.js'; import { usedOptions } from '@/utils/options/mine/index.js';
import { checkToken } from '@/utils/common.js'; import { checkToken } from '@/utils/common.js';
import { tabbar } from '@/utils/settings.js'; import { tabbar } from '@/utils/settings.js';
...@@ -36,7 +38,8 @@ export default { ...@@ -36,7 +38,8 @@ export default {
UserHeader, UserHeader,
VipCenter, VipCenter,
MyPackage, MyPackage,
UserTotal UserTotal,
BindPhone
}, },
data() { data() {
return { return {
...@@ -312,5 +315,35 @@ export default { ...@@ -312,5 +315,35 @@ export default {
border-radius: 8upx; border-radius: 8upx;
overflow: hidden; overflow: hidden;
} }
.bind-phone-button {
background-color: transparent;
padding: 0;
}
.bind-phone-view {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
background-color: #f4f9ff;
border-radius: 16rpx;
padding: 0 32rpx;
margin: 0 24rpx;
height: 72rpx;
.left-view {
font-weight: bold;
color: #333333;
}
.right-view {
color: #3383fe;
display: flex;
align-items: center;
.bind-view {
margin-right: 8rpx;
}
.arrow-right {
}
}
}
} }
</style> </style>
<template> <template>
<view class="binding-phone-view"> <view class="binding-phone-view">
<view class="title-view">绑定手机</view> <view class="title-view">绑定手机</view>
<view class="text-view">首次登录的用户需绑定手机</view> <view class="text-view">{{ isPhone ? '绑定手机,多平台登录' : '首次登录的用户需绑定手机' }}</view>
<view class="phone-view"> <view class="phone-view">
<view class="left-view">+86</view> <view class="left-view">+86</view>
<view class="middle-view"></view> <view class="middle-view"></view>
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
<script> <script>
import { sendCode } from '@/api/login/index.js'; import { sendCode } from '@/api/login/index.js';
import { bindPhone } from '@/utils/bind-mobile.js';
export default { export default {
data() { data() {
return { return {
...@@ -42,12 +44,16 @@ export default { ...@@ -42,12 +44,16 @@ export default {
height: '104rpx', height: '104rpx',
backgroundColor: '#02A074', backgroundColor: '#02A074',
color: 'transparent' color: 'transparent'
} },
type: 'login'
}; };
}, },
computed: { computed: {
disabled() { disabled() {
return this.code && this.phone ? false : true; return this.code && this.phone ? false : true;
},
isPhone() {
return this.type == 'phone';
} }
}, },
onReady() { onReady() {
...@@ -55,7 +61,9 @@ export default { ...@@ -55,7 +61,9 @@ export default {
}, },
onLoad(options) { onLoad(options) {
console.log('-----options----', options); console.log('-----options----', options);
if (options && options.type) {
this.type = options.type;
}
if (options) { if (options) {
let { unionId } = options; let { unionId } = options;
if (unionId) { if (unionId) {
...@@ -142,7 +150,71 @@ export default { ...@@ -142,7 +150,71 @@ export default {
} }
}, },
handleClickSave() { handleClickSave() {
this.signup(); var reg = /^[1][3456789][0-9]{9}$/;
if (!reg.test(this.phone)) {
uni.showToast({
icon: 'none',
title: '请输入正确的手机号'
});
return false;
}
if (this.isPhone) {
this.handleBindPhone();
} else {
this.onAppLogin();
}
},
handleBindPhone() {
bindPhone({
password: this.code,
account: this.phone
})
.then(res => {
console.log('------绑定手机接口:-------', res);
uni.showToast({
title: '绑定成功',
icon: 'none'
});
this.getUserInfo();
})
.catch(err => {
console.log('------绑定手机接口失败:-------', err);
uni.showToast({
title: '绑定手机失败',
icon: 'none'
});
});
},
async getUserInfo () {
try {
await this.$store.dispatch('Get_UserInfo');
this.goBackPage();
} catch (e) {
//TODO handle the exception
}
},
goBackPage() {
console.log('---------绑定成功跳转------');
let pages = getCurrentPages();
let len = pages.length;
if (len && len - 1) {
let prevPage = pages[len - 1]; //上一个页面
if (prevPage && prevPage.$vm) {
prevPage.$vm.isRefresh = true;
}
uni.navigateBack({
delta: 1
});
} else {
uni.switchTab({
url: '/pages/index/index'
});
}
}, },
signup() { signup() {
this.loading = true; this.loading = true;
...@@ -228,7 +300,7 @@ export default { ...@@ -228,7 +300,7 @@ export default {
}); });
} else if (data.code === -1) { } else if (data.code === -1) {
uni.redirectTo({ uni.redirectTo({
url: '/pages/login/binding-phone' url: '/pages/login/binding-phone/binding-phone'
}); });
} else { } else {
uni.showToast({ uni.showToast({
......
...@@ -238,7 +238,7 @@ export default { ...@@ -238,7 +238,7 @@ export default {
} else { } else {
// 临时解决方案 // 临时解决方案
that.$u.route({ that.$u.route({
url: 'pages/login/binding-phone', url: 'pages/login/binding-phone/binding-phone',
params: { params: {
encryptedData: that.params.encryptedData, encryptedData: that.params.encryptedData,
iv: that.params.iv iv: that.params.iv
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
<view class="auth-tip">我们需要取得您的手机号,以关联您的扳手记账账号</view> <view class="auth-tip">我们需要取得您的手机号,以关联您的扳手记账账号</view>
<view class="quick-center-buttons"> <view class="quick-center-buttons">
<button class="login-refuse" @tap="refuseAuth">拒绝</button> <button class="login-refuse" @tap="refuseAuth">拒绝</button>
<button class="login-refuse login-accept" open-type="getPhoneNumber" lang="zh_CN" @getphonenumber="signup">立即登录</button> <!-- <button class="login-refuse login-accept" open-type="getPhoneNumber" lang="zh_CN" @getphonenumber="signup">立即登录</button> -->
<button class="login-refuse login-accept" lang="zh_CN" @click="newLoginup">立即登录</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -224,7 +225,51 @@ export default { ...@@ -224,7 +225,51 @@ export default {
} }
}); });
}, },
newLoginup() {
uni.getUserProfile({
desc: '用于授权登录',
success: res => {
console.log('授权成功', res);
const userInfo = {
nickname: res.userInfo.nickName,
avatar: res.userInfo.avatarUrl
};
getApp().globalData.wxUserInfo = userInfo;
console.log('授权成功', JSON.stringify(userInfo));
uni.showLoading({
title: '授权中..',
mask: true
});
console.log('--------------', res);
this.$store
.dispatch('Auto_login',userInfo)
.then(res => {
console.log('登录成功', res);
setTimeout(() => {
if (this.returnUrl) { // 需要跳转到特定页面
var isSwitchTab = this.returnUrl.indexOf('pages/index/') != -1
this.$u.route({
url: this.returnUrl,
type: isSwitchTab ? 'switchTab' : 'redirectTo',
})
}else {
uni.switchTab({
url: '/pages/index/index'
});
}
}, 1000);
})
.catch(err => {
showToast('登录失败');
console.log('登录失败', err);
});
},
fail: function(res) {
console.log('授权失败', res);
return;
}
});
},
signup(e) { signup(e) {
log.setFilterMsg('getPhoneNumber'); log.setFilterMsg('getPhoneNumber');
let self = this; let self = this;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
<u-mask :show="messageFlag"></u-mask> <u-mask :show="messageFlag"></u-mask>
<!-- <view class="mask" v-if="messageFlag"></view> --> <!-- <view class="mask" v-if="messageFlag"></view> -->
<!-- 底部 --> <!-- 底部 -->
<PopBindPhone :visible.sync="showBind" @confirm="handleClickConfirm" />
</view> </view>
</template> </template>
...@@ -54,8 +55,13 @@ const log = require('@/utils/log.js'); ...@@ -54,8 +55,13 @@ const log = require('@/utils/log.js');
import { mineBaseUrl } from '@/utils/config.js'; import { mineBaseUrl } from '@/utils/config.js';
import { getList, checkCode, useCode } from '@/api/mine/cd-key.js'; import { getList, checkCode, useCode } from '@/api/mine/cd-key.js';
import PopBindPhone from '@/components/pop-bind-phone/index.vue';
import { mapGetters } from 'vuex';
export default { export default {
components: {
PopBindPhone
},
data() { data() {
return { return {
cdKey: '', cdKey: '',
...@@ -140,10 +146,13 @@ export default { ...@@ -140,10 +146,13 @@ export default {
day: 7, day: 7,
endDate: '', endDate: '',
uid: '', uid: '',
list: [] list: [],
showBind: false
}; };
}, },
computed: { computed: {
...mapGetters(['userInfo']),
noList() { noList() {
return !this.list || this.list.length == 0; return !this.list || this.list.length == 0;
} }
...@@ -207,6 +216,25 @@ export default { ...@@ -207,6 +216,25 @@ export default {
submitKey() { submitKey() {
log.setFilterMsg(this.uid); log.setFilterMsg(this.uid);
if (!this.userInfo.mobile) {
if (uni.$u.platform == '4' || uni.$u.platform == '3'|| uni.$u.platform == 'alipay') {
this.$refs.uToast.show({
title: '请绑定手机号',
type: 'warning',
duration: 1500,
callback: () => {
uni.navigateTo({
url: '/pages/login/binding-phone/binding-phone?type=phone'
});
}
});
} else {
this.showBind = true
}
return
}
if (!this.cdKey) { if (!this.cdKey) {
uni.showToast({ uni.showToast({
title: '请输入兑换码', title: '请输入兑换码',
...@@ -347,6 +375,9 @@ export default { ...@@ -347,6 +375,9 @@ export default {
animationType:'pop-in', animationType:'pop-in',
url: '../mine/service/service' url: '../mine/service/service'
}); });
},
handleClickConfirm() {
// this.userInfo = this.$store.getters.user_info;
} }
} }
}; };
......
...@@ -93,19 +93,22 @@ ...@@ -93,19 +93,22 @@
</view> </view>
<view v-if="!hidePay" class="bottom-view"><button class="buy-button" @tap="$u.throttle(handleClickBuy, 500)">立即购买</button></view> <view v-if="!hidePay" class="bottom-view"><button class="buy-button" @tap="$u.throttle(handleClickBuy, 500)">立即购买</button></view>
<BottomPay :visible.sync="showPayBottom" @buy="handleClickBottom" /> <BottomPay :visible.sync="showPayBottom" @buy="handleClickBottom" />
<PopBindPhone :visible.sync="showBind" @bind="handleClickConfirm" />
</view> </view>
</template> </template>
<script> <script>
import log from '@/utils/log.js'; import log from '@/utils/log.js';
import BottomPay from '@/components/bottom-pay/index.vue'; import BottomPay from '@/components/bottom-pay/index.vue';
import PopBindPhone from '@/components/pop-bind-phone/index.vue';
import { mineBaseUrl } from '@/utils/config.js'; import { mineBaseUrl } from '@/utils/config.js';
import { introOptions } from '@/utils/options/mine/pay.js'; import { introOptions } from '@/utils/options/mine/pay.js';
import { getGoodsList, getOrderInfo, systemExchange } from '@/api/mine/pay.js'; import { getGoodsList, getOrderInfo, systemExchange } from '@/api/mine/pay.js';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
export default { export default {
components: { components: {
BottomPay BottomPay,
PopBindPhone
}, },
data() { data() {
return { return {
...@@ -118,7 +121,8 @@ export default { ...@@ -118,7 +121,8 @@ export default {
showPayBottom: false, showPayBottom: false,
current: 0, current: 0,
iap: '', iap: '',
showCDKey: false showCDKey: false,
showBind: false
}; };
}, },
computed: { computed: {
...@@ -212,6 +216,24 @@ export default { ...@@ -212,6 +216,24 @@ export default {
}, },
handleClickBuy() { handleClickBuy() {
if (!this.userInfo.mobile) {
if (uni.$u.platform == '4' || uni.$u.platform == '3'|| uni.$u.platform == 'alipay') {
this.$refs.uToast.show({
title: '请绑定手机号',
type: 'warning',
duration: 1500,
callback: () => {
uni.navigateTo({
url: '/pages/login/binding-phone/binding-phone?type=phone'
});
}
});
} else {
this.showBind = true;
}
return;
}
if (this.platform == '4') { if (this.platform == '4') {
if (this.isIOS) { if (this.isIOS) {
this.getProvider(); this.getProvider();
...@@ -707,6 +729,9 @@ export default { ...@@ -707,6 +729,9 @@ export default {
animationType:'pop-in', animationType:'pop-in',
url: '/pages/mine/cd-key/cd-key' url: '/pages/mine/cd-key/cd-key'
}); });
},
handleClickConfirm() {
// this.userInfo = this.$store.getters.user_info;
} }
} }
}; };
......
...@@ -6,9 +6,24 @@ ...@@ -6,9 +6,24 @@
<u-avatar slot="right-icon" class="avatar-iamge" :src="userInfo.avatar ? userInfo.avatar : avatar" size="120"></u-avatar> <u-avatar slot="right-icon" class="avatar-iamge" :src="userInfo.avatar ? userInfo.avatar : avatar" size="120"></u-avatar>
<u-icon slot="right-icon" color="#D8D8D8" size="24" name="play-right-fill"></u-icon> <u-icon slot="right-icon" color="#D8D8D8" size="24" name="play-right-fill"></u-icon>
</u-cell-item> </u-cell-item>
<u-cell-item title="昵称" :value="userInfo.nickname" @click="handleClickChangeName" :border-bottom="false" :title-style="titleStyle" :value-style="valueStyle" :arrow="false"> <u-cell-item title="昵称" :value="userInfo.nickname" @click="handleClickChangeName" :title-style="titleStyle" :value-style="valueStyle" :arrow="false">
<u-icon slot="right-icon" color="#D8D8D8" size="24" name="play-right-fill"></u-icon> <u-icon slot="right-icon" color="#D8D8D8" size="24" name="play-right-fill"></u-icon>
</u-cell-item> </u-cell-item>
<u-cell-item title="手机号" :border-bottom="false" :title-style="titleStyle" :value-style="valueStyle" :arrow="false">
<!-- <u-icon slot="right-icon" color="#D8D8D8" size="24" name="play-right-fill"></u-icon> -->
<view slot="right-icon">
<BindPhone v-if="!userInfo.mobile" :customStyle="{padding: '0'}" @bind="handleClickConfirm">
<view slot="content" class="bind-phone-view" hover-class="u-hover-class">
<view class="bind-view">立即绑定</view>
<u-icon name="play-right-fill" color="#D8D8D8" :size="24" />
</view>
</BindPhone>
<view v-else class="bind-phone-button">
<view class="mobile-view">{{userInfo.mobile}}</view>
<u-icon name="play-right-fill" color="#D8D8D8" :size="24" />
</view>
</view>
</u-cell-item>
</u-cell-group> </u-cell-group>
</view> </view>
<view class="push-setting-view" v-if="platform == '4'"> <view class="push-setting-view" v-if="platform == '4'">
...@@ -34,6 +49,7 @@ ...@@ -34,6 +49,7 @@
</template> </template>
<script> <script>
import BindPhone from '@/components/bind-phone';
import upload from '@/utils/upload'; import upload from '@/utils/upload';
import { mineBaseUrl,UPLOAD_FILE_HOST } from '@/utils/config.js'; import { mineBaseUrl,UPLOAD_FILE_HOST } from '@/utils/config.js';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
...@@ -41,6 +57,9 @@ import { getQiNiuToken } from '@/api/common/index.js' ...@@ -41,6 +57,9 @@ import { getQiNiuToken } from '@/api/common/index.js'
import { update } from '@/api/user/index.js'; import { update } from '@/api/user/index.js';
import permision from "@/js_sdk/wa-permission/permission.js" import permision from "@/js_sdk/wa-permission/permission.js"
export default { export default {
components: {
BindPhone,
},
data() { data() {
return { return {
form:{ form:{
...@@ -166,6 +185,9 @@ export default { ...@@ -166,6 +185,9 @@ export default {
} }
} }
}); });
},
handleClickConfirm() {
} }
} }
}; };
...@@ -184,6 +206,28 @@ export default { ...@@ -184,6 +206,28 @@ export default {
background-color: #f6f7fa; background-color: #f6f7fa;
border-radius: 50%; border-radius: 50%;
} }
.bind-phone-button {
background-color: transparent;
padding: 0;
display: flex;
justify-content: flex-end;
align-items: center;
border: none;
}
.bind-phone-view {
display: flex;
justify-content: flex-end;
align-items: center;
font-size: 28rpx;
height: 54rpx;
.bind-view {
margin-right: 16rpx;
color: #8d8d8d;
}
}
.push-setting-view { .push-setting-view {
background-color: #ffffff; background-color: #ffffff;
margin-top: 24rpx; margin-top: 24rpx;
......
...@@ -166,8 +166,8 @@ const actions = { ...@@ -166,8 +166,8 @@ const actions = {
break; break;
} }
try { try {
let code="" let code = ''
if(params&&!params.account){ if(!params || params&&!params.account){
code=await wxLogin() code=await wxLogin()
} }
let info = { let info = {
......
import {
setUserinfo,
getUserinfo,
getChannel,
setToken
} from "@/utils/common.js"
import {
userBindMobile,
} from "@/api/login/index.js";
export function bindPhone(data) {
return new Promise(function(resolve, reject) {
var channel = getChannel()
userBindMobile({
...data,
loginChannel: channel.loginChannel, // 登录渠道
authType: channel.authType, // 授权渠道
}).then((res)=> {
if (res && res.data) {
setToken(res.data.token)
resolve(res);
} else {
reject(res);
}
}).catch((err)=> {
reject(err);
})
});
}
export function wxBindPhone(e, block = ()=>{}) {
console.log('-------e--------', e);
if (e.detail.errMsg.indexOf('user deny') > -1) {
uni.showModal({
title: '提示',
showCancel: false,
content: '未授权不能完成该操作',
success: function(res) {}
});
} else {
console.log('用户同意', e.detail);
var detail = e.detail
// 低版本没有 detail.code
if (detail && (detail.code || detail.encryptedData)) {
wxLogin()
.then(result => {
console.log('绑定手机之后微信登录成功', result);
var channel = getChannel()
userBindMobile({
encryptedData: detail.encryptedData,
iv: detail.iv,
code: result.code,
mobileCode: detail.code,
authType: 'WX',
loginChannel: channel.loginChannel, // 登录渠道
}).then((res)=> {
console.log('------绑定手机接口:-------', res)
if (res.data) {
setToken(res.data.token)
block();
} else {
uni.showToast({
title: '绑定手机号失败',
icon: 'none'
});
}
}).catch((err)=> {
uni.showToast({
title: detail.errMsg || '获取手机号code失败',
icon: 'none'
});
})
})
} else {
uni.showModal({
title: '提示',
showCancel: false,
content: '获取手机信息失败',
success: function(res) {}
});
}
}
}
function wxLogin() {
return new Promise(function(resolve, reject) {
uni.login({
success: (res) => {
console.log('-----wxLogin success-----', res)
if (!res.code) {
uni.hideLoading();
uni.showModal({
content: res.errMsg,
showCancel: false
});
}
resolve(res);
},
fail(e) {
console.log('-----wxLogin fail-----', e)
uni.hideLoading();
uni.showModal({
content: '登录失败',
showCancel: false
});
reject();
}
});
});
}
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