diff --git a/api/shop.js b/api/shop.js
index 9a1c0db4..1c29dee1 100644
--- a/api/shop.js
+++ b/api/shop.js
@@ -1,11 +1,16 @@
export const apiArr = {
goodsCateList: "/api/v2/wechat/commodity/cate",//商品分类列表
- getGoodsList:"/api/v2/wechat/commodity", //商品分类
- getGoodsInfo:"/api/v2/wechat/commodity/info", //商品详情
- getCar:"/api/v2/wechat/commodity/cart",//购物车
- getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
- addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
- deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
- updateCar:"/api/v2/wechat/commodity/cart/update",//更新购物车信息
- getUserDefAddress:"/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
+ getGoodsList: "/api/v2/wechat/commodity", //商品分类
+ getGoodsInfo: "/api/v2/wechat/commodity/info", //商品详情
+ getCar: "/api/v2/wechat/commodity/cart",//购物车
+ getCarCount: "/api/v2/wechat/commodity/cart/all_count",//购物车数量
+ addCar: "/api/v2/wechat/commodity/cart/add",//添加购物车
+ deleteCar: "/api/v2/wechat/commodity/cart/delete",//删除购物车
+ updateCar: "/api/v2/wechat/commodity/cart/update",//更新购物车信息
+ getUserDefAddress: "/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
+ createOrder: "/api/v2/wechat/commodity/order/create",//创建商品订单
+ payOrder: "/api/v2/wechat/commodity/order/pay",//支付订单
+ settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认
+ updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改
+ queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单
}
\ No newline at end of file
diff --git a/components/areaPopup/areaPopup.vue b/components/areaPopup/areaPopup.vue
index c487f639..b953b820 100644
--- a/components/areaPopup/areaPopup.vue
+++ b/components/areaPopup/areaPopup.vue
@@ -78,6 +78,9 @@ export default {
console.log('新市区跟旧市区不一直')
this.xsq = newDist;
this.getDistList(newDist, x);
+ } else {
+ console.log('新市区跟旧市区一直');
+ this.confirmDist = this.defaultDist[x]
}
return
}
diff --git a/packages/shop/addAddress/index.vue b/packages/shop/addAddress/index.vue
index e0a090ac..5a9db032 100644
--- a/packages/shop/addAddress/index.vue
+++ b/packages/shop/addAddress/index.vue
@@ -3,14 +3,14 @@
+
-
确定
+
确定
@@ -95,6 +94,7 @@
import {
apiArr
} from '../../../api/area';
+import { apiArr as apiArr2 } from '../../../api/shop';
import {
picUrl,
menuButtonInfo,
@@ -122,6 +122,16 @@ export default {
sf: true,
xsq: {},
value2: '',
+
+ isShow: false,
+ id: '',
+ type: '',
+ orientation: uni.getStorageSync('location'),
+ name: '',
+ phone: '',
+ houseNumber: '',
+ isDefault: 2,
+ showOrientation: true,
}
},
methods: {
@@ -130,6 +140,7 @@ export default {
},
chooseAddress() {
console.log(123);
+ this.isShow = true;
NavgateTo("/pages/shopcity/shopcity")
},
/////////////////////////////////// 省市区方法///////////////////////////////////////////
@@ -143,8 +154,9 @@ export default {
},
// 获取市区信息
- async getCityList(sq, x) {
+ async getCityList(sq, x,) {
console.log('11swq', sq);
+ console.log('获取x', x);
if (!this.sf) {
console.log('省份没变,查市跟区', this.cityList)
let newDist = this.cityList[sq];
@@ -153,6 +165,9 @@ export default {
console.log('新市区跟旧市区不一直')
this.xsq = newDist;
this.getDistList(newDist, x);
+ } else {
+ console.log('新市区跟旧市区一直');
+ this.confirmDist = this.defaultDist[x]
}
return
}
@@ -166,11 +181,101 @@ export default {
},
// 获取 县/区 信息
async getDistList(xsq, x) {
+ console.log('页面传递的x',x);
const res = await request(apiArr.getArea, 'POST', { parent_ad_code: xsq ? xsq.ad_code : this.confirmCity.ad_code }, { silent: false });
this.distList = res.rows;
this.defaultDist = res.rows;
this.confirmDist = res.rows[0] // 区的第一条信息
},
+
+ async headerSubmitClick() {
+ console.log('省' ,this.confirmProv1);
+ console.log('xsq' ,this.xsq);
+ console.log('confirmCity' ,this.confirmCity);
+ console.log('confirmDist' ,this.confirmDist);
+ const { confirmProv1, xsq, confirmCity, confirmDist } = this;
+ if(!this.name) {
+ uni.showToast({
+ title: '请输入收货人名称',
+ icon: 'none'
+ })
+ return
+ }
+ if(!this.phone) {
+ uni.showToast({
+ title: '请输入收货人手机号',
+ icon: 'none'
+ })
+ return
+ }
+ if(this.tab == 0 && this.showOrientation) {
+ uni.showToast({
+ title: '请输入收货地址',
+ icon: 'none'
+ })
+ return
+ }
+ if(!this.houseNumber) {
+ uni.showToast({
+ title: '请输入门牌号',
+ icon: 'none'
+ })
+ return
+ }
+ if(this.type === 'edit') {
+ const res = await request(apiArr2.updateAddress, "POST", {
+ id: this.id,
+ name: this.name,
+ phone: this.phone,
+ address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`,
+ house_number: this.houseNumber,
+ is_default: this.isDefault
+ }, { nested: true})
+ console.log('编辑成功', res);
+ if(res.code === 1) {
+ uni.showToast({
+ title: '地址更新成功',
+ icon: 'success',
+ mask: true
+ })
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: 1
+ })
+ }, 1000)
+ }
+ } else {
+ const res = await request(apiArr2.addAddress, 'POST', {
+ name: this.name,
+ phone: this.phone,
+ address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`,
+ house_number: this.houseNumber,
+ is_default: this.isDefault
+ }, { nested: true})
+ if(res.code === 1) {
+ uni.showToast({
+ title: '地址添加成功',
+ icon: 'success',
+ mask: true
+ })
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: 1
+ })
+ }, 1000)
+ }
+ }
+
+ },
+
+ headerConfirmClick() {
+ this.showOrientation = false;
+ this.isShow = true;
+ this.orientation = uni.getStorageSync('location');
+ },
+ headerSettingDefaultAddressClick() {
+ this.isDefault = this.isDefault == 2 ? 1 : 2;
+ },
async init() {
uni.showLoading({
title: '加载中',
@@ -205,11 +310,35 @@ export default {
/////////////////////////////////// 省市区方法///////////////////////////////////////////
},
onLoad(options) {
+ console.log('12231', options);
+ if(options.item) {
+ const item = JSON.parse(options.item);
+ console.log('1231', item);
+ this.name = item.name;
+ this.phone = item.phone;
+ this.orientation = {
+ region: item.address,
+ district: ''
+ }
+ this.showOrientation = false;
+ this.id = item.id;
+ this.type = 'edit';
+ this.isShow = false;
+ this.isDefault = item.is_default;
+ this.houseNumber = item.house_number;
+ }
const meun = menuButtonInfo();
this.top = meun.top;
this.localHeight = meun.height;
this.init()
},
+ onShow() {
+ if(!this.isShow ) return;
+ if(this.orientation.district !== uni.getStorageSync('location').district) {
+ this.orientation = uni.getStorageSync('location');
+ this.showOrientation = false;
+ }
+ },
onReachBottom() {
},
diff --git a/packages/shop/address/index.vue b/packages/shop/address/index.vue
index d16430cf..48abeba4 100644
--- a/packages/shop/address/index.vue
+++ b/packages/shop/address/index.vue
@@ -3,29 +3,27 @@
-
+
-
- 河北 衡水 桃城区 上海公馆 赞寓17层
+ {{item.name}} {{item.phone}}
默认
+
{{item.address}}{{ item.house_number }}