小程序端地址新增身份证信息填写、后台新增用户地址管理
@ -297,6 +297,9 @@ textarea {
|
||||
.form-container .form-gorup-text {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.form-container .form-gorup .switch {
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单图片上传
|
||||
|
||||
@ -24,6 +24,9 @@ App({
|
||||
// 用户传入信息缓存key
|
||||
cache_launch_info_key: "cache_shop_launch_info_key",
|
||||
|
||||
// 获取位置选择缓存key
|
||||
cache_userlocation_key: "cache_userlocation_key",
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: "/images/default-user.png",
|
||||
|
||||
@ -71,7 +74,7 @@ App({
|
||||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
request_url: 'http://shopxo.com/',
|
||||
request_url: 'http://dev.shopxo.net/',
|
||||
request_url: 'https://dev.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
@ -863,11 +866,34 @@ App({
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标)
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* 火星坐标GCJ02到百度坐标BD-09(高德,谷歌,腾讯坐标 -> 百度)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_gcj_to_bd(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng;
|
||||
let y = lat;
|
||||
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||||
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||||
let lngs = z * Math.cos(theta) + 0.0065;
|
||||
let lats = z * Math.sin(theta) + 0.006;
|
||||
return {
|
||||
lng: lngs,
|
||||
lat: lats
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(百度 -> 高德,谷歌,腾讯坐标)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_bd_to_gcj(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng - 0.0065;
|
||||
let y = lat - 0.006;
|
||||
@ -894,11 +920,15 @@ App({
|
||||
this.showToast('坐标有误');
|
||||
return false;
|
||||
}
|
||||
if((address || null) == null) {
|
||||
this.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 转换坐标打开位置
|
||||
var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat));
|
||||
var position = this.map_bd_to_gcj(lng, lat);
|
||||
my.openLocation({
|
||||
name: name || '',
|
||||
name: name || '当前位置',
|
||||
address: address || '',
|
||||
scale: scale || 18,
|
||||
longitude: position.lng,
|
||||
|
||||
BIN
sourcecode/alipay/images/default-idcard-back.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sourcecode/alipay/images/default-idcard-front.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
@ -392,7 +392,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@ Page({
|
||||
data: {
|
||||
params: null,
|
||||
is_show_open_setting: false,
|
||||
cache_key: 'cache_userlocation_key',
|
||||
cache_key: app.data.cache_userlocation_key,
|
||||
},
|
||||
|
||||
onLoad: function (params) {
|
||||
@ -20,6 +20,9 @@ Page({
|
||||
choose_location() {
|
||||
my.chooseLocation({
|
||||
success: res => {
|
||||
var position = app.map_gcj_to_bd(res.longitude, res.latitude);
|
||||
res.longitude = position.lng;
|
||||
res.latitude = position.lat;
|
||||
my.setStorageSync({key: this.data.cache_key, data: res});
|
||||
my.navigateBack();
|
||||
},
|
||||
|
||||
@ -115,7 +115,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -20,7 +20,7 @@ Page({
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
|
||||
user_location_cache_key: 'cache_userlocation_key',
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
|
||||
form_submit_disabled_status: false,
|
||||
@ -92,8 +92,8 @@ Page({
|
||||
});
|
||||
|
||||
// 地理位置
|
||||
var lng = (data.lng || 0) <= 0 ? null : data.lng;
|
||||
var lat = (data.lat || 0) <= 0 ? null : data.lat;
|
||||
var lng = data.lng || null;
|
||||
var lat = data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
@ -175,7 +175,6 @@ Page({
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
console.log(self.data.province_id)
|
||||
if (self.data.province_id) {
|
||||
my.request({
|
||||
url: app.get_request_url("index", "region"),
|
||||
@ -330,11 +329,22 @@ Page({
|
||||
form_data["county"] = self.data.county_id;
|
||||
|
||||
// 地理位置
|
||||
if ((self.data.user_location || null) != null)
|
||||
{
|
||||
form_data["lng"] = self.data.user_location.lng || 0;
|
||||
form_data["lat"] = self.data.user_location.lat || 0;
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.extraction_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.extraction_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.extraction_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
|
||||
@ -95,7 +95,7 @@ Page({
|
||||
var data = this.data.extraction;
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -1,34 +1,39 @@
|
||||
/* 填写信息 */
|
||||
.person-box{
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.person-box input{
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.addressee .addressee-name{
|
||||
width: 250rpx;
|
||||
/*
|
||||
* 三级联动
|
||||
*/
|
||||
.select-address {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.addressee .addressee-phone{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 250rpx);
|
||||
}
|
||||
/* 三级联动 */
|
||||
.select-address{
|
||||
box-sizing: border-box;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.select-address .section{
|
||||
width: 33%;
|
||||
.select-address .section {
|
||||
width: 33.33%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.select-address .section:not(:first-child) {
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
/* end 三级联动 */
|
||||
.addressee-address{
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
/*
|
||||
* 表单
|
||||
*/
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-bottom {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* 身份信息
|
||||
*/
|
||||
.idcard-container {
|
||||
background: #e0e0e0;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.idcard-container .form-upload-data .item image {
|
||||
width: 256rpx;
|
||||
height: 170rpx;
|
||||
border: 1px dashed #c2c2c2;
|
||||
}
|
||||
@ -1,39 +1,88 @@
|
||||
<form onSubmit="form_submit" a:if="{{data_list_loding_status == 0}}">
|
||||
<view class="person-box bg-white">
|
||||
<view class="addressee br-b oh">
|
||||
<input class="addressee-name fl br-r" name="name" type="text" value="{{name}}" placeholder="姓名" />
|
||||
<input class="addressee-phone fl" name="tel" type="number" value="{{tel}}" placeholder="手机号" />
|
||||
<view class="page">
|
||||
<form onSubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{address_data.alias || ''}}" maxlength="16" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
</view>
|
||||
|
||||
<!-- 地区选择 -->
|
||||
<view class="select-address br-b oh">
|
||||
<view class="section fl br-r">
|
||||
<picker name="province" onChange="select_province" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-888' : '' }}">{{province_list[province_value].name || default_province}}</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="{{address_data.name || ''}}" maxlength="16" 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="{{address_data.tel || ''}}" maxlength="30" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">省市区<text class="form-group-tips-must">必选</text></view>
|
||||
<view class="select-address oh">
|
||||
<view class="section fl">
|
||||
<picker name="province" onChange="select_province_event" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-ccc' : 'cr-666' }}">{{province_list[province_value].name || default_province}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="section fl br-r">
|
||||
<picker a:if="{{(province_id || null) != null}}" name="city" onChange="select_city" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-888' : '' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text a:else class="cr-888" onTap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker a:if="{{(city_id || null) != null}}" name="county" onChange="select_county" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-888' : '' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
<picker a:if="{{(province_id || null) != null}}" name="city" onChange="select_city_event" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-ccc' : 'cr-666' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text a:else class="cr-888" onTap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
<text a:else class="cr-ccc" onTap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker a:if="{{(city_id || null) != null}}" name="county" onChange="select_county_event" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-ccc' : 'cr-666' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
</picker>
|
||||
<text a:else class="cr-ccc" onTap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end地区选择 -->
|
||||
|
||||
<input name="address" class="addressee-address" type="text" value="{{address}}" placeholder="详细地址" />
|
||||
</view>
|
||||
<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="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none">保存</button>
|
||||
</form>
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view onTap="choose_location_event" class="form-gorup-text">
|
||||
<view a:if="{{(user_location || null) == null && (address_data.address || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view a:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view a:if="{{data_list_loding_status != 0}}">
|
||||
<import src="/pages/common/nodata.axml" />
|
||||
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
<view class="switch">
|
||||
<switch name="is_default" checked="{{address_data.is_default == 1 ? true : false}}" color="#04BE02" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 身份证信息 -->
|
||||
<view class="idcard-container">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">身份证姓名<text class="form-group-tips">选填,请务必与上传的身份证件姓名保持一致</text></view>
|
||||
<input type="text" name="idcard_name" value="{{address_data.idcard_name || ''}}" maxlength="16" 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">选填,请务必与上传的身份证件号码保持一致</text></view>
|
||||
<input type="idcard" name="idcard_number" value="{{address_data.idcard_number || ''}}" maxlength="18" placeholder-class="cr-ccc" class="cr-666" placeholder="身份证号码格式最多18个字符" />
|
||||
</view>
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">身份证照片<text class="form-group-tips">选填,请使用身份证原件拍摄,图片要清晰</text></view>
|
||||
<view class="form-upload-data">
|
||||
<view class="item fl">
|
||||
<text a:if="{{(idcard_images_data.idcard_front || null) != null}}" class="delete-icon" onTap="upload_delete_event" data-value="idcard_front">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_front || null) != null ? idcard_images_data.idcard_front : '/images/default-idcard-front.jpg'}}" data-value="idcard_front" mode="aspectFill" onTap="file_upload_event" />
|
||||
</view>
|
||||
<view class="item fl">
|
||||
<text a:if="{{(idcard_images_data.idcard_back || null) != null}}" class="delete-icon" onTap="upload_delete_event" data-value="idcard_back">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_back || null) != null ? idcard_images_data.idcard_back : '/images/default-idcard-back.jpg'}}" data-value="idcard_back" mode="aspectFill" onTap="file_upload_event" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none" disabled="{{form_submit_disabled_status}}">保存</button>
|
||||
</form>
|
||||
</view>
|
||||
@ -1,22 +1,18 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '处理错误',
|
||||
params: null,
|
||||
|
||||
name : '',
|
||||
tel : '',
|
||||
address: '',
|
||||
is_default: 0,
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
editor_path_type: '',
|
||||
address_data: null,
|
||||
province_list: [],
|
||||
city_list: [],
|
||||
county_list: [],
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
idcard_images_data: {},
|
||||
|
||||
default_province: "请选择省",
|
||||
default_city: "请选择市",
|
||||
@ -25,13 +21,18 @@ Page({
|
||||
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,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
onReady: function () {
|
||||
if((this.data.params.id || null) == null)
|
||||
{
|
||||
var title = app.data.common_pages_title.user_address_save_add;
|
||||
@ -39,9 +40,16 @@ Page({
|
||||
var title = app.data.common_pages_title.user_address_save_edit;
|
||||
}
|
||||
my.setNavigationBar({title: title});
|
||||
|
||||
// 清除位置缓存信息
|
||||
my.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.user_location_init();
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
@ -56,19 +64,8 @@ Page({
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
this.setData({
|
||||
data_list_loding_status: 0,
|
||||
data_list_loding_msg: '',
|
||||
});
|
||||
|
||||
// 获取地址数据
|
||||
if((this.data.params.id || null) != null)
|
||||
{
|
||||
this.get_user_address();
|
||||
}
|
||||
|
||||
// 获取省
|
||||
this.get_province_list();
|
||||
this.get_data();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -78,52 +75,95 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户地址
|
||||
get_user_address() {
|
||||
// 获取数据
|
||||
get_data() {
|
||||
var self = this;
|
||||
// 加载loding
|
||||
my.showLoading({ content: "加载中..." });
|
||||
|
||||
my.request({
|
||||
url: app.get_request_url("detail", "useraddress"),
|
||||
method: "POST",
|
||||
data: self.data.params,
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var data = res.data.data || null;
|
||||
var ads_data = data.data || null;
|
||||
var idcard_images = {
|
||||
idcard_front: (ads_data == null) ? '' : ads_data.idcard_front || '',
|
||||
idcard_back: (ads_data == null) ? '' : ads_data.idcard_back || '',
|
||||
};
|
||||
self.setData({
|
||||
address_data: ads_data,
|
||||
idcard_images_data: idcard_images,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
});
|
||||
|
||||
// 数据设置
|
||||
if(ads_data != null)
|
||||
{
|
||||
self.setData({
|
||||
name: data.name,
|
||||
tel: data.tel,
|
||||
address: data.address,
|
||||
province_id: data.province,
|
||||
city_id: data.city,
|
||||
county_id: data.county,
|
||||
is_default: data.is_default || 0,
|
||||
province_id: ads_data.province || null,
|
||||
city_id: ads_data.city || null,
|
||||
county_id: ads_data.county || null,
|
||||
});
|
||||
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
// 地理位置
|
||||
var lng = ads_data.lng || null;
|
||||
var lat = ads_data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
address: ads_data.address || '',
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
setTimeout(function() {
|
||||
self.init_value();
|
||||
}, 500);
|
||||
// 半秒后初始化数据
|
||||
setTimeout(function () {
|
||||
self.init_region_value();
|
||||
}, 500);
|
||||
} else {
|
||||
if (app.is_login_check(res.data, self, 'get_user_address')) {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
my.hideLoading();
|
||||
app.showToast('服务器请求出错');
|
||||
app.showToast("省份信息失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取选择的省市区
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
// 地区初始化匹配索引
|
||||
get_region_value(list, id) {
|
||||
var data = this.data[list];
|
||||
var data_id = this.data[id];
|
||||
var value = null;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 获取省份
|
||||
get_province_list() {
|
||||
var self = this;
|
||||
my.request({
|
||||
@ -131,7 +171,7 @@ Page({
|
||||
method: "POST",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -143,11 +183,12 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast('服务器请求出错');
|
||||
app.showToast("省份获取失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
if (self.data.province_id) {
|
||||
@ -158,7 +199,7 @@ Page({
|
||||
pid: self.data.province_id
|
||||
},
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -170,12 +211,13 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast('服务器请求出错');
|
||||
app.showToast("城市获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
if (self.data.city_id) {
|
||||
@ -187,7 +229,7 @@ Page({
|
||||
pid: self.data.city_id
|
||||
},
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -199,19 +241,19 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast('服务器请求出错');
|
||||
app.showToast("区/县获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
select_province(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.province_list[value];
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
province_value: value,
|
||||
province_value: index,
|
||||
province_id: data.id,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
@ -222,13 +264,13 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_city(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.city_list[value];
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
city_value: value,
|
||||
city_value: index,
|
||||
city_id: data.id,
|
||||
county_value: null,
|
||||
county_id: null
|
||||
@ -237,83 +279,197 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_county(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.county_list[value];
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
county_value: value,
|
||||
county_value: index,
|
||||
county_id: data.id
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init_value() {
|
||||
var province_value = this.get_init_value("province_list", "province_id"),
|
||||
city_value = this.get_init_value("city_list", "city_id"),
|
||||
county_value = this.get_init_value("county_list", "county_id");
|
||||
this.setData({
|
||||
province_value: province_value,
|
||||
city_value: city_value,
|
||||
county_value: county_value
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
},
|
||||
|
||||
// 选择地理位置
|
||||
choose_location_event(e) {
|
||||
my.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
},
|
||||
|
||||
get_init_value(list, id) {
|
||||
var data = this.data[list],
|
||||
data_id = this.data[id],
|
||||
value;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = my.getStorageSync({key: this.data.user_location_cache_key}) || null;
|
||||
var data = null;
|
||||
if (result != null && (result.data || null) != null)
|
||||
{
|
||||
data = {
|
||||
name: result.data.name || null,
|
||||
address: result.data.address || null,
|
||||
lat: result.data.latitude || null,
|
||||
lng: result.data.longitude || null
|
||||
}
|
||||
}
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
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, form_name);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(img_paths, success, fail, count, length, form_name) {
|
||||
var self = this;
|
||||
my.uploadFile({
|
||||
url: app.get_request_url("index", "ueditor"),
|
||||
filePath: img_paths[count],
|
||||
fileName: 'upfile',
|
||||
fileType: 'image',
|
||||
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_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = data.data.url;
|
||||
self.setData({ idcard_images_data: temp_idcard_images_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, form_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
my.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var temp_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = '';
|
||||
self.setData({ idcard_images_data: temp_idcard_images_data });
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
var self = this,
|
||||
data = self.data;
|
||||
var self = this;
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
|
||||
// 数据校验
|
||||
var validation = [
|
||||
{ fields: "name", msg: "请填写姓名" },
|
||||
{ fields: "tel", msg: "请填写手机号" },
|
||||
{ fields: "name", msg: "请填写联系人" },
|
||||
{ fields: "tel", msg: "请填写联系电话" },
|
||||
{ fields: "province", msg: "请选择省份" },
|
||||
{ fields: "city", msg: "请选择城市" },
|
||||
{ fields: "county", msg: "请选择区县" },
|
||||
{ fields: "address", msg: "请填写详细地址" }
|
||||
{ fields: "address", msg: "请填写详细地址" },
|
||||
{ fields: "lng", msg: "请选择地理位置" },
|
||||
{ fields: "lat", msg: "请选择地理位置" }
|
||||
];
|
||||
|
||||
form_data["province"] = data.province_id;
|
||||
form_data["city"] = data.city_id;
|
||||
form_data["county"] = data.county_id;
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id;
|
||||
form_data["id"] = self.data.params.id || 0;
|
||||
form_data["is_default"] = self.data.is_default || 0;
|
||||
form_data["is_default"] = form_data.is_default == true ? 1 : 0;
|
||||
form_data['idcard_front'] = self.data.idcard_images_data.idcard_front || '';
|
||||
form_data['idcard_back'] = self.data.idcard_images_data.idcard_back || '';
|
||||
|
||||
// 地理位置
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.address_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.address_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.address_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
// 加载loding
|
||||
// 数据保存
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
my.showLoading({ content: "处理中..." });
|
||||
|
||||
my.request({
|
||||
url: app.get_request_url("save", "useraddress"),
|
||||
method: "POST",
|
||||
data: form_data,
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
my.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, 'success');
|
||||
setTimeout(function() {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function () {
|
||||
my.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -322,19 +478,11 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
my.hideLoading();
|
||||
app.showToast('服务器请求出错');
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if(value != null)
|
||||
{
|
||||
app.showToast(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -8,6 +8,13 @@
|
||||
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);
|
||||
@ -21,8 +28,8 @@
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.operation .delete-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .submit-items button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<view class="item bg-white spacing-mb" a:for="{{data_list}}">
|
||||
<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>
|
||||
@ -17,10 +18,11 @@
|
||||
<image a:else class="item-icon" src="/images/default-select-icon.png" mode="widthFix" />
|
||||
<text>设为默认地址</text>
|
||||
</view>
|
||||
<button class="fr cr-666 delete-submit" type="default" size="mini" onTap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
<navigator url="/pages/user-address-save/user-address-save?id={{item.id}}" open-type="navigate" hover-class="none">
|
||||
<button class="fr cr-666" type="default" size="mini" onTap="address_edit_event" hover-class="none">编辑</button>
|
||||
</navigator>
|
||||
<view class="fr oh submit-items">
|
||||
<button a:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 br" type="default" size="mini" onTap="address_map_event" data-index="{{index}}" hover-class="none">位置</button>
|
||||
<button class="cr-666 br" type="default" size="mini" onTap="address_edit_event" data-index="{{index}}" hover-class="none">编辑</button>
|
||||
<button class="cr-666 br" type="default" size="mini" onTap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -10,11 +10,11 @@ Page({
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
my.setNavigationBar({title: app.data.common_pages_title.user_address});
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 初始化
|
||||
@ -285,5 +285,37 @@ Page({
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
my.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?id='+data.id
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
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);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ Page({
|
||||
var data = this.data.detail.address_data;
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -365,6 +365,9 @@ button[disabled].bg-primary {
|
||||
.form-container .form-gorup-text {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.form-container .form-gorup .switch {
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单图片上传
|
||||
|
||||
@ -24,6 +24,9 @@ App({
|
||||
// 用户传入信息缓存key
|
||||
cache_launch_info_key: "cache_shop_launch_info_key",
|
||||
|
||||
// 获取位置选择缓存key
|
||||
cache_userlocation_key: "cache_userlocation_key",
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: "/images/default-user.png",
|
||||
|
||||
@ -778,11 +781,34 @@ App({
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标)
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* 火星坐标GCJ02到百度坐标BD-09(高德,谷歌,腾讯坐标 -> 百度)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_gcj_to_bd(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng;
|
||||
let y = lat;
|
||||
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||||
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||||
let lngs = z * Math.cos(theta) + 0.0065;
|
||||
let lats = z * Math.sin(theta) + 0.006;
|
||||
return {
|
||||
lng: lngs,
|
||||
lat: lats
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(百度 -> 高德,谷歌,腾讯坐标)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_bd_to_gcj(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng - 0.0065;
|
||||
let y = lat - 0.006;
|
||||
@ -809,11 +835,15 @@ App({
|
||||
this.showToast('坐标有误');
|
||||
return false;
|
||||
}
|
||||
if((address || null) == null) {
|
||||
this.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 转换坐标打开位置
|
||||
var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat));
|
||||
var position = this.map_bd_to_gcj(lng, lat);
|
||||
swan.openLocation({
|
||||
name: name || '',
|
||||
name: name || '当前位置',
|
||||
address: address || '',
|
||||
scale: scale || 18,
|
||||
longitude: position.lng,
|
||||
|
||||
BIN
sourcecode/baidu/images/default-idcard-back.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sourcecode/baidu/images/default-idcard-front.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
@ -362,7 +362,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ Page({
|
||||
params: null,
|
||||
is_show_open_setting: false,
|
||||
auth: 'scope.userLocation',
|
||||
cache_key: 'cache_userlocation_key'
|
||||
cache_key: app.data.cache_userlocation_key
|
||||
},
|
||||
|
||||
onLoad: function (params) {
|
||||
@ -53,6 +53,9 @@ Page({
|
||||
choose_location() {
|
||||
swan.chooseLocation({
|
||||
success: res => {
|
||||
var position = app.map_gcj_to_bd(res.longitude, res.latitude);
|
||||
res.longitude = position.lng;
|
||||
res.latitude = position.lat;
|
||||
swan.setStorageSync(this.data.cache_key, res);
|
||||
swan.navigateBack();
|
||||
},
|
||||
|
||||
@ -114,7 +114,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -20,7 +20,7 @@ Page({
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
|
||||
user_location_cache_key: 'cache_userlocation_key',
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
|
||||
form_submit_disabled_status: false
|
||||
@ -172,7 +172,6 @@ Page({
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
console.log(self.data.province_id);
|
||||
if (self.data.province_id) {
|
||||
swan.request({
|
||||
url: app.get_request_url("index", "region"),
|
||||
@ -317,10 +316,22 @@ Page({
|
||||
form_data["county"] = self.data.county_id;
|
||||
|
||||
// 地理位置
|
||||
if ((self.data.user_location || null) != null) {
|
||||
form_data["lng"] = self.data.user_location.lng || 0;
|
||||
form_data["lat"] = self.data.user_location.lat || 0;
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.extraction_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.extraction_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.extraction_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
|
||||
@ -94,7 +94,7 @@ Page({
|
||||
var data = this.data.extraction;
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -1,41 +1,39 @@
|
||||
/* 填写信息 */
|
||||
.person-box{
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.person-box input{
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius:0;
|
||||
}
|
||||
.addressee .addressee-name{
|
||||
width: 250rpx;
|
||||
/*
|
||||
* 三级联动
|
||||
*/
|
||||
.select-address {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.addressee .addressee-phone{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 250rpx);
|
||||
}
|
||||
.submit-bottom {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
/* 三级联动 */
|
||||
.select-address{
|
||||
box-sizing: border-box;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.select-address .section {
|
||||
width: 33%;
|
||||
width: 33.33%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.select-address .section:not(:first-child) {
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
/* end 三级联动 */
|
||||
.addressee-address{
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
/*
|
||||
* 表单
|
||||
*/
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-bottom {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* 身份信息
|
||||
*/
|
||||
.idcard-container {
|
||||
background: #e0e0e0;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.idcard-container .form-upload-data .item image {
|
||||
width: 256rpx;
|
||||
height: 170rpx;
|
||||
border: 1px dashed #c2c2c2;
|
||||
}
|
||||
@ -1,22 +1,18 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '处理错误',
|
||||
params: null,
|
||||
|
||||
name : '',
|
||||
tel : '',
|
||||
address: '',
|
||||
is_default: 0,
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
editor_path_type: '',
|
||||
address_data: null,
|
||||
province_list: [],
|
||||
city_list: [],
|
||||
county_list: [],
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
idcard_images_data: {},
|
||||
|
||||
default_province: "请选择省",
|
||||
default_city: "请选择市",
|
||||
@ -24,23 +20,36 @@ Page({
|
||||
|
||||
province_value: null,
|
||||
city_value: null,
|
||||
county_value: null
|
||||
county_value: null,
|
||||
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
|
||||
form_submit_disabled_status: false,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if ((this.data.params.id || null) == null) {
|
||||
onReady: function () {
|
||||
if((this.data.params.id || null) == null)
|
||||
{
|
||||
var title = app.data.common_pages_title.user_address_save_add;
|
||||
} else {
|
||||
var title = app.data.common_pages_title.user_address_save_edit;
|
||||
}
|
||||
swan.setNavigationBarTitle({ title: title });
|
||||
swan.setNavigationBarTitle({title: title});
|
||||
|
||||
// 清除位置缓存信息
|
||||
swan.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.user_location_init();
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
@ -55,14 +64,8 @@ Page({
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取地址数据
|
||||
if((this.data.params.id || null) != null)
|
||||
{
|
||||
this.get_user_address();
|
||||
}
|
||||
|
||||
// 获取省
|
||||
this.get_province_list();
|
||||
this.get_data();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -72,12 +75,9 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户地址
|
||||
get_user_address() {
|
||||
// 获取数据
|
||||
get_data() {
|
||||
var self = this;
|
||||
// 加载loding
|
||||
swan.showLoading({ title: "加载中..." });
|
||||
|
||||
swan.request({
|
||||
url: app.get_request_url("detail", "useraddress"),
|
||||
method: "POST",
|
||||
@ -85,24 +85,48 @@ Page({
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
swan.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var data = res.data.data || null;
|
||||
var ads_data = data.data || null;
|
||||
var idcard_images = {
|
||||
idcard_front: (ads_data == null) ? '' : ads_data.idcard_front || '',
|
||||
idcard_back: (ads_data == null) ? '' : ads_data.idcard_back || '',
|
||||
};
|
||||
self.setData({
|
||||
name: data.name,
|
||||
tel: data.tel,
|
||||
address: data.address,
|
||||
province_id: data.province,
|
||||
city_id: data.city,
|
||||
county_id: data.county,
|
||||
is_default: data.is_default || 0
|
||||
address_data: ads_data,
|
||||
idcard_images_data: idcard_images,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
});
|
||||
|
||||
// 数据设置
|
||||
if(ads_data != null)
|
||||
{
|
||||
self.setData({
|
||||
province_id: ads_data.province || null,
|
||||
city_id: ads_data.city || null,
|
||||
county_id: ads_data.county || null,
|
||||
});
|
||||
|
||||
// 地理位置
|
||||
var lng = ads_data.lng || null;
|
||||
var lat = ads_data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
address: ads_data.address || '',
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
// 半秒后初始化数据
|
||||
setTimeout(function () {
|
||||
self.init_value();
|
||||
self.init_region_value();
|
||||
}, 500);
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
@ -111,13 +135,35 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
swan.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份信息失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取选择的省市区
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
// 地区初始化匹配索引
|
||||
get_region_value(list, id) {
|
||||
var data = this.data[list];
|
||||
var data_id = this.data[id];
|
||||
var value = null;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 获取省份
|
||||
get_province_list() {
|
||||
var self = this;
|
||||
swan.request({
|
||||
@ -137,11 +183,12 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份获取失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
if (self.data.province_id) {
|
||||
@ -164,12 +211,13 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("城市获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
if (self.data.city_id) {
|
||||
@ -193,19 +241,19 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("区/县获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
select_province(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.province_list[value];
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
province_value: value,
|
||||
province_value: index,
|
||||
province_id: data.id,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
@ -216,13 +264,13 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_city(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.city_list[value];
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
city_value: value,
|
||||
city_value: index,
|
||||
city_id: data.id,
|
||||
county_value: null,
|
||||
county_id: null
|
||||
@ -231,62 +279,181 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_county(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.county_list[value];
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
county_value: value,
|
||||
county_value: index,
|
||||
county_id: data.id
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init_value() {
|
||||
var province_value = this.get_init_value("province_list", "province_id"),
|
||||
city_value = this.get_init_value("city_list", "city_id"),
|
||||
county_value = this.get_init_value("county_list", "county_id");
|
||||
this.setData({
|
||||
province_value: province_value,
|
||||
city_value: city_value,
|
||||
county_value: county_value
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
},
|
||||
|
||||
// 选择地理位置
|
||||
choose_location_event(e) {
|
||||
swan.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
},
|
||||
|
||||
get_init_value(list, id) {
|
||||
var data = this.data[list],
|
||||
data_id = this.data[id],
|
||||
value;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = swan.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var data = null;
|
||||
if (result != null)
|
||||
{
|
||||
data = {
|
||||
name: result.name || null,
|
||||
address: result.address || null,
|
||||
lat: result.latitude || null,
|
||||
lng: result.longitude || null
|
||||
}
|
||||
}
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
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, form_name);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(img_paths, success, fail, count, length, form_name) {
|
||||
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_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = data.data.url;
|
||||
self.setData({ idcard_images_data: temp_idcard_images_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, form_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
swan.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var temp_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = '';
|
||||
self.setData({ idcard_images_data: temp_idcard_images_data });
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
var self = this,
|
||||
data = self.data;
|
||||
var self = this;
|
||||
// 表单数据
|
||||
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: "请填写详细地址" }];
|
||||
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: "请选择地理位置" }
|
||||
];
|
||||
|
||||
form_data["province"] = data.province_id;
|
||||
form_data["city"] = data.city_id;
|
||||
form_data["county"] = data.county_id;
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id;
|
||||
form_data["id"] = self.data.params.id || 0;
|
||||
form_data["is_default"] = self.data.is_default || 0;
|
||||
form_data["is_default"] = form_data.is_default == true ? 1 : 0;
|
||||
form_data['idcard_front'] = self.data.idcard_images_data.idcard_front || '';
|
||||
form_data['idcard_back'] = self.data.idcard_images_data.idcard_back || '';
|
||||
|
||||
// 地理位置
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.address_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.address_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.address_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
// 加载loding
|
||||
// 数据保存
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
swan.showLoading({ title: "处理中..." });
|
||||
|
||||
swan.request({
|
||||
url: app.get_request_url("save", "useraddress"),
|
||||
method: "POST",
|
||||
@ -301,6 +468,7 @@ Page({
|
||||
swan.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -309,19 +477,11 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
swan.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if(value != null)
|
||||
{
|
||||
app.showToast(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,34 +1,88 @@
|
||||
<form bindsubmit="form_submit">
|
||||
<view class="person-box bg-white">
|
||||
<view class="addressee br-b oh">
|
||||
<input class="addressee-name fl br-r" name="name" type="text" value="{=name=}" placeholder="姓名" />
|
||||
<input class="addressee-phone fl" name="tel" type="number" value="{=tel=}" placeholder="手机号" />
|
||||
<view class="page">
|
||||
<form bindsubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{address_data.alias || ''}}" maxlength="16" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
</view>
|
||||
|
||||
<!-- 地区选择 -->
|
||||
<view class="select-address br-b oh">
|
||||
<view class="section fl br-r">
|
||||
<picker name="province" bindchange="select_province" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-888' : '' }}">{{province_list[province_value].name || default_province}}</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="{{address_data.name || ''}}" maxlength="16" 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="{{address_data.tel || ''}}" maxlength="30" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">省市区<text class="form-group-tips-must">必选</text></view>
|
||||
<view class="select-address oh">
|
||||
<view class="section fl">
|
||||
<picker name="province" bindchange="select_province_event" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-ccc' : 'cr-666' }}">{{province_list[province_value].name || default_province}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="section fl br-r">
|
||||
<picker s-if="(province_id || null) != null" name="city" bindchange="select_city" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-888' : '' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text s-else class="cr-888" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker s-if="(city_id || null) != null" name="county" bindchange="select_county" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-888' : '' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
<picker s-if="(province_id || null) != null" name="city" bindchange="select_city_event" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-ccc' : 'cr-666' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text s-else class="cr-888" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
<text s-else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker s-if="(city_id || null) != null" name="county" bindchange="select_county_event" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-ccc' : 'cr-666' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
</picker>
|
||||
<text s-else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end地区选择 -->
|
||||
|
||||
<input name="address" class="addressee-address" type="text" value="{=address=}" placeholder="详细地址" />
|
||||
</view>
|
||||
<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="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none">保存</button>
|
||||
</form>
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view s-if="(user_location || null) == null && (address_data.address || null) == null" class="cr-888">请选择地理位置</view>
|
||||
<view s-else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
<view class="switch">
|
||||
<switch name="is_default" checked="{{address_data.is_default == 1 ? true : false}}" color="#04BE02" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 身份证信息 -->
|
||||
<view class="idcard-container">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">身份证姓名<text class="form-group-tips">选填,请务必与上传的身份证件姓名保持一致</text></view>
|
||||
<input type="text" name="idcard_name" value="{{address_data.idcard_name || ''}}" maxlength="16" 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">选填,请务必与上传的身份证件号码保持一致</text></view>
|
||||
<input type="idcard" name="idcard_number" value="{{address_data.idcard_number || ''}}" maxlength="18" placeholder-class="cr-ccc" class="cr-666" placeholder="身份证号码格式最多18个字符" />
|
||||
</view>
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">身份证照片<text class="form-group-tips">选填,请使用身份证原件拍摄,图片要清晰</text></view>
|
||||
<view class="form-upload-data">
|
||||
<view class="item fl">
|
||||
<text s-if="(idcard_images_data.idcard_front || null) != null" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_front">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_front || null) != null ? idcard_images_data.idcard_front : '/images/default-idcard-front.jpg'}}" data-value="idcard_front" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
<view class="item fl">
|
||||
<text s-if="(idcard_images_data.idcard_back || null) != null" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_back">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_back || null) != null ? idcard_images_data.idcard_back : '/images/default-idcard-back.jpg'}}" data-value="idcard_back" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none" disabled="{{form_submit_disabled_status}}">保存</button>
|
||||
</form>
|
||||
</view>
|
||||
@ -28,8 +28,8 @@
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.operation .delete-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .submit-items button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
|
||||
@ -10,11 +10,11 @@ Page({
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
swan.setNavigationBarTitle({ title: app.data.common_pages_title.user_address });
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 初始化
|
||||
@ -270,4 +270,36 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
swan.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?id='+data.id
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
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);
|
||||
},
|
||||
|
||||
});
|
||||
@ -18,10 +18,11 @@
|
||||
<image s-else class="item-icon" src="/images/default-select-icon.png" mode="widthFix" />
|
||||
<text>设为默认地址</text>
|
||||
</view>
|
||||
<button class="fr cr-666 delete-submit br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
<navigator url="/pages/user-address-save/user-address-save?id={{item.id}}" open-type="navigate" hover-class="none">
|
||||
<button class="fr cr-666 br" type="default" size="mini" bindtap="address_edit_event" hover-class="none">编辑</button>
|
||||
</navigator>
|
||||
<view class="fr oh submit-items">
|
||||
<button s-if="(item.lng || null) != null && (item.lat || null) != null" class="cr-666 br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">位置</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_edit_event" data-index="{{index}}" hover-class="none">编辑</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -108,7 +108,7 @@ Page({
|
||||
var data = this.data.detail.address_data;
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -24,6 +24,9 @@ App({
|
||||
// 启动参数缓存key
|
||||
cache_launch_info_key: "cache_shop_launch_info_key",
|
||||
|
||||
// 获取位置选择缓存key
|
||||
cache_userlocation_key: "cache_userlocation_key",
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: "/images/default-user.png",
|
||||
|
||||
@ -781,11 +784,34 @@ App({
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标)
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* 火星坐标GCJ02到百度坐标BD-09(高德,谷歌,腾讯坐标 -> 百度)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_gcj_to_bd(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng;
|
||||
let y = lat;
|
||||
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||||
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||||
let lngs = z * Math.cos(theta) + 0.0065;
|
||||
let lats = z * Math.sin(theta) + 0.006;
|
||||
return {
|
||||
lng: lngs,
|
||||
lat: lats
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(百度 -> 高德,谷歌,腾讯坐标)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_bd_to_gcj(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng - 0.0065;
|
||||
let y = lat - 0.006;
|
||||
@ -812,11 +838,15 @@ App({
|
||||
this.showToast('坐标有误');
|
||||
return false;
|
||||
}
|
||||
if((address || null) == null) {
|
||||
this.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 转换坐标打开位置
|
||||
var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat));
|
||||
var position = this.map_bd_to_gcj(lng, lat);
|
||||
qq.openLocation({
|
||||
name: name || '',
|
||||
name: name || '当前位置',
|
||||
address: address || '',
|
||||
scale: scale || 18,
|
||||
longitude: position.lng,
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
"pages/user-orderaftersale/user-orderaftersale",
|
||||
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
|
||||
"pages/extraction-address/extraction-address",
|
||||
"pages/common/open-setting-location/open-setting-location",
|
||||
"pages/plugins/coupon/index/index",
|
||||
"pages/plugins/coupon/user/user",
|
||||
"pages/plugins/wallet/user/user",
|
||||
|
||||
@ -373,6 +373,9 @@ button[disabled].bg-primary {
|
||||
.form-container .form-gorup-text {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.form-container .form-gorup .switch {
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单图片上传
|
||||
|
||||
BIN
sourcecode/qq/images/default-idcard-back.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sourcecode/qq/images/default-idcard-front.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
@ -379,7 +379,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
params: null,
|
||||
is_show_open_setting: false,
|
||||
auth: 'scope.userLocation',
|
||||
cache_key: app.data.cache_userlocation_key,
|
||||
},
|
||||
|
||||
onLoad: function (params) {
|
||||
this.setData({ params: params });
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 获取权限
|
||||
init() {
|
||||
var self = this;
|
||||
qq.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting[self.data.auth]) {
|
||||
qq.authorize({
|
||||
scope: self.data.auth,
|
||||
success(res) {
|
||||
self.choose_location();
|
||||
},
|
||||
fail: (res) => {
|
||||
self.setData({ is_show_open_setting: true });
|
||||
}
|
||||
})
|
||||
} else {
|
||||
self.choose_location();
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
app.showToast("请先获取授权");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 位置服务回调方法
|
||||
setting_callback_event(e) {
|
||||
var self = this;
|
||||
if (e.detail.authSetting[self.data.auth]) {
|
||||
self.setData({ is_show_open_setting: false });
|
||||
self.choose_location();
|
||||
}
|
||||
},
|
||||
|
||||
// 打开位置服务
|
||||
choose_location() {
|
||||
qq.chooseLocation({
|
||||
success: res => {
|
||||
var position = app.map_gcj_to_bd(res.longitude, res.latitude);
|
||||
res.longitude = position.lng;
|
||||
res.latitude = position.lat;
|
||||
qq.setStorageSync(this.data.cache_key, res);
|
||||
qq.navigateBack();
|
||||
},
|
||||
fail: (res) => {
|
||||
qq.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<view qq:if="{{is_show_open_setting}}" class="open-setting-view">
|
||||
<view class="content bg-white">
|
||||
<view class="msg cr-888">开启相应的权限服务</view>
|
||||
<view class="value cr-666">获取[ <text>位置信息</text> ]权限</view>
|
||||
<button type="primary" open-type="openSetting" size="mini" bindopensetting="setting_callback_event">打开设置页</button>
|
||||
</view>
|
||||
</view>
|
||||
<view qq:else class="open-setting-loding">
|
||||
<image src="/images/default-bg-loding.gif" class="avatar dis-block" mode="widthFix" />
|
||||
</view>
|
||||
@ -0,0 +1,39 @@
|
||||
page {
|
||||
background: #fbfbfb;
|
||||
}
|
||||
.open-setting-view {
|
||||
background: hsla(0, 0%, 0%, 0.1);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
z-index: 1000000;
|
||||
}
|
||||
.open-setting-view .content {
|
||||
margin:0 auto;
|
||||
width: 360rpx;
|
||||
height: 160rpx;
|
||||
padding: 50rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-top: 70%;
|
||||
position: relative;
|
||||
}
|
||||
.open-setting-view .content button {
|
||||
margin-top: 15rpx;
|
||||
}
|
||||
.open-setting-view .content .value {
|
||||
margin-top: 5rpx;
|
||||
}
|
||||
.open-setting-view .content .value text {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.open-setting-loding {
|
||||
padding-top: 35%;
|
||||
}
|
||||
.open-setting-loding image {
|
||||
margin: 0 auto;
|
||||
}
|
||||
@ -115,7 +115,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -1,22 +1,18 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '处理错误',
|
||||
params: null,
|
||||
|
||||
name : '',
|
||||
tel : '',
|
||||
address: '',
|
||||
is_default: 0,
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
editor_path_type: '',
|
||||
address_data: null,
|
||||
province_list: [],
|
||||
city_list: [],
|
||||
county_list: [],
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
idcard_images_data: {},
|
||||
|
||||
default_province: "请选择省",
|
||||
default_city: "请选择市",
|
||||
@ -25,13 +21,18 @@ Page({
|
||||
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,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
onReady: function () {
|
||||
if((this.data.params.id || null) == null)
|
||||
{
|
||||
var title = app.data.common_pages_title.user_address_save_add;
|
||||
@ -39,9 +40,16 @@ Page({
|
||||
var title = app.data.common_pages_title.user_address_save_edit;
|
||||
}
|
||||
qq.setNavigationBarTitle({title: title});
|
||||
|
||||
// 清除位置缓存信息
|
||||
qq.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.user_location_init();
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
@ -56,14 +64,8 @@ Page({
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取地址数据
|
||||
if((this.data.params.id || null) != null)
|
||||
{
|
||||
this.get_user_address();
|
||||
}
|
||||
|
||||
// 获取省
|
||||
this.get_province_list();
|
||||
this.get_data();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -73,12 +75,9 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户地址
|
||||
get_user_address() {
|
||||
// 获取数据
|
||||
get_data() {
|
||||
var self = this;
|
||||
// 加载loding
|
||||
qq.showLoading({title: "加载中..." });
|
||||
|
||||
qq.request({
|
||||
url: app.get_request_url("detail", "useraddress"),
|
||||
method: "POST",
|
||||
@ -86,25 +85,49 @@ Page({
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
qq.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var data = res.data.data || null;
|
||||
var ads_data = data.data || null;
|
||||
var idcard_images = {
|
||||
idcard_front: (ads_data == null) ? '' : ads_data.idcard_front || '',
|
||||
idcard_back: (ads_data == null) ? '' : ads_data.idcard_back || '',
|
||||
};
|
||||
self.setData({
|
||||
address_data: ads_data,
|
||||
idcard_images_data: idcard_images,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
});
|
||||
|
||||
// 数据设置
|
||||
if(ads_data != null)
|
||||
{
|
||||
self.setData({
|
||||
name: data.name,
|
||||
tel: data.tel,
|
||||
address: data.address,
|
||||
province_id: data.province,
|
||||
city_id: data.city,
|
||||
county_id: data.county,
|
||||
is_default: data.is_default || 0,
|
||||
province_id: ads_data.province || null,
|
||||
city_id: ads_data.city || null,
|
||||
county_id: ads_data.county || null,
|
||||
});
|
||||
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
// 地理位置
|
||||
var lng = ads_data.lng || null;
|
||||
var lat = ads_data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
address: ads_data.address || '',
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
setTimeout(function() {
|
||||
self.init_value();
|
||||
}, 500);
|
||||
// 半秒后初始化数据
|
||||
setTimeout(function () {
|
||||
self.init_region_value();
|
||||
}, 500);
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
@ -112,13 +135,35 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
qq.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份信息失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取选择的省市区
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
// 地区初始化匹配索引
|
||||
get_region_value(list, id) {
|
||||
var data = this.data[list];
|
||||
var data_id = this.data[id];
|
||||
var value = null;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 获取省份
|
||||
get_province_list() {
|
||||
var self = this;
|
||||
qq.request({
|
||||
@ -138,11 +183,12 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份获取失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
if (self.data.province_id) {
|
||||
@ -165,12 +211,13 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("城市获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
if (self.data.city_id) {
|
||||
@ -194,19 +241,19 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("区/县获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
select_province(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.province_list[value];
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
province_value: value,
|
||||
province_value: index,
|
||||
province_id: data.id,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
@ -217,13 +264,13 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_city(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.city_list[value];
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
city_value: value,
|
||||
city_value: index,
|
||||
city_id: data.id,
|
||||
county_value: null,
|
||||
county_id: null
|
||||
@ -232,69 +279,181 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_county(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.county_list[value];
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
county_value: value,
|
||||
county_value: index,
|
||||
county_id: data.id
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init_value() {
|
||||
var province_value = this.get_init_value("province_list", "province_id"),
|
||||
city_value = this.get_init_value("city_list", "city_id"),
|
||||
county_value = this.get_init_value("county_list", "county_id");
|
||||
this.setData({
|
||||
province_value: province_value,
|
||||
city_value: city_value,
|
||||
county_value: county_value
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
},
|
||||
|
||||
// 选择地理位置
|
||||
choose_location_event(e) {
|
||||
qq.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
},
|
||||
|
||||
get_init_value(list, id) {
|
||||
var data = this.data[list],
|
||||
data_id = this.data[id],
|
||||
value;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
// 地址信息初始化
|
||||
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});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
qq.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, form_name);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(img_paths, success, fail, count, length, form_name) {
|
||||
var self = this;
|
||||
qq.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_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = data.data.url;
|
||||
self.setData({ idcard_images_data: temp_idcard_images_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, form_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
qq.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var temp_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = '';
|
||||
self.setData({ idcard_images_data: temp_idcard_images_data });
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
var self = this,
|
||||
data = self.data;
|
||||
var self = this;
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
|
||||
// 数据校验
|
||||
var validation = [
|
||||
{ fields: "name", msg: "请填写姓名" },
|
||||
{ fields: "tel", msg: "请填写手机号" },
|
||||
{ fields: "name", msg: "请填写联系人" },
|
||||
{ fields: "tel", msg: "请填写联系电话" },
|
||||
{ fields: "province", msg: "请选择省份" },
|
||||
{ fields: "city", msg: "请选择城市" },
|
||||
{ fields: "county", msg: "请选择区县" },
|
||||
{ fields: "address", msg: "请填写详细地址" }
|
||||
{ fields: "address", msg: "请填写详细地址" },
|
||||
{ fields: "lng", msg: "请选择地理位置" },
|
||||
{ fields: "lat", msg: "请选择地理位置" }
|
||||
];
|
||||
|
||||
form_data["province"] = data.province_id;
|
||||
form_data["city"] = data.city_id;
|
||||
form_data["county"] = data.county_id;
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id;
|
||||
form_data["id"] = self.data.params.id || 0;
|
||||
form_data["is_default"] = self.data.is_default || 0;
|
||||
form_data["is_default"] = form_data.is_default == true ? 1 : 0;
|
||||
form_data['idcard_front'] = self.data.idcard_images_data.idcard_front || '';
|
||||
form_data['idcard_back'] = self.data.idcard_images_data.idcard_back || '';
|
||||
|
||||
// 地理位置
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.address_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.address_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.address_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
// 加载loding
|
||||
qq.showLoading({title: "处理中..." });
|
||||
|
||||
// 数据保存
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
qq.showLoading({ title: "处理中..." });
|
||||
qq.request({
|
||||
url: app.get_request_url("save", "useraddress"),
|
||||
method: "POST",
|
||||
@ -305,10 +464,11 @@ Page({
|
||||
qq.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
qq.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -317,19 +477,11 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
qq.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if(value != null)
|
||||
{
|
||||
app.showToast(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,34 +1,88 @@
|
||||
<form bindsubmit="form_submit">
|
||||
<view class="person-box bg-white">
|
||||
<view class="addressee br-b oh">
|
||||
<input class="addressee-name fl br-r" name="name" type="text" value="{{name}}" placeholder="姓名" />
|
||||
<input class="addressee-phone fl" name="tel" type="number" value="{{tel}}" placeholder="手机号" />
|
||||
<view class="page">
|
||||
<form bindsubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{address_data.alias || ''}}" maxlength="16" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
</view>
|
||||
|
||||
<!-- 地区选择 -->
|
||||
<view class="select-address br-b oh">
|
||||
<view class="section fl br-r">
|
||||
<picker name="province" bindchange="select_province" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-888' : '' }}">{{province_list[province_value].name || default_province}}</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="{{address_data.name || ''}}" maxlength="16" 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="{{address_data.tel || ''}}" maxlength="30" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">省市区<text class="form-group-tips-must">必选</text></view>
|
||||
<view class="select-address oh">
|
||||
<view class="section fl">
|
||||
<picker name="province" bindchange="select_province_event" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-ccc' : 'cr-666' }}">{{province_list[province_value].name || default_province}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="section fl br-r">
|
||||
<picker qq:if="{{(province_id || null) != null}}" name="city" bindchange="select_city" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-888' : '' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text qq:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker qq:if="{{(city_id || null) != null}}" name="county" bindchange="select_county" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-888' : '' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
<picker qq:if="{{(province_id || null) != null}}" name="city" bindchange="select_city_event" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-ccc' : 'cr-666' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text qq:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
<text qq:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker qq:if="{{(city_id || null) != null}}" name="county" bindchange="select_county_event" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-ccc' : 'cr-666' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
</picker>
|
||||
<text qq:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end地区选择 -->
|
||||
|
||||
<input name="address" class="addressee-address" type="text" value="{{address}}" placeholder="详细地址" />
|
||||
</view>
|
||||
<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="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none">保存</button>
|
||||
</form>
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view qq:if="{{(user_location || null) == null && (address_data.address || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view qq:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
<view class="switch">
|
||||
<switch name="is_default" checked="{{address_data.is_default == 1 ? true : false}}" color="#04BE02" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 身份证信息 -->
|
||||
<view class="idcard-container">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">身份证姓名<text class="form-group-tips">选填,请务必与上传的身份证件姓名保持一致</text></view>
|
||||
<input type="text" name="idcard_name" value="{{address_data.idcard_name || ''}}" maxlength="16" 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">选填,请务必与上传的身份证件号码保持一致</text></view>
|
||||
<input type="idcard" name="idcard_number" value="{{address_data.idcard_number || ''}}" maxlength="18" placeholder-class="cr-ccc" class="cr-666" placeholder="身份证号码格式最多18个字符" />
|
||||
</view>
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">身份证照片<text class="form-group-tips">选填,请使用身份证原件拍摄,图片要清晰</text></view>
|
||||
<view class="form-upload-data">
|
||||
<view class="item fl">
|
||||
<text qq:if="{{(idcard_images_data.idcard_front || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_front">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_front || null) != null ? idcard_images_data.idcard_front : '/images/default-idcard-front.jpg'}}" data-value="idcard_front" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
<view class="item fl">
|
||||
<text qq:if="{{(idcard_images_data.idcard_back || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_back">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_back || null) != null ? idcard_images_data.idcard_back : '/images/default-idcard-back.jpg'}}" data-value="idcard_back" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none" disabled="{{form_submit_disabled_status}}">保存</button>
|
||||
</form>
|
||||
</view>
|
||||
@ -1,38 +1,39 @@
|
||||
/* 填写信息 */
|
||||
.person-box{
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.person-box input{
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius:0;
|
||||
}
|
||||
.addressee .addressee-name{
|
||||
width: 250rpx;
|
||||
/*
|
||||
* 三级联动
|
||||
*/
|
||||
.select-address {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.addressee .addressee-phone{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 250rpx);
|
||||
}
|
||||
/* 三级联动 */
|
||||
.select-address{
|
||||
box-sizing: border-box;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.select-address .section {
|
||||
width: 33%;
|
||||
width: 33.33%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.select-address .section:not(:first-child) {
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
/* end 三级联动 */
|
||||
.addressee-address{
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
/*
|
||||
* 表单
|
||||
*/
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-bottom {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* 身份信息
|
||||
*/
|
||||
.idcard-container {
|
||||
background: #e0e0e0;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.idcard-container .form-upload-data .item image {
|
||||
width: 256rpx;
|
||||
height: 170rpx;
|
||||
border: 1px dashed #c2c2c2;
|
||||
}
|
||||
@ -10,11 +10,11 @@ Page({
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
qq.setNavigationBarTitle({title: app.data.common_pages_title.user_address});
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 初始化
|
||||
@ -281,5 +281,37 @@ Page({
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
qq.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?id='+data.id
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
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);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<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>
|
||||
@ -17,10 +18,11 @@
|
||||
<image qq:else class="item-icon" src="/images/default-select-icon.png" mode="widthFix" />
|
||||
<text>设为默认地址</text>
|
||||
</view>
|
||||
<button class="fr cr-666 delete-submit br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
<navigator url="/pages/user-address-save/user-address-save?id={{item.id}}" open-type="navigate" hover-class="none">
|
||||
<button class="fr cr-666 br" type="default" size="mini" bindtap="address_edit_event" hover-class="none">编辑</button>
|
||||
</navigator>
|
||||
<view class="fr oh submit-items">
|
||||
<button qq:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">位置</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_edit_event" data-index="{{index}}" hover-class="none">编辑</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -8,6 +8,13 @@
|
||||
width: 35rpx;
|
||||
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);
|
||||
@ -21,8 +28,8 @@
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.operation .delete-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .submit-items button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
|
||||
@ -110,7 +110,7 @@ Page({
|
||||
var data = this.data.detail.address_data;
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -24,6 +24,9 @@ App({
|
||||
// 启动参数缓存key
|
||||
cache_launch_info_key: "cache_shop_launch_info_key",
|
||||
|
||||
// 获取位置选择缓存key
|
||||
cache_userlocation_key: "cache_userlocation_key",
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: "/images/default-user.png",
|
||||
|
||||
@ -644,7 +647,17 @@ App({
|
||||
return json;
|
||||
},
|
||||
|
||||
// 文件上传权限获取
|
||||
/**
|
||||
* 文件上传权限获取
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-14
|
||||
* @desc description
|
||||
* @param {[object]} object [当前页面对象]
|
||||
* @param {[string]} method [回调方法]
|
||||
* @param {[object]} params [同步参数]
|
||||
*/
|
||||
file_upload_authorize(object, method, params) {
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
@ -705,14 +718,26 @@ App({
|
||||
});
|
||||
},
|
||||
|
||||
// 位置权限获取
|
||||
location_authorize(object, method, params) {
|
||||
/**
|
||||
* 权限获取
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2020-10-14
|
||||
* @desc description
|
||||
* @param {[string]} auth_type [权限名称]
|
||||
* @param {[object]} object [当前页面对象]
|
||||
* @param {[string]} method [回调方法]
|
||||
* @param {[object]} params [同步参数]
|
||||
* @param {[string]} msg [提示名称]
|
||||
*/
|
||||
auth_setting_authorize(auth_type, object, method, params, msg) {
|
||||
var self = this;
|
||||
tt.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.userLocation']) {
|
||||
if (!res.authSetting[auth_type]) {
|
||||
tt.authorize({
|
||||
scope: 'scope.userLocation',
|
||||
scope: auth_type,
|
||||
success (res) {
|
||||
if (typeof object === 'object' && (method || null) != null) {
|
||||
object[method](params);
|
||||
@ -720,7 +745,7 @@ App({
|
||||
},
|
||||
fail (res) {
|
||||
tt.openSetting();
|
||||
self.showToast('请同意地理位置授权');
|
||||
self.showToast('请同意'+(msg || auth_type)+'授权');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -877,11 +902,34 @@ App({
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标)
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* 火星坐标GCJ02到百度坐标BD-09(高德,谷歌,腾讯坐标 -> 百度)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_gcj_to_bd(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng;
|
||||
let y = lat;
|
||||
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||||
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||||
let lngs = z * Math.cos(theta) + 0.0065;
|
||||
let lats = z * Math.sin(theta) + 0.006;
|
||||
return {
|
||||
lng: lngs,
|
||||
lat: lats
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(百度 -> 高德,谷歌,腾讯坐标)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_bd_to_gcj(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng - 0.0065;
|
||||
let y = lat - 0.006;
|
||||
@ -908,11 +956,15 @@ App({
|
||||
this.showToast('坐标有误');
|
||||
return false;
|
||||
}
|
||||
if((address || null) == null) {
|
||||
this.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 转换坐标打开位置
|
||||
var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat));
|
||||
var position = this.map_bd_to_gcj(lng, lat);
|
||||
tt.openLocation({
|
||||
name: name || '',
|
||||
name: name || '当前位置',
|
||||
address: address || '',
|
||||
scale: scale || 18,
|
||||
longitude: position.lng,
|
||||
|
||||
@ -374,6 +374,9 @@ button[disabled].bg-primary {
|
||||
.form-container .form-gorup-text {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.form-container .form-gorup .switch {
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单图片上传
|
||||
|
||||
BIN
sourcecode/toutiao/images/default-idcard-back.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sourcecode/toutiao/images/default-idcard-front.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
@ -397,7 +397,7 @@ Page({
|
||||
if((e.is_power || 0) == 0)
|
||||
{
|
||||
e['is_power'] = 1;
|
||||
app.location_authorize(this, 'map_event', e);
|
||||
app.auth_setting_authorize('scope.userLocation', this, 'map_event', e, '地理位置');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -410,7 +410,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ Page({
|
||||
if((e.is_power || 0) == 0)
|
||||
{
|
||||
e['is_power'] = 1;
|
||||
app.location_authorize(this, 'address_map_event', e);
|
||||
app.auth_setting_authorize('scope.userLocation', this, 'address_map_event', e, '地理位置');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ Page({
|
||||
province_value: null,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
user_location_cache_key: 'cache_userlocation_key',
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
form_submit_disabled_status: false
|
||||
},
|
||||
@ -177,8 +177,6 @@ Page({
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
console.log(self.data.province_id);
|
||||
|
||||
if (self.data.province_id) {
|
||||
tt.request({
|
||||
url: app.get_request_url("index", "region"),
|
||||
|
||||
@ -94,7 +94,7 @@ Page({
|
||||
if((e.is_power || 0) == 0)
|
||||
{
|
||||
e['is_power'] = 1;
|
||||
app.location_authorize(this, 'address_map_event', e);
|
||||
app.auth_setting_authorize('scope.userLocation', this, 'address_map_event', e, '地理位置');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -1,22 +1,18 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '处理错误',
|
||||
params: null,
|
||||
|
||||
name : '',
|
||||
tel : '',
|
||||
address: '',
|
||||
is_default: 0,
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
editor_path_type: '',
|
||||
address_data: null,
|
||||
province_list: [],
|
||||
city_list: [],
|
||||
county_list: [],
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
idcard_images_data: {},
|
||||
|
||||
default_province: "请选择省",
|
||||
default_city: "请选择市",
|
||||
@ -25,13 +21,18 @@ Page({
|
||||
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,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
onReady: function () {
|
||||
if((this.data.params.id || null) == null)
|
||||
{
|
||||
var title = app.data.common_pages_title.user_address_save_add;
|
||||
@ -39,9 +40,16 @@ Page({
|
||||
var title = app.data.common_pages_title.user_address_save_edit;
|
||||
}
|
||||
tt.setNavigationBarTitle({title: title});
|
||||
|
||||
// 清除位置缓存信息
|
||||
tt.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.user_location_init();
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
@ -56,14 +64,8 @@ Page({
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取地址数据
|
||||
if((this.data.params.id || null) != null)
|
||||
{
|
||||
this.get_user_address();
|
||||
}
|
||||
|
||||
// 获取省
|
||||
this.get_province_list();
|
||||
this.get_data();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -73,12 +75,9 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户地址
|
||||
get_user_address() {
|
||||
// 获取数据
|
||||
get_data() {
|
||||
var self = this;
|
||||
// 加载loding
|
||||
tt.showLoading({title: "加载中..." });
|
||||
|
||||
tt.request({
|
||||
url: app.get_request_url("detail", "useraddress"),
|
||||
method: "POST",
|
||||
@ -86,25 +85,49 @@ Page({
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
tt.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var data = res.data.data || null;
|
||||
var ads_data = data.data || null;
|
||||
var idcard_images = {
|
||||
idcard_front: (ads_data == null) ? '' : ads_data.idcard_front || '',
|
||||
idcard_back: (ads_data == null) ? '' : ads_data.idcard_back || '',
|
||||
};
|
||||
self.setData({
|
||||
address_data: ads_data,
|
||||
idcard_images_data: idcard_images,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
});
|
||||
|
||||
// 数据设置
|
||||
if(ads_data != null)
|
||||
{
|
||||
self.setData({
|
||||
name: data.name,
|
||||
tel: data.tel,
|
||||
address: data.address,
|
||||
province_id: data.province,
|
||||
city_id: data.city,
|
||||
county_id: data.county,
|
||||
is_default: data.is_default || 0,
|
||||
province_id: ads_data.province || null,
|
||||
city_id: ads_data.city || null,
|
||||
county_id: ads_data.county || null,
|
||||
});
|
||||
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
// 地理位置
|
||||
var lng = ads_data.lng || null;
|
||||
var lat = ads_data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
address: ads_data.address || '',
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
setTimeout(function() {
|
||||
self.init_value();
|
||||
}, 500);
|
||||
// 半秒后初始化数据
|
||||
setTimeout(function () {
|
||||
self.init_region_value();
|
||||
}, 500);
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
@ -112,13 +135,35 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
tt.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份信息失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取选择的省市区
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
// 地区初始化匹配索引
|
||||
get_region_value(list, id) {
|
||||
var data = this.data[list];
|
||||
var data_id = this.data[id];
|
||||
var value = null;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 获取省份
|
||||
get_province_list() {
|
||||
var self = this;
|
||||
tt.request({
|
||||
@ -138,11 +183,12 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份获取失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
if (self.data.province_id) {
|
||||
@ -165,12 +211,13 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("城市获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
if (self.data.city_id) {
|
||||
@ -194,19 +241,19 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("区/县获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
select_province(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.province_list[value];
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
province_value: value,
|
||||
province_value: index,
|
||||
province_id: data.id,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
@ -217,13 +264,13 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_city(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.city_list[value];
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
city_value: value,
|
||||
city_value: index,
|
||||
city_id: data.id,
|
||||
county_value: null,
|
||||
county_id: null
|
||||
@ -232,69 +279,187 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_county(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.county_list[value];
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
county_value: value,
|
||||
county_value: index,
|
||||
county_id: data.id
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init_value() {
|
||||
var province_value = this.get_init_value("province_list", "province_id"),
|
||||
city_value = this.get_init_value("city_list", "city_id"),
|
||||
county_value = this.get_init_value("county_list", "county_id");
|
||||
this.setData({
|
||||
province_value: province_value,
|
||||
city_value: city_value,
|
||||
county_value: county_value
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
},
|
||||
|
||||
// 选择地理位置
|
||||
choose_location_event(e) {
|
||||
tt.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
},
|
||||
|
||||
get_init_value(list, id) {
|
||||
var data = this.data[list],
|
||||
data_id = this.data[id],
|
||||
value;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
// 地址信息初始化
|
||||
user_location_init() {
|
||||
var result = tt.getStorageSync(this.data.user_location_cache_key) || null;
|
||||
var data = null;
|
||||
if (result != null)
|
||||
{
|
||||
data = {
|
||||
name: result.name || null,
|
||||
address: result.address || null,
|
||||
lat: result.latitude || null,
|
||||
lng: result.longitude || null
|
||||
}
|
||||
}
|
||||
this.setData({user_location: data});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
// 调用相机、相册权限
|
||||
app.file_upload_authorize(this, 'file_upload_handle', e);
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_handle(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
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, form_name);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(img_paths, success, fail, count, length, form_name) {
|
||||
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_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = data.data.url;
|
||||
self.setData({ idcard_images_data: temp_idcard_images_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, form_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
tt.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var temp_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = '';
|
||||
self.setData({ idcard_images_data: temp_idcard_images_data });
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
var self = this,
|
||||
data = self.data;
|
||||
var self = this;
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
|
||||
// 数据校验
|
||||
var validation = [
|
||||
{ fields: "name", msg: "请填写姓名" },
|
||||
{ fields: "tel", msg: "请填写手机号" },
|
||||
{ fields: "name", msg: "请填写联系人" },
|
||||
{ fields: "tel", msg: "请填写联系电话" },
|
||||
{ fields: "province", msg: "请选择省份" },
|
||||
{ fields: "city", msg: "请选择城市" },
|
||||
{ fields: "county", msg: "请选择区县" },
|
||||
{ fields: "address", msg: "请填写详细地址" }
|
||||
{ fields: "address", msg: "请填写详细地址" },
|
||||
// { fields: "lng", msg: "请选择地理位置" },
|
||||
// { fields: "lat", msg: "请选择地理位置" }
|
||||
];
|
||||
|
||||
form_data["province"] = data.province_id;
|
||||
form_data["city"] = data.city_id;
|
||||
form_data["county"] = data.county_id;
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id;
|
||||
form_data["id"] = self.data.params.id || 0;
|
||||
form_data["is_default"] = self.data.is_default || 0;
|
||||
form_data["is_default"] = form_data.is_default == true ? 1 : 0;
|
||||
form_data['idcard_front'] = self.data.idcard_images_data.idcard_front || '';
|
||||
form_data['idcard_back'] = self.data.idcard_images_data.idcard_back || '';
|
||||
|
||||
// 地理位置
|
||||
// var lng = 0;
|
||||
// var lat = 0;
|
||||
// if((self.data.user_location || null) != null) {
|
||||
// lng = self.data.user_location.lng || 0;
|
||||
// lat = self.data.user_location.lat || 0;
|
||||
// }
|
||||
// if((self.data.address_data || null) != null) {
|
||||
// if((lng || null) == null) {
|
||||
// lng = self.data.address_data.lng || 0;
|
||||
// }
|
||||
// if((lat || null) == null) {
|
||||
// lat = self.data.address_data.lat || 0;
|
||||
// }
|
||||
// }
|
||||
// form_data["lng"] = lng;
|
||||
// form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
// 加载loding
|
||||
tt.showLoading({title: "处理中..." });
|
||||
|
||||
// 数据保存
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
tt.showLoading({ title: "处理中..." });
|
||||
tt.request({
|
||||
url: app.get_request_url("save", "useraddress"),
|
||||
method: "POST",
|
||||
@ -305,10 +470,11 @@ Page({
|
||||
tt.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
tt.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -317,19 +483,11 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
tt.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if(value != null)
|
||||
{
|
||||
app.showToast(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,34 +1,88 @@
|
||||
<form bindsubmit="form_submit">
|
||||
<view class="person-box bg-white">
|
||||
<view class="addressee br-b oh">
|
||||
<input class="addressee-name fl br-r" name="name" type="text" value="{{name}}" placeholder="姓名" />
|
||||
<input class="addressee-phone fl" name="tel" type="number" value="{{tel}}" placeholder="手机号" />
|
||||
<view class="page">
|
||||
<form bindsubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{address_data.alias || ''}}" maxlength="16" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
</view>
|
||||
|
||||
<!-- 地区选择 -->
|
||||
<view class="select-address br-b oh">
|
||||
<view class="section fl br-r">
|
||||
<picker name="province" bindchange="select_province" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-888' : '' }}">{{province_list[province_value].name || default_province}}</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="{{address_data.name || ''}}" maxlength="16" 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="{{address_data.tel || ''}}" maxlength="30" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">省市区<text class="form-group-tips-must">必选</text></view>
|
||||
<view class="select-address oh">
|
||||
<view class="section fl">
|
||||
<picker name="province" bindchange="select_province_event" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-ccc' : 'cr-666' }}">{{province_list[province_value].name || default_province}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="section fl br-r">
|
||||
<picker tt:if="{{(province_id || null) != null}}" name="city" bindchange="select_city" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-888' : '' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text tt:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker tt:if="{{(city_id || null) != null}}" name="county" bindchange="select_county" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-888' : '' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
<picker tt:if="{{(province_id || null) != null}}" name="city" bindchange="select_city_event" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-ccc' : 'cr-666' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text tt:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
<text tt:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker tt:if="{{(city_id || null) != null}}" name="county" bindchange="select_county_event" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-ccc' : 'cr-666' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
</picker>
|
||||
<text tt:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end地区选择 -->
|
||||
|
||||
<input name="address" class="addressee-address" type="text" value="{{address}}" placeholder="详细地址" />
|
||||
</view>
|
||||
<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="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none">保存</button>
|
||||
</form>
|
||||
<!-- <view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view tt:if="{{(user_location || null) == null && (address_data.address || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view tt:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
<view class="switch">
|
||||
<switch name="is_default" checked="{{address_data.is_default == 1 ? true : false}}" color="#04BE02" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 身份证信息 -->
|
||||
<view class="idcard-container">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">身份证姓名<text class="form-group-tips">选填,请务必与上传的身份证件姓名保持一致</text></view>
|
||||
<input type="text" name="idcard_name" value="{{address_data.idcard_name || ''}}" maxlength="16" 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">选填,请务必与上传的身份证件号码保持一致</text></view>
|
||||
<input type="idcard" name="idcard_number" value="{{address_data.idcard_number || ''}}" maxlength="18" placeholder-class="cr-ccc" class="cr-666" placeholder="身份证号码格式最多18个字符" />
|
||||
</view>
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">身份证照片<text class="form-group-tips">选填,请使用身份证原件拍摄,图片要清晰</text></view>
|
||||
<view class="form-upload-data">
|
||||
<view class="item fl">
|
||||
<text tt:if="{{(idcard_images_data.idcard_front || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_front">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_front || null) != null ? idcard_images_data.idcard_front : '/images/default-idcard-front.jpg'}}" data-value="idcard_front" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
<view class="item fl">
|
||||
<text tt:if="{{(idcard_images_data.idcard_back || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_back">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_back || null) != null ? idcard_images_data.idcard_back : '/images/default-idcard-back.jpg'}}" data-value="idcard_back" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none" disabled="{{form_submit_disabled_status}}">保存</button>
|
||||
</form>
|
||||
</view>
|
||||
@ -1,38 +1,39 @@
|
||||
/* 填写信息 */
|
||||
.person-box{
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.person-box input{
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius:0;
|
||||
}
|
||||
.addressee .addressee-name{
|
||||
width: 250rpx;
|
||||
/*
|
||||
* 三级联动
|
||||
*/
|
||||
.select-address {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.addressee .addressee-phone{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 250rpx);
|
||||
}
|
||||
/* 三级联动 */
|
||||
.select-address{
|
||||
box-sizing: border-box;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.select-address .section {
|
||||
width: 33%;
|
||||
width: 33.33%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.select-address .section:not(:first-child) {
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
/* end 三级联动 */
|
||||
.addressee-address{
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
/*
|
||||
* 表单
|
||||
*/
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-bottom {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* 身份信息
|
||||
*/
|
||||
.idcard-container {
|
||||
background: #e0e0e0;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.idcard-container .form-upload-data .item image {
|
||||
width: 256rpx;
|
||||
height: 170rpx;
|
||||
border: 1px dashed #c2c2c2;
|
||||
}
|
||||
@ -10,11 +10,11 @@ Page({
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
tt.setNavigationBarTitle({title: app.data.common_pages_title.user_address});
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 初始化
|
||||
@ -236,5 +236,88 @@ Page({
|
||||
tt.navigateBack();
|
||||
}
|
||||
},
|
||||
|
||||
// 获取系统地址
|
||||
choose_system_address_event(e) {
|
||||
if((e.is_power || 0) == 0)
|
||||
{
|
||||
e['is_power'] = 1;
|
||||
app.auth_setting_authorize('scope.address', this, 'choose_system_address_event', e, '收货地址');
|
||||
return false;
|
||||
}
|
||||
var self = this;
|
||||
tt.chooseAddress({
|
||||
success (res) {
|
||||
var data = {
|
||||
"name": res.userName || '',
|
||||
"tel": res.telNumber || '',
|
||||
"province": res.provinceName || '',
|
||||
"city": res.cityName || '',
|
||||
"county": res.countyName || '',
|
||||
"address": res.detailInfo || '',
|
||||
};
|
||||
|
||||
// 加载loding
|
||||
tt.showLoading({ title: "处理中..." });
|
||||
|
||||
// 获取数据
|
||||
tt.request({
|
||||
url: app.get_request_url("outsystemadd", "useraddress"),
|
||||
method: "POST",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
tt.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
self.get_data_list();
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
app.showToast('提交失败,请重试!');
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
tt.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
tt.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?id='+data.id
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
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);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -18,10 +18,11 @@
|
||||
<image tt:else class="item-icon" src="/images/default-select-icon.png" mode="widthFix" />
|
||||
<text>设为默认地址</text>
|
||||
</view>
|
||||
<button class="fr cr-666 delete-submit br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
<navigator url="/pages/user-address-save/user-address-save?id={{item.id}}" open-type="navigate" hover-class="none">
|
||||
<button class="fr cr-666 br" type="default" size="mini" bindtap="address_edit_event" hover-class="none">编辑</button>
|
||||
</navigator>
|
||||
<view class="fr oh submit-items">
|
||||
<button tt:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">位置</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_edit_event" data-index="{{index}}" hover-class="none">编辑</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -34,7 +35,10 @@
|
||||
<import src="/pages/common/bottom_line.ttml" />
|
||||
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
|
||||
|
||||
<navigator url="/pages/user-address-save/user-address-save" open-type="navigate" hover-class="none">
|
||||
<button class="submit-fixed submit-bottom" type="default" hover-class="none">新增地址</button>
|
||||
</navigator>
|
||||
<view class="submit-list">
|
||||
<navigator url="/pages/user-address-save/user-address-save" open-type="navigate" hover-class="none">
|
||||
<button class="submit-fixed submit-bottom" type="default" hover-class="none">添加新地址</button>
|
||||
</navigator>
|
||||
<button class="submit-fixed submit-bottom import-system-address-submit" type="default" hover-class="none" bindtap="choose_system_address_event">导入头条地址</button>
|
||||
</view>
|
||||
</view>
|
||||
@ -28,9 +28,17 @@
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.operation .delete-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .submit-items button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-list button {
|
||||
width: 50%;
|
||||
}
|
||||
.submit-list .import-system-address-submit {
|
||||
background: #07c160 !important;
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
@ -105,7 +105,7 @@ Page({
|
||||
if((e.is_power || 0) == 0)
|
||||
{
|
||||
e['is_power'] = 1;
|
||||
app.location_authorize(this, 'address_map_event', e);
|
||||
app.auth_setting_authorize('scope.userLocation', this, 'address_map_event', e, '地理位置');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ Page({
|
||||
var data = this.data.detail.address_data;
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -24,6 +24,9 @@ App({
|
||||
// 启动参数缓存key
|
||||
cache_launch_info_key: "cache_shop_launch_info_key",
|
||||
|
||||
// 获取位置选择缓存key
|
||||
cache_userlocation_key: "cache_userlocation_key",
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: "/images/default-user.png",
|
||||
|
||||
@ -71,7 +74,7 @@ App({
|
||||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
request_url: 'http://shopxo.com/',
|
||||
// request_url: 'https://dev.shopxo.net/',
|
||||
request_url: 'https://dev.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
@ -793,11 +796,34 @@ App({
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(高德,谷歌,腾讯坐标)
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* 火星坐标GCJ02到百度坐标BD-09(高德,谷歌,腾讯坐标 -> 百度)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_gcj_to_bd(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng;
|
||||
let y = lat;
|
||||
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||||
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||||
let lngs = z * Math.cos(theta) + 0.0065;
|
||||
let lats = z * Math.sin(theta) + 0.006;
|
||||
return {
|
||||
lng: lngs,
|
||||
lat: lats
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 百度坐标BD-09到火星坐标GCJ02(百度 -> 高德,谷歌,腾讯坐标)
|
||||
* lng 经度
|
||||
* lat 纬度
|
||||
*/
|
||||
map_bd_to_gcj(lng, lat) {
|
||||
lng = parseFloat(lng);
|
||||
lat = parseFloat(lat);
|
||||
let x_pi = 3.14159265358979324 * 3000.0 / 180.0;
|
||||
let x = lng - 0.0065;
|
||||
let y = lat - 0.006;
|
||||
@ -824,11 +850,15 @@ App({
|
||||
this.showToast('坐标有误');
|
||||
return false;
|
||||
}
|
||||
if((address || null) == null) {
|
||||
this.showToast('地址有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 转换坐标打开位置
|
||||
var position = this.map_bd_to_gcj(parseFloat(lng), parseFloat(lat));
|
||||
var position = this.map_bd_to_gcj(lng, lat);
|
||||
wx.openLocation({
|
||||
name: name || '',
|
||||
name: name || '当前位置',
|
||||
address: address || '',
|
||||
scale: scale || 18,
|
||||
longitude: position.lng,
|
||||
|
||||
@ -373,6 +373,9 @@ button[disabled].bg-primary {
|
||||
.form-container .form-gorup-text {
|
||||
padding: 20rpx 10rpx;
|
||||
}
|
||||
.form-container .form-gorup .switch {
|
||||
margin: 30rpx 0 20rpx 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单图片上传
|
||||
|
||||
BIN
sourcecode/weixin/images/default-idcard-back.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
sourcecode/weixin/images/default-idcard-front.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
@ -380,7 +380,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.name || data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -4,7 +4,7 @@ Page({
|
||||
params: null,
|
||||
is_show_open_setting: false,
|
||||
auth: 'scope.userLocation',
|
||||
cache_key: 'cache_userlocation_key',
|
||||
cache_key: app.data.cache_userlocation_key,
|
||||
},
|
||||
|
||||
onLoad: function (params) {
|
||||
@ -50,6 +50,9 @@ Page({
|
||||
choose_location() {
|
||||
wx.chooseLocation({
|
||||
success: res => {
|
||||
var position = app.map_gcj_to_bd(res.longitude, res.latitude);
|
||||
res.longitude = position.lng;
|
||||
res.latitude = position.lat;
|
||||
wx.setStorageSync(this.data.cache_key, res);
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
@ -115,7 +115,7 @@ Page({
|
||||
}
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -20,7 +20,7 @@ Page({
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
|
||||
user_location_cache_key: 'cache_userlocation_key',
|
||||
user_location_cache_key: app.data.cache_userlocation_key,
|
||||
user_location: null,
|
||||
|
||||
form_submit_disabled_status: false,
|
||||
@ -91,8 +91,8 @@ Page({
|
||||
});
|
||||
|
||||
// 地理位置
|
||||
var lng = (data.lng || 0) <= 0 ? null : data.lng;
|
||||
var lat = (data.lat || 0) <= 0 ? null : data.lat;
|
||||
var lng = data.lng || null;
|
||||
var lat = data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
@ -174,7 +174,6 @@ Page({
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
console.log(self.data.province_id)
|
||||
if (self.data.province_id) {
|
||||
wx.request({
|
||||
url: app.get_request_url("index", "region"),
|
||||
@ -329,11 +328,22 @@ Page({
|
||||
form_data["county"] = self.data.county_id;
|
||||
|
||||
// 地理位置
|
||||
if ((self.data.user_location || null) != null)
|
||||
{
|
||||
form_data["lng"] = self.data.user_location.lng || 0;
|
||||
form_data["lat"] = self.data.user_location.lat || 0;
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.extraction_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.extraction_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.extraction_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
|
||||
@ -94,7 +94,7 @@ Page({
|
||||
var data = this.data.extraction;
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||
@ -1,22 +1,18 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '处理错误',
|
||||
params: null,
|
||||
|
||||
name : '',
|
||||
tel : '',
|
||||
address: '',
|
||||
is_default: 0,
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
editor_path_type: '',
|
||||
address_data: null,
|
||||
province_list: [],
|
||||
city_list: [],
|
||||
county_list: [],
|
||||
province_id: null,
|
||||
city_id: null,
|
||||
county_id: null,
|
||||
idcard_images_data: {},
|
||||
|
||||
default_province: "请选择省",
|
||||
default_city: "请选择市",
|
||||
@ -25,13 +21,18 @@ Page({
|
||||
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,
|
||||
},
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.setData({ params: params });
|
||||
},
|
||||
|
||||
onShow() {
|
||||
onReady: function () {
|
||||
if((this.data.params.id || null) == null)
|
||||
{
|
||||
var title = app.data.common_pages_title.user_address_save_add;
|
||||
@ -39,9 +40,16 @@ Page({
|
||||
var title = app.data.common_pages_title.user_address_save_edit;
|
||||
}
|
||||
wx.setNavigationBarTitle({title: title});
|
||||
|
||||
// 清除位置缓存信息
|
||||
wx.removeStorage({key: this.data.user_location_cache_key});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.user_location_init();
|
||||
},
|
||||
|
||||
init() {
|
||||
var user = app.get_user_info(this, "init");
|
||||
if (user != false) {
|
||||
@ -56,14 +64,8 @@ Page({
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
// 获取地址数据
|
||||
if((this.data.params.id || null) != null)
|
||||
{
|
||||
this.get_user_address();
|
||||
}
|
||||
|
||||
// 获取省
|
||||
this.get_province_list();
|
||||
this.get_data();
|
||||
}
|
||||
} else {
|
||||
this.setData({
|
||||
@ -73,12 +75,9 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 获取用户地址
|
||||
get_user_address() {
|
||||
// 获取数据
|
||||
get_data() {
|
||||
var self = this;
|
||||
// 加载loding
|
||||
wx.showLoading({title: "加载中..." });
|
||||
|
||||
wx.request({
|
||||
url: app.get_request_url("detail", "useraddress"),
|
||||
method: "POST",
|
||||
@ -86,25 +85,49 @@ Page({
|
||||
dataType: "json",
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
var data = res.data.data || null;
|
||||
var ads_data = data.data || null;
|
||||
var idcard_images = {
|
||||
idcard_front: (ads_data == null) ? '' : ads_data.idcard_front || '',
|
||||
idcard_back: (ads_data == null) ? '' : ads_data.idcard_back || '',
|
||||
};
|
||||
self.setData({
|
||||
address_data: ads_data,
|
||||
idcard_images_data: idcard_images,
|
||||
editor_path_type: data.editor_path_type || '',
|
||||
});
|
||||
|
||||
// 数据设置
|
||||
if(ads_data != null)
|
||||
{
|
||||
self.setData({
|
||||
name: data.name,
|
||||
tel: data.tel,
|
||||
address: data.address,
|
||||
province_id: data.province,
|
||||
city_id: data.city,
|
||||
county_id: data.county,
|
||||
is_default: data.is_default || 0,
|
||||
province_id: ads_data.province || null,
|
||||
city_id: ads_data.city || null,
|
||||
county_id: ads_data.county || null,
|
||||
});
|
||||
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
// 地理位置
|
||||
var lng = ads_data.lng || null;
|
||||
var lat = ads_data.lat || null;
|
||||
if (lng != null && lat != null)
|
||||
{
|
||||
self.setData({ user_location: {
|
||||
lng: lng,
|
||||
lat: lat,
|
||||
address: ads_data.address || '',
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取城市、区县
|
||||
self.get_city_list();
|
||||
self.get_county_list();
|
||||
|
||||
setTimeout(function() {
|
||||
self.init_value();
|
||||
}, 500);
|
||||
// 半秒后初始化数据
|
||||
setTimeout(function () {
|
||||
self.init_region_value();
|
||||
}, 500);
|
||||
} else {
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
@ -112,13 +135,35 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份信息失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取选择的省市区
|
||||
// 地区数据初始化
|
||||
init_region_value() {
|
||||
this.setData({
|
||||
province_value: this.get_region_value("province_list", "province_id"),
|
||||
city_value: this.get_region_value("city_list", "city_id"),
|
||||
county_value: this.get_region_value("county_list", "county_id"),
|
||||
});
|
||||
},
|
||||
|
||||
// 地区初始化匹配索引
|
||||
get_region_value(list, id) {
|
||||
var data = this.data[list];
|
||||
var data_id = this.data[id];
|
||||
var value = null;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 获取省份
|
||||
get_province_list() {
|
||||
var self = this;
|
||||
wx.request({
|
||||
@ -138,11 +183,12 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("省份获取失败");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取市
|
||||
get_city_list() {
|
||||
var self = this;
|
||||
if (self.data.province_id) {
|
||||
@ -165,12 +211,13 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("城市获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 获取区/县
|
||||
get_county_list() {
|
||||
var self = this;
|
||||
if (self.data.city_id) {
|
||||
@ -194,19 +241,19 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
app.showToast("服务器请求出错");
|
||||
app.showToast("区/县获取失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
select_province(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.province_list[value];
|
||||
// 省份事件
|
||||
select_province_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.province_list[index];
|
||||
this.setData({
|
||||
province_value: value,
|
||||
province_value: index,
|
||||
province_id: data.id,
|
||||
city_value: null,
|
||||
county_value: null,
|
||||
@ -217,13 +264,13 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_city(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.city_list[value];
|
||||
// 市事件
|
||||
select_city_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.city_list[index];
|
||||
this.setData({
|
||||
city_value: value,
|
||||
city_value: index,
|
||||
city_id: data.id,
|
||||
county_value: null,
|
||||
county_id: null
|
||||
@ -232,69 +279,181 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
select_county(e) {
|
||||
if(e.detail.value >= 0)
|
||||
{
|
||||
var value = e.detail.value,
|
||||
data = this.data.county_list[value];
|
||||
// 区/县事件
|
||||
select_county_event(e) {
|
||||
var index = e.detail.value || 0;
|
||||
if (index >= 0) {
|
||||
var data = this.data.county_list[index];
|
||||
this.setData({
|
||||
county_value: value,
|
||||
county_value: index,
|
||||
county_id: data.id
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init_value() {
|
||||
var province_value = this.get_init_value("province_list", "province_id"),
|
||||
city_value = this.get_init_value("city_list", "city_id"),
|
||||
county_value = this.get_init_value("county_list", "county_id");
|
||||
this.setData({
|
||||
province_value: province_value,
|
||||
city_value: city_value,
|
||||
county_value: county_value
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if (value != null) {
|
||||
app.showToast(value);
|
||||
}
|
||||
},
|
||||
|
||||
// 选择地理位置
|
||||
choose_location_event(e) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/common/open-setting-location/open-setting-location'
|
||||
});
|
||||
},
|
||||
|
||||
get_init_value(list, id) {
|
||||
var data = this.data[list],
|
||||
data_id = this.data[id],
|
||||
value;
|
||||
data.forEach((d, i) => {
|
||||
if (d.id == data_id) {
|
||||
value = i;
|
||||
return false;
|
||||
// 地址信息初始化
|
||||
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});
|
||||
},
|
||||
|
||||
// 文件上传
|
||||
file_upload_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
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, form_name);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 采用递归的方式上传多张
|
||||
upload_one_by_one(img_paths, success, fail, count, length, form_name) {
|
||||
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_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = data.data.url;
|
||||
self.setData({ idcard_images_data: temp_idcard_images_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, form_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 图片删除
|
||||
upload_delete_event(e) {
|
||||
var form_name = e.currentTarget.dataset.value || null;
|
||||
if(form_name == null) {
|
||||
app.showToast('表单名称类型有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
wx.showModal({
|
||||
title: '温馨提示',
|
||||
content: '删除后不可恢复、继续吗?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
var temp_idcard_images_data = self.data.idcard_images_data || {};
|
||||
temp_idcard_images_data[form_name] = '';
|
||||
self.setData({ idcard_images_data: temp_idcard_images_data });
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
|
||||
// 数据提交
|
||||
form_submit(e) {
|
||||
var self = this,
|
||||
data = self.data;
|
||||
var self = this;
|
||||
// 表单数据
|
||||
var form_data = e.detail.value;
|
||||
|
||||
// 数据校验
|
||||
var validation = [
|
||||
{ fields: "name", msg: "请填写姓名" },
|
||||
{ fields: "tel", msg: "请填写手机号" },
|
||||
{ fields: "name", msg: "请填写联系人" },
|
||||
{ fields: "tel", msg: "请填写联系电话" },
|
||||
{ fields: "province", msg: "请选择省份" },
|
||||
{ fields: "city", msg: "请选择城市" },
|
||||
{ fields: "county", msg: "请选择区县" },
|
||||
{ fields: "address", msg: "请填写详细地址" }
|
||||
{ fields: "address", msg: "请填写详细地址" },
|
||||
{ fields: "lng", msg: "请选择地理位置" },
|
||||
{ fields: "lat", msg: "请选择地理位置" }
|
||||
];
|
||||
|
||||
form_data["province"] = data.province_id;
|
||||
form_data["city"] = data.city_id;
|
||||
form_data["county"] = data.county_id;
|
||||
form_data["province"] = self.data.province_id;
|
||||
form_data["city"] = self.data.city_id;
|
||||
form_data["county"] = self.data.county_id;
|
||||
form_data["id"] = self.data.params.id || 0;
|
||||
form_data["is_default"] = self.data.is_default || 0;
|
||||
form_data["is_default"] = form_data.is_default == true ? 1 : 0;
|
||||
form_data['idcard_front'] = self.data.idcard_images_data.idcard_front || '';
|
||||
form_data['idcard_back'] = self.data.idcard_images_data.idcard_back || '';
|
||||
|
||||
// 地理位置
|
||||
var lng = 0;
|
||||
var lat = 0;
|
||||
if((self.data.user_location || null) != null) {
|
||||
lng = self.data.user_location.lng || 0;
|
||||
lat = self.data.user_location.lat || 0;
|
||||
}
|
||||
if((self.data.address_data || null) != null) {
|
||||
if((lng || null) == null) {
|
||||
lng = self.data.address_data.lng || 0;
|
||||
}
|
||||
if((lat || null) == null) {
|
||||
lat = self.data.address_data.lat || 0;
|
||||
}
|
||||
}
|
||||
form_data["lng"] = lng;
|
||||
form_data["lat"] = lat;
|
||||
|
||||
// 验证提交表单
|
||||
if (app.fields_check(form_data, validation)) {
|
||||
// 加载loding
|
||||
wx.showLoading({title: "处理中..." });
|
||||
|
||||
// 数据保存
|
||||
self.setData({ form_submit_disabled_status: true });
|
||||
wx.showLoading({ title: "处理中..." });
|
||||
wx.request({
|
||||
url: app.get_request_url("save", "useraddress"),
|
||||
method: "POST",
|
||||
@ -305,10 +464,11 @@ Page({
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
app.showToast(res.data.msg, "success");
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
wx.navigateBack();
|
||||
}, 1000);
|
||||
} else {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
if (app.is_login_check(res.data)) {
|
||||
app.showToast(res.data.msg);
|
||||
} else {
|
||||
@ -317,19 +477,11 @@ Page({
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
self.setData({ form_submit_disabled_status: false });
|
||||
wx.hideLoading();
|
||||
app.showToast("服务器请求出错");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 省市区未按照顺序选择提示
|
||||
region_select_error_event(e) {
|
||||
var value = e.currentTarget.dataset.value || null;
|
||||
if(value != null)
|
||||
{
|
||||
app.showToast(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,34 +1,88 @@
|
||||
<form bindsubmit="form_submit">
|
||||
<view class="person-box bg-white">
|
||||
<view class="addressee br-b oh">
|
||||
<input class="addressee-name fl br-r" name="name" type="text" value="{{name}}" placeholder="姓名" />
|
||||
<input class="addressee-phone fl" name="tel" type="number" value="{{tel}}" placeholder="手机号" />
|
||||
<view class="page">
|
||||
<form bindsubmit="form_submit" class="form-container oh">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">别名<text class="form-group-tips">选填</text></view>
|
||||
<input type="text" name="alias" value="{{address_data.alias || ''}}" maxlength="16" placeholder-class="cr-ccc" class="cr-666" placeholder="别名格式最多 16 个字符" />
|
||||
</view>
|
||||
|
||||
<!-- 地区选择 -->
|
||||
<view class="select-address br-b oh">
|
||||
<view class="section fl br-r">
|
||||
<picker name="province" bindchange="select_province" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-888' : '' }}">{{province_list[province_value].name || default_province}}</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="{{address_data.name || ''}}" maxlength="16" 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="{{address_data.tel || ''}}" maxlength="30" placeholder-class="cr-ccc" class="cr-666" placeholder="座机 或 手机" />
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">省市区<text class="form-group-tips-must">必选</text></view>
|
||||
<view class="select-address oh">
|
||||
<view class="section fl">
|
||||
<picker name="province" bindchange="select_province_event" value="{{province_value}}" range="{{province_list}}" range-key="name">
|
||||
<view class="name {{(province_value == null) ? 'cr-ccc' : 'cr-666' }}">{{province_list[province_value].name || default_province}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="section fl br-r">
|
||||
<picker wx:if="{{(province_id || null) != null}}" name="city" bindchange="select_city" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-888' : '' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text wx:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker wx:if="{{(city_id || null) != null}}" name="county" bindchange="select_county" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-888' : '' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
<picker wx:if="{{(province_id || null) != null}}" name="city" bindchange="select_city_event" value="{{city_value}}" range="{{city_list}}" range-key="name">
|
||||
<view class="name {{(city_value == null) ? 'cr-ccc' : 'cr-666' }}">{{city_list[city_value].name || default_city}}</view>
|
||||
</picker>
|
||||
<text wx:else class="cr-888" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
<text wx:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择省份">请先选择省份</text>
|
||||
</view>
|
||||
<view class="section fl">
|
||||
<picker wx:if="{{(city_id || null) != null}}" name="county" bindchange="select_county_event" value="{{county_value}}" range="{{county_list}}" range-key="name">
|
||||
<view class="name {{(county_value == null) ? 'cr-ccc' : 'cr-666' }}">{{county_list[county_value].name || default_county}}</view>
|
||||
</picker>
|
||||
<text wx:else class="cr-ccc" bindtap="region_select_error_event" data-value="请先选择城市">请先选择城市</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- end地区选择 -->
|
||||
|
||||
<input name="address" class="addressee-address" type="text" value="{{address}}" placeholder="详细地址" />
|
||||
</view>
|
||||
<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="{{address_data.address || ''}}" maxlength="80" placeholder-class="cr-ccc" class="cr-666" placeholder="详细地址格式 1~80 个字符之间" />
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none">保存</button>
|
||||
</form>
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">地理位置<text class="form-group-tips-must">必选</text></view>
|
||||
<view bindtap="choose_location_event" class="form-gorup-text">
|
||||
<view wx:if="{{(user_location || null) == null && (address_data.address || null) == null}}" class="cr-888">请选择地理位置</view>
|
||||
<view wx:else class="cr-666">{{((user_location || null) != null && (user_location.name || null) != null) ? user_location.name+' ' : ''}}{{user_location.address || address_data.address || ''}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">是否默认<text class="form-group-tips">选填</text></view>
|
||||
<view class="switch">
|
||||
<switch name="is_default" checked="{{address_data.is_default == 1 ? true : false}}" color="#04BE02" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 身份证信息 -->
|
||||
<view class="idcard-container">
|
||||
<view class="form-gorup bg-white">
|
||||
<view class="form-gorup-title">身份证姓名<text class="form-group-tips">选填,请务必与上传的身份证件姓名保持一致</text></view>
|
||||
<input type="text" name="idcard_name" value="{{address_data.idcard_name || ''}}" maxlength="16" 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">选填,请务必与上传的身份证件号码保持一致</text></view>
|
||||
<input type="idcard" name="idcard_number" value="{{address_data.idcard_number || ''}}" maxlength="18" placeholder-class="cr-ccc" class="cr-666" placeholder="身份证号码格式最多18个字符" />
|
||||
</view>
|
||||
<view class="form-gorup bg-white form-container-upload oh">
|
||||
<view class="form-gorup-title">身份证照片<text class="form-group-tips">选填,请使用身份证原件拍摄,图片要清晰</text></view>
|
||||
<view class="form-upload-data">
|
||||
<view class="item fl">
|
||||
<text wx:if="{{(idcard_images_data.idcard_front || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_front">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_front || null) != null ? idcard_images_data.idcard_front : '/images/default-idcard-front.jpg'}}" data-value="idcard_front" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
<view class="item fl">
|
||||
<text wx:if="{{(idcard_images_data.idcard_back || null) != null}}" class="delete-icon" bindtap="upload_delete_event" data-value="idcard_back">x</text>
|
||||
<image src="{{(idcard_images_data.idcard_back || null) != null ? idcard_images_data.idcard_back : '/images/default-idcard-back.jpg'}}" data-value="idcard_back" mode="aspectFill" bindtap="file_upload_event" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="submit-fixed submit-bottom" type="default" formType="submit" hover-class="none" disabled="{{form_submit_disabled_status}}">保存</button>
|
||||
</form>
|
||||
</view>
|
||||
@ -1,38 +1,39 @@
|
||||
/* 填写信息 */
|
||||
.person-box{
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
.person-box input{
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
font-size: 28rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius:0;
|
||||
}
|
||||
.addressee .addressee-name{
|
||||
width: 250rpx;
|
||||
/*
|
||||
* 三级联动
|
||||
*/
|
||||
.select-address {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.addressee .addressee-phone{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 250rpx);
|
||||
}
|
||||
/* 三级联动 */
|
||||
.select-address{
|
||||
box-sizing: border-box;
|
||||
height: 100rpx;
|
||||
line-height: 100rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
padding: 0 10rpx;
|
||||
}
|
||||
.select-address .section {
|
||||
width: 33%;
|
||||
width: 33.33%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.select-address .section:not(:first-child) {
|
||||
padding: 0 5rpx;
|
||||
}
|
||||
/* end 三级联动 */
|
||||
.addressee-address{
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
/*
|
||||
* 表单
|
||||
*/
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
}
|
||||
.submit-bottom {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* 身份信息
|
||||
*/
|
||||
.idcard-container {
|
||||
background: #e0e0e0;
|
||||
padding: 30rpx;
|
||||
}
|
||||
.idcard-container .form-upload-data .item image {
|
||||
width: 256rpx;
|
||||
height: 170rpx;
|
||||
border: 1px dashed #c2c2c2;
|
||||
}
|
||||
@ -10,11 +10,11 @@ Page({
|
||||
|
||||
onLoad(params) {
|
||||
this.setData({params: params});
|
||||
this.init();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
wx.setNavigationBarTitle({title: app.data.common_pages_title.user_address});
|
||||
this.init();
|
||||
},
|
||||
|
||||
// 初始化
|
||||
@ -289,5 +289,37 @@ Page({
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 地址编辑
|
||||
address_edit_event(e) {
|
||||
var index = e.currentTarget.dataset.index || 0;
|
||||
var data = this.data.data_list[index] || null;
|
||||
if (data == null)
|
||||
{
|
||||
app.showToast("地址有误");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 进入编辑页面
|
||||
wx.navigateTo({
|
||||
url: '/pages/user-address-save/user-address-save?id='+data.id
|
||||
});
|
||||
},
|
||||
|
||||
// 地图查看
|
||||
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);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -18,10 +18,11 @@
|
||||
<image wx:else class="item-icon" src="/images/default-select-icon.png" mode="widthFix" />
|
||||
<text>设为默认地址</text>
|
||||
</view>
|
||||
<button class="fr cr-666 delete-submit br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
<navigator url="/pages/user-address-save/user-address-save?id={{item.id}}" open-type="navigate" hover-class="none">
|
||||
<button class="fr cr-666 br" type="default" size="mini" bindtap="address_edit_event" hover-class="none">编辑</button>
|
||||
</navigator>
|
||||
<view class="fr oh submit-items">
|
||||
<button wx:if="{{(item.lng || null) != null && (item.lat || null) != null}}" class="cr-666 br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">位置</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_edit_event" data-index="{{index}}" hover-class="none">编辑</button>
|
||||
<button class="cr-666 br" type="default" size="mini" bindtap="address_delete_event" data-index="{{index}}" data-value="{{item.id}}" hover-class="none">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
margin-right: 10rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.operation .delete-submit {
|
||||
margin-left: 20rpx;
|
||||
.operation .submit-items button:not(:last-child) {
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
.page {
|
||||
padding-bottom: 85rpx;
|
||||
|
||||
@ -110,7 +110,7 @@ Page({
|
||||
var data = this.data.detail.address_data;
|
||||
|
||||
// 打开地图
|
||||
var name = data.alias || '';
|
||||
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);
|
||||
},
|
||||
|
||||