用户地址授权优化、一键绑定手机优化

master
gongfuxiang 2021-11-18 10:32:07 +08:00
parent e9377a9156
commit 2472ad6ec7
3 changed files with 91 additions and 71 deletions

33
App.vue
View File

@ -43,7 +43,7 @@
//
version: "v2.2.1",
//
currency_symbol: "¥",
currency_symbol: "¥",
//
// yellow #f6c133
// red #ff0036
@ -597,7 +597,6 @@
if (user == false) {
return true;
}
//
if ((user.is_mandatory_bind_mobile || 0) == 1) {
if ((user.mobile || null) == null) {
@ -614,7 +613,6 @@
var json = new Object();
if ((url_params || null) != null) {
var arr = url_params.split('&');
for (var i = 0; i < arr.length; i++) {
var temp = arr[i].split('=');
json[temp[0]] = temp[1];
@ -983,6 +981,35 @@
value = 'h5';
//#endif
return value;
},
//
auth_check(object, method, scope, msg) {
var self = this;
uni.getSetting({
success(res) {
if (!res.authSetting[scope]) {
uni.authorize({
scope: scope,
success (res) {
if (typeof object === 'object' && (method || null) != null) {
object[method](1);
}
},
fail (res) {
self.showToast(msg || '请打开授权');
setTimeout(function() {
uni.openSetting();
}, 1000);
}
});
} else {
if (typeof object === 'object' && (method || null) != null) {
object[method](1);
}
}
}
});
}
},

View File

@ -17,7 +17,9 @@
<view v-if="(user.nickname || null) != null" class="cr-base">{{user.nickname}}</view>
<view class="margin-top-xxxl padding-top-xxxl">
<button class="bg-main-pair br-main-pair cr-white round text-size" type="warn" hover-class="none" @tap="confirm_verify_event"></button>
<button v-if="common_user_is_onekey_bind_mobile == 1" class="margin-top-xxl bg-main br-main cr-white round text-size" type="default" hover-class="none" open-type="getPhoneNumber" @getphonenumber="confirm_phone_number_event"></button>
<!-- #ifdef MP-WEIXIN || MP-BAIDU -->
<button v-if="common_user_is_onekey_bind_mobile == 1" class="margin-top-xxl bg-main br-main cr-white round text-size" type="default" hover-class="none" open-type="getPhoneNumber" @getphonenumber="confirm_phone_number_event"></button>
<!-- #endif -->
</view>
</view>
</view>
@ -97,8 +99,7 @@
this.setData({
common_user_is_onekey_bind_mobile: app.globalData.get_config('config.common_user_is_onekey_bind_mobile'),
home_site_logo_square: app.globalData.get_config('config.home_site_logo_square')
});
console.log(this.home_site_logo_square)
});
} else {
app.globalData.is_config(this, 'init_config');
}
@ -144,30 +145,17 @@
this.user_auth_code(userinfo);
// #endif
// #ifdef MP-TOUTIAO
var self = this;
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userInfo']) {
uni.authorize({
scope: 'scope.userInfo',
success (res) {},
fail (res) {
app.globalData.showToast('请同意用户授权');
setTimeout(function() {
uni.openSetting();
}, 1000);
}
});
} else {
uni.getUserInfo({
success (res) {
var userinfo = JSON.parse(res.rawData);
self.user_auth_code(userinfo);
}
});
if(e == 1) {
var self = this;
uni.getUserInfo({
success (res) {
var userinfo = JSON.parse(res.rawData);
self.user_auth_code(userinfo);
}
}
});
});
} else {
app.globalData.auth_check(this, 'get_user_info_event', 'scope.userInfo');
}
// #endif
},

View File

@ -300,48 +300,53 @@
},
//
choose_system_address_event(e) {
uni.chooseAddress({
success(res) {
var data = {
"name": res.userName || '',
"tel": res.telNumber || '',
"province": res.provinceName || '',
"city": res.cityName || '',
"county": res.countyName || '',
"address": res.detailInfo || ''
};
// loding
uni.showLoading({
title: "处理中..."
});
//
uni.request({
url: app.globalData.get_request_url("outsystemadd", "useraddress"),
method: "POST",
data: data,
dataType: "json",
success: res => {
uni.hideLoading();
if (res.data.code == 0) {
this.get_data_list();
} else {
if (app.globalData.is_login_check(res.data)) {
app.globalData.showToast(res.data.msg);
} else {
app.globalData.showToast('提交失败,请重试!');
}
}
},
fail: () => {
uni.hideLoading();
app.globalData.showToast("服务器请求出错");
}
});
}
});
choose_system_address_event(e) {
console.log(e);
if(e == 1) {
console.log(0);
uni.chooseAddress({
success(res) {
var data = {
"name": res.userName || '',
"tel": res.telNumber || '',
"province": res.provinceName || '',
"city": res.cityName || '',
"county": res.countyName || '',
"address": res.detailInfo || ''
};
//
uni.showLoading({
title: "处理中..."
});
uni.request({
url: app.globalData.get_request_url("outsystemadd", "useraddress"),
method: "POST",
data: data,
dataType: "json",
success: res => {
uni.hideLoading();
if (res.data.code == 0) {
this.get_data_list();
} else {
if (app.globalData.is_login_check(res.data)) {
app.globalData.showToast(res.data.msg);
} else {
app.globalData.showToast('提交失败,请重试!');
}
}
},
fail: () => {
uni.hideLoading();
app.globalData.showToast("服务器请求出错");
}
});
}
});
} else {
console.log(1);
app.globalData.auth_check(this, 'choose_system_address_event', 'scope.address');
}
},
//