From 3ca9b27607c0b44606e1b1d75f0769f5d7e8d3c6 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Sun, 15 Sep 2024 22:18:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 1 + api/api.js | 143 +++++++- api/http.js | 5 +- components/base/tabbar.vue | 35 +- components/config/PrivacyAgreementPoup.vue | 4 +- components/user/productList.vue | 17 +- config.js | 4 +- pages/index/cart.vue | 1 - pages/index/category.vue | 110 +++--- pages/index/center.vue | 1 - pages/index/index.vue | 61 +++- pages/index/order.vue | 100 ++++-- pages_order/auth/wxLogin.vue | 2 +- pages_order/auth/wxUserInfo.vue | 2 +- pages_order/components/address/addressList.vue | 137 +++++--- pages_order/components/address/redactAddress.vue | 198 +++++------ .../components/product/submitUnitSelect.vue | 59 ++-- pages_order/mine/address.vue | 368 ++------------------- pages_order/product/productDetail.vue | 39 ++- store/store.js | 71 +++- 20 files changed, 679 insertions(+), 679 deletions(-) diff --git a/App.vue b/App.vue index 5676699..0ce7f61 100644 --- a/App.vue +++ b/App.vue @@ -4,6 +4,7 @@ }, onShow: function() { // this.$store.commit('initConfig') + this.$store.commit('getPosition') }, onHide: function() { } diff --git a/api/api.js b/api/api.js index a91ebb0..1984ae2 100644 --- a/api/api.js +++ b/api/api.js @@ -6,39 +6,154 @@ const config = { // auth : false, showLoading : true, loadingTitle : '加载中...', // limit : 1000 // }, + + getConfig: { + url: '/api/getConfig', + method: 'GET' + }, + + // banner列表 + bannerList: { + url: '/banner/list', + method: 'GET', + showLoading : true, + }, + + // 公告列表 + noticeList: { + url: '/notice/list', + method: 'GET', + showLoading : true, + }, + // 公告详情 + noticeOne: { + url: '/notice/one', + method: 'GET', + showLoading : true, + }, + + // 商品列表 + goodsPage: { + url: '/goods/page', + method: 'GET', + showLoading : true, + }, + // 商品详情 + goodsOne: { + url: '/goods/one', + method: 'GET', + showLoading : true, + }, + + //分类列表 + categoryList: { + url: '/category/list', + method: 'GET', + showLoading : true, + }, + + //新增地址 + addressAdd: { + url: '/address/add', + method: 'POST', + limit: 500, + // auth : true, + showLoading : true, + }, + //修改默认地址 + addressDefault: { + url: '/address/default', + method: 'POST', + // auth : true, + showLoading : true, + }, + //删除地址 + addressDelete: { + url: '/address/delete', + method: 'POST', + // auth : true, + showLoading : true, + }, + //修改地址 + addressEdit: { + url: '/address/edit', + method: 'POST', + limit: 500, + // auth : true, + showLoading : true, + }, + //分页查询地址 + addressPage: { + url: '/address/page', + method: 'GET', + // auth : true, + showLoading : true, + }, - getConfig : {url : '/api/getConfig', method : 'GET', limit : 500}, + + //分页查询订单 + orderPage: { + url: '/order/page', + method: 'GET', + // auth : true, + showLoading : true, + }, + //查询订单详情 + orderOne: { + url: '/order/one', + method: 'GET', + // auth : true, + showLoading : true, + }, + + + // 微信登录接口 + wxLogin: { + url: '/login/login', + method: 'POST', + limit : 500, + showLoading : true, + }, + + // 修改个人信息接口 + updateInfo: { + url: '/info/updateInfo', + method: 'POST', + auth: true, + limit : 500, + showLoading : true, + }, } -export function api(key, data, callback, loadingTitle){ +export function api(key, data, callback, loadingTitle) { let req = config[key] - + if (!req) { console.error('无效key' + key); return } - - if(typeof callback == 'string'){ + + if (typeof callback == 'string') { loadingTitle = callback } - - if(typeof data == 'function'){ + + if (typeof data == 'function') { callback = data data = {} } - + // 接口限流 - if(req.limit){ + if (req.limit) { let storageKey = 'limit:' + req.url let storage = uni.getStorageSync(storageKey) - if(storage && new Date().getTime() - parseInt(storage) < req.limit){ + if (storage && new Date().getTime() - parseInt(storage) < req.limit) { return } uni.setStorageSync(storageKey, new Date().getTime()) } - + //必须登录 if (req.auth) { if (!uni.getStorageSync('token')) { @@ -49,9 +164,9 @@ export function api(key, data, callback, loadingTitle){ return } } - - http.http(req.url, data, callback, req.method, - loadingTitle || req.showLoading, loadingTitle || req.loadingTitle) + + 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 7ccb930..8f7078e 100644 --- a/api/http.js +++ b/api/http.js @@ -25,11 +25,12 @@ function http(uri, data, callback, method = 'GET', showLoading, title) { } if(res.statusCode == 401 || - res.data.message == '操作失败,token非法无效!'){ + res.data.message == '操作失败,token非法无效!' || + res.data.message == '操作失败,用户不存在!'){ uni.removeStorageSync('token') console.error('登录过期'); uni.navigateTo({ - url: '/pages/auth/login' + url: '/pages_order/auth/wxLogin' }) } diff --git a/components/base/tabbar.vue b/components/base/tabbar.vue index 7807784..732e9ef 100644 --- a/components/base/tabbar.vue +++ b/components/base/tabbar.vue @@ -1,18 +1,21 @@