刘翔宇-旅管家 3 years ago
parent 81591b4ec0
commit 325bb1a363

@ -184,16 +184,15 @@
<u-popup v-model="showUser" mode="center" closeable="true">
<u-popup v-model="showPhone" mode="center" closeable="false">
<view class="userBox" style="padding: 20rpx;">
<view class="userInfoContent" style="padding: 80rpx;font-size: 28rpx;">
<text class="">为了更好的提供服务请授权您的微信昵称</text>
<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>
<button class="userBoxBottomCol btnuserBoxBottomCol" style="border-radius:0;flex:1;"
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权手机号</button>
</view>
</view>
</u-popup>
@ -255,7 +254,8 @@
shareHeight: 500,
imgAvatar: "",
poster: "",
showUser: false
showUser: false,
showPhone: false,
}
},
onShareAppMessage() {
@ -266,15 +266,26 @@
imageUrl: this.img
}
},
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);
this.loadInfo();
this.loadPage();
},
onLoad(options) {
var that = this;
this.id = options.id;
weixin.getOpenidInfo(info => {
that.user_info = info.user_info
}, false)
this.openid = that.user_info.openid;
this.form.member_name = that.user_info.name || that.user_info.wechat_nickname;
this.form.phone = that.user_info.phone;
const scene = decodeURIComponent(options.scene);
console.log(scene)
if (!weixin.isNull(scene)) {
@ -293,13 +304,45 @@
this.loadInfo();
this.loadPage();
},
methods: {
getPhoneNumber(e) {
let that = this;
if (e.detail.iv) {
weixin.getOpenidInfo(r => {
var user_info = r.user_info;
console.log(user_info)
uni.request({
url: this.baseUrl + '/api/member/get-phone-by-openid',
method: 'POST',
data: {
sessionKey: user_info.session_key,
iv: e.detail.iv,
encryptedData: e.detail.encryptedData,
openid: user_info.wechat_openid,
},
success: (r) => {
if (r.data.status == 1) {
weixin.getOpenidInfo(openidInfo => {
uni.setStorageSync("userInfo", openidInfo)
that.form.phone = openidInfo.user_info.phone;
}, true);
} else {
uni.showToast({
title: r.data.msg,
duration: 2000,
icon: 'none'
})
}
that.showPhone = false;
that.showPop = true;
}
})
})
}
},
bindRegionChange: function(e) {
this.rindex = e.target.value;
this.form.region = this.arrRegion[e.target.value];
@ -310,34 +353,6 @@
this.form.hospital = this.arrHospital[e.target.value];
}
},
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 => {}, true)
that.showUser = false;
} else {
uni.showToast({
title: r.data.msg,
duration: 2000,
icon: 'none'
})
}
}
})
})
},
getPoster: function() {
var that = this;
uni.getImageInfo({
@ -348,9 +363,6 @@
}
});
},
touserInfoClose() {
this.showUser = false;
},
getAvatar: function() {
let userProfile = uni.getStorageSync('user_profile');
@ -567,8 +579,8 @@
toBuy() {
let user_info = weixin.getUserInfoCache();
if (weixin.isNull(user_info.user_info.wechat_nickname) || weixin.isNull(user_info.user_info.avatar)) {
this.showUser = true;
if (weixin.isNull(user_info.user_info.phone)) {
this.showPhone = true;
return false;
//this.getUserProfile();
}
@ -596,7 +608,14 @@
return false;
}
if (this.form.region == "请选择区域" || weixin.isNull(this.form.region)) {
this.alert('请选择区域')
return
}
if (this.form.hospital == "请选择建卡医院") {
this.alert('请选择建卡医院')
return
}
this.toDoBuy();
@ -609,7 +628,7 @@
data: this.form,
utilSuccess: r => {
if (parseFloat(r.data.total) == 0) {
uni.navigateTo({
uni.redirectTo({
url: '../buyMemberSuccess/buyMemberSuccess?id=' +
this.form.product_id
})
@ -633,7 +652,7 @@
let payParams = JSON.parse(res.jsApiParameters)
payParams.provider = 'wxpay'
payParams.success = result => {
uni.navigateTo({
uni.redirectTo({
url: '../buyMemberSuccess/buyMemberSuccess?id=' +
this.form.product_id
})

@ -96,19 +96,19 @@
"canceled_by_merchant": "商家标注无效单",
"finished": "已取消",
"canceled": "已取消"
},
user_info:{},
openid:""
},
user_info: {},
openid: ""
}
},
onLoad(options) {
this.id = options.id;
this.getOrder();
weixin.getOpenidInfo(info => {
that.user_info = info.user_info
}, false)
this.openid = that.user_info.openid;
this.getOrder();
weixin.getOpenidInfo(info => {
that.user_info = info.user_info
that.openid = that.user_info.openid;
}, true)
},
onShow: function() {
@ -132,7 +132,7 @@
if (r.data.items) {
for (var m of r.data.items) {
m.statusName =that.corderstatusLabels[m.state]
m.statusName = that.corderstatusLabels[m.state]
}
}
},

@ -128,7 +128,23 @@
</view>
</view>
</view> -->
</view>
</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>
@ -151,7 +167,8 @@
],
current: 0,
userProfile: {},
user_info: {}
user_info: {},
showUser:false
}
},
onLoad() {
@ -167,9 +184,7 @@
let user = uni.getStorageSync("userInfo").user_info;
that.user_info = user;
if (weixin.isNull(user.wechat_nickname) || weixin.isNull(user.avatar)) {
uni.navigateTo({
url: '../login/index?showProfile=1'
})
that.showUser=true;
} else {
that.user_info.wechat_nickname = user.wechat_nickname;
}
@ -184,7 +199,42 @@
that.showTiele = false;
}
},
methods: {
methods: {
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'
})
}
}
})
})
},
//
stytemInfo: function() {
var that = this;
@ -432,6 +482,23 @@
display: flex;
justify-content: space-between;
width: 100%;
}
.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;
}
}
.row_col {

@ -91,6 +91,10 @@ export const weixin = {
}
//重新静默登录
return false;
} else {

Loading…
Cancel
Save