自提地址新增距离排序

This commit is contained in:
Devil
2021-03-14 23:03:31 +08:00
parent e1798f3d1b
commit 92c2fb6a8d
51 changed files with 2168 additions and 213 deletions

View File

@ -432,4 +432,159 @@ textarea {
*/
.common-online-service {
bottom: 35%;
}
/**
* 公共样式
*/
.margin-top-xs {
margin-top: 5rpx;
}
.margin-top-sm {
margin-top: 10rpx;
}
.margin-top, .margin-top-default {
margin-top: 15rpx;
}
.margin-top-lg {
margin-top: 20rpx;
}
.margin-top-xl {
margin-top: 25rpx;
}
.margin-top-xxl {
margin-top: 30rpx;
}
.margin-right-xs {
margin-right: 5rpx;
}
.margin-right-sm {
margin-right: 10rpx;
}
.margin-right, .margin-right-default {
margin-right: 15rpx;
}
.margin-right-lg {
margin-right: 20rpx;
}
.margin-right-xl {
margin-right: 25rpx;
}
.margin-right-xxl {
margin-right: 30rpx;
}
.margin-left-xs {
margin-left: 5rpx;
}
.margin-left-sm {
margin-left: 10rpx;
}
.margin-left, .margin-left-default {
margin-left: 15rpx;
}
.margin-left-lg {
margin-left: 20rpx;
}
.margin-left-xl {
margin-left: 25rpx;
}
.margin-left-xxl {
margin-left: 30rpx;
}
.margin-bottom-xs {
margin-bottom: 5rpx;
}
.margin-bottom-sm {
margin-bottom: 10rpx;
}
.margin-bottom, .margin-bottom-default {
margin-bottom: 15rpx;
}
.margin-bottom-lg {
margin-bottom: 20rpx;
}
.margin-bottom-xl {
margin-bottom: 25rpx;
}
.margin-bottom-xxl {
margin-bottom: 30rpx;
}
.padding-top-xs {
padding-top: 5rpx;
}
.padding-top-sm {
padding-top: 10rpx;
}
.padding-top, .padding-top-default {
padding-top: 15rpx;
}
.padding-top-lg {
padding-top: 20rpx;
}
.padding-top-xl {
padding-top: 25rpx;
}
.padding-top-xxl {
padding-top: 30rpx;
}
.padding-right-xs {
padding-right: 5rpx;
}
.padding-right-sm {
padding-right: 10rpx;
}
.padding-right, .padding-right-default {
padding-right: 15rpx;
}
.padding-right-lg {
padding-right: 20rpx;
}
.padding-right-xl {
padding-right: 25rpx;
}
.padding-right-xxl {
padding-right: 30rpx;
}
.padding-left-xs {
padding-left: 5rpx;
}
.padding-left-sm {
padding-left: 10rpx;
}
.padding-left, .padding-left-default {
padding-left: 15rpx;
}
.padding-left-lg {
padding-left: 20rpx;
}
.padding-left-xl {
padding-left: 25rpx;
}
.padding-left-xxl {
padding-left: 30rpx;
}
.padding-bottom-xs {
padding-bottom: 5rpx;
}
.padding-bottom-sm {
padding-bottom: 10rpx;
}
.padding-bottom, .padding-bottom-default {
padding-bottom: 15rpx;
}
.padding-bottom-lg {
padding-bottom: 20rpx;
}
.padding-bottom-xl {
padding-bottom: 25rpx;
}
.padding-bottom-xxl {
padding-bottom: 30rpx;
}

View File

@ -355,7 +355,7 @@ Page({
} else if (this.data.common_site_type == 2 || (this.data.common_site_type == 4 && this.data.site_model == 2))
{
my.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
url: '/pages/extraction-address/extraction-address?is_back=1&is_buy=1'
});
} else {
app.showToast('当前模式不允许使用地址');

View File

@ -1,12 +1,16 @@
.item {
padding: 10rpx 10rpx 0 10rpx;
padding: 10rpx 10rpx 0 10rpx;
}
.address-logo {
width: 140rpx;
height: 140rpx !important;
}
.base, .address, .operation {
padding: 20rpx 0;
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
@ -16,9 +20,9 @@
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
margin-left: 20rpx;
}

View File

@ -2,17 +2,27 @@
<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}}">
<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 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="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 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>
<button a:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="fr cr-666 map-submit br" type="default" size="mini" onTap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
</view>
</view>

View File

@ -6,15 +6,50 @@ Page({
data_list: [],
params: null,
is_default: 0,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
is_first: 1,
home_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({ params: params });
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
my.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_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 });
this.init();
// 是否需要选择地理位置
if(this.data.home_buy_extraction_address_position == 1)
{
// 首次不请求数据
if(this.data.is_first == 0)
{
this.user_location_init();
this.init();
}
} else {
this.init();
}
this.setData({ is_first: 0 });
},
// 初始化
@ -39,6 +74,22 @@ Page({
}
},
// 地址信息初始化
user_location_init() {
var result = my.getStorageSync(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
@ -47,11 +98,21 @@ Page({
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("extraction", "useraddress"),
method: "POST",
data: {},
data: data,
dataType: "json",
success: res => {
my.hideLoading();

View File

@ -1,4 +1,17 @@
<form onSubmit="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 a:if="{{(extraction_data.logo || null) != null}}">
<view class="item fl">
<text class="delete-icon" onTap="upload_delete_event">x</text>
<image src="{{extraction_data.logo}}" onTap="upload_show_event" mode="aspectFill" />
</view>
</block>
</view>
<image class="upload-icon" src="/images/default-upload-icon.png" mode="aspectFill" onTap="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 个字符" />

View File

@ -11,6 +11,7 @@ Page({
province_id: null,
city_id: null,
county_id: null,
editor_path_type: '',
default_province: "请选择省",
default_city: "请选择市",
@ -77,29 +78,31 @@ Page({
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
if (res.data.code == 0) {
var data = res.data.data || null;
var data = res.data.data;
var extraction_data = data.extraction_data || null;
self.setData({
extraction_data: data,
extraction_data: extraction_data || null,
editor_path_type: data.editor_path_type || '',
});
// 数据设置
if(data != null)
if(extraction_data != null)
{
self.setData({
province_id: data.province || null,
city_id: data.city || null,
county_id: data.county || null,
province_id: extraction_data.province || null,
city_id: extraction_data.city || null,
county_id: extraction_data.county || null,
});
// 地理位置
var lng = data.lng || null;
var lat = data.lat || null;
var lng = extraction_data.lng || null;
var lat = extraction_data.lat || null;
if (lng != null && lat != null)
{
self.setData({ user_location: {
lng: lng,
lat: lat,
address: data.address || '',
address: extraction_data.address || '',
}});
}
}
@ -324,6 +327,10 @@ Page({
{ fields: "lat", msg: "请选择地理位置" }
];
// logo
form_data['logo'] = 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;
@ -401,4 +408,85 @@ Page({
}
});
},
// 上传图片预览
upload_show_event(e) {
my.previewImage({
current: 0,
urls: [this.data.extraction_data.logo],
});
},
// 图片删除
upload_delete_event(e) {
var self = this;
my.showModal({
title: '温馨提示',
content: '删除后不可恢复、继续吗?',
success(res) {
if (res.confirm) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = '';
self.setData({
extraction_data: temp_data,
});
}
}
});
},
// 文件上传
file_upload_event(e) {
var self = this;
my.chooseImage({
count: 1,
success(res) {
var success = 0;
var fail = 0;
var length = res.tempFilePaths.length;
var count = 0;
self.upload_one_by_one(res.tempFilePaths, success, fail, count, length);
}
});
},
// 采用递归的方式上传多张
upload_one_by_one(img_paths, success, fail, count, length) {
var self = this;
my.uploadFile({
url: app.get_request_url("index", "ueditor"),
filePath: img_paths[count],
name: 'upfile',
formData: {
action: 'uploadimage',
path_type: self.data.editor_path_type
},
success: function (res) {
success++;
if (res.statusCode == 200) {
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
if (data.code == 0 && (data.data.url || null) != null) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = data.data.url;
self.setData({ extraction_data: temp_data });
} else {
app.showToast(data.msg);
}
}
},
fail: function (e) {
fail++;
},
complete: function (e) {
count++; // 下一张
if (count >= length) {
// 上传完毕,作一下提示
//app.showToast('上传成功' + success +'张', 'success');
} else {
// 递归调用,上传下一张
self.upload_one_by_one(img_paths, success, fail, count, length);
}
}
});
},
});

View File

@ -493,4 +493,160 @@ button[disabled].bg-primary {
.common-quick-nav image {
width: 60rpx;
height: 60rpx;
}
/**
* 公共样式
*/
.margin-top-xs {
margin-top: 5rpx;
}
.margin-top-sm {
margin-top: 10rpx;
}
.margin-top, .margin-top-default {
margin-top: 15rpx;
}
.margin-top-lg {
margin-top: 20rpx;
}
.margin-top-xl {
margin-top: 25rpx;
}
.margin-top-xxl {
margin-top: 30rpx;
}
.margin-right-xs {
margin-right: 5rpx;
}
.margin-right-sm {
margin-right: 10rpx;
}
.margin-right, .margin-right-default {
margin-right: 15rpx;
}
.margin-right-lg {
margin-right: 20rpx;
}
.margin-right-xl {
margin-right: 25rpx;
}
.margin-right-xxl {
margin-right: 30rpx;
}
.margin-left-xs {
margin-left: 5rpx;
}
.margin-left-sm {
margin-left: 10rpx;
}
.margin-left, .margin-left-default {
margin-left: 15rpx;
}
.margin-left-lg {
margin-left: 20rpx;
}
.margin-left-xl {
margin-left: 25rpx;
}
.margin-left-xxl {
margin-left: 30rpx;
}
.margin-bottom-xs {
margin-bottom: 5rpx;
}
.margin-bottom-sm {
margin-bottom: 10rpx;
}
.margin-bottom, .margin-bottom-default {
margin-bottom: 15rpx;
}
.margin-bottom-lg {
margin-bottom: 20rpx;
}
.margin-bottom-xl {
margin-bottom: 25rpx;
}
.margin-bottom-xxl {
margin-bottom: 30rpx;
}
.padding-top-xs {
padding-top: 5rpx;
}
.padding-top-sm {
padding-top: 10rpx;
}
.padding-top, .padding-top-default {
padding-top: 15rpx;
}
.padding-top-lg {
padding-top: 20rpx;
}
.padding-top-xl {
padding-top: 25rpx;
}
.padding-top-xxl {
padding-top: 30rpx;
}
.padding-right-xs {
padding-right: 5rpx;
}
.padding-right-sm {
padding-right: 10rpx;
}
.padding-right, .padding-right-default {
padding-right: 15rpx;
}
.padding-right-lg {
padding-right: 20rpx;
}
.padding-right-xl {
padding-right: 25rpx;
}
.padding-right-xxl {
padding-right: 30rpx;
}
.padding-left-xs {
padding-left: 5rpx;
}
.padding-left-sm {
padding-left: 10rpx;
}
.padding-left, .padding-left-default {
padding-left: 15rpx;
}
.padding-left-lg {
padding-left: 20rpx;
}
.padding-left-xl {
padding-left: 25rpx;
}
.padding-left-xxl {
padding-left: 30rpx;
}
.padding-bottom-xs {
padding-bottom: 5rpx;
}
.padding-bottom-sm {
padding-bottom: 10rpx;
}
.padding-bottom, .padding-bottom-default {
padding-bottom: 15rpx;
}
.padding-bottom-lg {
padding-bottom: 20rpx;
}
.padding-bottom-xl {
padding-bottom: 25rpx;
}
.padding-bottom-xxl {
padding-bottom: 30rpx;
}

View File

@ -337,7 +337,7 @@ Page({
});
} else if (this.data.common_site_type == 2 || this.data.common_site_type == 4 && this.data.site_model == 2) {
swan.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
url: '/pages/extraction-address/extraction-address?is_back=1&is_buy=1'
});
} else {
app.showToast('当前模式不允许使用地址');

View File

@ -1,12 +1,16 @@
.item {
padding: 10rpx 10rpx 0 10rpx;
padding: 10rpx 10rpx 0 10rpx;
}
.address-logo {
width: 140rpx;
height: 140rpx !important;
}
.base, .address, .operation {
padding: 20rpx 0;
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
@ -16,9 +20,9 @@
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
margin-left: 20rpx;
}

View File

@ -5,16 +5,51 @@ Page({
data_bottom_line_status: false,
data_list: [],
params: null,
is_default: 0
is_default: 0,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
is_first: 1,
home_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({ params: params });
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
swan.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_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 });
this.init();
// 是否需要选择地理位置
if(this.data.home_buy_extraction_address_position == 1)
{
// 首次不请求数据
if(this.data.is_first == 0)
{
this.user_location_init();
this.init();
}
} else {
this.init();
}
this.setData({ is_first: 0 });
},
// 初始化
@ -39,6 +74,22 @@ Page({
}
},
// 地址信息初始化
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
@ -47,11 +98,21 @@ Page({
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("extraction", "useraddress"),
method: "POST",
data: {},
data: data,
dataType: "json",
success: res => {
swan.hideLoading();

View File

@ -2,17 +2,27 @@
<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}}">
<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 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="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 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>
<button s-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>
</view>
</view>

View File

@ -11,6 +11,7 @@ Page({
province_id: null,
city_id: null,
county_id: null,
editor_path_type: '',
default_province: "请选择省",
default_city: "请选择市",
@ -76,31 +77,35 @@ Page({
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
if (res.data.code == 0) {
var data = res.data.data || null;
var data = res.data.data;
var extraction_data = data.extraction_data || null;
self.setData({
extraction_data: data
extraction_data: extraction_data || null,
editor_path_type: data.editor_path_type || '',
});
// 数据设置
if (data != null) {
if(extraction_data != null)
{
self.setData({
province_id: data.province || null,
city_id: data.city || null,
county_id: data.county || null
province_id: extraction_data.province || null,
city_id: extraction_data.city || null,
county_id: extraction_data.county || null,
});
// 地理位置
var lng = (data.lng || 0) <= 0 ? null : data.lng;
var lat = (data.lat || 0) <= 0 ? null : data.lat;
if (lng != null && lat != null) {
var lng = extraction_data.lng || null;
var lat = extraction_data.lat || null;
if (lng != null && lat != null)
{
self.setData({ user_location: {
lng: lng,
lat: lat,
address: data.address || ''
} });
lng: lng,
lat: lat,
address: extraction_data.address || '',
}});
}
}
// 获取城市、区县
self.get_city_list();
self.get_county_list();
@ -309,8 +314,21 @@ Page({
var form_data = e.detail.value;
// 数据校验
var validation = [{ fields: "name", msg: "请填写联系人" }, { fields: "tel", msg: "请填写联系电话" }, { fields: "province", msg: "请选择省份" }, { fields: "city", msg: "请选择城市" }, { fields: "county", msg: "请选择区县" }, { fields: "address", msg: "请填写详细地址" }, { fields: "lng", msg: "请选择地理位置" }, { fields: "lat", msg: "请选择地理位置" }];
var validation = [
{ fields: "name", msg: "请填写联系人" },
{ fields: "tel", msg: "请填写联系电话" },
{ fields: "province", msg: "请选择省份" },
{ fields: "city", msg: "请选择城市" },
{ fields: "county", msg: "请选择区县" },
{ fields: "address", msg: "请填写详细地址" },
{ fields: "lng", msg: "请选择地理位置" },
{ fields: "lat", msg: "请选择地理位置" }
];
// logo
form_data['logo'] = 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;
@ -386,5 +404,86 @@ Page({
app.showToast("服务器请求出错");
}
});
}
},
// 上传图片预览
upload_show_event(e) {
swan.previewImage({
current: this.data.extraction_data.logo,
urls: [this.data.extraction_data.logo],
});
},
// 图片删除
upload_delete_event(e) {
var self = this;
swan.showModal({
title: '温馨提示',
content: '删除后不可恢复、继续吗?',
success(res) {
if (res.confirm) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = '';
self.setData({
extraction_data: temp_data,
});
}
}
});
},
// 文件上传
file_upload_event(e) {
var self = this;
swan.chooseImage({
count: 1,
success(res) {
var success = 0;
var fail = 0;
var length = res.tempFilePaths.length;
var count = 0;
self.upload_one_by_one(res.tempFilePaths, success, fail, count, length);
}
});
},
// 采用递归的方式上传多张
upload_one_by_one(img_paths, success, fail, count, length) {
var self = this;
swan.uploadFile({
url: app.get_request_url("index", "ueditor"),
filePath: img_paths[count],
name: 'upfile',
formData: {
action: 'uploadimage',
path_type: self.data.editor_path_type
},
success: function (res) {
success++;
if (res.statusCode == 200) {
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
if (data.code == 0 && (data.data.url || null) != null) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = data.data.url;
self.setData({ extraction_data: temp_data });
} else {
app.showToast(data.msg);
}
}
},
fail: function (e) {
fail++;
},
complete: function (e) {
count++; // 下一张
if (count >= length) {
// 上传完毕,作一下提示
//app.showToast('上传成功' + success +'张', 'success');
} else {
// 递归调用,上传下一张
self.upload_one_by_one(img_paths, success, fail, count, length);
}
}
});
},
});

View File

@ -1,17 +1,30 @@
<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 s-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 个字符" />
<input type="text" name="alias" value="{{extraction_data.alias || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
</view>
<view class="form-gorup bg-white">
<view class="form-gorup-title">联系人<text class="form-group-tips-must">必填</text></view>
<input type="text" name="name" value="{=extraction_data.name || ''=}" placeholder-class="cr-ccc" class="cr-666" placeholder="联系人格式 2~16 个字符之间" />
<input type="text" name="name" value="{{extraction_data.name || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="联系人格式 2~16 个字符之间" />
</view>
<view class="form-gorup bg-white">
<view class="form-gorup-title">联系电话<text class="form-group-tips-must">必填</text></view>
<input type="text" name="tel" value="{=extraction_data.tel || ''=}" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
<input type="text" name="tel" value="{{extraction_data.tel || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
</view>
<view class="form-gorup bg-white">
@ -39,7 +52,7 @@
<view class="form-gorup bg-white">
<view class="form-gorup-title">详细地址<text class="form-group-tips-must">必填</text></view>
<input type="text" name="address" value="{=extraction_data.address || ''=}" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
<input type="text" name="address" value="{{extraction_data.address || ''}}" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
</view>
<view class="form-gorup bg-white">

View File

@ -483,4 +483,160 @@ button[disabled].bg-primary {
}
.coupon-container .item-disabled {
border: 1px solid #dfdfdf !important;
}
/**
* 公共样式
*/
.margin-top-xs {
margin-top: 5rpx;
}
.margin-top-sm {
margin-top: 10rpx;
}
.margin-top, .margin-top-default {
margin-top: 15rpx;
}
.margin-top-lg {
margin-top: 20rpx;
}
.margin-top-xl {
margin-top: 25rpx;
}
.margin-top-xxl {
margin-top: 30rpx;
}
.margin-right-xs {
margin-right: 5rpx;
}
.margin-right-sm {
margin-right: 10rpx;
}
.margin-right, .margin-right-default {
margin-right: 15rpx;
}
.margin-right-lg {
margin-right: 20rpx;
}
.margin-right-xl {
margin-right: 25rpx;
}
.margin-right-xxl {
margin-right: 30rpx;
}
.margin-left-xs {
margin-left: 5rpx;
}
.margin-left-sm {
margin-left: 10rpx;
}
.margin-left, .margin-left-default {
margin-left: 15rpx;
}
.margin-left-lg {
margin-left: 20rpx;
}
.margin-left-xl {
margin-left: 25rpx;
}
.margin-left-xxl {
margin-left: 30rpx;
}
.margin-bottom-xs {
margin-bottom: 5rpx;
}
.margin-bottom-sm {
margin-bottom: 10rpx;
}
.margin-bottom, .margin-bottom-default {
margin-bottom: 15rpx;
}
.margin-bottom-lg {
margin-bottom: 20rpx;
}
.margin-bottom-xl {
margin-bottom: 25rpx;
}
.margin-bottom-xxl {
margin-bottom: 30rpx;
}
.padding-top-xs {
padding-top: 5rpx;
}
.padding-top-sm {
padding-top: 10rpx;
}
.padding-top, .padding-top-default {
padding-top: 15rpx;
}
.padding-top-lg {
padding-top: 20rpx;
}
.padding-top-xl {
padding-top: 25rpx;
}
.padding-top-xxl {
padding-top: 30rpx;
}
.padding-right-xs {
padding-right: 5rpx;
}
.padding-right-sm {
padding-right: 10rpx;
}
.padding-right, .padding-right-default {
padding-right: 15rpx;
}
.padding-right-lg {
padding-right: 20rpx;
}
.padding-right-xl {
padding-right: 25rpx;
}
.padding-right-xxl {
padding-right: 30rpx;
}
.padding-left-xs {
padding-left: 5rpx;
}
.padding-left-sm {
padding-left: 10rpx;
}
.padding-left, .padding-left-default {
padding-left: 15rpx;
}
.padding-left-lg {
padding-left: 20rpx;
}
.padding-left-xl {
padding-left: 25rpx;
}
.padding-left-xxl {
padding-left: 30rpx;
}
.padding-bottom-xs {
padding-bottom: 5rpx;
}
.padding-bottom-sm {
padding-bottom: 10rpx;
}
.padding-bottom, .padding-bottom-default {
padding-bottom: 15rpx;
}
.padding-bottom-lg {
padding-bottom: 20rpx;
}
.padding-bottom-xl {
padding-bottom: 25rpx;
}
.padding-bottom-xxl {
padding-bottom: 30rpx;
}

View File

@ -351,7 +351,7 @@ Page({
} else if (this.data.common_site_type == 2 || (this.data.common_site_type == 4 && this.data.site_model == 2))
{
qq.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
url: '/pages/extraction-address/extraction-address?is_back=1&is_buy=1'
});
} else {
app.showToast('当前模式不允许使用地址');

View File

@ -6,15 +6,50 @@ Page({
data_list: [],
params: null,
is_default: 0,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
is_first: 1,
home_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({ params: params });
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
qq.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_extraction_address_position == 1)
{
qq.navigateTo({
url: '/pages/common/open-setting-location/open-setting-location'
});
}
},
onShow() {
qq.setNavigationBarTitle({ title: app.data.common_pages_title.extraction_address });
this.init();
// 是否需要选择地理位置
if(this.data.home_buy_extraction_address_position == 1)
{
// 首次不请求数据
if(this.data.is_first == 0)
{
this.user_location_init();
this.init();
}
} else {
this.init();
}
this.setData({ is_first: 0 });
},
// 初始化
@ -39,6 +74,22 @@ Page({
}
},
// 地址信息初始化
user_location_init() {
var result = qq.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
@ -47,11 +98,21 @@ Page({
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;
}
// 获取数据
qq.request({
url: app.get_request_url("extraction", "useraddress"),
method: "POST",
data: {},
data: data,
dataType: "json",
success: res => {
qq.hideLoading();

View File

@ -2,17 +2,27 @@
<view qq:if="{{data_list.length > 0}}">
<view class="item bg-white spacing-mb" qq:for="{{data_list}}" qq:key="key">
<view bindtap="address_conent_event" data-index="{{index}}">
<view class="base oh">
<text qq:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
<text>{{item.name}}</text>
<text class="fr">{{item.tel}}</text>
<view qq: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="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 class="oh">
<view class="base oh">
<text qq: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 qq: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>
<button qq: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>
</view>
</view>

View File

@ -1,12 +1,16 @@
.item {
padding: 10rpx 10rpx 0 10rpx;
padding: 10rpx 10rpx 0 10rpx;
}
.address-logo {
width: 140rpx;
height: 140rpx !important;
}
.base, .address, .operation {
padding: 20rpx 0;
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
@ -16,9 +20,9 @@
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
margin-left: 20rpx;
}

View File

@ -484,4 +484,160 @@ button[disabled].bg-primary {
}
.coupon-container .item-disabled {
border: 1px solid #dfdfdf !important;
}
/**
* 公共样式
*/
.margin-top-xs {
margin-top: 5rpx;
}
.margin-top-sm {
margin-top: 10rpx;
}
.margin-top, .margin-top-default {
margin-top: 15rpx;
}
.margin-top-lg {
margin-top: 20rpx;
}
.margin-top-xl {
margin-top: 25rpx;
}
.margin-top-xxl {
margin-top: 30rpx;
}
.margin-right-xs {
margin-right: 5rpx;
}
.margin-right-sm {
margin-right: 10rpx;
}
.margin-right, .margin-right-default {
margin-right: 15rpx;
}
.margin-right-lg {
margin-right: 20rpx;
}
.margin-right-xl {
margin-right: 25rpx;
}
.margin-right-xxl {
margin-right: 30rpx;
}
.margin-left-xs {
margin-left: 5rpx;
}
.margin-left-sm {
margin-left: 10rpx;
}
.margin-left, .margin-left-default {
margin-left: 15rpx;
}
.margin-left-lg {
margin-left: 20rpx;
}
.margin-left-xl {
margin-left: 25rpx;
}
.margin-left-xxl {
margin-left: 30rpx;
}
.margin-bottom-xs {
margin-bottom: 5rpx;
}
.margin-bottom-sm {
margin-bottom: 10rpx;
}
.margin-bottom, .margin-bottom-default {
margin-bottom: 15rpx;
}
.margin-bottom-lg {
margin-bottom: 20rpx;
}
.margin-bottom-xl {
margin-bottom: 25rpx;
}
.margin-bottom-xxl {
margin-bottom: 30rpx;
}
.padding-top-xs {
padding-top: 5rpx;
}
.padding-top-sm {
padding-top: 10rpx;
}
.padding-top, .padding-top-default {
padding-top: 15rpx;
}
.padding-top-lg {
padding-top: 20rpx;
}
.padding-top-xl {
padding-top: 25rpx;
}
.padding-top-xxl {
padding-top: 30rpx;
}
.padding-right-xs {
padding-right: 5rpx;
}
.padding-right-sm {
padding-right: 10rpx;
}
.padding-right, .padding-right-default {
padding-right: 15rpx;
}
.padding-right-lg {
padding-right: 20rpx;
}
.padding-right-xl {
padding-right: 25rpx;
}
.padding-right-xxl {
padding-right: 30rpx;
}
.padding-left-xs {
padding-left: 5rpx;
}
.padding-left-sm {
padding-left: 10rpx;
}
.padding-left, .padding-left-default {
padding-left: 15rpx;
}
.padding-left-lg {
padding-left: 20rpx;
}
.padding-left-xl {
padding-left: 25rpx;
}
.padding-left-xxl {
padding-left: 30rpx;
}
.padding-bottom-xs {
padding-bottom: 5rpx;
}
.padding-bottom-sm {
padding-bottom: 10rpx;
}
.padding-bottom, .padding-bottom-default {
padding-bottom: 15rpx;
}
.padding-bottom-lg {
padding-bottom: 20rpx;
}
.padding-bottom-xl {
padding-bottom: 25rpx;
}
.padding-bottom-xxl {
padding-bottom: 30rpx;
}

View File

@ -376,7 +376,7 @@ Page({
});
} else if (this.data.common_site_type == 2 || this.data.common_site_type == 4 && this.data.site_model == 2) {
tt.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
url: '/pages/extraction-address/extraction-address?is_back=1&is_buy=1'
});
} else {
app.showToast('当前模式不允许使用地址');

View File

@ -6,15 +6,50 @@ Page({
data_list: [],
params: null,
is_default: 0,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
is_first: 1,
home_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({ params: params });
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
tt.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_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 });
this.init();
// 是否需要选择地理位置
if(this.data.home_buy_extraction_address_position == 1)
{
// 首次不请求数据
if(this.data.is_first == 0)
{
this.user_location_init();
this.init();
}
} else {
this.init();
}
this.setData({ is_first: 0 });
},
// 初始化
@ -39,6 +74,22 @@ Page({
}
},
// 地址信息初始化
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
@ -48,10 +99,20 @@ Page({
});
// 获取数据
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("extraction", "useraddress"),
method: "POST",
data: {},
data: data,
dataType: "json",
success: res => {
tt.hideLoading();

View File

@ -2,17 +2,27 @@
<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}}">
<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 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="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 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>
<button tt: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>
</view>
</view>

View File

@ -1,12 +1,16 @@
.item {
padding: 10rpx 10rpx 0 10rpx;
padding: 10rpx 10rpx 0 10rpx;
}
.address-logo {
width: 140rpx;
height: 140rpx !important;
}
.base, .address, .operation {
padding: 20rpx 0;
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
@ -16,9 +20,9 @@
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
margin-left: 20rpx;
}

View File

@ -11,14 +11,19 @@ Page({
province_id: null,
city_id: null,
county_id: null,
editor_path_type: '',
default_province: "请选择省",
default_city: "请选择市",
default_county: "请选择区/县",
province_value: null,
city_value: null,
county_value: null,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
form_submit_disabled_status: false
},
@ -79,36 +84,40 @@ Page({
},
success: res => {
if (res.data.code == 0) {
var data = res.data.data || null;
var data = res.data.data;
var extraction_data = data.extraction_data || null;
self.setData({
extraction_data: data
}); // 数据设置
extraction_data: extraction_data || null,
editor_path_type: data.editor_path_type || '',
});
if (data != null) {
// 数据设置
if(extraction_data != null)
{
self.setData({
province_id: data.province || null,
city_id: data.city || null,
county_id: data.county || null
}); // 地理位置
province_id: extraction_data.province || null,
city_id: extraction_data.city || null,
county_id: extraction_data.county || null,
});
var lng = (data.lng || 0) <= 0 ? null : data.lng;
var lat = (data.lat || 0) <= 0 ? null : data.lat;
if (lng != null && lat != null) {
self.setData({
user_location: {
lng: lng,
lat: lat,
address: data.address || ''
}
});
// 地理位置
var lng = extraction_data.lng || null;
var lat = extraction_data.lat || null;
if (lng != null && lat != null)
{
self.setData({ user_location: {
lng: lng,
lat: lat,
address: extraction_data.address || '',
}});
}
} // 获取城市、区县
}
// 获取城市、区县
self.get_city_list();
self.get_county_list(); // 半秒后初始化数据
self.get_county_list();
// 半秒后初始化数据
setTimeout(function () {
self.init_region_value();
}, 500);
@ -332,35 +341,26 @@ Page({
// 数据提交
form_submit(e) {
var self = this; // 表单数据
var self = this;
// 表单数据
var form_data = e.detail.value;
var form_data = e.detail.value; // 数据校验
// 数据校验
var validation = [
{ fields: "name", msg: "请填写联系人" },
{ fields: "tel", msg: "请填写联系电话" },
{ fields: "province", msg: "请选择省份" },
{ fields: "city", msg: "请选择城市" },
{ fields: "county", msg: "请选择区县" },
{ fields: "address", msg: "请填写详细地址" },
{ fields: "lng", msg: "请选择地理位置" },
{ fields: "lat", msg: "请选择地理位置" }
];
var validation = [{
fields: "name",
msg: "请填写联系人"
}, {
fields: "tel",
msg: "请填写联系电话"
}, {
fields: "province",
msg: "请选择省份"
}, {
fields: "city",
msg: "请选择城市"
}, {
fields: "county",
msg: "请选择区县"
}, {
fields: "address",
msg: "请填写详细地址"
}, {
fields: "lng",
msg: "请输入经度"
}, {
fields: "lat",
msg: "请输入纬度"
}];
// logo
form_data['logo'] = 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; // 地理位置
@ -430,6 +430,87 @@ Page({
app.showToast("服务器请求出错");
}
});
}
},
// 上传图片预览
upload_show_event(e) {
tt.previewImage({
current: this.data.extraction_data.logo,
urls: [this.data.extraction_data.logo],
});
},
// 图片删除
upload_delete_event(e) {
var self = this;
tt.showModal({
title: '温馨提示',
content: '删除后不可恢复、继续吗?',
success(res) {
if (res.confirm) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = '';
self.setData({
extraction_data: temp_data,
});
}
}
});
},
// 文件上传
file_upload_event(e) {
var self = this;
tt.chooseImage({
count: 1,
success(res) {
var success = 0;
var fail = 0;
var length = res.tempFilePaths.length;
var count = 0;
self.upload_one_by_one(res.tempFilePaths, success, fail, count, length);
}
});
},
// 采用递归的方式上传多张
upload_one_by_one(img_paths, success, fail, count, length) {
var self = this;
tt.uploadFile({
url: app.get_request_url("index", "ueditor"),
filePath: img_paths[count],
name: 'upfile',
formData: {
action: 'uploadimage',
path_type: self.data.editor_path_type
},
success: function (res) {
success++;
if (res.statusCode == 200) {
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
if (data.code == 0 && (data.data.url || null) != null) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = data.data.url;
self.setData({ extraction_data: temp_data });
} else {
app.showToast(data.msg);
}
}
},
fail: function (e) {
fail++;
},
complete: function (e) {
count++; // 下一张
if (count >= length) {
// 上传完毕,作一下提示
//app.showToast('上传成功' + success +'张', 'success');
} else {
// 递归调用,上传下一张
self.upload_one_by_one(img_paths, success, fail, count, length);
}
}
});
},
});

View File

@ -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",

View File

@ -483,4 +483,159 @@ button[disabled].bg-primary {
}
.coupon-container .item-disabled {
border: 1px solid #dfdfdf !important;
}
/**
* 公共样式
*/
.margin-top-xs {
margin-top: 5rpx;
}
.margin-top-sm {
margin-top: 10rpx;
}
.margin-top, .margin-top-default {
margin-top: 15rpx;
}
.margin-top-lg {
margin-top: 20rpx;
}
.margin-top-xl {
margin-top: 25rpx;
}
.margin-top-xxl {
margin-top: 30rpx;
}
.margin-right-xs {
margin-right: 5rpx;
}
.margin-right-sm {
margin-right: 10rpx;
}
.margin-right, .margin-right-default {
margin-right: 15rpx;
}
.margin-right-lg {
margin-right: 20rpx;
}
.margin-right-xl {
margin-right: 25rpx;
}
.margin-right-xxl {
margin-right: 30rpx;
}
.margin-left-xs {
margin-left: 5rpx;
}
.margin-left-sm {
margin-left: 10rpx;
}
.margin-left, .margin-left-default {
margin-left: 15rpx;
}
.margin-left-lg {
margin-left: 20rpx;
}
.margin-left-xl {
margin-left: 25rpx;
}
.margin-left-xxl {
margin-left: 30rpx;
}
.margin-bottom-xs {
margin-bottom: 5rpx;
}
.margin-bottom-sm {
margin-bottom: 10rpx;
}
.margin-bottom, .margin-bottom-default {
margin-bottom: 15rpx;
}
.margin-bottom-lg {
margin-bottom: 20rpx;
}
.margin-bottom-xl {
margin-bottom: 25rpx;
}
.margin-bottom-xxl {
margin-bottom: 30rpx;
}
.padding-top-xs {
padding-top: 5rpx;
}
.padding-top-sm {
padding-top: 10rpx;
}
.padding-top, .padding-top-default {
padding-top: 15rpx;
}
.padding-top-lg {
padding-top: 20rpx;
}
.padding-top-xl {
padding-top: 25rpx;
}
.padding-top-xxl {
padding-top: 30rpx;
}
.padding-right-xs {
padding-right: 5rpx;
}
.padding-right-sm {
padding-right: 10rpx;
}
.padding-right, .padding-right-default {
padding-right: 15rpx;
}
.padding-right-lg {
padding-right: 20rpx;
}
.padding-right-xl {
padding-right: 25rpx;
}
.padding-right-xxl {
padding-right: 30rpx;
}
.padding-left-xs {
padding-left: 5rpx;
}
.padding-left-sm {
padding-left: 10rpx;
}
.padding-left, .padding-left-default {
padding-left: 15rpx;
}
.padding-left-lg {
padding-left: 20rpx;
}
.padding-left-xl {
padding-left: 25rpx;
}
.padding-left-xxl {
padding-left: 30rpx;
}
.padding-bottom-xs {
padding-bottom: 5rpx;
}
.padding-bottom-sm {
padding-bottom: 10rpx;
}
.padding-bottom, .padding-bottom-default {
padding-bottom: 15rpx;
}
.padding-bottom-lg {
padding-bottom: 20rpx;
}
.padding-bottom-xl {
padding-bottom: 25rpx;
}
.padding-bottom-xxl {
padding-bottom: 30rpx;
}

View File

@ -352,7 +352,7 @@ Page({
} else if (this.data.common_site_type == 2 || (this.data.common_site_type == 4 && this.data.site_model == 2))
{
wx.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
url: '/pages/extraction-address/extraction-address?is_back=1&is_buy=1'
});
} else {
app.showToast('当前模式不允许使用地址');

View File

@ -6,15 +6,50 @@ Page({
data_list: [],
params: null,
is_default: 0,
user_location_cache_key: app.data.cache_userlocation_key,
user_location: null,
is_first: 1,
home_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({ params: params });
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
wx.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_extraction_address_position == 1)
{
wx.navigateTo({
url: '/pages/common/open-setting-location/open-setting-location'
});
}
},
onShow() {
wx.setNavigationBarTitle({ title: app.data.common_pages_title.extraction_address });
this.init();
// 是否需要选择地理位置
if(this.data.home_buy_extraction_address_position == 1)
{
// 首次不请求数据
if(this.data.is_first == 0)
{
this.user_location_init();
this.init();
}
} else {
this.init();
}
this.setData({ is_first: 0 });
},
// 初始化
@ -39,6 +74,22 @@ Page({
}
},
// 地址信息初始化
user_location_init() {
var result = wx.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
@ -48,10 +99,20 @@ Page({
});
// 获取数据
var data = {};
// 是否有坐标
if((this.data.user_location || null) != null)
{
data['lng'] = this.data.user_location.lng;
data['lat'] = this.data.user_location.lat;
}
// 请求接口
wx.request({
url: app.get_request_url("extraction", "useraddress"),
method: "POST",
data: {},
data: data,
dataType: "json",
success: res => {
wx.hideLoading();

View File

@ -1,18 +1,28 @@
<view class="page">
<view wx:if="{{data_list.length > 0}}">
<view class="item bg-white spacing-mb" wx:for="{{data_list}}" wx:key="key">
<view bindtap="address_conent_event" data-index="{{index}}">
<view class="base oh">
<text wx:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
<text>{{item.name}}</text>
<text class="fr">{{item.tel}}</text>
<view bindtap="address_conent_event" data-index="{{index}}" class="oh">
<view wx: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="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 class="oh">
<view class="base oh">
<text wx: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 wx: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>
<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>
</view>
</view>

View File

@ -1,12 +1,16 @@
.item {
padding: 10rpx 10rpx 0 10rpx;
padding: 10rpx 10rpx 0 10rpx;
}
.address-logo {
width: 140rpx;
height: 140rpx !important;
}
.base, .address, .operation {
padding: 20rpx 0;
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
@ -16,9 +20,9 @@
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
margin-left: 20rpx;
}

View File

@ -11,6 +11,7 @@ Page({
province_id: null,
city_id: null,
county_id: null,
editor_path_type: '',
default_province: "请选择省",
default_city: "请选择市",
@ -76,29 +77,31 @@ Page({
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
if (res.data.code == 0) {
var data = res.data.data || null;
var data = res.data.data;
var extraction_data = data.extraction_data || null;
self.setData({
extraction_data: data,
extraction_data: extraction_data || null,
editor_path_type: data.editor_path_type || '',
});
// 数据设置
if(data != null)
if(extraction_data != null)
{
self.setData({
province_id: data.province || null,
city_id: data.city || null,
county_id: data.county || null,
province_id: extraction_data.province || null,
city_id: extraction_data.city || null,
county_id: extraction_data.county || null,
});
// 地理位置
var lng = data.lng || null;
var lat = data.lat || null;
var lng = extraction_data.lng || null;
var lat = extraction_data.lat || null;
if (lng != null && lat != null)
{
self.setData({ user_location: {
lng: lng,
lat: lat,
address: data.address || '',
address: extraction_data.address || '',
}});
}
}
@ -323,6 +326,10 @@ Page({
{ fields: "lat", msg: "请选择地理位置" }
];
// logo
form_data['logo'] = 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;
@ -400,4 +407,86 @@ Page({
}
});
},
// 上传图片预览
upload_show_event(e) {
wx.previewImage({
current: this.data.extraction_data.logo,
urls: [this.data.extraction_data.logo],
});
},
// 图片删除
upload_delete_event(e) {
var self = this;
wx.showModal({
title: '温馨提示',
content: '删除后不可恢复、继续吗?',
success(res) {
if (res.confirm) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = '';
self.setData({
extraction_data: temp_data,
});
}
}
});
},
// 文件上传
file_upload_event(e) {
var self = this;
wx.chooseImage({
count: 1,
success(res) {
var success = 0;
var fail = 0;
var length = res.tempFilePaths.length;
var count = 0;
self.upload_one_by_one(res.tempFilePaths, success, fail, count, length);
}
});
},
// 采用递归的方式上传多张
upload_one_by_one(img_paths, success, fail, count, length) {
var self = this;
wx.uploadFile({
url: app.get_request_url("index", "ueditor"),
filePath: img_paths[count],
name: 'upfile',
formData: {
action: 'uploadimage',
path_type: self.data.editor_path_type
},
success: function (res) {
success++;
if (res.statusCode == 200) {
var data = (typeof (res.data) == 'object') ? res.data : JSON.parse(res.data);
if (data.code == 0 && (data.data.url || null) != null) {
var temp_data = self.data.extraction_data || {};
temp_data['logo'] = data.data.url;
self.setData({ extraction_data: temp_data });
} else {
app.showToast(data.msg);
}
}
},
fail: function (e) {
fail++;
},
complete: function (e) {
count++; // 下一张
if (count >= length) {
// 上传完毕,作一下提示
//app.showToast('上传成功' + success +'张', 'success');
} else {
// 递归调用,上传下一张
self.upload_one_by_one(img_paths, success, fail, count, length);
}
}
});
},
});

View File

@ -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 wx: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 个字符" />

View File

@ -0,0 +1,209 @@
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_buy_extraction_address_position: 0,
},
onLoad(params) {
this.setData({
params: params,
home_buy_extraction_address_position: app.get_config('config.home_buy_extraction_address_position', 0),
});
},
onReady: function () {
// 清除位置缓存信息
wx.removeStorage({key: this.data.user_location_cache_key});
// 是否获取位置
if((this.data.params.is_buy || 0) == 1 && this.data.home_buy_extraction_address_position == 1)
{
wx.navigateTo({
url: '/pages/common/open-setting-location/open-setting-location'
});
}
},
onShow() {
wx.setNavigationBarTitle({ title: app.data.common_pages_title.extraction_address });
// 是否需要选择地理位置
if(this.data.home_buy_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)) {
wx.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
wx.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;
}
// 请求接口
wx.request({
url: app.get_request_url("switchinfo", "extraction", "distribution"),
method: "POST",
data: data,
dataType: "json",
success: res => {
wx.hideLoading();
wx.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: () => {
wx.hideLoading();
wx.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) {
wx.setStorage({
key: app.data.cache_buy_user_address_select_key,
data: this.data.data_list[index]
});
wx.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;
wx.showLoading({ title: "处理中..." });
wx.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 => {
wx.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: () => {
wx.hideLoading();
app.showToast("服务器请求出错");
}
});
},
});

View File

@ -0,0 +1,3 @@
{
"enablePullDownRefresh": true
}

View File

@ -0,0 +1,40 @@
<view class="page">
<view wx:if="{{data_list.length > 0}}">
<view class="item bg-white spacing-mb" wx:for="{{data_list}}" wx:key="key">
<view bindtap="address_conent_event" data-index="{{index}}" class="oh">
<view wx: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 wx: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 wx: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>
<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>
</view>
</view>
<view wx:if="{{data_list.length == 0}}">
<import src="/pages/common/nodata.wxml" />
<template is="nodata" data="{{status: data_list_loding_status}}"></template>
</view>
<import src="/pages/common/bottom_line.wxml" />
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
</view>

View File

@ -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 .map-submit {
margin-left: 20rpx;
}