mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-07 02:12:25 +08:00
小程序适配取货地址切换
This commit is contained in:
@ -50,6 +50,7 @@
|
||||
"pages/plugins/distribution/extraction/extraction",
|
||||
"pages/plugins/distribution/extraction-apply/extraction-apply",
|
||||
"pages/plugins/distribution/extraction-order/extraction-order",
|
||||
"pages/plugins/distribution/extraction-switch/extraction-switch",
|
||||
"pages/plugins/distribution/introduce/introduce",
|
||||
"pages/plugins/wallet/user/user",
|
||||
"pages/plugins/wallet/recharge/recharge",
|
||||
|
||||
@ -76,7 +76,7 @@ Page({
|
||||
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = my.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var result = my.getStorageSync({key: this.data.user_location_cache_key}) || null;
|
||||
var data = null;
|
||||
if (result != null && (result.data || null) != null)
|
||||
{
|
||||
|
||||
@ -328,7 +328,7 @@ Page({
|
||||
];
|
||||
|
||||
// logo
|
||||
form_data['logo'] = this.data.extraction_data.logo || '';
|
||||
form_data['logo'] = (this.data.extraction_data || null) != null ? (this.data.extraction_data.logo || '') : '';
|
||||
|
||||
// 地区
|
||||
form_data["province"] = self.data.province_id;
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
.item {
|
||||
padding: 10rpx 10rpx 0 10rpx;
|
||||
}
|
||||
.address-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx !important;
|
||||
}
|
||||
.base, .address, .operation {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.address .item-icon {
|
||||
width: 30rpx;
|
||||
height: 35rpx !important;
|
||||
}
|
||||
.address-alias {
|
||||
border: 1px solid #d2364c;
|
||||
color: #d2364c;
|
||||
padding: 2rpx 10rpx;
|
||||
border-radius: 6rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.address .text {
|
||||
line-height: 44rpx;
|
||||
width: calc(100% - 40rpx);
|
||||
}
|
||||
.operation .button-list button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<view class="page">
|
||||
<view a:if="{{data_list.length > 0}}">
|
||||
<view class="item bg-white spacing-mb" a:for="{{data_list}}" a:key="key">
|
||||
<view onTap="address_conent_event" data-index="{{index}}" class="oh">
|
||||
<view a:if="{{(item.logo || null) != null}}" class="fl oh margin-right-lg">
|
||||
<image class="dis-block address-logo" src="{{item.logo}}" mode="widthFix" />
|
||||
</view>
|
||||
<view class="oh">
|
||||
<view class="base oh">
|
||||
<text a:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
|
||||
<text>{{item.name}}</text>
|
||||
<text class="fr">{{item.tel}}</text>
|
||||
</view>
|
||||
<view class="address oh">
|
||||
<image class="item-icon fl" src="/images/user-address.png" mode="widthFix" />
|
||||
<view class="text fr">{{item.province_name || ''}}{{item.city_name || ''}}{{item.county_name || ''}}{{item.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="operation br-t oh">
|
||||
<view a:if="{{(item.distance_value || null) != null && (item.distance_unit || null) != null}}" class="fl margin-top-lg">
|
||||
<text class="cr-888">距离</text>
|
||||
<text class="cr-666">{{item.distance_value}}</text>
|
||||
<text class="cr-888">{{item.distance_unit}}</text>
|
||||
</view>
|
||||
<view class="fr oh button-list">
|
||||
<button a:if="{{(item.is_default || 0) == 0}}" class="cr-666 map-submit br" type="default" size="mini" onTap="address_switch_event" data-index="{{index}}" hover-class="none">选择</button>
|
||||
<button a:else class="cr-ccc map-submit br-main" type="default" size="mini" hover-class="none" disabled="{{true}}">默认</button>
|
||||
<button a:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 map-submit br" type="default" size="mini" onTap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view a:if="{{data_list.length == 0}}">
|
||||
<import src="/pages/common/nodata.axml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.axml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
</view>
|
||||
@ -0,0 +1,225 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
data_list: [],
|
||||
params: null,
|
||||
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
is_first: 1,
|
||||
home_extraction_address_position: 0,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params,
|
||||
home_extraction_address_position: app.get_config('config.home_extraction_address_position', 0),
|
||||
});
|
||||
},
|
||||
|
||||
onReady: function () {
|
||||
// 清除位置缓存信息
|
||||
my.removeStorage({key: this.data.user_location_cache_key});
|
||||
|
||||
// 是否获取位置
|
||||
if(this.data.home_extraction_address_position == 1)
|
||||
{
|
||||
my.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({ title: app.data.common_pages_title.extraction_address });
|
||||
|
||||
// 是否需要选择地理位置
|
||||
if(this.data.home_extraction_address_position == 1)
|
||||
{
|
||||
// 首次不请求数据
|
||||
if(this.data.is_first == 0)
|
||||
{
|
||||
this.user_location_init();
|
||||
this.init();
|
||||
}
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
|
||||
this.setData({ is_first: 0 });
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
my.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,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = my.getStorageSync({key: this.data.user_location_cache_key}) || null;
|
||||
var data = null;
|
||||
if (result != null && (result.data || null) != null)
|
||||
{
|
||||
data = {
|
||||
name: result.data.name || null,
|
||||
address: result.data.address || null,
|
||||
lat: result.data.latitude || null,
|
||||
lng: result.data.longitude || null
|
||||
}
|
||||
}
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list() {
|
||||
// 加载loding
|
||||
my.showLoading({ content: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
var data = {};
|
||||
|
||||
// 是否有坐标
|
||||
if((this.data.user_location || null) != null)
|
||||
{
|
||||
data['lng'] = this.data.user_location.lng;
|
||||
data['lat'] = this.data.user_location.lat;
|
||||
}
|
||||
|
||||
// 请求接口
|
||||
my.request({
|
||||
url: app.get_request_url("switchinfo", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
if (data.extraction_address.length > 0) {
|
||||
this.setData({
|
||||
data_list: data.extraction_address,
|
||||
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
|
||||
});
|
||||
if (app.is_login_check(res.data, this, 'get_data_list')) {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
my.stopPullDownRefresh();
|
||||
|
||||
this.setData({
|
||||
data_list_loding_status: 2
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
address_map_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || data.name || '';
|
||||
var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || '');
|
||||
app.open_location(data.lng, data.lat, name, address);
|
||||
},
|
||||
|
||||
// 地址内容事件
|
||||
address_conent_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var is_back = this.data.params.is_back || 0;
|
||||
if (is_back == 1) {
|
||||
my.setStorage({
|
||||
key: app.data.cache_buy_user_address_select_key,
|
||||
data: this.data.data_list[index]
|
||||
});
|
||||
my.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 切换选择事件
|
||||
address_switch_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var temp_data = this.data.data_list;
|
||||
if((temp_data[index] || null) == null)
|
||||
{
|
||||
app.showToast('数据有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求切换
|
||||
var self = this;
|
||||
my.showLoading({ content: "处理中..." });
|
||||
my.request({
|
||||
url: app.get_request_url("switchsave", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: {"id":temp_data[index]['id'], "value":temp_data[index]['id_old'] || 0},
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
self.get_data_list();
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
app.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"pullRefresh": true
|
||||
}
|
||||
@ -45,6 +45,9 @@ Page({
|
||||
}
|
||||
my.setNavigationBar({title: title});
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 清除位置缓存信息
|
||||
my.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
"pages/plugins/distribution/extraction/extraction",
|
||||
"pages/plugins/distribution/extraction-apply/extraction-apply",
|
||||
"pages/plugins/distribution/extraction-order/extraction-order",
|
||||
"pages/plugins/distribution/extraction-switch/extraction-switch",
|
||||
"pages/plugins/distribution/introduce/introduce",
|
||||
"pages/plugins/exchangerate/currency/currency",
|
||||
"pages/plugins/invoice/user/user",
|
||||
|
||||
@ -326,7 +326,7 @@ Page({
|
||||
];
|
||||
|
||||
// logo
|
||||
form_data['logo'] = this.data.extraction_data.logo || '';
|
||||
form_data['logo'] = (this.data.extraction_data || null) != null ? (this.data.extraction_data.logo || '') : '';
|
||||
|
||||
// 地区
|
||||
form_data["province"] = self.data.province_id;
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
.item {
|
||||
padding: 10rpx 10rpx 0 10rpx;
|
||||
}
|
||||
.address-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx !important;
|
||||
}
|
||||
.base, .address, .operation {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.address .item-icon {
|
||||
width: 30rpx;
|
||||
height: 35rpx !important;
|
||||
}
|
||||
.address-alias {
|
||||
border: 1px solid #d2364c;
|
||||
color: #d2364c;
|
||||
padding: 2rpx 10rpx;
|
||||
border-radius: 6rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.address .text {
|
||||
line-height: 44rpx;
|
||||
width: calc(100% - 40rpx);
|
||||
}
|
||||
.operation .button-list button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
@ -0,0 +1,244 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
data_list: [],
|
||||
params: null,
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
is_first: 1,
|
||||
home_extraction_address_position: 0
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params,
|
||||
home_extraction_address_position: app.get_config('config.home_extraction_address_position', 0)
|
||||
});
|
||||
},
|
||||
|
||||
onReady: function () {
|
||||
// 清除位置缓存信息
|
||||
swan.removeStorage({
|
||||
key: this.data.user_location_cache_key
|
||||
});
|
||||
|
||||
// 是否获取位置
|
||||
if (this.data.home_extraction_address_position == 1) {
|
||||
swan.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({
|
||||
title: app.data.common_pages_title.extraction_address
|
||||
});
|
||||
|
||||
// 是否需要选择地理位置
|
||||
if (this.data.home_extraction_address_position == 1) {
|
||||
// 首次不请求数据
|
||||
if (this.data.is_first == 0) {
|
||||
this.user_location_init();
|
||||
this.init();
|
||||
}
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
|
||||
this.setData({
|
||||
is_first: 0
|
||||
});
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
swan.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
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = swan.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var data = null;
|
||||
|
||||
if (result != null) {
|
||||
data = {
|
||||
name: result.name || null,
|
||||
address: result.address || null,
|
||||
lat: result.latitude || null,
|
||||
lng: result.longitude || null
|
||||
};
|
||||
}
|
||||
|
||||
this.setData({
|
||||
user_location: data
|
||||
});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list() {
|
||||
// 加载loding
|
||||
swan.showLoading({
|
||||
title: "加载中..."
|
||||
});
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
var data = {};
|
||||
|
||||
// 是否有坐标
|
||||
if ((this.data.user_location || null) != null) {
|
||||
data['lng'] = this.data.user_location.lng;
|
||||
data['lat'] = this.data.user_location.lat;
|
||||
}
|
||||
|
||||
// 请求接口
|
||||
swan.request({
|
||||
url: app.get_request_url("switchinfo", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
|
||||
if (data.extraction_address.length > 0) {
|
||||
this.setData({
|
||||
data_list: data.extraction_address,
|
||||
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
|
||||
});
|
||||
|
||||
if (app.is_login_check(res.data, this, 'get_data_list')) {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
swan.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_list_loding_status: 2
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
address_map_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
|
||||
if (data == null) {
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || data.name || '';
|
||||
var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || '');
|
||||
app.open_location(data.lng, data.lat, name, address);
|
||||
},
|
||||
|
||||
// 地址内容事件
|
||||
address_conent_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var is_back = this.data.params.is_back || 0;
|
||||
|
||||
if (is_back == 1) {
|
||||
swan.setStorage({
|
||||
key: app.data.cache_buy_user_address_select_key,
|
||||
data: this.data.data_list[index]
|
||||
});
|
||||
swan.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 切换选择事件
|
||||
address_switch_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var temp_data = this.data.data_list;
|
||||
|
||||
if ((temp_data[index] || null) == null) {
|
||||
app.showToast('数据有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求切换
|
||||
var self = this;
|
||||
swan.showLoading({
|
||||
title: "处理中..."
|
||||
});
|
||||
swan.request({
|
||||
url: app.get_request_url("switchsave", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: {
|
||||
"id": temp_data[index]['id'],
|
||||
"value": temp_data[index]['id_old'] || 0
|
||||
},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
self.get_data_list();
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
app.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<view class="page">
|
||||
<view s-if="data_list.length > 0">
|
||||
<view class="item bg-white spacing-mb" s-for="item, index in data_list" s-key="key">
|
||||
<view bindtap="address_conent_event" data-index="{{index}}" class="oh">
|
||||
<view s-if="(item.logo || null) != null" class="fl oh margin-right-lg">
|
||||
<image class="dis-block address-logo" src="{{item.logo}}" mode="widthFix" />
|
||||
</view>
|
||||
<view class="oh">
|
||||
<view class="base oh">
|
||||
<text s-if="(item.alias || null) != null" class="address-alias">{{item.alias}}</text>
|
||||
<text>{{item.name}}</text>
|
||||
<text class="fr">{{item.tel}}</text>
|
||||
</view>
|
||||
<view class="address oh">
|
||||
<image class="item-icon fl" src="/images/user-address.png" mode="widthFix" />
|
||||
<view class="text fr">{{item.province_name || ''}}{{item.city_name || ''}}{{item.county_name || ''}}{{item.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="operation br-t oh">
|
||||
<view s-if="(item.distance_value || null) != null && (item.distance_unit || null) != null" class="fl margin-top-lg">
|
||||
<text class="cr-888">距离</text>
|
||||
<text class="cr-666">{{item.distance_value}}</text>
|
||||
<text class="cr-888">{{item.distance_unit}}</text>
|
||||
</view>
|
||||
<view class="fr oh button-list">
|
||||
<button s-if="(item.is_default || 0) == 0" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_switch_event" data-index="{{index}}" hover-class="none">选择</button>
|
||||
<button s-else class="cr-ccc map-submit br" type="default" size="mini" hover-class="none" disabled="{{true}}">默认</button>
|
||||
<button s-if="(item.lng || null) != null && (item.lat || null) != null" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view s-if="data_list.length == 0">
|
||||
<import src="/pages/common/nodata.swan" />
|
||||
<template is="nodata" data="{{{status: data_list_loding_status}}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.swan" />
|
||||
<template is="bottom_line" data="{{{status: data_bottom_line_status}}}"></template>
|
||||
</view>
|
||||
@ -45,6 +45,9 @@ Page({
|
||||
}
|
||||
swan.setNavigationBarTitle({title: title});
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 清除位置缓存信息
|
||||
swan.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
@ -136,7 +139,7 @@ Page({
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
@ -45,6 +45,9 @@ Page({
|
||||
}
|
||||
qq.setNavigationBarTitle({title: title});
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 清除位置缓存信息
|
||||
qq.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
"pages/user-orderaftersale/user-orderaftersale",
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
|
||||
"pages/extraction-address/extraction-address",
|
||||
"pages/common/open-setting-location/open-setting-location",
|
||||
"pages/plugins/coupon/index/index",
|
||||
"pages/plugins/coupon/user/user",
|
||||
"pages/plugins/membershiplevelvip/index/index",
|
||||
@ -49,6 +50,7 @@
|
||||
"pages/plugins/distribution/extraction/extraction",
|
||||
"pages/plugins/distribution/extraction-apply/extraction-apply",
|
||||
"pages/plugins/distribution/extraction-order/extraction-order",
|
||||
"pages/plugins/distribution/extraction-switch/extraction-switch",
|
||||
"pages/plugins/distribution/introduce/introduce",
|
||||
"pages/plugins/wallet/user/user",
|
||||
"pages/plugins/wallet/recharge/recharge",
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
params: null,
|
||||
is_show_open_setting: false,
|
||||
auth: 'scope.userLocation',
|
||||
cache_key: app.data.cache_userlocation_key,
|
||||
},
|
||||
|
||||
onLoad: function (params) {
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 获取权限
|
||||
init() {
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
success(res) {
|
||||
console.log(res)
|
||||
if (!res.authSetting[self.data.auth]) {
|
||||
tt.authorize({
|
||||
scope: self.data.auth,
|
||||
success(res) {
|
||||
self.choose_location();
|
||||
},
|
||||
fail: (res) => {
|
||||
self.setData({ is_show_open_setting: true });
|
||||
}
|
||||
})
|
||||
} else {
|
||||
self.choose_location();
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
app.showToast("请先获取授权");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 打开设置方法
|
||||
opne_setting_event(e) {
|
||||
var self = this;
|
||||
tt.openSetting({
|
||||
success: (res) => {
|
||||
if (res.authSetting[self.data.auth]) {
|
||||
self.setData({ is_show_open_setting: false });
|
||||
self.choose_location();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 打开位置服务
|
||||
choose_location() {
|
||||
tt.chooseLocation({
|
||||
success: res => {
|
||||
var position = app.map_gcj_to_bd(res.longitude, res.latitude);
|
||||
res.longitude = position.lng;
|
||||
res.latitude = position.lat;
|
||||
tt.setStorageSync(this.data.cache_key, res);
|
||||
tt.navigateBack();
|
||||
},
|
||||
fail: (res) => {
|
||||
tt.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<view tt:if="{{is_show_open_setting}}" class="open-setting-view">
|
||||
<view class="content bg-white">
|
||||
<view class="msg cr-888">开启相应的权限服务</view>
|
||||
<view class="value cr-666">获取[ <text>位置信息</text> ]权限</view>
|
||||
<button type="primary" size="mini" bindtap="opne_setting_event">打开设置页</button>
|
||||
</view>
|
||||
</view>
|
||||
<view tt:else class="open-setting-loding">
|
||||
<image src="/images/default-bg-loding.gif" class="avatar dis-block" mode="widthFix" />
|
||||
</view>
|
||||
@ -0,0 +1,39 @@
|
||||
page {
|
||||
background: #fbfbfb;
|
||||
}
|
||||
.open-setting-view {
|
||||
background: hsla(0, 0%, 0%, 0.1);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
z-index: 1000000;
|
||||
}
|
||||
.open-setting-view .content {
|
||||
margin:0 auto;
|
||||
width: 360rpx;
|
||||
height: 160rpx;
|
||||
padding: 50rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-top: 70%;
|
||||
position: relative;
|
||||
}
|
||||
.open-setting-view .content button {
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
.open-setting-view .content .value {
|
||||
margin-top: 5rpx;
|
||||
}
|
||||
.open-setting-view .content .value text {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.open-setting-loding {
|
||||
padding-top: 35%;
|
||||
}
|
||||
.open-setting-loding image {
|
||||
margin: 0 auto;
|
||||
}
|
||||
@ -24,20 +24,16 @@ Page({
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
|
||||
form_submit_disabled_status: false
|
||||
form_submit_disabled_status: false,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params
|
||||
});
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onReady: function () {
|
||||
// 清除位置缓存信息
|
||||
tt.removeStorage({
|
||||
key: this.data.user_location_cache_key
|
||||
});
|
||||
tt.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
@ -47,7 +43,6 @@ Page({
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
@ -56,7 +51,7 @@ Page({
|
||||
});
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '请先绑定手机号码'
|
||||
data_list_loding_msg: '请先绑定手机号码',
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
@ -66,7 +61,7 @@ Page({
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: '请先授权用户信息'
|
||||
data_list_loding_msg: '请先授权用户信息',
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -79,9 +74,7 @@ Page({
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -135,10 +128,10 @@ Page({
|
||||
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id")
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
@ -164,9 +157,7 @@ Page({
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -194,9 +185,7 @@ Page({
|
||||
pid: self.data.province_id
|
||||
},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -217,7 +206,6 @@ Page({
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
|
||||
if (self.data.city_id) {
|
||||
// 加载loding
|
||||
tt.request({
|
||||
@ -227,9 +215,7 @@ Page({
|
||||
pid: self.data.city_id
|
||||
},
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -250,7 +236,6 @@ Page({
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
@ -268,7 +253,6 @@ Page({
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
@ -284,7 +268,6 @@ Page({
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
@ -297,7 +280,6 @@ Page({
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
@ -310,33 +292,20 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
// 复制百度地图坐标拾取地址
|
||||
baidu_map_copy_event(e) {
|
||||
tt.setClipboardData({
|
||||
data: 'https://lbs.amap.com/console/show/picker',
|
||||
success(res) {
|
||||
app.showToast('复制成功', 'success');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = tt.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var data = null;
|
||||
|
||||
if (result != null) {
|
||||
if (result != null)
|
||||
{
|
||||
data = {
|
||||
name: result.name || null,
|
||||
address: result.address || null,
|
||||
lat: result.latitude || null,
|
||||
lng: result.longitude || null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this.setData({
|
||||
user_location: data
|
||||
});
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
@ -358,26 +327,45 @@ Page({
|
||||
];
|
||||
|
||||
// logo
|
||||
form_data['logo'] = this.data.extraction_data.logo || '';
|
||||
form_data['logo'] = (this.data.extraction_data || null) != null ? (this.data.extraction_data.logo || '') : '';
|
||||
|
||||
// 地区
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id; // 地理位置
|
||||
form_data["county"] = self.data.county_id;
|
||||
|
||||
// 地理位置
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.extraction_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.extraction_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.extraction_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
if ((self.data.extraction_data || null) != null && (self.data.extraction_data.status || 0) == 1) {
|
||||
if ((self.data.extraction_data || null) != null && (self.data.extraction_data.status || 0) == 1)
|
||||
{
|
||||
tt.showModal({
|
||||
title: '温馨提示',
|
||||
content: '数据需重新审核后方可生效',
|
||||
confirmText: '确认',
|
||||
cancelText: '暂不',
|
||||
success: result => {
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
self.request_data_save(form_data);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
self.request_data_save(form_data);
|
||||
@ -388,33 +376,23 @@ Page({
|
||||
// 数据保存
|
||||
request_data_save(data) {
|
||||
var self = this;
|
||||
self.setData({
|
||||
form_submit_disabled_status: true
|
||||
});
|
||||
tt.showLoading({
|
||||
title: "处理中..."
|
||||
});
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
tt.showLoading({ title: "处理中..." });
|
||||
tt.request({
|
||||
url: app.get_request_url("applysave", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
tt.hideLoading();
|
||||
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function () {
|
||||
tt.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({
|
||||
form_submit_disabled_status: false
|
||||
});
|
||||
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -423,9 +401,7 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({
|
||||
form_submit_disabled_status: false
|
||||
});
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
tt.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
@ -513,4 +489,4 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,17 @@
|
||||
<form bindsubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">logo图片<text class="form-group-tips">选传,建议300x300px</text></view>
|
||||
<view class="form-upload-data fl">
|
||||
<block tt:if="{{(extraction_data.logo || null) != null}}">
|
||||
<view class="item fl">
|
||||
<text class="delete-icon" bindtap="upload_delete_event">x</text>
|
||||
<image src="{{extraction_data.logo}}" bindtap="upload_show_event" mode="aspectFill" />
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
<image class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{extraction_data.alias || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
@ -43,12 +56,10 @@
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必填</text></view>
|
||||
<input type="digit" name="lng" value="{{extraction_data.lng || ''}}" placeholder-class="cr-ccc" class="cr-666 br-b" placeholder="请输入经度,如:116.397451" />
|
||||
<input type="digit" name="lat" value="{{extraction_data.lat || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="请输入纬度,如:39.909187" />
|
||||
<view class="tips">
|
||||
由于当前系统不支持位置选择,您可以登录电脑端使用高德拾取坐标系统获取相应的经纬度填写对应输入框,地址:https://lbs.amap.com/console/show/picker ,可复制地址去浏览器粘贴打开。
|
||||
<button type="primary" size="mini" hover-class="none" bindtap="baidu_map_copy_event">点击复制地址</button>
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view tt:if="{{(user_location || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view tt:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@ -0,0 +1,225 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_bottom_line_status: false,
|
||||
data_list: [],
|
||||
params: null,
|
||||
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
is_first: 1,
|
||||
home_extraction_address_position: 0,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({
|
||||
params: params,
|
||||
home_extraction_address_position: app.get_config('config.home_extraction_address_position', 0),
|
||||
});
|
||||
},
|
||||
|
||||
onReady: function () {
|
||||
// 清除位置缓存信息
|
||||
tt.removeStorage({key: this.data.user_location_cache_key});
|
||||
|
||||
// 是否获取位置
|
||||
if(this.data.home_extraction_address_position == 1)
|
||||
{
|
||||
tt.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
tt.setNavigationBarTitle({ title: app.data.common_pages_title.extraction_address });
|
||||
|
||||
// 是否需要选择地理位置
|
||||
if(this.data.home_extraction_address_position == 1)
|
||||
{
|
||||
// 首次不请求数据
|
||||
if(this.data.is_first == 0)
|
||||
{
|
||||
this.user_location_init();
|
||||
this.init();
|
||||
}
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
|
||||
this.setData({ is_first: 0 });
|
||||
},
|
||||
|
||||
// 初始化
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
// 用户未绑定用户则转到登录页面
|
||||
if (app.user_is_need_login(user)) {
|
||||
tt.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,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = tt.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var data = null;
|
||||
if (result != null)
|
||||
{
|
||||
data = {
|
||||
name: result.name || null,
|
||||
address: result.address || null,
|
||||
lat: result.latitude || null,
|
||||
lng: result.longitude || null
|
||||
}
|
||||
}
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 获取数据列表
|
||||
get_data_list() {
|
||||
// 加载loding
|
||||
tt.showLoading({ title: "加载中..." });
|
||||
this.setData({
|
||||
data_list_loding_status: 1
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
var data = {};
|
||||
|
||||
// 是否有坐标
|
||||
if((this.data.user_location || null) != null)
|
||||
{
|
||||
data['lng'] = this.data.user_location.lng;
|
||||
data['lat'] = this.data.user_location.lat;
|
||||
}
|
||||
|
||||
// 请求接口
|
||||
tt.request({
|
||||
url: app.get_request_url("switchinfo", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: res => {
|
||||
tt.hideLoading();
|
||||
tt.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
if (data.extraction_address.length > 0) {
|
||||
this.setData({
|
||||
data_list: data.extraction_address,
|
||||
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
|
||||
});
|
||||
if (app.is_login_check(res.data, this, 'get_data_list')) {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
tt.hideLoading();
|
||||
tt.stopPullDownRefresh();
|
||||
|
||||
this.setData({
|
||||
data_list_loding_status: 2
|
||||
});
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data_list();
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
address_map_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || data.name || '';
|
||||
var address = (data.province_name || '') + (data.city_name || '') + (data.county_name || '') + (data.address || '');
|
||||
app.open_location(data.lng, data.lat, name, address);
|
||||
},
|
||||
|
||||
// 地址内容事件
|
||||
address_conent_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var is_back = this.data.params.is_back || 0;
|
||||
if (is_back == 1) {
|
||||
tt.setStorage({
|
||||
key: app.data.cache_buy_user_address_select_key,
|
||||
data: this.data.data_list[index]
|
||||
});
|
||||
tt.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 切换选择事件
|
||||
address_switch_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var temp_data = this.data.data_list;
|
||||
if((temp_data[index] || null) == null)
|
||||
{
|
||||
app.showToast('数据有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 请求切换
|
||||
var self = this;
|
||||
tt.showLoading({ title: "处理中..." });
|
||||
tt.request({
|
||||
url: app.get_request_url("switchsave", "extraction", "distribution"),
|
||||
method: "POST",
|
||||
data: {"id":temp_data[index]['id'], "value":temp_data[index]['id_old'] || 0},
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
tt.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
self.get_data_list();
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
app.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
tt.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
<view class="page">
|
||||
<view tt:if="{{data_list.length > 0}}">
|
||||
<view class="item bg-white spacing-mb" tt:for="{{data_list}}" tt:key="key">
|
||||
<view bindtap="address_conent_event" data-index="{{index}}" class="oh">
|
||||
<view tt:if="{{(item.logo || null) != null}}" class="fl oh margin-right-lg">
|
||||
<image class="dis-block address-logo" src="{{item.logo}}" mode="widthFix" />
|
||||
</view>
|
||||
<view class="oh">
|
||||
<view class="base oh">
|
||||
<text tt:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
|
||||
<text>{{item.name}}</text>
|
||||
<text class="fr">{{item.tel}}</text>
|
||||
</view>
|
||||
<view class="address oh">
|
||||
<image class="item-icon fl" src="/images/user-address.png" mode="widthFix" />
|
||||
<view class="text fr">{{item.province_name || ''}}{{item.city_name || ''}}{{item.county_name || ''}}{{item.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="operation br-t oh">
|
||||
<view tt:if="{{(item.distance_value || null) != null && (item.distance_unit || null) != null}}" class="fl margin-top-lg">
|
||||
<text class="cr-888">距离</text>
|
||||
<text class="cr-666">{{item.distance_value}}</text>
|
||||
<text class="cr-888">{{item.distance_unit}}</text>
|
||||
</view>
|
||||
<view class="fr oh button-list">
|
||||
<button tt:if="{{(item.is_default || 0) == 0}}" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_switch_event" data-index="{{index}}" hover-class="none">选择</button>
|
||||
<button tt:else class="cr-ccc map-submit br" type="default" size="mini" hover-class="none" disabled="{{true}}">默认</button>
|
||||
<button tt:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view tt:if="{{data_list.length == 0}}">
|
||||
<import src="/pages/common/nodata.ttml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status}}"></template>
|
||||
</view>
|
||||
|
||||
<import src="/pages/common/bottom_line.ttml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
</view>
|
||||
@ -0,0 +1,28 @@
|
||||
.item {
|
||||
padding: 10rpx 10rpx 0 10rpx;
|
||||
}
|
||||
.address-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx !important;
|
||||
}
|
||||
.base, .address, .operation {
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.address .item-icon {
|
||||
width: 30rpx;
|
||||
height: 35rpx !important;
|
||||
}
|
||||
.address-alias {
|
||||
border: 1px solid #d2364c;
|
||||
color: #d2364c;
|
||||
padding: 2rpx 10rpx;
|
||||
border-radius: 6rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.address .text {
|
||||
line-height: 44rpx;
|
||||
width: calc(100% - 40rpx);
|
||||
}
|
||||
.operation .button-list button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
@ -45,6 +45,9 @@ Page({
|
||||
}
|
||||
tt.setNavigationBarTitle({title: title});
|
||||
|
||||
// 初始化配置
|
||||
this.init_config();
|
||||
|
||||
// 清除位置缓存信息
|
||||
tt.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
@ -445,11 +448,11 @@ Page({
|
||||
];
|
||||
|
||||
// 是否开启了地理位置选择
|
||||
// if(self.data.home_user_address_map_status == 1)
|
||||
// {
|
||||
// validation.push({ fields: "lng", msg: "请选择地理位置" });
|
||||
// validation.push({ fields: "lat", msg: "请选择地理位置" });
|
||||
// }
|
||||
if(self.data.home_user_address_map_status == 1)
|
||||
{
|
||||
validation.push({ fields: "lng", msg: "请选择地理位置" });
|
||||
validation.push({ fields: "lat", msg: "请选择地理位置" });
|
||||
}
|
||||
|
||||
// 是否开启了用户身份证信息
|
||||
if(self.data.home_user_address_idcard_status == 1)
|
||||
@ -472,22 +475,22 @@ Page({
|
||||
form_data['is_default'] = form_data.is_default == true ? 1 : 0;
|
||||
|
||||
// 地理位置
|
||||
// var lng = 0;
|
||||
// var lat = 0;
|
||||
// if((self.data.user_location || null) != null) {
|
||||
// lng = self.data.user_location.lng || 0;
|
||||
// lat = self.data.user_location.lat || 0;
|
||||
// }
|
||||
// if((self.data.address_data || null) != null) {
|
||||
// if((lng || null) == null) {
|
||||
// lng = self.data.address_data.lng || 0;
|
||||
// }
|
||||
// if((lat || null) == null) {
|
||||
// lat = self.data.address_data.lat || 0;
|
||||
// }
|
||||
// }
|
||||
// form_data['lng'] = lng;
|
||||
// form_data['lat'] = lat;
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.address_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.address_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.address_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data['lng'] = lng;
|
||||
form_data['lat'] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
|
||||
@ -43,13 +43,13 @@
|
||||
<input type="text" name="address" value="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<!-- <view tt:if="{{home_user_address_map_status == 1}}" class="form-gorup bg-white">
|
||||
<view tt:if="{{home_user_address_map_status == 1}}" class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view tt:if="{{(user_location || null) == null && (address_data.address || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view tt:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
|
||||
@ -73,8 +73,8 @@ App({
|
||||
|
||||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
request_url: 'http://shopxo.com/',
|
||||
request_url: 'https://dev.shopxo.net/',
|
||||
// request_url: 'http://shopxo.com/',
|
||||
// request_url: 'https://dev.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
|
||||
@ -327,7 +327,7 @@ Page({
|
||||
];
|
||||
|
||||
// logo
|
||||
form_data['logo'] = this.data.extraction_data.logo || '';
|
||||
form_data['logo'] = (this.data.extraction_data || null) != null ? (this.data.extraction_data.logo || '') : '';
|
||||
|
||||
// 地区
|
||||
form_data["province"] = self.data.province_id;
|
||||
|
||||
@ -23,9 +23,11 @@
|
||||
<text class="cr-666">{{item.distance_value}}</text>
|
||||
<text class="cr-888">{{item.distance_unit}}</text>
|
||||
</view>
|
||||
<button wx:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="fr cr-666 map-submit br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
|
||||
<button wx:if="{{(item.is_default || 0) == 0}}" class="fr cr-666 map-submit br" type="default" size="mini" bindtap="address_switch_event" data-index="{{index}}" hover-class="none">选择</button>
|
||||
<button wx:else class="fr cr-666 map-submit br" type="default" size="mini" hover-class="none" disabled="{{true}}">默认</button>
|
||||
<view class="fr oh button-list">
|
||||
<button wx:if="{{(item.is_default || 0) == 0}}" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_switch_event" data-index="{{index}}" hover-class="none">选择</button>
|
||||
<button wx:else class="cr-ccc map-submit br" type="default" size="mini" hover-class="none" disabled="{{true}}">默认</button>
|
||||
<button wx:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 map-submit br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -23,6 +23,6 @@
|
||||
line-height: 44rpx;
|
||||
width: calc(100% - 40rpx);
|
||||
}
|
||||
.operation .map-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .button-list button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user