1.优化
parent
d57ca12b1a
commit
4629d913d1
|
|
@ -131,8 +131,12 @@ button:before {
|
|||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.spacing-10 {
|
||||
padding-top: 10rpx;
|
||||
.spacing-mt-10 {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.spacing-mb-10 {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.spacing-mb {
|
||||
|
|
|
|||
|
|
@ -35,263 +35,265 @@
|
|||
</view>
|
||||
</template>
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentPopup from "../../components/popup/popup";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
application_client_type: app.globalData.application_client_type(),
|
||||
default_avatar: app.globalData.data.default_user_head_src,
|
||||
cache_key: app.globalData.data.cache_user_base_personal_interval_time_key,
|
||||
popup_status: false,
|
||||
user: {},
|
||||
user_avatar: "",
|
||||
nickname: "",
|
||||
pages: [],
|
||||
client: [],
|
||||
interval_time: 0,
|
||||
form_submit_disabled_status: true,
|
||||
testValue: "",
|
||||
};
|
||||
},
|
||||
|
||||
components: {
|
||||
componentPopup,
|
||||
},
|
||||
props: {
|
||||
propIsGrayscale: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
created: function () {
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
pages: app.globalData.get_config("config.common_app_user_base_popup_pages", []),
|
||||
client: app.globalData.get_config("config.common_app_user_base_popup_client", []),
|
||||
interval_time: parseInt(app.globalData.get_config("config.common_app_user_base_popup_interval_time", 1800)),
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, "init_config");
|
||||
}
|
||||
},
|
||||
|
||||
// 初始配置
|
||||
init(type = "") {
|
||||
// 初始化配置
|
||||
this.init_config(true);
|
||||
|
||||
// 是否需要展示弹窗提示
|
||||
if (!this.popup_status && this.pages.indexOf(type) != -1 && this.client.indexOf(this.application_client_type) != -1) {
|
||||
// 当前缓存用户
|
||||
var user = app.globalData.get_user_cache_info() || null;
|
||||
// 默认昵称则赋空值
|
||||
var arr = ["支付宝用户", "百度用户", "头条用户", "QQ用户", "快手用户", "微信用户", "WeChat User", "Usuarios de Wechat"];
|
||||
if (user != null && (user.nickname || null) != null && arr.indexOf(user.nickname) != -1) {
|
||||
user.nickname = "";
|
||||
}
|
||||
// 头像是默认则置为空
|
||||
if (user != null && (user.avatar || null) != null && user.avatar.indexOf("default-user-avatar") != -1) {
|
||||
user.avatar = "";
|
||||
}
|
||||
// 状态
|
||||
var status = user == null ? false : (user.avatar || null) == null || (user.nickname || null) == null ? true : false;
|
||||
// 间隔时间
|
||||
var cache_time = parseInt(uni.getStorageSync(this.cache_key) || 0);
|
||||
var current_time = Date.parse(new Date()) / 1000;
|
||||
if (status && !this.popup_status && cache_time > 0 && current_time < cache_time + parseInt(this.interval_time)) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
// 1秒后再提示用户填写信息
|
||||
var self = this;
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(function () {
|
||||
self.setData({
|
||||
popup_status: status,
|
||||
user: user,
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
|
||||
// 弹层关闭
|
||||
popup_close_event(e) {
|
||||
this.setData({
|
||||
popup_status: false,
|
||||
});
|
||||
uni.setStorageSync(this.cache_key, Date.parse(new Date()) / 1000);
|
||||
},
|
||||
|
||||
// 头像事件
|
||||
choose_avatar_event(e) {
|
||||
var self = this;
|
||||
if (this.application_client_type == "weixin") {
|
||||
self.upload_handle(e.detail.avatarUrl);
|
||||
} else {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success(res) {
|
||||
if (res.tempFilePaths.length > 0) {
|
||||
self.upload_handle(res.tempFilePaths[0]);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 上传处理
|
||||
upload_handle(image) {
|
||||
var self = this;
|
||||
uni.uploadFile({
|
||||
url: app.globalData.get_request_url("useravatarupload", "personal"),
|
||||
filePath: image,
|
||||
name: "file",
|
||||
formData: {},
|
||||
success: function (res) {
|
||||
if (res.statusCode == 200) {
|
||||
var data = typeof res.data == "object" ? res.data : JSON.parse(res.data);
|
||||
if (data.code == 0) {
|
||||
self.setData({
|
||||
user_avatar: data.data,
|
||||
});
|
||||
if (this.nickname) {
|
||||
this.setData({
|
||||
form_submit_disabled_status: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
app.globalData.showToast(data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
// 头像
|
||||
form_data["avatar"] = this.user_avatar || "";
|
||||
|
||||
// 验证数据项
|
||||
var validation = [];
|
||||
if ((this.user.avatar || null) == null) {
|
||||
validation.push({
|
||||
fields: "avatar",
|
||||
msg: "请上传头像",
|
||||
});
|
||||
}
|
||||
if ((this.user.nickname || null) == null) {
|
||||
validation.push({
|
||||
fields: "nickname",
|
||||
msg: "请填写昵称",
|
||||
});
|
||||
}
|
||||
if (app.globalData.fields_check(e.detail.value, validation)) {
|
||||
// 数据保存
|
||||
uni.showLoading({
|
||||
title: "处理中...",
|
||||
});
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("save", "personal"),
|
||||
method: "POST",
|
||||
data: form_data,
|
||||
dataType: "json",
|
||||
success: (res) => {
|
||||
uni.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
uni.setStorageSync(app.globalData.data.cache_user_info_key, res.data.data);
|
||||
app.globalData.showToast(res.data.msg, "success");
|
||||
this.setData({
|
||||
popup_status: false,
|
||||
});
|
||||
} 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("服务器请求出错");
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
// 输入框值监听
|
||||
on_input_name(event) {
|
||||
if (event.detail.value) {
|
||||
this.setData({
|
||||
nickname: event.detail.value,
|
||||
});
|
||||
if (this.user_avatar) {
|
||||
this.setData({
|
||||
form_submit_disabled_status: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
const app = getApp();
|
||||
import componentPopup from '../../components/popup/popup';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
application_client_type: app.globalData.application_client_type(),
|
||||
default_avatar: app.globalData.data.default_user_head_src,
|
||||
cache_key: app.globalData.data.cache_user_base_personal_interval_time_key,
|
||||
popup_status: true,
|
||||
user: {},
|
||||
user_avatar: '',
|
||||
nickname: '',
|
||||
pages: [],
|
||||
client: [],
|
||||
interval_time: 0,
|
||||
form_submit_disabled_status: true,
|
||||
});
|
||||
testValue: '',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
components: {
|
||||
componentPopup,
|
||||
},
|
||||
props: {
|
||||
propIsGrayscale: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
created: function () {
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
pages: app.globalData.get_config('config.common_app_user_base_popup_pages', []),
|
||||
client: app.globalData.get_config('config.common_app_user_base_popup_client', []),
|
||||
interval_time: parseInt(app.globalData.get_config('config.common_app_user_base_popup_interval_time', 1800)),
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 初始配置
|
||||
init(type = '') {
|
||||
// 初始化配置
|
||||
this.init_config(true);
|
||||
|
||||
// 是否需要展示弹窗提示
|
||||
if (!this.popup_status && this.pages.indexOf(type) != -1 && this.client.indexOf(this.application_client_type) != -1) {
|
||||
// 当前缓存用户
|
||||
var user = app.globalData.get_user_cache_info() || null;
|
||||
// 默认昵称则赋空值
|
||||
var arr = ['支付宝用户', '百度用户', '头条用户', 'QQ用户', '快手用户', '微信用户', 'WeChat User', 'Usuarios de Wechat'];
|
||||
if (user != null && (user.nickname || null) != null && arr.indexOf(user.nickname) != -1) {
|
||||
user.nickname = '';
|
||||
}
|
||||
// 头像是默认则置为空
|
||||
if (user != null && (user.avatar || null) != null && user.avatar.indexOf('default-user-avatar') != -1) {
|
||||
user.avatar = '';
|
||||
}
|
||||
// 状态
|
||||
var status = user == null ? false : (user.avatar || null) == null || (user.nickname || null) == null ? true : false;
|
||||
// 间隔时间
|
||||
var cache_time = parseInt(uni.getStorageSync(this.cache_key) || 0);
|
||||
var current_time = Date.parse(new Date()) / 1000;
|
||||
if (status && !this.popup_status && cache_time > 0 && current_time < cache_time + parseInt(this.interval_time)) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
// 1秒后再提示用户填写信息
|
||||
var self = this;
|
||||
clearTimeout(this.timer);
|
||||
this.timer = setTimeout(function () {
|
||||
self.setData({
|
||||
popup_status: status,
|
||||
user: user,
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
|
||||
// 弹层关闭
|
||||
popup_close_event(e) {
|
||||
this.setData({
|
||||
popup_status: false,
|
||||
});
|
||||
uni.setStorageSync(this.cache_key, Date.parse(new Date()) / 1000);
|
||||
},
|
||||
|
||||
// 头像事件
|
||||
choose_avatar_event(e) {
|
||||
var self = this;
|
||||
if (this.application_client_type == 'weixin') {
|
||||
self.upload_handle(e.detail.avatarUrl);
|
||||
} else {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success(res) {
|
||||
if (res.tempFilePaths.length > 0) {
|
||||
self.upload_handle(res.tempFilePaths[0]);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 上传处理
|
||||
upload_handle(image) {
|
||||
var self = this;
|
||||
uni.uploadFile({
|
||||
url: app.globalData.get_request_url('useravatarupload', 'personal'),
|
||||
filePath: image,
|
||||
name: 'file',
|
||||
formData: {},
|
||||
success: function (res) {
|
||||
if (res.statusCode == 200) {
|
||||
var data = typeof res.data == 'object' ? res.data : JSON.parse(res.data);
|
||||
if (data.code == 0) {
|
||||
self.setData({
|
||||
user_avatar: data.data,
|
||||
});
|
||||
console.log('nickname2', self.nickname);
|
||||
if (self.nickname) {
|
||||
self.setData({
|
||||
form_submit_disabled_status: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
app.globalData.showToast(data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
// 头像
|
||||
form_data['avatar'] = this.user_avatar || '';
|
||||
|
||||
// 验证数据项
|
||||
var validation = [];
|
||||
if ((this.user.avatar || null) == null) {
|
||||
validation.push({
|
||||
fields: 'avatar',
|
||||
msg: '请上传头像',
|
||||
});
|
||||
}
|
||||
if ((this.user.nickname || null) == null) {
|
||||
validation.push({
|
||||
fields: 'nickname',
|
||||
msg: '请填写昵称',
|
||||
});
|
||||
}
|
||||
if (app.globalData.fields_check(e.detail.value, validation)) {
|
||||
// 数据保存
|
||||
uni.showLoading({
|
||||
title: '处理中...',
|
||||
});
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('save', 'personal'),
|
||||
method: 'POST',
|
||||
data: form_data,
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
uni.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
uni.setStorageSync(app.globalData.data.cache_user_info_key, res.data.data);
|
||||
app.globalData.showToast(res.data.msg, 'success');
|
||||
this.setData({
|
||||
popup_status: false,
|
||||
});
|
||||
} 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('服务器请求出错');
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
// 输入框值监听
|
||||
on_input_name(event) {
|
||||
if (event.detail.value) {
|
||||
this.setData({
|
||||
nickname: event.detail.value,
|
||||
});
|
||||
console.log('nickname', this.nickname);
|
||||
if (this.user_avatar) {
|
||||
this.setData({
|
||||
form_submit_disabled_status: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
form_submit_disabled_status: true,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.user-base-popup {
|
||||
padding: 36rpx;
|
||||
position: relative;
|
||||
}
|
||||
.user-base-popup .close {
|
||||
position: absolute;
|
||||
top: 36rpx;
|
||||
right: 36rpx;
|
||||
z-index: 2;
|
||||
}
|
||||
.user-base-avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx !important;
|
||||
}
|
||||
.user-base-popup .form-gorup-title {
|
||||
line-height: 70rpx;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.user-base-popup .user-nickname-container {
|
||||
width: calc(100% - 120rpx);
|
||||
}
|
||||
.form-container .form-gorup {
|
||||
padding: 24rpx 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.form-container .form-gorup-title {
|
||||
font-weight: 400;
|
||||
}
|
||||
.bottom-fixed {
|
||||
/* #ifdef H5 */
|
||||
bottom: var(--window-bottom) !important;
|
||||
/* #endif */
|
||||
}
|
||||
.sub-btn {
|
||||
width: 336rpx;
|
||||
height: 84rpx;
|
||||
line-height: 84rpx;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
.user-base-popup {
|
||||
padding: 36rpx;
|
||||
position: relative;
|
||||
}
|
||||
.user-base-popup .close {
|
||||
position: absolute;
|
||||
top: 36rpx;
|
||||
right: 36rpx;
|
||||
z-index: 2;
|
||||
}
|
||||
.user-base-avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx !important;
|
||||
}
|
||||
.user-base-popup .form-gorup-title {
|
||||
line-height: 70rpx;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.user-base-popup .user-nickname-container {
|
||||
width: calc(100% - 120rpx);
|
||||
}
|
||||
.form-container .form-gorup {
|
||||
padding: 24rpx 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.form-container .form-gorup-title {
|
||||
font-weight: 400;
|
||||
}
|
||||
.bottom-fixed {
|
||||
/* #ifdef H5 */
|
||||
bottom: var(--window-bottom) !important;
|
||||
/* #endif */
|
||||
}
|
||||
.sub-btn {
|
||||
width: 336rpx;
|
||||
height: 84rpx;
|
||||
line-height: 84rpx;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
padding: 0 20rpx;
|
||||
height: 48rpx;
|
||||
line-height: 48rpx;
|
||||
background-color: #FF8273;
|
||||
background-color: #FF8AA1;
|
||||
}
|
||||
|
||||
.head-item .level-icon {
|
||||
|
|
@ -77,6 +77,10 @@
|
|||
padding: 10rpx 40rpx;
|
||||
}
|
||||
|
||||
.promotion-size {
|
||||
font-size: 44rpx;
|
||||
}
|
||||
|
||||
/*
|
||||
* 导航
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@
|
|||
<view class="padding-main flex-1" :class="stats_user_promotion_data_list.length - 1 > index ? 'divider-r-f5' : ''">
|
||||
<view class="cr-base">{{ item.name }}</view>
|
||||
<view class="single-text margin-top-sm">
|
||||
<text :class="'fw-b text-size ' + item.ent">{{ item.value }}</text>
|
||||
<text v-if="(item.unit || null) != null" class="cr-grey text-size-xs margin-left-sm">人</text>
|
||||
<text class="fw-b promotion-size">{{ item.value }}</text>
|
||||
<text v-if="(item.unit || null) != null" class="cr-grey-9 text-size-xs">人</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
.head-base .level-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx !important;
|
||||
left: 10rpx;
|
||||
left: 16rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
.vip-badge {
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
padding: 0 10rpx 0 45rpx;
|
||||
padding: 0 16rpx 0 51rpx;
|
||||
color: #FFAF36;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
}
|
||||
|
||||
.intelligent-identification button {
|
||||
width: 96rpx;
|
||||
height: 44rpx;
|
||||
line-height: 44rpx;
|
||||
padding: 0 24rpx !important;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -154,11 +154,12 @@
|
|||
/**
|
||||
* 底部保存按钮
|
||||
*/
|
||||
.bottom-fixed {
|
||||
padding-left: 90rpx;
|
||||
padding-right: 90rpx;
|
||||
.bottom-line-exclude {
|
||||
padding-left: 66rpx;
|
||||
padding-right: 66rpx;
|
||||
}
|
||||
|
||||
.rotate-180 {
|
||||
transform: rotate(180deg);
|
||||
.bottom-line-exclude button {
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -8,12 +8,10 @@
|
|||
<text v-if="is_default == item.id" class="default-address margin-right-sm text-size-xss border-radius-sm">默认</text>
|
||||
<text v-if="(item.alias || null) != null" class="address-alias br-main cr-main margin-right-sm text-size-xss border-radius-sm">{{ item.alias }}</text>
|
||||
<view class="single-text flex-1 flex-width fw-b">
|
||||
<text>{{ item.province_name || "" }}{{ item.city_name || "" }}{{ item.county_name || "" }}{{ item.address || "" }}</text>
|
||||
<text>{{ item.province_name || '' }}{{ item.city_name || '' }}{{ item.county_name || '' }}{{ item.address || '' }}</text>
|
||||
<view v-if="(item.distance_value || null) != null && (item.distance_unit || null) != null" class="cr-grey margin-left-lg">
|
||||
距离
|
||||
<text class="cr-base">
|
||||
{{ item.distance_value }}
|
||||
</text>
|
||||
<text class="cr-base"> {{ item.distance_value }} </text>
|
||||
{{ item.distance_unit }}
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -55,265 +53,265 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentNoData from "../../components/no-data/no-data";
|
||||
import componentBottomLine from "../../components/bottom-line/bottom-line";
|
||||
const theme_color = app.globalData.get_theme_color();
|
||||
const theme_color_light = app.globalData.get_theme_color(true);
|
||||
const app = getApp();
|
||||
import componentNoData from '../../components/no-data/no-data';
|
||||
import componentBottomLine from '../../components/bottom-line/bottom-line';
|
||||
const theme_color = app.globalData.get_theme_color();
|
||||
const theme_color_light = app.globalData.get_theme_color(true);
|
||||
|
||||
var common_static_url = app.globalData.get_static_url("common");
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
theme_color: theme_color,
|
||||
theme_color_light: theme_color_light,
|
||||
btn_bg_color: "background:linear-gradient(107deg, " + theme_color_light + " 0%, " + theme_color + " 100%)",
|
||||
common_static_url: common_static_url,
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
common_user_address_platform_import_list: [],
|
||||
client_value: app.globalData.application_client_type(),
|
||||
data_list: [],
|
||||
params: null,
|
||||
is_default: 0,
|
||||
};
|
||||
},
|
||||
|
||||
components: {
|
||||
componentNoData,
|
||||
componentBottomLine,
|
||||
},
|
||||
props: {},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params,
|
||||
});
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 异步初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 数据初始化
|
||||
this.init();
|
||||
|
||||
// 分享菜单处理
|
||||
app.globalData.page_share_handle();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
common_user_address_platform_import_list: app.globalData.get_config("config.common_user_address_platform_import_list", []),
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, "init_config");
|
||||
}
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
var user = app.globalData.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/login?event_callback=init",
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
data_bottom_line_status: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list() {
|
||||
// 加载loding
|
||||
uni.showLoading({
|
||||
title: "加载中...",
|
||||
});
|
||||
this.setData({
|
||||
var common_static_url = app.globalData.get_static_url('common');
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
theme_color: theme_color,
|
||||
theme_color_light: theme_color_light,
|
||||
btn_bg_color: 'background:linear-gradient(107deg, ' + theme_color_light + ' 0%, ' + theme_color + ' 100%)',
|
||||
common_static_url: common_static_url,
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
common_user_address_platform_import_list: [],
|
||||
client_value: app.globalData.application_client_type(),
|
||||
data_list: [],
|
||||
params: null,
|
||||
is_default: 0,
|
||||
};
|
||||
},
|
||||
|
||||
components: {
|
||||
componentNoData,
|
||||
componentBottomLine,
|
||||
},
|
||||
props: {},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params,
|
||||
});
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "useraddress"),
|
||||
method: "POST",
|
||||
data: this.params,
|
||||
dataType: "json",
|
||||
success: (res) => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
if (data.data.length > 0) {
|
||||
// 获取当前默认地址
|
||||
var is_default = 0;
|
||||
for (var i in data.data) {
|
||||
if (data.data[i]["is_default"] == 1) {
|
||||
is_default = data.data[i]["id"];
|
||||
onShow() {
|
||||
// 异步初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 数据初始化
|
||||
this.init();
|
||||
|
||||
// 分享菜单处理
|
||||
app.globalData.page_share_handle();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 初始化配置
|
||||
init_config(status) {
|
||||
if ((status || false) == true) {
|
||||
this.setData({
|
||||
common_user_address_platform_import_list: app.globalData.get_config('config.common_user_address_platform_import_list', []),
|
||||
});
|
||||
} else {
|
||||
app.globalData.is_config(this, 'init_config');
|
||||
}
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
var user = app.globalData.get_user_info(this, 'init');
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.globalData.user_is_need_login(user)) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/login/login?event_callback=init',
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取数据
|
||||
this.get_data_list();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
data_bottom_line_status: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list() {
|
||||
// 加载loding
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
});
|
||||
this.setData({
|
||||
data_list_loding_status: 1,
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url('index', 'useraddress'),
|
||||
method: 'POST',
|
||||
data: this.params,
|
||||
dataType: 'json',
|
||||
success: (res) => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
if (data.data.length > 0) {
|
||||
// 获取当前默认地址
|
||||
var is_default = 0;
|
||||
for (var i in data.data) {
|
||||
if (data.data[i]['is_default'] == 1) {
|
||||
is_default = data.data[i]['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置数据
|
||||
this.setData({
|
||||
data_list: data.data,
|
||||
is_default: is_default,
|
||||
data_list_loding_status: 3,
|
||||
data_bottom_line_status: true,
|
||||
});
|
||||
// 设置数据
|
||||
this.setData({
|
||||
data_list: data.data,
|
||||
is_default: is_default,
|
||||
data_list_loding_status: 3,
|
||||
data_bottom_line_status: true,
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
});
|
||||
if (app.globalData.is_login_check(res.data, this, "get_data_list")) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
});
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 地址内容事件
|
||||
address_conent_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var is_back = this.params.is_back || 0;
|
||||
if (is_back == 1) {
|
||||
uni.setStorage({
|
||||
key: app.globalData.data.cache_buy_user_address_select_key,
|
||||
data: this.data_list[index],
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取系统地址事件
|
||||
choose_system_address_event(e) {
|
||||
// 百度、头条则需要验证授权
|
||||
// #ifdef MP-BAIDU || MP-TOUTIAO
|
||||
// 去验证授权
|
||||
if (e != 1) {
|
||||
app.globalData.auth_check(this, "choose_system_address_event", "scope.address");
|
||||
return false;
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 获取地址授权信息
|
||||
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("提交失败,请重试!");
|
||||
}
|
||||
if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
|
||||
app.globalData.showToast(res.data.msg);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
app.globalData.showToast("服务器请求出错");
|
||||
},
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
});
|
||||
app.globalData.showToast('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 地址内容事件
|
||||
address_conent_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var is_back = this.params.is_back || 0;
|
||||
if (is_back == 1) {
|
||||
uni.setStorage({
|
||||
key: app.globalData.data.cache_buy_user_address_select_key,
|
||||
data: this.data_list[index],
|
||||
});
|
||||
},
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取系统地址事件
|
||||
choose_system_address_event(e) {
|
||||
// 百度、头条则需要验证授权
|
||||
// #ifdef MP-BAIDU || MP-TOUTIAO
|
||||
// 去验证授权
|
||||
if (e != 1) {
|
||||
app.globalData.auth_check(this, 'choose_system_address_event', 'scope.address');
|
||||
return false;
|
||||
}
|
||||
// #endif
|
||||
|
||||
// 获取地址授权信息
|
||||
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('服务器请求出错');
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 添加地址事件
|
||||
address_add_event(e) {
|
||||
var temp_params = this.params;
|
||||
temp_params['id'] = 0;
|
||||
var query = app.globalData.json_to_url_params(temp_params);
|
||||
uni.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?' + query,
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data_list[index] || null;
|
||||
if (data == null) {
|
||||
app.globalData.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
var temp_params = this.params;
|
||||
temp_params['id'] = data.id;
|
||||
var query = app.globalData.json_to_url_params(temp_params);
|
||||
uni.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?' + query,
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
address_map_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data_list[index] || null;
|
||||
if (data == null) {
|
||||
app.globalData.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || data.name || '';
|
||||
var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || '');
|
||||
app.globalData.open_location(data.lng, data.lat, name, address);
|
||||
},
|
||||
},
|
||||
|
||||
// 添加地址事件
|
||||
address_add_event(e) {
|
||||
var temp_params = this.params;
|
||||
temp_params["id"] = 0;
|
||||
var query = app.globalData.json_to_url_params(temp_params);
|
||||
uni.navigateTo({
|
||||
url: "/pages/user-address-save/user-address-save?" + query,
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data_list[index] || null;
|
||||
if (data == null) {
|
||||
app.globalData.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
var temp_params = this.params;
|
||||
temp_params["id"] = data.id;
|
||||
var query = app.globalData.json_to_url_params(temp_params);
|
||||
uni.navigateTo({
|
||||
url: "/pages/user-address-save/user-address-save?" + query,
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
address_map_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data_list[index] || null;
|
||||
if (data == null) {
|
||||
app.globalData.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || data.name || "";
|
||||
var address = (data.province_name || "") + (data.city_name || "") + (data.county_name || "") + (data.address || "");
|
||||
app.globalData.open_location(data.lng, data.lat, name, address);
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
@import "./user-address.css";
|
||||
@import './user-address.css';
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue