自提地址新增距离排序

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

@ -22,6 +22,15 @@
</select>
</div>
<div class="am-form-group">
<label>{{$data.home_buy_extraction_address_position.name}}<span class="am-form-group-label-tips">{{$data.home_buy_extraction_address_position.describe}}</span></label>
<select name="{{$data.home_buy_extraction_address_position.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.home_buy_extraction_address_position.error_tips}}" required>
{{foreach $common_close_open_list as $v}}
<option value="{{$v.value}}" {{if isset($data['home_buy_extraction_address_position']['value']) and $data['home_buy_extraction_address_position']['value'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</div>
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
<input type="hidden" name="nav_type" value="{{$nav_type}}" />
<input type="hidden" name="view_type" value="{{$view_type}}" />

View File

@ -1,2 +1,9 @@
<!-- 继承公共的 form -->
{{extend name="public/module/form" /}}
{{extend name="public/module/form" /}}
<!-- 表单顶部操作栏 -->
{{block name="form_operate_top"}}
<a href="{{:MyUrl('admin/useraddress/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
<!-- 父级内容 -->
{__block__}
{{/block}}

View File

@ -9,14 +9,21 @@
<span class="am-text-default">用户地址{{if empty($data['id'])}}添加{{else /}}编辑{{/if}}</span>
<a href="{{:MyUrl('admin/useraddress/index', $params)}}" class="am-fr am-text-sm am-margin-top-xs am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-alert am-alert-secondary am-nbfc am-margin-vertical-0">
<img src="{{$data.user.avatar}}" alt="{{$data.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left am-margin-right-xs am-margin-bottom-0" width="75" height="75" />
<ul class="user-base">
<li>名称:{{if empty($data['user']['username'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.username}}{{/if}}</li>
<li>昵称:{{if empty($data['user']['nickname'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.nickname}}{{/if}}</li>
<li>手机:{{if empty($data['user']['mobile'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.mobile}}{{/if}}</li>
<li>邮箱:{{if empty($data['user']['email'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.email}}{{/if}}</li>
</ul>
{{if !empty($data) and !empty($data['user'])}}
<div class="am-alert am-alert-secondary am-nbfc am-margin-top-0">
<img src="{{$data.user.avatar}}" alt="{{$data.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left am-margin-right-xs am-margin-bottom-0" width="75" height="75" />
<ul class="user-base">
<li>名称:{{if empty($data['user']['username'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.username}}{{/if}}</li>
<li>昵称:{{if empty($data['user']['nickname'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.nickname}}{{/if}}</li>
<li>手机:{{if empty($data['user']['mobile'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.mobile}}{{/if}}</li>
<li>邮箱:{{if empty($data['user']['email'])}}<span class="cr-ccc"></span>{{else /}}{{$data.user.email}}{{/if}}</li>
</ul>
</div>
{{/if}}
<div class="am-form-group">
<label>用户id<span class="am-form-group-label-tips-must">必填</span></label>
<input type="number" name="user_id" placeholder="用户id" min="0" data-validation-message="请填写用户id" class="am-radius" {{if !empty($data['user_id'])}} value="{{$data.user_id}}"{{/if}} required />
</div>
<div class="am-form-group">
@ -90,7 +97,6 @@
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
<input type="hidden" name="id" {{if !empty($data['id'])}} value="{{$data.id}}"{{/if}} />
<input type="hidden" name="user_id" {{if !empty($data['user_id'])}} value="{{$data.user_id}}"{{/if}} />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
</div>
</form>

View File

@ -134,7 +134,9 @@ class UserAddress extends Common
*/
public function Extraction()
{
return ConfigService::SiteTypeExtractionAddressList();
$params = $this->data_post;
$params['user'] = $this->user;
return ConfigService::SiteTypeExtractionAddressList(null, $params);
}
/**

View File

@ -11,6 +11,43 @@
// 应用公共文件
/**
* 文件快速排序
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-03-09
* @desc description
* @param [array] $data [需要排序的数据(选择一个基准元素,将待排序分成小和打两罐部分,以此类推递归的排序划分两罐部分)]
* @param [array] [数组字段]
* @return [array] [排序好的数据,从小到大排序]
*/
function ArrayQuickSort($data, $field)
{
if(!empty($data) && is_array($data))
{
$len = count($data);
if($len <= 1) return $data;
$base = $data[0];
$left_array = array();
$right_array = array();
for($i=1; $i<$len; $i++)
{
if($base[$field] > $data[$i][$field])
{
$left_array[] = $data[$i];
} else {
$right_array[] = $data[$i];
}
}
if(!empty($left_array)) $left_array = ArrayQuickSort($left_array, $field);
if(!empty($right_array)) $right_array = ArrayQuickSort($right_array, $field);
return array_merge($left_array, array($base), $right_array);
}
}
/**
* 是否base64加密的字符串
* @author Devil

View File

@ -7,7 +7,7 @@
<ul class="am-avg-sm-3 am-avg-md-4 am-avg-lg-4 left-main-quick-content">
{{foreach $nav_quick as $nav}}
{{if !empty($nav['images_url']) and !empty($nav['name'])}}
<li class="am-text-center am-padding-sm {{if isset($nav['class_name'])}}{{$nav.class_name}}{{/if}}">
<li class="am-text-center am-padding-sm {{if isset($nav['class_name'])}}{{$nav.class_name}}{{/if}}" {{if !empty($nav['data_value'])}}data-value="{{$nav.data_value}}"{{/if}}>
{{if isset($nav['event_type']) and isset($nav['event_value']) and in_array($nav['event_type'], [3,4])}}
{{switch nav.event_type}}
{{case 3}}

View File

@ -65,6 +65,7 @@ class BaseService
// 订单相关
'home_is_enable_order_bulk_pay' => (int) MyC('home_is_enable_order_bulk_pay', 0),
'home_buy_extraction_address_position'=> (int) MyC('home_buy_extraction_address_position', 0),
// 用户中心相关
'common_user_center_notice' => MyC('common_user_center_notice', null, true),

View File

@ -339,9 +339,10 @@ class ConfigService
* @version 1.0.0
* @date 2019-11-13
* @desc description
* @param [string] $value [自提的配置数据]
* @param [string] $value [自提的配置数据]
* @param [array] $params [输入参数]
*/
public static function SiteTypeExtractionAddressList($value = null)
public static function SiteTypeExtractionAddressList($value = null, $params = [])
{
// 未指定内容则从缓存读取
if(empty($value))
@ -363,7 +364,10 @@ class ConfigService
{
foreach($data as &$v)
{
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
if(array_key_exists('logo', $v))
{
$v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']);
}
}
}
@ -375,6 +379,27 @@ class ConfigService
'data' => &$data,
]);
// 数据距离处理
if(!empty($data) && is_array($data) && !empty($params) && !empty($params['lng']) && !empty($params['lat']))
{
$unit = 'km';
foreach($data as &$v)
{
if(!empty($v) && is_array($v))
{
// 计算距离
$v['distance_value'] = \base\GeoTransUtil::GetDistance($v['lng'], $v['lat'], $params['lng'], $params['lat'], 2);
$v['distance_unit'] = $unit;
}
}
// 根据距离排序
if(count($data) > 1)
{
$data = ArrayQuickSort($data, 'distance_value');
}
}
return DataReturn('操作成功', 0, $data);
}

View File

@ -2094,17 +2094,12 @@ class GoodsService
// 有规格值
if(!empty($params['spec']))
{
$value = [];
// 规格不为数组则为json字符串
if(!is_array($params['spec']))
{
$params['spec'] = json_decode(htmlspecialchars_decode($params['spec']), true);
}
foreach($params['spec'] as $v)
{
$value[] = $v['value'];
}
$where['value'] = $value;
$where['value'] = array_column($params['spec'], 'value');
// 获取规格值基础值id
$ids = Db::name('GoodsSpecValue')->where($where)->column('goods_spec_base_id');
@ -2217,16 +2212,11 @@ class GoodsService
];
// 规格不为数组则为json字符串
$value = [];
if(!is_array($params['spec']))
{
$params['spec'] = json_decode(htmlspecialchars_decode($params['spec']), true);
}
foreach($params['spec'] as $v)
{
$value[] = $v['value'];
}
$where['value'] = $value;
$where['value'] = array_column($params['spec'], 'value');
// 获取规格值基础值id
$ids = Db::name('GoodsSpecValue')->where($where)->column('goods_spec_base_id');

View File

@ -312,6 +312,7 @@ class QuickNavService
// 快捷导航钩子
// web端数据参数可以自定义新增 class_name 名称、方便非url事件使用js控制点击事件
// 支持标签自定义数据值 data_value 名称、方便自定义事件响应需要依赖的数据
$hook_name = 'plugins_service_quick_navigation_'.$platform;
Hook::listen($hook_name, [
'hook_name' => $hook_name,

View File

@ -47,6 +47,7 @@ return array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\share\\Hook',
2 => 'app\\plugins\\points\\Hook',
3 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_navigation_header_handle' =>
array (
@ -56,10 +57,12 @@ return array (
'plugins_service_users_center_left_menu_handle' =>
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_header_navigation_top_right_handle' =>
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_warehouse_goods_inventory_deduct' =>
array (
@ -113,10 +116,12 @@ return array (
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\points\\Hook',
2 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_system_begin' =>
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\themeswitch\\Hook',
),
'plugins_view_buy_form_inside' =>
array (
@ -136,10 +141,12 @@ return array (
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\points\\Hook',
2 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_order_aftersale_audit_handle_end' =>
array (
0 => 'app\\plugins\\store\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_goods_buy_nav_button_handle' =>
array (
@ -161,34 +168,42 @@ return array (
'plugins_service_quick_navigation_pc' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_h5' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_weixin' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_alipay' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_baidu' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_qq' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_quick_navigation_toutiao' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_goods_handle_end' =>
array (
0 => 'app\\plugins\\points\\Hook',
1 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_buy_group_goods_handle' =>
array (
@ -198,5 +213,37 @@ return array (
array (
0 => 'app\\plugins\\points\\Hook',
),
'plugins_service_site_extraction_address_list' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_goods_spec_extends_handle' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_view_admin_user_save' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_user_save_handle' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_service_goods_spec_base' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_view_goods_detail_panel_price_top' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_module_form_admin_user_index' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
'plugins_module_form_admin_user_detail' =>
array (
0 => 'app\\plugins\\distribution\\Hook',
),
);
?>

View File

@ -569,7 +569,7 @@ button.colorpicker-submit img {
background: #e8e6e6;
min-width: 100px;
position: sticky;
z-index: 1;
z-index: 1011;
top: 0;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-xxxl {
@ -605,11 +605,11 @@ button.colorpicker-submit img {
.am-table-scrollable-horizontal .am-table tr td.am-grid-fixed-left,
.am-table-scrollable-horizontal .am-table tr td.am-grid-fixed-right {
background: #fff;
z-index: 2;
z-index: 1011;
}
.am-table-scrollable-horizontal .am-table tr th.am-grid-fixed-left,
.am-table-scrollable-horizontal .am-table tr th.am-grid-fixed-right {
z-index: 3;
z-index: 1012;
}
.am-table-scrollable-horizontal .am-table tr .am-grid-fixed-left {
-webkit-box-shadow: 1px 0px 1px #ddd;

File diff suppressed because one or more lines are too long

View File

@ -458,7 +458,7 @@ ul.am-dropdown-content > .am-active > a:focus,
@media only screen and (max-width: 641px) {
.common-login-modal {
height: 410px;
top: calc(100% - 410px);
top: calc(50% - 210px);
}
}

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;
}