diff --git a/order-app/src/api/user.js b/order-app/src/api/user.js
index a5454aa..5a09860 100644
--- a/order-app/src/api/user.js
+++ b/order-app/src/api/user.js
@@ -49,4 +49,12 @@ export const userLogin = async () => {
//新增地址
export const addAddressApi = (parm) => {
return http.post("/wxapi/address", parm)
+}
+//地址列表
+export const addressListApi = (parm) => {
+ return http.get("/wxapi/address/list", parm)
+}
+//编辑地址
+export const editAddressApi = (parm) => {
+ return http.put("/wxapi/address", parm)
}
\ No newline at end of file
diff --git a/order-app/src/pages.json b/order-app/src/pages.json
index eaec275..2f62334 100644
--- a/order-app/src/pages.json
+++ b/order-app/src/pages.json
@@ -51,6 +51,13 @@
"style": {
"navigationBarTitleText": "确认订单"
}
+ },
+ {
+ "path" : "pages/addresslist/addresslist",
+ "style" :
+ {
+ "navigationBarTitleText" : ""
+ }
}
],
"globalStyle": {
diff --git a/order-app/src/pages/address/address.vue b/order-app/src/pages/address/address.vue
index 2fe4f22..ab27076 100644
--- a/order-app/src/pages/address/address.vue
+++ b/order-app/src/pages/address/address.vue
@@ -26,7 +26,7 @@
提醒:每次下单会默认推荐该地址
-
+
@@ -41,7 +41,11 @@
ref
} from 'vue'
import {
- addAddressApi
+ onLoad
+ } from '@dcloudio/uni-app';
+ import {
+ addAddressApi,
+ editAddressApi
} from '../../api/user.js'
const show = ref(false)
const finalAddress = ref('')
@@ -74,9 +78,63 @@
//提交
const addBtn = async () => {
console.log(address)
- let res = await addAddressApi(address)
+ //表单验证
+ if (!address.userName) {
+ uni.showToast({
+ icon: 'none',
+ title: '请填写姓名'
+ })
+ return;
+ }
+ if (!address.phone) {
+ uni.showToast({
+ icon: 'none',
+ title: '请填写电话'
+ })
+ return;
+ }
+ if (!address.area) {
+ uni.showToast({
+ icon: 'none',
+ title: '请填写区域'
+ })
+ return;
+ }
+ if (!address.address) {
+ uni.showToast({
+ icon: 'none',
+ title: '请填写详细地址'
+ })
+ return;
+ }
+ let res = null;
+ if (type.value == '0') {
+ res = await addAddressApi(address)
+ } else {
+ res = await editAddressApi(address)
+ }
console.log(res)
+ if (res && res.code == 200) {
+ //返回列表
+ uni.navigateBack()
+ }
}
+ //区分是新增 还是编辑
+ const type = ref('0')
+ onLoad((options) => {
+ console.log(options)
+ //编辑设置值
+ if (options.item) {
+ type.value = '1';
+ const item = JSON.parse(options.item)
+ address.addressId = item.addressId
+ address.phone = item.phone
+ address.userName = item.userName
+ address.area = item.area
+ address.address = item.address
+ address.status = item.status
+ }
+ })
\ No newline at end of file
diff --git a/order-app/src/pages/detail/detail.vue b/order-app/src/pages/detail/detail.vue
index 78d5148..efe03f1 100644
--- a/order-app/src/pages/detail/detail.vue
+++ b/order-app/src/pages/detail/detail.vue
@@ -88,16 +88,20 @@
import {
onLoad
} from '@dcloudio/uni-app';
- import { carStore } from '../../store/car.js'
+ import {
+ carStore
+ } from '../../store/car.js'
import {
orderStore
} from '../../store/order.js'
- import {userLogin} from '../../api/user.js'
+ import {
+ userLogin
+ } from '../../api/user.js'
//获取store
const store = carStore()
const ostore = orderStore()
//购物车数量
- const carCount = computed(()=>{
+ const carCount = computed(() => {
return store.carList.length
})
//菜品详情
@@ -153,11 +157,11 @@
swiperCurrent.value = index;
}
//加入购物车
- const addCar = ()=>{
+ const addCar = () => {
store.addCar(carData.value)
}
//立即购买
- const addBuy = ()=>{
+ const addBuy = () => {
//清空
ostore.orderList = []
ostore.addOrder(carData.value)
@@ -365,4 +369,4 @@
.page-box {
padding: 20rpx;
}
-
+
\ No newline at end of file