diff --git a/api/api.js b/api/api.js index 1984ae2..e6c2e52 100644 --- a/api/api.js +++ b/api/api.js @@ -1,5 +1,8 @@ import http from './http.js' +let limit = {} +let debounce = {} + const config = { // 示例 // wxLogin : {url : '/api/wxLogin', method : 'POST', @@ -31,6 +34,7 @@ const config = { method: 'GET', showLoading : true, }, + // 商品列表 goodsPage: { @@ -44,6 +48,36 @@ const config = { method: 'GET', showLoading : true, }, + // 购物车分页 + cartPage: { + url: '/goods/shopping/cart/page', + method: 'GET', + showLoading : true, + auth : true, + }, + // 加入购物车 + cartAdd: { + url: '/goods/join/shopping/cart', + method: 'POST', + showLoading : true, + auth : true, + }, + // 删除购物车 + cartDel: { + url: '/goods/shopping/cart/delete', + method: 'POST', + showLoading : true, + auth : true, + }, + // 修改购物车数量 + cartNum: { + url: '/goods/shopping/cart/add/or/delete', + method: 'POST', + auth : true, + debounce : 1000, + }, + + //分类列表 categoryList: { @@ -57,21 +91,21 @@ const config = { url: '/address/add', method: 'POST', limit: 500, - // auth : true, + auth : true, showLoading : true, }, //修改默认地址 addressDefault: { url: '/address/default', method: 'POST', - // auth : true, + auth : true, showLoading : true, }, //删除地址 addressDelete: { url: '/address/delete', method: 'POST', - // auth : true, + auth : true, showLoading : true, }, //修改地址 @@ -79,14 +113,14 @@ const config = { url: '/address/edit', method: 'POST', limit: 500, - // auth : true, + auth : true, showLoading : true, }, //分页查询地址 addressPage: { url: '/address/page', method: 'GET', - // auth : true, + auth : true, showLoading : true, }, @@ -95,14 +129,14 @@ const config = { orderPage: { url: '/order/page', method: 'GET', - // auth : true, + auth : true, showLoading : true, }, //查询订单详情 orderOne: { url: '/order/one', method: 'GET', - // auth : true, + auth : true, showLoading : true, }, @@ -146,12 +180,12 @@ export function api(key, data, callback, loadingTitle) { // 接口限流 if (req.limit) { - let storageKey = 'limit:' + req.url - let storage = uni.getStorageSync(storageKey) - if (storage && new Date().getTime() - parseInt(storage) < req.limit) { + let storageKey = req.url + let storage = limit[storageKey] + if (storage && new Date().getTime() - storage < req.limit) { return } - uni.setStorageSync(storageKey, new Date().getTime()) + limit[storageKey] = new Date().getTime() } //必须登录 @@ -164,6 +198,29 @@ export function api(key, data, callback, loadingTitle) { return } } + + // 接口防抖 + if(req.debounce){ + + let storageKey = req.url + let storage = debounce[storageKey] + + if (storage) { + clearTimeout(storage) + } + + debounce[storageKey] = setTimeout(() => { + + clearTimeout(storage) + + delete debounce[storageKey] + + http.http(req.url, data, callback, req.method, + loadingTitle || req.showLoading, loadingTitle || req.loadingTitle) + }, req.debounce) + + return + } http.http(req.url, data, callback, req.method, loadingTitle || req.showLoading, loadingTitle || req.loadingTitle) diff --git a/api/http.js b/api/http.js index 8f7078e..1598d64 100644 --- a/api/http.js +++ b/api/http.js @@ -43,7 +43,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) { }); } - callback(res.data) + callback && callback(res.data) }, fail: () => { diff --git a/components/user/productList.vue b/components/user/productList.vue index cd91e95..85a32c1 100644 --- a/components/user/productList.vue +++ b/components/user/productList.vue @@ -6,7 +6,7 @@ :key="index"> + :src="item.pic || 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg'" mode="aspectFill"> {{ item.name }} diff --git a/pages.json b/pages.json index 42e5874..142de53 100644 --- a/pages.json +++ b/pages.json @@ -64,6 +64,9 @@ }, { "path": "auth/loginAndRegisterAndForgetPassword" + }, + { + "path": "mine/lease" } ] }], diff --git a/pages/index/cart.vue b/pages/index/cart.vue index 688c7d2..f7a64fc 100644 --- a/pages/index/cart.vue +++ b/pages/index/cart.vue @@ -9,11 +9,12 @@ + :options="options" + @click="delCart(item, index)"> - {{ item.title }} + {{ item.name }} + @change="e => valChange(item, e)"> - 规格:{{ item.unit }} + 规格:{{ item.title }} @@ -97,24 +98,13 @@ style: { backgroundColor: '#FA5A0A' } - }, - ], - list : [ - { - id : 1, - title : '桌布租赁', - num : 1, - price : 299, - unit : '120*40*75【桌子尺寸】', - }, - { - id : 2, - title : '桌布租赁', - num : 1, - price : 299, - unit : '120*40*75【桌子尺寸】', }, ], + queryParams: { + pageNo: 1, + pageSize: 10 + }, + list : [], } }, computed: { @@ -123,7 +113,7 @@ return 0 } let price = 0 - this.list.forEach(n => { + this.list.records.forEach(n => { if(this.checkboxValue.includes(n.id)){ price += n.price * n.num } @@ -131,9 +121,44 @@ return price }, }, + onShow() { + this.getData() + }, + //滚动到屏幕底部 + onReachBottom() { + if(this.queryParams.pageSize < this.list.total){ + this.queryParams.pageSize += 10 + this.getData() + } + }, methods: { - valChange(){ - + valChange(item, e){ + console.log(e.value); + this.$api('cartNum', { + id : item.id, + num : e.value, + }) + }, + // 购物车分页 + getData(){ + this.$api('cartPage', this.queryParams, res => { + if(res.code == 200){ + this.list = res.result + } + }) + }, + // 删除购物车 + delCart(item, index){ + this.$api('cartDel', { + id : item.id + }, res => { + if(res.code == 200){ + this.getData() + uni.showToast({ + title: '删除成功', + }); + } + }) }, } } @@ -141,6 +166,9 @@ + .right { + display: flex; + justify-content: center; + align-items: center; + width: 10%; + color: #666666; + background-color: #ffffff; + } + } + \ No newline at end of file diff --git a/pages_order/components/product/submitUnitSelect.vue b/pages_order/components/product/submitUnitSelect.vue index 4dbfbf8..0bc0ff7 100644 --- a/pages_order/components/product/submitUnitSelect.vue +++ b/pages_order/components/product/submitUnitSelect.vue @@ -75,7 +75,13 @@ - {{ submiitTitle }} + + 加入租赁车 + + + {{ submiitTitle }} + @@ -150,6 +156,19 @@ this.unit = item this.unitIndex = index }, + addCart(){ + this.$api('cartAdd', { + id : this.detail.id, + skuId : this.unit.id, + }, res => { + if(res.code == 200){ + uni.showToast({ + title: '添加成功', + }); + this.$refs.popup.close() + } + }) + }, } } @@ -260,7 +279,6 @@ } } .submit-btn{ - background: $uni-color; width: 600rpx; height: 80rpx; color: #fff; @@ -270,6 +288,23 @@ display: flex; justify-content: center; align-items: center; + border: 1rpx solid $uni-color; + overflow: hidden; + .l{ + flex: 1; + display: flex; + justify-content: center; + align-items: center; + color: $uni-color; + } + .r{ + background: $uni-color; + flex: 1; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + } } } diff --git a/pages_order/mine/lease.vue b/pages_order/mine/lease.vue new file mode 100644 index 0000000..292bb5d --- /dev/null +++ b/pages_order/mine/lease.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/pages_order/order/orderDetail.vue b/pages_order/order/orderDetail.vue index 8ca27b7..5a11a9a 100644 --- a/pages_order/order/orderDetail.vue +++ b/pages_order/order/orderDetail.vue @@ -50,22 +50,22 @@ - + - {{msgOrder.projectName}} + {{order.title}} - {{msgOrder.money}} + {{order.orderPay}} - 规格:{{msgOrder.unit}} + 规格:{{order.unit}} @@ -120,49 +120,57 @@ 服务地址 --> - + - {{msgOrder.name}} {{msgOrder.phone}} - {{msgOrder.address}} + {{order.userName}} {{order.userPhone}} + {{order.userAddress}} - + + + 实付款 - ¥{{ msgOrder.money }} + ¥{{ order.orderPay }} - + + + 租赁费用 - ¥{{ msgOrder.price }} + ¥{{ order.rentPay }} - + + 水洗费用 - ¥{{ msgOrder.price}} + ¥{{ order.washPay}} - + @@ -177,7 +185,7 @@ 订单编号 - {{msgOrder.id}} + {{order.id}} @@ -185,7 +193,7 @@ 下单时间 - {{msgOrder.createTime}} + {{order.createTime}} @@ -244,10 +252,24 @@ createTime : '2024-01-18 15:39', projectName : '桌布租赁' }, + order : {}, + orderId : 0, } }, + onLoad(agrs) { + this.orderId = agrs.id + this.getData() + }, methods: { - + getData(){ + this.$api('orderOne', { + id : this.orderId + }, res => { + if(res.code == 200){ + this.order = res.result + } + }) + }, } } diff --git a/pages_order/order/refundsOrExchange.vue b/pages_order/order/refundsOrExchange.vue index 3bce4d8..f74afd0 100644 --- a/pages_order/order/refundsOrExchange.vue +++ b/pages_order/order/refundsOrExchange.vue @@ -1,366 +1,350 @@ \ No newline at end of file