parent
6442fc5c11
commit
e08f65b4cb
49
api/api.js
49
api/api.js
|
@ -1,12 +1,12 @@
|
|||
import request from "@/utils/request.js";
|
||||
/**
|
||||
* 公共接口 ,优惠券接口 , 行业此讯 , 手机号码注册
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取主页数据 无需授权
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getIndexData()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ export function getIndexData()
|
|||
|
||||
/**
|
||||
* 获取登录授权login
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getLogo()
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ export function getLogo()
|
|||
|
||||
/**
|
||||
* 保存form_id
|
||||
* @param string formId
|
||||
* @param string formId
|
||||
*/
|
||||
export function setFormId(formId) {
|
||||
return request.post("wechat/set_form_id", { formId: formId});
|
||||
|
@ -34,7 +34,7 @@ export function setFormId(formId) {
|
|||
/**
|
||||
* 领取优惠卷
|
||||
* @param int couponId
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function setCouponReceive(couponId){
|
||||
return request.post('coupon/receive', { couponId: couponId});
|
||||
|
@ -57,7 +57,7 @@ export function getUserCoupons(data){
|
|||
|
||||
/**
|
||||
* 文章分类列表
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getArticleCategoryList(){
|
||||
return request.get('article/category/list',{},{noAuth:true})
|
||||
|
@ -66,7 +66,7 @@ export function getArticleCategoryList(){
|
|||
/**
|
||||
* 文章列表
|
||||
* @param int cid
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getArticleList(cid,data){
|
||||
return request.get('article/list/' + cid, data,{noAuth:true})
|
||||
|
@ -74,7 +74,7 @@ export function getArticleList(cid,data){
|
|||
|
||||
/**
|
||||
* 文章 热门列表
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getArticleHotList(){
|
||||
return request.get('article/hot/list',{},{noAuth:true});
|
||||
|
@ -82,7 +82,7 @@ export function getArticleHotList(){
|
|||
|
||||
/**
|
||||
* 文章 轮播列表
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function getArticleBannerList(){
|
||||
return request.get('article/banner/list',{},{noAuth:true})
|
||||
|
@ -90,8 +90,8 @@ export function getArticleBannerList(){
|
|||
|
||||
/**
|
||||
* 文章详情
|
||||
* @param int id
|
||||
*
|
||||
* @param int id
|
||||
*
|
||||
*/
|
||||
export function getArticleDetails(id){
|
||||
return request.get('article/info',id,{noAuth:true});
|
||||
|
@ -124,7 +124,7 @@ export function registerVerify(phone){
|
|||
/**
|
||||
* 手机号注册
|
||||
* @param object data
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function phoneRegister(data){
|
||||
return request.post('register',data,{noAuth:true});
|
||||
|
@ -133,7 +133,7 @@ export function phoneRegister(data){
|
|||
/**
|
||||
* 手机号修改密码
|
||||
* @param object data
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function phoneRegisterReset(data){
|
||||
return request.post('register/reset',data,{noAuth:true})
|
||||
|
@ -142,7 +142,7 @@ export function phoneRegisterReset(data){
|
|||
/**
|
||||
* 手机号+密码登录
|
||||
* @param object data
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function phoneLogin(data){
|
||||
return request.post('login',data,{noAuth:true})
|
||||
|
@ -169,7 +169,7 @@ export function switchH5Login() {
|
|||
|
||||
/**
|
||||
* 换绑手机号
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function bindingPhone(data){
|
||||
return request.post('update/binding',data);
|
||||
|
@ -177,7 +177,7 @@ export function bindingPhone(data){
|
|||
|
||||
/**
|
||||
* 换绑手机号校验
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function bindingVerify(data){
|
||||
return request.post('update/binding/verify',data);
|
||||
|
@ -185,7 +185,7 @@ export function bindingVerify(data){
|
|||
|
||||
/**
|
||||
* 退出登錄
|
||||
*
|
||||
*
|
||||
*/
|
||||
export function logout(){
|
||||
return request.get('logout');
|
||||
|
@ -199,21 +199,6 @@ export function getTemlIds(data)
|
|||
return request.get('wechat/program/my/temp/list', data , { noAuth:true});
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页拼团数据
|
||||
*/
|
||||
export function pink()
|
||||
{
|
||||
return request.get('pink', {}, { noAuth:true});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取城市信息
|
||||
*/
|
||||
export function getCity() {
|
||||
return request.get('city/list', { }, { noAuth: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序直播列表
|
||||
*/
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
import request from "@/utils/request.js";
|
||||
|
||||
// 获得用户收件地址
|
||||
export function getAddress(id) {
|
||||
return request.get('app-api/member/address/get', {
|
||||
id
|
||||
});
|
||||
}
|
||||
|
||||
// 获得用户收件地址列表
|
||||
export function getAddressList() {
|
||||
return request.get('app-api/member/address/list', {});
|
||||
}
|
||||
|
||||
// 创建用户收件地址
|
||||
export function createAddress(data) {
|
||||
return request.post('app-api/member/address/create', data);
|
||||
}
|
||||
|
||||
// 更新用户收件地址
|
||||
export function updateAddress(data) {
|
||||
return request.put('app-api/member/address/update', data);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import request from "@/utils/request.js";
|
||||
|
||||
// 获得地区树
|
||||
export function getAreaTree() {
|
||||
return request.get("app-api/system/area/tree", {}, {
|
||||
noAuth: true // TODO 芋艿:后续要做调整
|
||||
});
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view>
|
||||
<view class="address-window" :class="address.address==true?'on':''">
|
||||
<view class="address-window" :class="address.address ? 'on' : ''">
|
||||
<view class='title'>选择地址<text class='iconfont icon-guanbi' @tap='close'></text></view>
|
||||
<view class='list'>
|
||||
<view class='item acea-row row-between-wrapper' :class='active==index?"font-color":""' v-for="(item,index) in addressList"
|
||||
|
@ -19,7 +19,7 @@
|
|||
</view>
|
||||
<view class='addressBnt bg-color' @tap='goAddressPages'>选择其地址</view>
|
||||
</view>
|
||||
<view class='mask' catchtouchmove="true" :hidden='address.address==false' @tap='close'></view>
|
||||
<view class='mask' catchtouchmove="true" :hidden='!address.address' @tap='close' />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
|||
type: Object,
|
||||
default: function() {
|
||||
return {
|
||||
address: true,
|
||||
address: true, // 是否打开
|
||||
addressId: 0,
|
||||
};
|
||||
}
|
||||
|
@ -54,13 +54,12 @@
|
|||
addressList: []
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
tapAddress: function(e, addressid) {
|
||||
this.active = e;
|
||||
let a = {};
|
||||
for (let i = 0, leng = this.addressList.length; i < leng; i++) {
|
||||
if (this.addressList[i].id == addressid) {
|
||||
if (this.addressList[i].id === addressid) {
|
||||
a = this.addressList[i];
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,139 +0,0 @@
|
|||
/* eslint-disable */
|
||||
var provinceData = [{
|
||||
"label": "北京市",
|
||||
"value": "11"
|
||||
},
|
||||
{
|
||||
"label": "天津市",
|
||||
"value": "12"
|
||||
},
|
||||
{
|
||||
"label": "河北省",
|
||||
"value": "13"
|
||||
},
|
||||
{
|
||||
"label": "山西省",
|
||||
"value": "14"
|
||||
},
|
||||
{
|
||||
"label": "内蒙古自治区",
|
||||
"value": "15"
|
||||
},
|
||||
{
|
||||
"label": "辽宁省",
|
||||
"value": "21"
|
||||
},
|
||||
{
|
||||
"label": "吉林省",
|
||||
"value": "22"
|
||||
},
|
||||
{
|
||||
"label": "黑龙江省",
|
||||
"value": "23"
|
||||
},
|
||||
{
|
||||
"label": "上海市",
|
||||
"value": "31"
|
||||
},
|
||||
{
|
||||
"label": "江苏省",
|
||||
"value": "32"
|
||||
},
|
||||
{
|
||||
"label": "浙江省",
|
||||
"value": "33"
|
||||
},
|
||||
{
|
||||
"label": "安徽省",
|
||||
"value": "34"
|
||||
},
|
||||
{
|
||||
"label": "福建省",
|
||||
"value": "35"
|
||||
},
|
||||
{
|
||||
"label": "江西省",
|
||||
"value": "36"
|
||||
},
|
||||
{
|
||||
"label": "山东省",
|
||||
"value": "37"
|
||||
},
|
||||
{
|
||||
"label": "河南省",
|
||||
"value": "41"
|
||||
},
|
||||
{
|
||||
"label": "湖北省",
|
||||
"value": "42"
|
||||
},
|
||||
{
|
||||
"label": "湖南省",
|
||||
"value": "43"
|
||||
},
|
||||
{
|
||||
"label": "广东省",
|
||||
"value": "44"
|
||||
},
|
||||
{
|
||||
"label": "广西壮族自治区",
|
||||
"value": "45"
|
||||
},
|
||||
{
|
||||
"label": "海南省",
|
||||
"value": "46"
|
||||
},
|
||||
{
|
||||
"label": "重庆市",
|
||||
"value": "50"
|
||||
},
|
||||
{
|
||||
"label": "四川省",
|
||||
"value": "51"
|
||||
},
|
||||
{
|
||||
"label": "贵州省",
|
||||
"value": "52"
|
||||
},
|
||||
{
|
||||
"label": "云南省",
|
||||
"value": "53"
|
||||
},
|
||||
{
|
||||
"label": "西藏自治区",
|
||||
"value": "54"
|
||||
},
|
||||
{
|
||||
"label": "陕西省",
|
||||
"value": "61"
|
||||
},
|
||||
{
|
||||
"label": "甘肃省",
|
||||
"value": "62"
|
||||
},
|
||||
{
|
||||
"label": "青海省",
|
||||
"value": "63"
|
||||
},
|
||||
{
|
||||
"label": "宁夏回族自治区",
|
||||
"value": "64"
|
||||
},
|
||||
{
|
||||
"label": "新疆维吾尔自治区",
|
||||
"value": "65"
|
||||
},
|
||||
{
|
||||
"label": "台湾",
|
||||
"value": "66"
|
||||
},
|
||||
{
|
||||
"label": "香港",
|
||||
"value": "67"
|
||||
},
|
||||
{
|
||||
"label": "澳门",
|
||||
"value": "68"
|
||||
}
|
||||
]
|
||||
export default provinceData;
|
|
@ -1,680 +0,0 @@
|
|||
const forMatNum=(num)=>{
|
||||
return num<10?'0'+num:num+'';
|
||||
}
|
||||
const initPicker={
|
||||
//日期
|
||||
date:{
|
||||
init(start,end,mode="date",step,value,flag,disabled,hasSecond){
|
||||
let aToday=new Date();
|
||||
let tYear,tMonth,tDay,tHours,tMinutes,tSeconds,defaultVal=[];
|
||||
let initstartDate=new Date(start.toString());
|
||||
let endDate=new Date(end.toString());
|
||||
if(start>end){
|
||||
initstartDate=new Date(end.toString());
|
||||
endDate=new Date(start.toString());
|
||||
};
|
||||
let startYear=initstartDate.getFullYear();
|
||||
let startMonth=initstartDate.getMonth()+1;
|
||||
let endYear=endDate.getFullYear();
|
||||
let years=[],months=[],days=[],hours=[],minutes=[],seconds=[],areas=[],returnArr=[],dvalDate=[];
|
||||
switch(mode){
|
||||
case "half":
|
||||
dvalDate=flag?[...value.split(" ")[0].split("-"),...value.split(" ")[1].split(":")]:[...value.split(" ")[0].split("-"),value.split(" ")[1]];
|
||||
break;
|
||||
case "date":
|
||||
case "yearMonth":
|
||||
dvalDate=value.split("-");
|
||||
break;
|
||||
case "dateTime":
|
||||
dvalDate=[...value.split(" ")[0].split("-"),...value.split(" ")[1].split(":")];
|
||||
break;
|
||||
case "time":
|
||||
dvalDate=value.split(":");
|
||||
break;
|
||||
}
|
||||
let curMonth=flag?dvalDate[1]*1:(dvalDate[1]+1);
|
||||
let dYear=aToday.getFullYear();
|
||||
let dMonth=aToday.getMonth()+1;
|
||||
let dDate=aToday.getDate();
|
||||
let totalDays=new Date(startYear,curMonth,0).getDate();
|
||||
let dvalObj={};
|
||||
switch(mode){
|
||||
case "half":
|
||||
case "date":
|
||||
case "yearMonth":
|
||||
let curYear=dvalDate[0];
|
||||
let curMonth=dvalDate[1];
|
||||
if(disabled){
|
||||
for(let s=startYear;s<=dYear;s++){
|
||||
years.push(s+'');
|
||||
};
|
||||
if(curYear==dYear){
|
||||
for(let m=1;m<=dMonth;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}else{
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}
|
||||
if(curMonth==dMonth){
|
||||
for(let d=1;d<=dDate;d++){
|
||||
days.push(forMatNum(d));
|
||||
}
|
||||
}else{
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
for(let s=startYear;s<=endYear;s++){
|
||||
years.push(s+'');
|
||||
};
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
}
|
||||
};
|
||||
break;
|
||||
default:
|
||||
for(let s=startYear;s<=endYear;s++){
|
||||
years.push(s+'');
|
||||
};
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
}
|
||||
break;
|
||||
}
|
||||
for(let h=0;h<24;h++){
|
||||
hours.push(forMatNum(h));
|
||||
}
|
||||
for(let m=0;m<60;m+=step*1){
|
||||
minutes.push(forMatNum(m));
|
||||
}
|
||||
for(let s=0;s<60;s++){
|
||||
seconds.push(forMatNum(s));
|
||||
}
|
||||
if(flag){
|
||||
returnArr=[
|
||||
years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1]),
|
||||
days.indexOf(dvalDate[2]),
|
||||
hours.indexOf(dvalDate[3]),
|
||||
minutes.indexOf(dvalDate[4])==-1?0:minutes.indexOf(dvalDate[4]),
|
||||
seconds.indexOf(dvalDate[5])
|
||||
]
|
||||
}
|
||||
switch(mode){
|
||||
case "date":
|
||||
if(flag){
|
||||
defaultVal=[returnArr[0],returnArr[1],returnArr[2]];
|
||||
return {years,months,days,defaultVal}
|
||||
}else{
|
||||
defaultVal=[
|
||||
years.indexOf(dvalDate[0])==-1?0:years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1])==-1?0:months.indexOf(dvalDate[1]),
|
||||
days.indexOf(dvalDate[2])==-1?0:days.indexOf(dvalDate[2])
|
||||
];
|
||||
return {years,months,days,defaultVal}
|
||||
}
|
||||
break;
|
||||
case "half":
|
||||
areas=[{
|
||||
label:"上午",
|
||||
value:0
|
||||
},{
|
||||
label:"下午",
|
||||
value:1
|
||||
}];
|
||||
if(flag){
|
||||
defaultVal=[returnArr[0],returnArr[1],returnArr[2],returnArr[3]];
|
||||
return {years,months,days,areas,defaultVal}
|
||||
}else{
|
||||
let idx=0;
|
||||
areas.map((v,k)=>{
|
||||
if(v.label==dvalDate[3]){
|
||||
idx=v.value;
|
||||
}
|
||||
})
|
||||
defaultVal=[
|
||||
years.indexOf(dvalDate[0])==-1?0:years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1])==-1?0:months.indexOf(dvalDate[1]),
|
||||
days.indexOf(dvalDate[2])==-1?0:days.indexOf(dvalDate[2]),
|
||||
idx
|
||||
];
|
||||
return {years,months,days,areas,defaultVal}
|
||||
}
|
||||
break;
|
||||
case "yearMonth":
|
||||
if(flag){
|
||||
defaultVal=[returnArr[0],returnArr[1]];
|
||||
return {years,months,defaultVal}
|
||||
}else{
|
||||
defaultVal=[
|
||||
years.indexOf(dvalDate[0])==-1?0:years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1])==-1?0:months.indexOf(dvalDate[1])
|
||||
];
|
||||
return {years,months,defaultVal}
|
||||
}
|
||||
break;
|
||||
case "dateTime":
|
||||
if(flag){
|
||||
defaultVal=returnArr;
|
||||
}else{
|
||||
if(hasSecond){
|
||||
defaultVal=[
|
||||
years.indexOf(dvalDate[0])==-1?0:years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1])==-1?0:months.indexOf(dvalDate[1]),
|
||||
days.indexOf(dvalDate[2])==-1?0:days.indexOf(dvalDate[2]),
|
||||
hours.indexOf(dvalDate[3])==-1?0:hours.indexOf(dvalDate[3]),
|
||||
minutes.indexOf(dvalDate[4])==-1?0:minutes.indexOf(dvalDate[4]),
|
||||
seconds.indexOf(dvalDate[5])==-1?0:seconds.indexOf(dvalDate[5])
|
||||
];
|
||||
}else{
|
||||
defaultVal=[
|
||||
years.indexOf(dvalDate[0])==-1?0:years.indexOf(dvalDate[0]),
|
||||
months.indexOf(dvalDate[1])==-1?0:months.indexOf(dvalDate[1]),
|
||||
days.indexOf(dvalDate[2])==-1?0:days.indexOf(dvalDate[2]),
|
||||
hours.indexOf(dvalDate[3])==-1?0:hours.indexOf(dvalDate[3]),
|
||||
minutes.indexOf(dvalDate[4])==-1?0:minutes.indexOf(dvalDate[4])
|
||||
];
|
||||
}
|
||||
}
|
||||
if(hasSecond){
|
||||
return {years,months,days,hours,minutes,seconds,defaultVal}
|
||||
}else{
|
||||
return {years,months,days,hours,minutes,defaultVal}
|
||||
}
|
||||
break;
|
||||
case "time":
|
||||
if(flag){
|
||||
defaultVal=[returnArr[3],returnArr[4],returnArr[5]];
|
||||
}else{
|
||||
if(hasSecond){
|
||||
defaultVal=[
|
||||
hours.indexOf(dvalDate[0])==-1?0:hours.indexOf(dvalDate[0]),
|
||||
minutes.indexOf(dvalDate[1])==-1?0:minutes.indexOf(dvalDate[1]),
|
||||
seconds.indexOf(dvalDate[2])==-1?0:seconds.indexOf(dvalDate[2])
|
||||
];
|
||||
}else{
|
||||
defaultVal=[
|
||||
hours.indexOf(dvalDate[0])==-1?0:hours.indexOf(dvalDate[0]),
|
||||
minutes.indexOf(dvalDate[1])==-1?0:minutes.indexOf(dvalDate[1])
|
||||
];
|
||||
}
|
||||
}
|
||||
return {hours,minutes,seconds,defaultVal}
|
||||
break;
|
||||
}
|
||||
},
|
||||
initMonths:(year,disabled)=>{
|
||||
let aDate=new Date();
|
||||
let dYear=aDate.getFullYear();
|
||||
let dMonth=aDate.getMonth()+1;
|
||||
let dDate=aDate.getDate();
|
||||
let flag=dYear==year?true:false;
|
||||
let months=[];
|
||||
if(disabled){
|
||||
if(flag){
|
||||
for(let m=1;m<=dMonth;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}else{
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}
|
||||
}else{
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
};
|
||||
return months;
|
||||
},
|
||||
initDays:(year,month,disabled)=>{
|
||||
let aDate=new Date();
|
||||
let dYear=aDate.getFullYear();
|
||||
let dMonth=aDate.getMonth()+1;
|
||||
let dDate=aDate.getDate();
|
||||
let flag=(dYear==year&&dMonth==month)?true:false;
|
||||
let totalDays=new Date(year,month,0).getDate();
|
||||
let dates=[];
|
||||
if(flag&&disabled){
|
||||
for(let d=1;d<=dDate;d++){
|
||||
dates.push(forMatNum(d));
|
||||
};
|
||||
}else{
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
dates.push(forMatNum(d));
|
||||
};
|
||||
};
|
||||
return dates;
|
||||
},
|
||||
},
|
||||
//短期日期上下午
|
||||
limitHour:{
|
||||
init(dayStep=7,dVal){
|
||||
let startDate=new Date();
|
||||
let date=[],areas=[],hours=[];
|
||||
let hour=new Date().getHours();
|
||||
let weeks=["周日","周一","周二","周三","周四","周五","周六"];
|
||||
let arrs=[];
|
||||
let defaultVal=[];
|
||||
let d=0,a=0,h=0;
|
||||
for(let i=0;i<dayStep;i++){
|
||||
let year,month,day,weekday;
|
||||
year=startDate.getFullYear();
|
||||
month=forMatNum(startDate.getMonth()+1);
|
||||
day=forMatNum(startDate.getDate());
|
||||
weekday=weeks[startDate.getDay()];
|
||||
let label="";
|
||||
switch(i){
|
||||
case 0:
|
||||
label="今天";
|
||||
break;
|
||||
case 1:
|
||||
label="明天"
|
||||
break;
|
||||
case 2:
|
||||
label="后天"
|
||||
break;
|
||||
default:
|
||||
label=month+"月"+day+"日"+" "+weekday;
|
||||
break;
|
||||
}
|
||||
date.push({
|
||||
label:label,
|
||||
value:year+"-"+month+"-"+day,
|
||||
today:i==0?true:false
|
||||
})
|
||||
startDate.setDate(startDate.getDate()+1);
|
||||
}
|
||||
if(hour>12){
|
||||
areas=[{
|
||||
label:"下午",
|
||||
value:1
|
||||
}]
|
||||
}else{
|
||||
areas=[{
|
||||
label:"上午",
|
||||
value:0
|
||||
},{
|
||||
label:"下午",
|
||||
value:1
|
||||
}]
|
||||
};
|
||||
for(let k=hour>12?hour-12:hour;k<=12;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(hour>12?k+12:k)
|
||||
})
|
||||
};
|
||||
date.map((v,k)=>{
|
||||
if(v.label==dVal[0]){
|
||||
d=k
|
||||
}
|
||||
})
|
||||
if(d!=0){
|
||||
areas=this.initAreas(date[d]);
|
||||
hours=this.initHours(date[d],areas[a]);
|
||||
}
|
||||
areas.map((v,k)=>{
|
||||
if(v.label==dVal[1]){
|
||||
a=k
|
||||
}
|
||||
})
|
||||
hours.map((v,k)=>{
|
||||
if(v.label==dVal[2]){
|
||||
h=k
|
||||
}
|
||||
});
|
||||
defaultVal=[d,a,h]
|
||||
return {date,areas,hours,defaultVal};
|
||||
},
|
||||
initAreas(date){
|
||||
let areas=[];
|
||||
let hour=new Date().getHours();
|
||||
if(date.today){
|
||||
if(hour>12){
|
||||
areas=[{
|
||||
label:"下午",
|
||||
value:1
|
||||
}]
|
||||
}else{
|
||||
areas=[{
|
||||
label:"上午",
|
||||
value:0
|
||||
},{
|
||||
label:"下午",
|
||||
value:1
|
||||
}]
|
||||
};
|
||||
}else{
|
||||
areas=[{
|
||||
label:"上午",
|
||||
value:0
|
||||
},{
|
||||
label:"下午",
|
||||
value:1
|
||||
}]
|
||||
}
|
||||
return areas;
|
||||
},
|
||||
initHours(dateCol,hourCol){
|
||||
let hours=[];
|
||||
let hour=new Date().getHours();
|
||||
if(dateCol.today){
|
||||
if(hourCol.value==1&&hour<=12){
|
||||
for(let k=1;k<=12;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(hourCol.value==1?k+12:k)
|
||||
})
|
||||
};
|
||||
}else{
|
||||
for(let k=hour>12?hour-12:hour;k<=12;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(hourCol.value==1?k+12:k)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
}else{
|
||||
for(let k=1;k<=12;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(hourCol.value==1?k+12:k)
|
||||
})
|
||||
};
|
||||
};
|
||||
return hours
|
||||
}
|
||||
},
|
||||
//短期日期时间初始化
|
||||
limit:{
|
||||
init(dayStep=7,startHour=8,endHour=20,minuteStep=1,afterStep=30,dVal){
|
||||
let startDate=new Date();
|
||||
let bsDate=new Date(new Date().getTime()+afterStep*60*1000);
|
||||
let date=[],hours=[],minutes=[];
|
||||
let hour=bsDate.getHours();
|
||||
let minute=Math.floor(bsDate.getMinutes()/minuteStep)*minuteStep;
|
||||
let weeks=["周日","周一","周二","周三","周四","周五","周六"];
|
||||
let d=0,h=0,m=0;
|
||||
let defaultVal=[];
|
||||
for(let i=0;i<dayStep;i++){
|
||||
let year,month,day,weekday;
|
||||
year=startDate.getFullYear();
|
||||
month=forMatNum(startDate.getMonth()+1);
|
||||
day=forMatNum(startDate.getDate());
|
||||
weekday=weeks[startDate.getDay()];
|
||||
let label="";
|
||||
switch(i){
|
||||
case 0:
|
||||
label="今天";
|
||||
break;
|
||||
case 1:
|
||||
label="明天"
|
||||
break;
|
||||
case 2:
|
||||
label="后天"
|
||||
break;
|
||||
default:
|
||||
label=month+"月"+day+"日"+" "+weekday;
|
||||
break;
|
||||
}
|
||||
date.push({
|
||||
label:label,
|
||||
value:year+"-"+month+"-"+day,
|
||||
flag:i==0?true:false
|
||||
})
|
||||
startDate.setDate(startDate.getDate()+1);
|
||||
}
|
||||
if(hour<startHour){
|
||||
hour=startHour;
|
||||
};
|
||||
if(hour>endHour){
|
||||
hour=endHour;
|
||||
};
|
||||
for(let k=hour*1;k<=endHour*1;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(k),
|
||||
flag:k==hour?true:false
|
||||
})
|
||||
};
|
||||
for(let j=minute;j<60;j+=minuteStep*1){
|
||||
minutes.push({
|
||||
label:forMatNum(j),
|
||||
value:forMatNum(j)
|
||||
});
|
||||
}
|
||||
date.map((v,k)=>{
|
||||
if(v.label==dVal[0]){
|
||||
d=k
|
||||
}
|
||||
})
|
||||
if(d!=0){
|
||||
hours=this.initHours(startHour=8,endHour=20,minuteStep=1,afterStep=30,date[d].value);
|
||||
}
|
||||
hours.map((v,k)=>{
|
||||
if(v.label==dVal[1]){
|
||||
h=k
|
||||
}
|
||||
})
|
||||
minutes.map((v,k)=>{
|
||||
if(v.label==dVal[2]){
|
||||
m=k
|
||||
}
|
||||
})
|
||||
defaultVal=[d,h,m];
|
||||
return {date,hours,minutes,defaultVal};
|
||||
},
|
||||
initHours(startHour=8,endHour=20,minuteStep=1,afterStep=30,date){
|
||||
let hours=[];
|
||||
let arr=date.split("-");
|
||||
let aDate=new Date();
|
||||
let dYear=aDate.getFullYear();
|
||||
let dMonth=aDate.getMonth()+1;
|
||||
let dDate=aDate.getDate();
|
||||
let bsDate=new Date(new Date().getTime()+afterStep*60*1000);
|
||||
let hour=bsDate.getHours();
|
||||
let flag=(dYear==arr[0]&&dMonth==arr[1]&&dDate==arr[2])?true:false;
|
||||
if(hour>endHour){
|
||||
hour=endHour;
|
||||
};
|
||||
if(flag){
|
||||
for(let k=hour*1;k<=endHour*1;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(k),
|
||||
flag:k==hour?true:false
|
||||
})
|
||||
};
|
||||
}else{
|
||||
for(let k=startHour*1;k<=endHour*1;k++){
|
||||
hours.push({
|
||||
label:forMatNum(k),
|
||||
value:forMatNum(k),
|
||||
flag:false
|
||||
})
|
||||
}
|
||||
};
|
||||
return hours;
|
||||
},
|
||||
initMinutes(startHour=8,endHour=20,minuteStep=1,afterStep=30,date,hour){
|
||||
let minutes=[];
|
||||
let bsDate=new Date(new Date().getTime()+afterStep*60*1000);
|
||||
let arr=date.split("-");
|
||||
let aDate=new Date();
|
||||
let dYear=aDate.getFullYear();
|
||||
let dMonth=aDate.getMonth()+1;
|
||||
let dDate=aDate.getDate();
|
||||
let dHour=bsDate.getHours();;
|
||||
let minute=Math.floor(bsDate.getMinutes()/minuteStep)*minuteStep;
|
||||
let flag=(dYear==arr[0]&&dMonth==arr[1]&&dDate==arr[2])?true:false;
|
||||
if(flag){
|
||||
if(hour==dHour){
|
||||
for(let j=minute;j<60;j+=minuteStep*1){
|
||||
minutes.push({
|
||||
label:forMatNum(j),
|
||||
value:forMatNum(j)
|
||||
});
|
||||
}
|
||||
}else{
|
||||
for(let j=0;j<60;j+=minuteStep*1){
|
||||
minutes.push({
|
||||
label:forMatNum(j),
|
||||
value:forMatNum(j)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
for(let j=0;j<60;j+=minuteStep*1){
|
||||
minutes.push({
|
||||
label:forMatNum(j),
|
||||
value:forMatNum(j)
|
||||
})
|
||||
}
|
||||
}
|
||||
return minutes;
|
||||
}
|
||||
},
|
||||
//选择区间初始化
|
||||
range:{
|
||||
init(start,end,value,flag){
|
||||
let aToday=new Date();
|
||||
let tYear,tMonth,tDay,tHours,tMinutes,tSeconds,defaultVal=[];
|
||||
let initstartDate=new Date(start.toString());
|
||||
let endDate=new Date(end.toString());
|
||||
if(start>end){
|
||||
initstartDate=new Date(end.toString());
|
||||
endDate=new Date(start.toString());
|
||||
};
|
||||
let startYear=initstartDate.getFullYear();
|
||||
let startMonth=initstartDate.getMonth()+1;
|
||||
let endYear=endDate.getFullYear();
|
||||
let fyears=[],fmonths=[],fdays=[],tyears=[],tmonths=[],tdays=[],returnArr=[],startDVal=[],endDVal=[];
|
||||
startDVal=value[0].split("-");
|
||||
endDVal=value[1].split("-");
|
||||
let curMonth=flag?startDVal[1]*1:(startDVal[1]+1);
|
||||
let totalDays=new Date(startYear,curMonth,0).getDate();
|
||||
for(let s=startYear;s<=endYear;s++){
|
||||
fyears.push(s+'');
|
||||
};
|
||||
for(let m=1;m<=12;m++){
|
||||
fmonths.push(forMatNum(m));
|
||||
};
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
fdays.push(forMatNum(d));
|
||||
};
|
||||
for(let s=startDVal[0];s<=endYear;s++){
|
||||
tyears.push(s+'');
|
||||
};
|
||||
if(endDVal[0]>startDVal[0]){
|
||||
for(let m=1;m<=12;m++){
|
||||
tmonths.push(forMatNum(m));
|
||||
};
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
tdays.push(forMatNum(d));
|
||||
};
|
||||
}else{
|
||||
for(let m=startDVal[1];m<=12;m++){
|
||||
tmonths.push(forMatNum(m));
|
||||
};
|
||||
for(let d=startDVal[2];d<=totalDays;d++){
|
||||
tdays.push(forMatNum(d));
|
||||
};
|
||||
};
|
||||
|
||||
defaultVal=[
|
||||
fyears.indexOf(startDVal[0])==-1?0:fyears.indexOf(startDVal[0]),
|
||||
fmonths.indexOf(startDVal[1])==-1?0:fmonths.indexOf(startDVal[1]),
|
||||
fdays.indexOf(startDVal[2])==-1?0:fdays.indexOf(startDVal[2]),
|
||||
0,
|
||||
tyears.indexOf(endDVal[0])==-1?0:tyears.indexOf(endDVal[0]),
|
||||
tmonths.indexOf(endDVal[1])==-1?0:tmonths.indexOf(endDVal[1]),
|
||||
tdays.indexOf(endDVal[2])==-1?0:tdays.indexOf(endDVal[2])
|
||||
];
|
||||
return {
|
||||
fyears,
|
||||
fmonths,
|
||||
fdays,
|
||||
tyears,
|
||||
tmonths,
|
||||
tdays,
|
||||
defaultVal
|
||||
}
|
||||
},
|
||||
initStartDays(year,month){
|
||||
let totalDays=new Date(year,month,0).getDate();
|
||||
let dates=[];
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
dates.push(forMatNum(d));
|
||||
};
|
||||
return dates;
|
||||
},
|
||||
initEndYears(curYear,startYear,endYear){
|
||||
let years=[];
|
||||
for(let y=curYear;y<=endYear;y++){
|
||||
years.push(forMatNum(y));
|
||||
};
|
||||
return years;
|
||||
},
|
||||
initEndMonths(curMonth){
|
||||
let months=[];
|
||||
for(let m=curMonth*1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
return months;
|
||||
},
|
||||
initEndDays(curYear,curMonth,curDate,tYear,tMonth){
|
||||
let totalDays=new Date(curYear,curMonth,0).getDate();
|
||||
let days=[];
|
||||
for(let d=curDate*1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
};
|
||||
return days;
|
||||
},
|
||||
initToMonths(curYear,curMonth,curDate,tYear){
|
||||
let aDate=new Date(curYear,curMonth,curDate).getTime();
|
||||
let bDate=new Date(tYear,curMonth,curDate).getTime();
|
||||
let months=[];
|
||||
if(bDate-aDate>0){
|
||||
for(let m=1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}else{
|
||||
for(let m=curMonth*1;m<=12;m++){
|
||||
months.push(forMatNum(m));
|
||||
};
|
||||
}
|
||||
return months;
|
||||
},
|
||||
initToDays(curYear,curMonth,curDate,tYear,tMonth){
|
||||
let aDate=new Date(curYear,curMonth,curDate).getTime();
|
||||
let bDate=new Date(tYear,tMonth,curDate).getTime();
|
||||
let totalDays=new Date(tYear,tMonth,0).getDate();
|
||||
let days=[];
|
||||
if(bDate-aDate>0){
|
||||
for(let d=1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
};
|
||||
}else{
|
||||
for(let d=curDate*1;d<=totalDays;d++){
|
||||
days.push(forMatNum(d));
|
||||
};
|
||||
}
|
||||
return days;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default initPicker
|
File diff suppressed because it is too large
Load Diff
|
@ -291,8 +291,10 @@
|
|||
let list = data[0]
|
||||
this.getElementData(`#tab_item`, (data) => {
|
||||
let el = data[this.listActive]
|
||||
lineLeft = el.width / 2 + (-list.left) + el.left - list.width / 2 - this.scrollLeft
|
||||
this.tabsScrollLeft = this.scrollLeft + lineLeft
|
||||
if (el) {
|
||||
lineLeft = el.width / 2 + (-list.left) + el.left - list.width / 2 - this.scrollLeft
|
||||
this.tabsScrollLeft = this.scrollLeft + lineLeft
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
|
@ -5,19 +5,19 @@
|
|||
<view class='list borRadius14'>
|
||||
<view class='item acea-row row-between-wrapper' style="border: none;">
|
||||
<view class='name'>姓名</view>
|
||||
<input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='realName' :value="userAddress.realName"
|
||||
placeholder-class='placeholder' maxlength="4"></input>
|
||||
<input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='name'
|
||||
:value="userAddress.name" placeholder-class='placeholder' maxlength="4" />
|
||||
</view>
|
||||
<view class='item acea-row row-between-wrapper'>
|
||||
<view class='name'>联系电话</view>
|
||||
<input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="phone" :value='userAddress.phone'
|
||||
placeholder-class='placeholder' maxlength="11"></input>
|
||||
<input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="mobile"
|
||||
:value='userAddress.mobile' placeholder-class='placeholder' maxlength="11" />
|
||||
</view>
|
||||
<view class='item acea-row row-between-wrapper relative'>
|
||||
<view class='name'>所在地区</view>
|
||||
<view class="address">
|
||||
<picker mode="multiSelector" @change="bindRegionChange"
|
||||
@columnchange="bindMultiPickerColumnChange" :value="valueRegion" :range="multiArray">
|
||||
@columnchange="bindMultiPickerColumnChange" :range="multiArray">
|
||||
<view class='acea-row'>
|
||||
<view class="picker line1">{{region[0]}},{{region[1]}},{{region[2]}}</view>
|
||||
<view class='iconfont icon-xiangyou abs_right'></view>
|
||||
|
@ -27,14 +27,14 @@
|
|||
</view>
|
||||
<view class='item acea-row row-between-wrapper relative'>
|
||||
<view class='name'>详细地址</view>
|
||||
<input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detail' placeholder-class='placeholder'
|
||||
v-model='userAddress.detail' maxlength="18"></input>
|
||||
<view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation"></view>
|
||||
<input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detailAddress'
|
||||
placeholder-class='placeholder' v-model='userAddress.detailAddress' maxlength="18" />
|
||||
<view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation" />
|
||||
</view>
|
||||
</view>
|
||||
<view class='default acea-row row-middle borRadius14'>
|
||||
<checkbox-group @change='ChangeIsDefault'>
|
||||
<checkbox :checked="userAddress.isDefault" />设置为默认地址
|
||||
<checkbox :checked="userAddress.defaultStatus" />设置为默认地址
|
||||
</checkbox-group>
|
||||
</view>
|
||||
|
||||
|
@ -47,63 +47,40 @@
|
|||
<!-- #endif -->
|
||||
</view>
|
||||
</form>
|
||||
<!-- #ifdef MP -->
|
||||
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
|
||||
<!-- #endif -->
|
||||
<!-- <home></home> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
editAddress,
|
||||
getAddressDetail
|
||||
} from '@/api/user.js';
|
||||
import {
|
||||
getCity
|
||||
} from '@/api/api.js';
|
||||
import {
|
||||
toLogin
|
||||
} from '@/libs/login.js';
|
||||
import {
|
||||
mapGetters
|
||||
} from "vuex";
|
||||
// #ifdef MP
|
||||
import authorize from '@/components/Authorize';
|
||||
// #endif
|
||||
import { editAddress } from '@/api/user.js';
|
||||
import * as AddressApi from '@/api/member/address.js';
|
||||
import * as AreaApi from '@/api/system/area.js';
|
||||
import { toLogin } from '@/libs/login.js';
|
||||
import { mapGetters } from "vuex";
|
||||
import home from '@/components/home';
|
||||
// import city from '@/utils/cityData';
|
||||
let app = getApp();
|
||||
export default {
|
||||
components: {
|
||||
// #ifdef MP
|
||||
authorize,
|
||||
// #endif
|
||||
home
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
regionDval: ['浙江省', '杭州市', '滨江区'],
|
||||
cartId: '', //购物车id
|
||||
pinkId: 0, //拼团id
|
||||
couponId: 0, //优惠券id
|
||||
id: 0, //地址id
|
||||
id: 0, // 地址 id
|
||||
district: [], // 地区,树形结构
|
||||
userAddress: {
|
||||
isDefault: false
|
||||
}, //地址详情
|
||||
region: ['省', '市', '区'],
|
||||
valueRegion: [0, 0, 0],
|
||||
isAuto: false, //没有授权的不会自动授权
|
||||
isShowAuth: false, //是否隐藏授权
|
||||
district: [],
|
||||
multiArray: [],
|
||||
multiIndex: [0, 0, 0],
|
||||
cityId: 0,
|
||||
defaultRegion: ['广东省', '广州市', '番禺区'],
|
||||
defaultRegionCode: '440113',
|
||||
bargain: false, //是否是砍价
|
||||
combination: false, //是否是拼团
|
||||
secKill: false, //是否是秒杀
|
||||
defaultStatus: false
|
||||
}, // 地址详情
|
||||
region: ['省', '市', '区'], // userAddress 对应的省市区
|
||||
multiArray: [], // 当前的省、市、区
|
||||
multiIndex: [0, 0, 0], // 当前选中的省 index、市 index、区 index
|
||||
cityId: 0, // 区的编号~ 变量名暂时没改过来
|
||||
|
||||
// TODO 芋艿:看看后面咋搞回来
|
||||
cartId: '', // 购物车id
|
||||
pinkId: 0, // 拼团id
|
||||
couponId: 0, // 优惠券id
|
||||
bargain: false, // 是否是砍价
|
||||
combination: false, // 是否是拼团
|
||||
secKill: false, // 是否是秒杀
|
||||
};
|
||||
},
|
||||
computed: mapGetters(['isLogin']),
|
||||
|
@ -119,105 +96,208 @@
|
|||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
if (this.isLogin) {
|
||||
this.preOrderNo = options.preOrderNo || 0;
|
||||
this.id = options.id || 0;
|
||||
uni.setNavigationBarTitle({
|
||||
title: options.id ? '修改地址' : '添加地址'
|
||||
})
|
||||
this.getUserAddress();
|
||||
if(this.$Cache.has('cityList')){
|
||||
//检测城市数据是否存在缓存,有的话从缓存取,没有的话请求接口
|
||||
this.district = this.$Cache.getItem('cityList')
|
||||
this.initialize();
|
||||
}else{
|
||||
this.getCityList();
|
||||
}
|
||||
} else {
|
||||
toLogin();
|
||||
if (!this.isLogin) {
|
||||
toLogin();
|
||||
return
|
||||
}
|
||||
|
||||
this.preOrderNo = options.preOrderNo || 0;
|
||||
this.id = options.id || 0;
|
||||
uni.setNavigationBarTitle({
|
||||
title: options.id ? '修改地址' : '添加地址'
|
||||
})
|
||||
|
||||
// 获取地址详情
|
||||
this.getUserAddress();
|
||||
|
||||
// 检测城市数据是否存在缓存,有的话从缓存取,没有的话请求接口
|
||||
if (this.$Cache.has('cityList')) {
|
||||
this.district = this.$Cache.getItem('cityList')
|
||||
this.initialize();
|
||||
} else {
|
||||
this.getCityList();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// #ifdef APP-PLUS
|
||||
// 获取选择的地区
|
||||
handleGetRegion(region) {
|
||||
this.region = region
|
||||
},
|
||||
// #endif
|
||||
// 获取地址数据
|
||||
/**
|
||||
* 获得地址
|
||||
*/
|
||||
getUserAddress: function() {
|
||||
if (!this.id) {
|
||||
return false;
|
||||
}
|
||||
AddressApi.getAddress(this.id).then(res => {
|
||||
this.$set(this, 'userAddress', res.data);
|
||||
this.$set(this, 'region', res.data.areaName.split(' '));
|
||||
this.city_id = res.data.areaId
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 提交用户添加地址
|
||||
*/
|
||||
formSubmit: function(e) {
|
||||
// 参数校验
|
||||
const value = e.detail.value;
|
||||
if (!value.name) {
|
||||
return this.$util.Tips({
|
||||
title: '请填写收货人姓名'
|
||||
});
|
||||
}
|
||||
if (!value.mobile) {
|
||||
return this.$util.Tips({
|
||||
title: '请填写联系电话'
|
||||
});
|
||||
}
|
||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(value.mobile)) {
|
||||
return this.$util.Tips({
|
||||
title: '请输入正确的手机号码'
|
||||
});
|
||||
}
|
||||
if (this.region === '省-市-区') {
|
||||
return this.$util.Tips({
|
||||
title: '请选择所在地区'
|
||||
});
|
||||
}
|
||||
if (!value.detailAddress) {
|
||||
return this.$util.Tips({
|
||||
title: '请填写详细地址'
|
||||
});
|
||||
}
|
||||
value.id = this.id;
|
||||
value.areaId = this.cityId;
|
||||
value.defaultStatus = this.userAddress.defaultStatus;
|
||||
|
||||
// 提交保存
|
||||
uni.showLoading({
|
||||
title: '保存中',
|
||||
mask: true
|
||||
})
|
||||
const saveOrUpdateAddress = this.id > 0 ? AddressApi.updateAddress : AddressApi.createAddress;
|
||||
saveOrUpdateAddress(value).then(res => {
|
||||
if (this.id) {
|
||||
this.$util.Tips({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
this.$util.Tips({
|
||||
title: '添加成功',
|
||||
icon: 'success'
|
||||
});
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.preOrderNo > 0) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/users/order_confirm/index?preOrderNo=' + this.preOrderNo + '&addressId=' + (this.id ? this.id : res.data)
|
||||
})
|
||||
} else {
|
||||
// #ifdef H5
|
||||
return history.back();
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
return uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
}, 1000);
|
||||
}).catch(err => {
|
||||
return this.$util.Tips({
|
||||
title: err
|
||||
});
|
||||
})
|
||||
},
|
||||
// TODO 芋艿:需要改下
|
||||
ChangeIsDefault: function(e) {
|
||||
this.$set(this.userAddress, 'defaultStatus', !this.userAddress.defaultStatus);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取地址数据
|
||||
*/
|
||||
getCityList: function() {
|
||||
let that = this;
|
||||
getCity().then(res => {
|
||||
AreaApi.getAreaTree().then(res => {
|
||||
this.district = res.data;
|
||||
let oneDay = 24 * 3600 * 1000;
|
||||
// this.$Cache.set('cityList', JSON.stringify(res.data)); //设置不过期时间的方法
|
||||
this.$Cache.setItem({name:'cityList',value:res.data,expires:oneDay * 7}); //设置七天过期时间
|
||||
that.initialize();
|
||||
this.$Cache.setItem({name: 'cityList', value:res.data, expires:oneDay * 7}); //设置七天过期时间
|
||||
this.initialize();
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 初始化当前的 multiArray
|
||||
*/
|
||||
initialize: function() {
|
||||
let that = this,province = [],city = [],area = [];
|
||||
if (that.district.length) {
|
||||
let cityChildren = that.district[0].child || [];
|
||||
let areaChildren = cityChildren.length ? (cityChildren[0].child || []) : [];
|
||||
that.district.forEach(function(item) {
|
||||
const province = [];
|
||||
const city = [];
|
||||
const area = [];
|
||||
if (this.district.length) {
|
||||
// 省
|
||||
this.district.forEach(item => {
|
||||
province.push(item.name);
|
||||
});
|
||||
cityChildren.forEach(function(item) {
|
||||
// 市
|
||||
const cityChildren = this.district[0].children || [];
|
||||
cityChildren.forEach(item => {
|
||||
city.push(item.name);
|
||||
});
|
||||
areaChildren.forEach(function(item) {
|
||||
// 区
|
||||
const areaChildren = cityChildren.length ? (cityChildren[0].children || []) : [];
|
||||
areaChildren.forEach(item => {
|
||||
area.push(item.name);
|
||||
});
|
||||
this.multiArray = [province, city, area]
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 提交省市区的选择
|
||||
*/
|
||||
bindRegionChange: function(e) {
|
||||
let multiIndex = this.multiIndex,
|
||||
province = this.district[multiIndex[0]] || {
|
||||
child: []
|
||||
},
|
||||
city = province.child[multiIndex[1]] || {
|
||||
cityId: 0
|
||||
},
|
||||
multiArray = this.multiArray,
|
||||
value = e.detail.value;
|
||||
|
||||
const multiIndex = this.multiIndex;
|
||||
const multiArray = this.multiArray;
|
||||
const value = e.detail.value;
|
||||
const province = this.district[multiIndex[0]] || {
|
||||
children: []
|
||||
};
|
||||
const city = province.children[multiIndex[1]] || {
|
||||
children: []
|
||||
};
|
||||
const area = city.children[multiIndex[2]] || {
|
||||
id: 0
|
||||
};
|
||||
this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]]
|
||||
this.cityId = city.cityId
|
||||
this.valueRegion = [0, 0, 0]
|
||||
this.initialize();
|
||||
},
|
||||
this.cityId = area.id
|
||||
},
|
||||
/**
|
||||
* 选择省市区的滚动
|
||||
*/
|
||||
bindMultiPickerColumnChange: function(e) {
|
||||
let that = this,
|
||||
column = e.detail.column,
|
||||
value = e.detail.value,
|
||||
currentCity = this.district[value] || {
|
||||
child: []
|
||||
},
|
||||
multiArray = that.multiArray,
|
||||
multiIndex = that.multiIndex;
|
||||
const column = e.detail.column; // multiArray 的下标
|
||||
const value = e.detail.value; // multiArray 的值,即选中的第几个
|
||||
const multiArray = this.multiArray;
|
||||
const multiIndex = this.multiIndex;
|
||||
multiIndex[column] = value;
|
||||
switch (column) {
|
||||
case 0:
|
||||
let areaList = currentCity.child[0] || {
|
||||
case 0: // 选择【省】
|
||||
const currentCity = this.district[value] || {
|
||||
child: []
|
||||
};
|
||||
const areaList = currentCity.children[0] || {
|
||||
child: []
|
||||
};
|
||||
multiArray[1] = currentCity.child.map((item) => {
|
||||
multiArray[1] = currentCity.children.map((item) => {
|
||||
return item.name;
|
||||
});
|
||||
multiArray[2] = areaList.child.map((item) => {
|
||||
multiArray[2] = areaList.children.map((item) => {
|
||||
return item.name;
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
let cityList = that.district[multiIndex[0]].child[multiIndex[1]].child || [];
|
||||
multiArray[2] = cityList.map((item) => {
|
||||
case 1: // 选择【市】
|
||||
const cityList = this.district[multiIndex[0]].children[multiIndex[1]].children || [];
|
||||
multiArray[2] = cityList.map(item => {
|
||||
return item.name;
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
|
||||
case 2: // 选择【区】
|
||||
break;
|
||||
}
|
||||
// #ifdef MP || APP-PLUS
|
||||
|
@ -229,40 +309,19 @@
|
|||
this.multiArray = multiArray;
|
||||
// #endif
|
||||
this.multiIndex = multiIndex
|
||||
// this.setData({ multiArray: multiArray, multiIndex: multiIndex});
|
||||
},
|
||||
// 授权回调
|
||||
onLoadFun: function() {
|
||||
this.getUserAddress();
|
||||
},
|
||||
// 授权关闭
|
||||
authColse: function(e) {
|
||||
this.isShowAuth = e
|
||||
},
|
||||
toggleTab(str) {
|
||||
this.$refs[str].show();
|
||||
},
|
||||
onConfirm(val) {
|
||||
this.region = val.checkArr[0] + '-' + val.checkArr[1] + '-' + val.checkArr[2];
|
||||
},
|
||||
getUserAddress: function() {
|
||||
if (!this.id) return false;
|
||||
let that = this;
|
||||
getAddressDetail(this.id).then(res => {
|
||||
let region = [res.data.province, res.data.city, res.data.district];
|
||||
that.$set(that, 'userAddress', res.data);
|
||||
that.$set(that, 'region', region);
|
||||
that.city_id = res.data.cityId
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 通过地图,选择到具体的地址
|
||||
* TODO 芋艿:需要测试下;
|
||||
*/
|
||||
chooseLocation: function () {
|
||||
uni.chooseLocation({
|
||||
success: (res) => {
|
||||
this.$set(this.userAddress,'detail',res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,''));
|
||||
this.$set(this.userAddress, 'detailAddress', res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,''));
|
||||
}
|
||||
})
|
||||
},
|
||||
// 导入共享地址(小程序)
|
||||
// 导入共享地址(小程序)TODO 芋艿:待实现
|
||||
getWxAddress: function() {
|
||||
let that = this;
|
||||
uni.authorize({
|
||||
|
@ -277,10 +336,10 @@
|
|||
addressP.cityId = 0;
|
||||
editAddress({
|
||||
address: addressP,
|
||||
isDefault: 1,
|
||||
realName: res.userName,
|
||||
defaultStatus: 1,
|
||||
name: res.userName,
|
||||
postCode: res.postalCode,
|
||||
phone: res.telNumber,
|
||||
mobile: res.telNumber,
|
||||
detail: res.detailInfo,
|
||||
id: 0
|
||||
}).then(res => {
|
||||
|
@ -354,15 +413,15 @@
|
|||
},
|
||||
})
|
||||
},
|
||||
// 导入共享地址(微信);
|
||||
// 导入共享地址(微信);TODO 芋艿:待实现
|
||||
getAddress() {
|
||||
let that = this;
|
||||
that.$wechat.openAddress().then(userInfo => {
|
||||
// open();
|
||||
editAddress({
|
||||
id: this.id,
|
||||
realName: userInfo.userName,
|
||||
phone: userInfo.telNumber,
|
||||
name: userInfo.userName,
|
||||
mobile: userInfo.telNumber,
|
||||
address: {
|
||||
province: userInfo.provinceName,
|
||||
city: userInfo.cityName,
|
||||
|
@ -370,7 +429,7 @@
|
|||
cityId: 0
|
||||
},
|
||||
detail: userInfo.detailInfo,
|
||||
isDefault: 1,
|
||||
defaultStatus: 1,
|
||||
postCode: userInfo.postalCode
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -414,78 +473,6 @@
|
|||
console.log(err);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 提交用户添加地址
|
||||
*
|
||||
*/
|
||||
formSubmit: function(e) {
|
||||
let that = this,
|
||||
value = e.detail.value;
|
||||
if (!value.realName) return that.$util.Tips({
|
||||
title: '请填写收货人姓名'
|
||||
});
|
||||
if (!value.phone) return that.$util.Tips({
|
||||
title: '请填写联系电话'
|
||||
});
|
||||
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(value.phone)) return that.$util.Tips({
|
||||
title: '请输入正确的手机号码'
|
||||
});
|
||||
if (that.region == '省-市-区') return that.$util.Tips({
|
||||
title: '请选择所在地区'
|
||||
});
|
||||
if (!value.detail) return that.$util.Tips({
|
||||
title: '请填写详细地址'
|
||||
});
|
||||
value.id = that.id;
|
||||
let regionArray = that.region;
|
||||
value.address = {
|
||||
province: regionArray[0],
|
||||
city: regionArray[1],
|
||||
district: regionArray[2],
|
||||
cityId: that.cityId,
|
||||
};
|
||||
value.isDefault = that.userAddress.isDefault;
|
||||
|
||||
uni.showLoading({
|
||||
title: '保存中',
|
||||
mask: true
|
||||
})
|
||||
editAddress(value).then(res => {
|
||||
if (that.id)
|
||||
that.$util.Tips({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
});
|
||||
else
|
||||
that.$util.Tips({
|
||||
title: '添加成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(function() {
|
||||
if (that.preOrderNo>0) {
|
||||
uni.redirectTo({
|
||||
url: '/pages/users/order_confirm/index?preOrderNo=' + that.preOrderNo + '&addressId=' + (that.id ? that.id : res.data.id)
|
||||
})
|
||||
} else {
|
||||
// #ifdef H5
|
||||
return history.back();
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
return uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
}, 1000);
|
||||
}).catch(err => {
|
||||
return that.$util.Tips({
|
||||
title: err
|
||||
});
|
||||
})
|
||||
},
|
||||
ChangeIsDefault: function(e) {
|
||||
this.$set(this.userAddress, 'isDefault', !this.userAddress.isDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue