【收货地址添加】

1. 功能实现
pull/1/MERGE
YunaiV 2023-06-26 20:06:29 +08:00
parent 6442fc5c11
commit e08f65b4cb
11 changed files with 257 additions and 16266 deletions

View File

@ -1,12 +1,12 @@
import request from "@/utils/request.js"; import request from "@/utils/request.js";
/** /**
* 公共接口 优惠券接口 , 行业此讯 , 手机号码注册 * 公共接口 优惠券接口 , 行业此讯 , 手机号码注册
* *
*/ */
/** /**
* 获取主页数据 无需授权 * 获取主页数据 无需授权
* *
*/ */
export function getIndexData() export function getIndexData()
{ {
@ -15,7 +15,7 @@ export function getIndexData()
/** /**
* 获取登录授权login * 获取登录授权login
* *
*/ */
export function getLogo() export function getLogo()
{ {
@ -25,7 +25,7 @@ export function getLogo()
/** /**
* 保存form_id * 保存form_id
* @param string formId * @param string formId
*/ */
export function setFormId(formId) { export function setFormId(formId) {
return request.post("wechat/set_form_id", { formId: formId}); return request.post("wechat/set_form_id", { formId: formId});
@ -34,7 +34,7 @@ export function setFormId(formId) {
/** /**
* 领取优惠卷 * 领取优惠卷
* @param int couponId * @param int couponId
* *
*/ */
export function setCouponReceive(couponId){ export function setCouponReceive(couponId){
return request.post('coupon/receive', { couponId: couponId}); return request.post('coupon/receive', { couponId: couponId});
@ -57,7 +57,7 @@ export function getUserCoupons(data){
/** /**
* 文章分类列表 * 文章分类列表
* *
*/ */
export function getArticleCategoryList(){ export function getArticleCategoryList(){
return request.get('article/category/list',{},{noAuth:true}) return request.get('article/category/list',{},{noAuth:true})
@ -66,7 +66,7 @@ export function getArticleCategoryList(){
/** /**
* 文章列表 * 文章列表
* @param int cid * @param int cid
* *
*/ */
export function getArticleList(cid,data){ export function getArticleList(cid,data){
return request.get('article/list/' + cid, data,{noAuth:true}) return request.get('article/list/' + cid, data,{noAuth:true})
@ -74,7 +74,7 @@ export function getArticleList(cid,data){
/** /**
* 文章 热门列表 * 文章 热门列表
* *
*/ */
export function getArticleHotList(){ export function getArticleHotList(){
return request.get('article/hot/list',{},{noAuth:true}); return request.get('article/hot/list',{},{noAuth:true});
@ -82,7 +82,7 @@ export function getArticleHotList(){
/** /**
* 文章 轮播列表 * 文章 轮播列表
* *
*/ */
export function getArticleBannerList(){ export function getArticleBannerList(){
return request.get('article/banner/list',{},{noAuth:true}) 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){ export function getArticleDetails(id){
return request.get('article/info',id,{noAuth:true}); return request.get('article/info',id,{noAuth:true});
@ -124,7 +124,7 @@ export function registerVerify(phone){
/** /**
* 手机号注册 * 手机号注册
* @param object data * @param object data
* *
*/ */
export function phoneRegister(data){ export function phoneRegister(data){
return request.post('register',data,{noAuth:true}); return request.post('register',data,{noAuth:true});
@ -133,7 +133,7 @@ export function phoneRegister(data){
/** /**
* 手机号修改密码 * 手机号修改密码
* @param object data * @param object data
* *
*/ */
export function phoneRegisterReset(data){ export function phoneRegisterReset(data){
return request.post('register/reset',data,{noAuth:true}) return request.post('register/reset',data,{noAuth:true})
@ -142,7 +142,7 @@ export function phoneRegisterReset(data){
/** /**
* 手机号+密码登录 * 手机号+密码登录
* @param object data * @param object data
* *
*/ */
export function phoneLogin(data){ export function phoneLogin(data){
return request.post('login',data,{noAuth:true}) return request.post('login',data,{noAuth:true})
@ -169,7 +169,7 @@ export function switchH5Login() {
/** /**
* 换绑手机号 * 换绑手机号
* *
*/ */
export function bindingPhone(data){ export function bindingPhone(data){
return request.post('update/binding',data); return request.post('update/binding',data);
@ -177,7 +177,7 @@ export function bindingPhone(data){
/** /**
* 换绑手机号校验 * 换绑手机号校验
* *
*/ */
export function bindingVerify(data){ export function bindingVerify(data){
return request.post('update/binding/verify',data); return request.post('update/binding/verify',data);
@ -185,7 +185,7 @@ export function bindingVerify(data){
/** /**
* 退出登錄 * 退出登錄
* *
*/ */
export function logout(){ export function logout(){
return request.get('logout'); return request.get('logout');
@ -199,21 +199,6 @@ export function getTemlIds(data)
return request.get('wechat/program/my/temp/list', data , { noAuth:true}); 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 });
}
/** /**
* 获取小程序直播列表 * 获取小程序直播列表
*/ */

View File

@ -1,10 +1,22 @@
import request from "@/utils/request.js"; import request from "@/utils/request.js";
// 获得用户收件地址
export function getAddress(id) {
return request.get('app-api/member/address/get', {
id
});
}
// 获得用户收件地址列表 // 获得用户收件地址列表
export function getAddressList() { export function getAddressList() {
return request.get('app-api/member/address/list', {}); 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) { export function updateAddress(data) {
return request.put('app-api/member/address/update', data); return request.put('app-api/member/address/update', data);

8
api/system/area.js Normal file
View File

@ -0,0 +1,8 @@
import request from "@/utils/request.js";
// 获得地区树
export function getAreaTree() {
return request.get("app-api/system/area/tree", {}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

View File

@ -1,6 +1,6 @@
<template> <template>
<view> <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='title'>选择地址<text class='iconfont icon-guanbi' @tap='close'></text></view>
<view class='list'> <view class='list'>
<view class='item acea-row row-between-wrapper' :class='active==index?"font-color":""' v-for="(item,index) in addressList" <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>
<view class='addressBnt bg-color' @tap='goAddressPages'>选择其地址</view> <view class='addressBnt bg-color' @tap='goAddressPages'>选择其地址</view>
</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> </view>
</template> </template>
@ -37,7 +37,7 @@
type: Object, type: Object,
default: function() { default: function() {
return { return {
address: true, address: true, //
addressId: 0, addressId: 0,
}; };
} }
@ -54,13 +54,12 @@
addressList: [] addressList: []
}; };
}, },
methods: { methods: {
tapAddress: function(e, addressid) { tapAddress: function(e, addressid) {
this.active = e; this.active = e;
let a = {}; let a = {};
for (let i = 0, leng = this.addressList.length; i < leng; i++) { 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]; a = this.addressList[i];
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -291,8 +291,10 @@
let list = data[0] let list = data[0]
this.getElementData(`#tab_item`, (data) => { this.getElementData(`#tab_item`, (data) => {
let el = data[this.listActive] let el = data[this.listActive]
lineLeft = el.width / 2 + (-list.left) + el.left - list.width / 2 - this.scrollLeft if (el) {
this.tabsScrollLeft = this.scrollLeft + lineLeft lineLeft = el.width / 2 + (-list.left) + el.left - list.width / 2 - this.scrollLeft
this.tabsScrollLeft = this.scrollLeft + lineLeft
}
}) })
}) })
}, },

View File

@ -5,19 +5,19 @@
<view class='list borRadius14'> <view class='list borRadius14'>
<view class='item acea-row row-between-wrapper' style="border: none;"> <view class='item acea-row row-between-wrapper' style="border: none;">
<view class='name'>姓名</view> <view class='name'>姓名</view>
<input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='realName' :value="userAddress.realName" <input type='text' placeholder='请输入姓名' placeholder-style="color:#ccc;" name='name'
placeholder-class='placeholder' maxlength="4"></input> :value="userAddress.name" placeholder-class='placeholder' maxlength="4" />
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view class='name'>联系电话</view> <view class='name'>联系电话</view>
<input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="phone" :value='userAddress.phone' <input type='number' placeholder='请输入联系电话' placeholder-style="color:#ccc;" name="mobile"
placeholder-class='placeholder' maxlength="11"></input> :value='userAddress.mobile' placeholder-class='placeholder' maxlength="11" />
</view> </view>
<view class='item acea-row row-between-wrapper relative'> <view class='item acea-row row-between-wrapper relative'>
<view class='name'>所在地区</view> <view class='name'>所在地区</view>
<view class="address"> <view class="address">
<picker mode="multiSelector" @change="bindRegionChange" <picker mode="multiSelector" @change="bindRegionChange"
@columnchange="bindMultiPickerColumnChange" :value="valueRegion" :range="multiArray"> @columnchange="bindMultiPickerColumnChange" :range="multiArray">
<view class='acea-row'> <view class='acea-row'>
<view class="picker line1">{{region[0]}}{{region[1]}}{{region[2]}}</view> <view class="picker line1">{{region[0]}}{{region[1]}}{{region[2]}}</view>
<view class='iconfont icon-xiangyou abs_right'></view> <view class='iconfont icon-xiangyou abs_right'></view>
@ -27,14 +27,14 @@
</view> </view>
<view class='item acea-row row-between-wrapper relative'> <view class='item acea-row row-between-wrapper relative'>
<view class='name'>详细地址</view> <view class='name'>详细地址</view>
<input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detail' placeholder-class='placeholder' <input type='text' placeholder='请填写具体地址' placeholder-style="color:#ccc;" name='detailAddress'
v-model='userAddress.detail' maxlength="18"></input> placeholder-class='placeholder' v-model='userAddress.detailAddress' maxlength="18" />
<view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation"></view> <view class='iconfont icon-dizhi font-color abs_right' @tap="chooseLocation" />
</view> </view>
</view> </view>
<view class='default acea-row row-middle borRadius14'> <view class='default acea-row row-middle borRadius14'>
<checkbox-group @change='ChangeIsDefault'> <checkbox-group @change='ChangeIsDefault'>
<checkbox :checked="userAddress.isDefault" />设置为默认地址 <checkbox :checked="userAddress.defaultStatus" />设置为默认地址
</checkbox-group> </checkbox-group>
</view> </view>
@ -47,63 +47,40 @@
<!-- #endif --> <!-- #endif -->
</view> </view>
</form> </form>
<!-- #ifdef MP -->
<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
<!-- #endif -->
<!-- <home></home> -->
</view> </view>
</template> </template>
<script> <script>
import { import { editAddress } from '@/api/user.js';
editAddress, import * as AddressApi from '@/api/member/address.js';
getAddressDetail import * as AreaApi from '@/api/system/area.js';
} from '@/api/user.js'; import { toLogin } from '@/libs/login.js';
import { import { mapGetters } from "vuex";
getCity
} from '@/api/api.js';
import {
toLogin
} from '@/libs/login.js';
import {
mapGetters
} from "vuex";
// #ifdef MP
import authorize from '@/components/Authorize';
// #endif
import home from '@/components/home'; import home from '@/components/home';
// import city from '@/utils/cityData';
let app = getApp(); let app = getApp();
export default { export default {
components: { components: {
// #ifdef MP
authorize,
// #endif
home home
}, },
data() { data() {
return { return {
regionDval: ['浙江省', '杭州市', '滨江区'], id: 0, // id
cartId: '', //id district: [], //
pinkId: 0, //id
couponId: 0, //id
id: 0, //id
userAddress: { userAddress: {
isDefault: false defaultStatus: false
}, // }, //
region: ['省', '市', '区'], region: ['省', '市', '区'], // userAddress
valueRegion: [0, 0, 0], multiArray: [], //
isAuto: false, // multiIndex: [0, 0, 0], // index index index
isShowAuth: false, // cityId: 0, // ~
district: [],
multiArray: [], // TODO
multiIndex: [0, 0, 0], cartId: '', // id
cityId: 0, pinkId: 0, // id
defaultRegion: ['广东省', '广州市', '番禺区'], couponId: 0, // id
defaultRegionCode: '440113', bargain: false, //
bargain: false, // combination: false, //
combination: false, // secKill: false, //
secKill: false, //
}; };
}, },
computed: mapGetters(['isLogin']), computed: mapGetters(['isLogin']),
@ -119,105 +96,208 @@
} }
}, },
onLoad(options) { onLoad(options) {
if (this.isLogin) { if (!this.isLogin) {
this.preOrderNo = options.preOrderNo || 0; toLogin();
this.id = options.id || 0; return
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();
} }
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: { methods: {
// #ifdef APP-PLUS /**
// * 获得地址
handleGetRegion(region) { */
this.region = region getUserAddress: function() {
}, if (!this.id) {
// #endif 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() { getCityList: function() {
let that = this; AreaApi.getAreaTree().then(res => {
getCity().then(res => {
this.district = res.data; this.district = res.data;
let oneDay = 24 * 3600 * 1000; let oneDay = 24 * 3600 * 1000;
// this.$Cache.set('cityList', JSON.stringify(res.data)); // this.$Cache.setItem({name: 'cityList', value:res.data, expires:oneDay * 7}); //
this.$Cache.setItem({name:'cityList',value:res.data,expires:oneDay * 7}); // this.initialize();
that.initialize();
}) })
}, },
/**
* 初始化当前的 multiArray
*/
initialize: function() { initialize: function() {
let that = this,province = [],city = [],area = []; const province = [];
if (that.district.length) { const city = [];
let cityChildren = that.district[0].child || []; const area = [];
let areaChildren = cityChildren.length ? (cityChildren[0].child || []) : []; if (this.district.length) {
that.district.forEach(function(item) { //
this.district.forEach(item => {
province.push(item.name); province.push(item.name);
}); });
cityChildren.forEach(function(item) { //
const cityChildren = this.district[0].children || [];
cityChildren.forEach(item => {
city.push(item.name); city.push(item.name);
}); });
areaChildren.forEach(function(item) { //
const areaChildren = cityChildren.length ? (cityChildren[0].children || []) : [];
areaChildren.forEach(item => {
area.push(item.name); area.push(item.name);
}); });
this.multiArray = [province, city, area] this.multiArray = [province, city, area]
} }
}, },
/**
* 提交省市区的选择
*/
bindRegionChange: function(e) { bindRegionChange: function(e) {
let multiIndex = this.multiIndex, const multiIndex = this.multiIndex;
province = this.district[multiIndex[0]] || { const multiArray = this.multiArray;
child: [] const value = e.detail.value;
}, const province = this.district[multiIndex[0]] || {
city = province.child[multiIndex[1]] || { children: []
cityId: 0 };
}, const city = province.children[multiIndex[1]] || {
multiArray = this.multiArray, children: []
value = e.detail.value; };
const area = city.children[multiIndex[2]] || {
id: 0
};
this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]] this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]]
this.cityId = city.cityId this.cityId = area.id
this.valueRegion = [0, 0, 0] },
this.initialize(); /**
}, * 选择省市区的滚动
*/
bindMultiPickerColumnChange: function(e) { bindMultiPickerColumnChange: function(e) {
let that = this, const column = e.detail.column; // multiArray
column = e.detail.column, const value = e.detail.value; // multiArray
value = e.detail.value, const multiArray = this.multiArray;
currentCity = this.district[value] || { const multiIndex = this.multiIndex;
child: []
},
multiArray = that.multiArray,
multiIndex = that.multiIndex;
multiIndex[column] = value; multiIndex[column] = value;
switch (column) { switch (column) {
case 0: case 0: //
let areaList = currentCity.child[0] || { const currentCity = this.district[value] || {
child: []
};
const areaList = currentCity.children[0] || {
child: [] child: []
}; };
multiArray[1] = currentCity.child.map((item) => { multiArray[1] = currentCity.children.map((item) => {
return item.name; return item.name;
}); });
multiArray[2] = areaList.child.map((item) => { multiArray[2] = areaList.children.map((item) => {
return item.name; return item.name;
}); });
break; break;
case 1: case 1: //
let cityList = that.district[multiIndex[0]].child[multiIndex[1]].child || []; const cityList = this.district[multiIndex[0]].children[multiIndex[1]].children || [];
multiArray[2] = cityList.map((item) => { multiArray[2] = cityList.map(item => {
return item.name; return item.name;
}); });
break; break;
case 2: case 2: //
break; break;
} }
// #ifdef MP || APP-PLUS // #ifdef MP || APP-PLUS
@ -229,40 +309,19 @@
this.multiArray = multiArray; this.multiArray = multiArray;
// #endif // #endif
this.multiIndex = multiIndex 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 () { chooseLocation: function () {
uni.chooseLocation({ uni.chooseLocation({
success: (res) => { success: (res) => {
this.$set(this.userAddress,'detail',res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,'')); this.$set(this.userAddress, 'detailAddress', res.address.replace(/.+?(省|市|自治区|自治州|县|区)/g,''));
} }
}) })
}, },
// // TODO
getWxAddress: function() { getWxAddress: function() {
let that = this; let that = this;
uni.authorize({ uni.authorize({
@ -277,10 +336,10 @@
addressP.cityId = 0; addressP.cityId = 0;
editAddress({ editAddress({
address: addressP, address: addressP,
isDefault: 1, defaultStatus: 1,
realName: res.userName, name: res.userName,
postCode: res.postalCode, postCode: res.postalCode,
phone: res.telNumber, mobile: res.telNumber,
detail: res.detailInfo, detail: res.detailInfo,
id: 0 id: 0
}).then(res => { }).then(res => {
@ -354,15 +413,15 @@
}, },
}) })
}, },
// // TODO
getAddress() { getAddress() {
let that = this; let that = this;
that.$wechat.openAddress().then(userInfo => { that.$wechat.openAddress().then(userInfo => {
// open(); // open();
editAddress({ editAddress({
id: this.id, id: this.id,
realName: userInfo.userName, name: userInfo.userName,
phone: userInfo.telNumber, mobile: userInfo.telNumber,
address: { address: {
province: userInfo.provinceName, province: userInfo.provinceName,
city: userInfo.cityName, city: userInfo.cityName,
@ -370,7 +429,7 @@
cityId: 0 cityId: 0
}, },
detail: userInfo.detailInfo, detail: userInfo.detailInfo,
isDefault: 1, defaultStatus: 1,
postCode: userInfo.postalCode postCode: userInfo.postalCode
}) })
.then(() => { .then(() => {
@ -414,78 +473,6 @@
console.log(err); 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> </script>