刘翔宇-旅管家 3 years ago
parent 325bb1a363
commit 155d3b4b0e

@ -0,0 +1,78 @@
<template>
<view>
<u-popup v-model="showUser" mode="center" closeable="true">
<view class="userBox" style="padding: 20rpx;">
<view class="userInfoContent" style="padding: 80rpx;font-size: 28rpx;">
<text class="">为了更好的提供服务请授权您的微信昵称</text>
</view>
<view class="userBoxBottom">
<button class="userBoxBottomCol btnuserBoxBottomCol" @click="getUserProfile"
style="border-radius:0;flex:1;">授权</button>
<button class="userBoxBottomCol" @click="touserInfoClose"
style="border-radius:0;flex:1;">关闭</button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: "wechat-auth",
data() {
return {
};
},
methods(){
touserInfoClose() {
this.showUser = false;
},
getUserProfile() {
var that = this;
weixin.getUserProfile((res) => {
weixin.request({
api: '/api/member/update-wechat-info',
method: 'POST',
data: {
nickname: res.nickName,
avatar: res.avatarUrl
},
utilSuccess: function(r) {
console.log(r)
if (r.status == 1) {
weixin.getOpenidInfo(openidInfo => {}, true)
} else {
uni.showToast({
title: r.data.msg,
duration: 2000,
icon: 'none'
})
}
}
})
})
}
}
}
</script>
<style lang="scss">
.userBoxBottom {
.userBoxBottomCol {
font-size: 28rpx;
}
.btnuserBoxBottomCol {
background: linear-gradient(90deg, #FF7E95 0%, #FF447B 100%);
border-radius: 36rpx;
font-size: 28rpx;
font-weight: 500;
text-align: center;
line-height: 72rpx;
color: #fff;
}
}
</style>

@ -138,7 +138,7 @@
<picker :value="rindex" @change="bindRegionChange" :range="arrRegion">
<view class="uni-input">{{arrRegion[rindex]}}</view>
</picker>
<input type="text" v-if="rindex!=0" v-model="info.address" style="margin-top: 10rpx;"
<input type="text" v-if="rindex!=0" v-model="form.address" style="margin-top: 10rpx;"
placeholder="请输入具体街道/地址">
</view>
</view>
@ -194,6 +194,21 @@
<button class="userBoxBottomCol btnuserBoxBottomCol" style="border-radius:0;flex:1;"
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权手机号</button>
</view>
<view class="userBoxBottomPass" v-if="showPass" @click="toPassGetPhone"> >> </view>
</view>
</u-popup>
<u-popup v-model="showUser" mode="center" closeable="true">
<view class="userBox" style="padding: 20rpx;">
<view class="userInfoContent" style="padding: 80rpx;font-size: 28rpx;">
<text class="">为了更好的提供服务请授权您的微信昵称</text>
</view>
<view class="userBoxBottom">
<button class="userBoxBottomCol btnuserBoxBottomCol" @click="getUserProfile"
style="border-radius:0;flex:1;">授权</button>
<button class="userBoxBottomCol" @click="touserInfoClose"
style="border-radius:0;flex:1;">关闭</button>
</view>
</view>
</u-popup>
@ -216,6 +231,7 @@
})
return {
id: "",
showPass: false,
info: {},
dataList: [],
form: {
@ -256,6 +272,7 @@
poster: "",
showUser: false,
showPhone: false,
}
},
onShareAppMessage() {
@ -267,20 +284,26 @@
}
},
onShow() {
var that = this;
weixin.getOpenidInfo(info => {
that.user_info = info.user_info;
that.openid = that.user_info.openid;
that.form.member_name = that.user_info.name || that.user_info.wechat_nickname;
that.form.phone = that.user_info.phone;
}, true);
if (weixin.isNull(info.user_info.wechat_nickname) || weixin.isNull(info.user_info.avatar)) {
that.showUser = true;
} else {
that.form.member_name = info.user_info.wechat_nickname;
}
that.loadInfo();
that.loadPage();
}, true);
this.loadInfo();
this.loadPage();
},
onLoad(options) {
var that = this;
@ -307,6 +330,45 @@
},
methods: {
toPassGetPhone() {
this.showPhone = false;
this.showPop = true;
},
touserInfoClose() {
this.showUser = false;
},
getUserProfile() {
var that = this;
weixin.getUserProfile((res) => {
console.log(res)
weixin.request({
api: '/api/member/update-wechat-info',
method: 'POST',
data: {
nickname: res.nickName,
avatar: res.avatarUrl
},
utilSuccess: function(r) {
console.log(r)
if (r.status == 1) {
weixin.getOpenidInfo(openidInfo => {
that.user_info.wechat_nickname = openidInfo.user_info
.wechat_nickname;
that.user_info.avatar = openidInfo.user_info.avatar;
}, true)
that.showUser = false;
} else {
uni.showToast({
title: r.data.msg,
duration: 2000,
icon: 'none'
})
}
}
})
})
},
getPhoneNumber(e) {
let that = this;
if (e.detail.iv) {
@ -324,6 +386,7 @@
},
success: (r) => {
if (r.data.status == 1) {
that.showPass = false;
weixin.getOpenidInfo(openidInfo => {
uni.setStorageSync("userInfo", openidInfo)
that.form.phone = openidInfo.user_info.phone;
@ -334,9 +397,10 @@
duration: 2000,
icon: 'none'
})
}
that.showPhone = false;
that.showPass = true;
}
that.showPhone = false;
that.showPop = true;
}
})
@ -758,6 +822,12 @@
border: none
}
.userBoxBottomPass {
font-size: 28rpx;
text-align: center;
padding: 20rpx 0rpx;
}
.payBtn {
width: 90%;
height: 100rpx;

Loading…
Cancel
Save