From ad58f01675119b787564954c82aa51511c0f31e7 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Mon, 3 Jun 2024 16:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/cart.js | 4 +- api/user.js | 12 +- pageQuota/feedBack/index.vue | 10 +- pages.json | 16 +- pages/cart/cart.vue | 19 +- pages/index/index.vue | 1571 ++++++++++++------------ pages/my/my.vue | 5 +- pagesOrder/addressEdit/addressEdit.vue | 10 +- pagesOrder/detail/detail.vue | 4 +- static/tab/da.png | Bin 0 -> 1362 bytes store/user.js | 4 +- utils/request.js | 139 ++- 12 files changed, 937 insertions(+), 857 deletions(-) create mode 100644 static/tab/da.png diff --git a/api/cart.js b/api/cart.js index 94f7427..d025b43 100644 --- a/api/cart.js +++ b/api/cart.js @@ -17,7 +17,9 @@ export const cartDeleteApi = (data)=>{ //购物车-零售列表 export const cartListApi = (data)=>{ - return request.get('/order/cart/list', data); + return request.get('/order/cart/list', data, { + noAuth: true + }); } //购物车-常买记录 diff --git a/api/user.js b/api/user.js index bf1e4b7..5292983 100644 --- a/api/user.js +++ b/api/user.js @@ -2,17 +2,23 @@ import request from '@/utils/request'; // 密码登录 export const userLoginApi = (data)=>{ - return request.post('/login/account', data); + return request.post('/login/account', data, { + noAuth: true + }); } // 微信登录 export const userLoginWeixinApi = (data)=>{ - return request.post('/login/mnpLogin', data); + return request.post('/login/mnpLogin', data, { + noAuth: true + }); } // 微信获取手机号 export const getMobileByMnpApi = (data)=>{ - return request.post('/user/User/getMobileByMnp', data); + return request.post('/user/User/getMobileByMnp', data, { + noAuth: true + }); } // 更新信息 diff --git a/pageQuota/feedBack/index.vue b/pageQuota/feedBack/index.vue index 2641f09..ae67a85 100644 --- a/pageQuota/feedBack/index.vue +++ b/pageQuota/feedBack/index.vue @@ -46,7 +46,7 @@ v-model="formData.contact"> - + 反馈记录 @@ -133,7 +133,7 @@ const uploadFilePromise = (url) => { return new Promise((resolve, reject) => { let a = uni.uploadFile({ - url: config.HTTP_REQUEST_URL + '/api/upload/image', // 仅为示例,非真实的接口地址 + url: config.HTTP_REQUEST_URL + '/api/upload/image', filePath: url, name: 'file', header: { @@ -149,6 +149,10 @@ }; const submit = async () => { + if(formData.content=='') return uni.showToast({title:'请输入反馈内容',icon:'none'}) + uni.showLoading({ + title: '提交中' + }) formData.images = formData.images.map(item => { return item.url }) @@ -156,7 +160,7 @@ await addFeedBackApi({ ...formData }) - + uni.hideLoading() uni.showToast({ title: '提交成功', duration: 1500 diff --git a/pages.json b/pages.json index 7178b6b..1787b7b 100644 --- a/pages.json +++ b/pages.json @@ -9,14 +9,6 @@ } }, "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages - { - "path": "pages/login/login", - "style": { - "navigationBarTitleText": "登录", - "enablePullDownRefresh": false, - "navigationStyle": "custom" - } - }, { "path": "pages/index/index", "style": { @@ -30,6 +22,14 @@ } } }, + { + "path": "pages/login/login", + "style": { + "navigationBarTitleText": "登录", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } + }, { "path": "pages/cart/cart", "style": { diff --git a/pages/cart/cart.vue b/pages/cart/cart.vue index edc1a3b..645006c 100644 --- a/pages/cart/cart.vue +++ b/pages/cart/cart.vue @@ -13,7 +13,7 @@ - + 共计{{cartList.length}} @@ -52,7 +52,7 @@ - + @@ -172,6 +172,7 @@ // 删除 const deleteCartList = () => { let list = []; + if(!cartList.value.length) return uni.showToast({ title: '请选择商品', icon: 'none' }); cartList.value.forEach(item => { if (item.check) list.push(item.cart_id); }) @@ -226,6 +227,9 @@ total_price: res.data?.extend.total_price || '0.00', count: res.data?.count || 0 } + setTimeout(()=>{ + triggered.value = false; + }, 300) }) } @@ -277,9 +281,18 @@ ...where.value }).then(res => { frequentlyList.value = res.data; + setTimeout(()=>{ + triggered.value = false; + }, 300) }) } + const triggered = ref(false); + const refresherrefresh = (type=1)=>{ + triggered.value = true; + if(type==1) getcartList(); + if(type==2) getFrequentlyPurchase(); + } onShow(() => { getcartList(); @@ -304,6 +317,7 @@ flex-direction: column; height: calc(100vh - var(--window-top)); width: 100%; + background-color: #f6f6f6; } .swiper-box { @@ -325,7 +339,6 @@ top: var(--window-top); left: 0; right: 0; - background-color: #f6f6f6; z-index: 100; height: 60rpx; line-height: 60rpx; diff --git a/pages/index/index.vue b/pages/index/index.vue index 3afdf3a..9979a56 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,865 +1,894 @@ \ No newline at end of file diff --git a/pages/my/my.vue b/pages/my/my.vue index b9e5dbe..95655bc 100644 --- a/pages/my/my.vue +++ b/pages/my/my.vue @@ -46,7 +46,7 @@ - + @@ -74,7 +74,7 @@ const userStore = useUserStore(); - const userInfo = userStore.userInfo; + const userInfo = ref({}); const orderCount = ref({ no_pay: 0, @@ -102,6 +102,7 @@ } onShow(() => { + userInfo.value = userStore.userInfo; getOrderCount(); }) diff --git a/pagesOrder/addressEdit/addressEdit.vue b/pagesOrder/addressEdit/addressEdit.vue index acd7112..a257d32 100644 --- a/pagesOrder/addressEdit/addressEdit.vue +++ b/pagesOrder/addressEdit/addressEdit.vue @@ -41,7 +41,15 @@ }) const rules = ref({ real_name: [{ required: true, message: '请输入姓名', trigger: ['blur'] }], - phone: [{ required: true, message: '请输入手机号', trigger: ['blur'] }], + phone: [{ required: true, message: '请输入手机号', trigger: ['blur'] },{ + validator: (rule, value, callback) => { + // 上面有说,返回true表示校验通过,返回false表示不通过 + // uni.$u.test.mobile()就是返回true或者false的 + return uni.$u.test.mobile(value); + }, + message: '手机号码不正确', + trigger: ['change','blur'], + }], detail: [{ required: true, message: '请输入地址', trigger: ['blur'] }] }) const uForm = ref(null); diff --git a/pagesOrder/detail/detail.vue b/pagesOrder/detail/detail.vue index 0f6c6f1..8bfe621 100644 --- a/pagesOrder/detail/detail.vue +++ b/pagesOrder/detail/detail.vue @@ -75,7 +75,7 @@ {{}} - x{{item.nums+item.goods_unit}} + x{{item.nums}}{{item.unit_name}} {{item.msg}} @@ -243,7 +243,7 @@ addressRef.value.setCheck(addressInfo.value.address_id); }) if (!res.data.paid) { - targetDate = new Date(res.data.create_time).getTime() + 30 * 60 * 1000; + targetDate = new Date(res.data.create_time).getTime() + 10 * 60 * 1000; // 每秒更新一次倒计时 timer = setInterval(updateCountdown, 1000); updateCountdown(); diff --git a/static/tab/da.png b/static/tab/da.png new file mode 100644 index 0000000000000000000000000000000000000000..b2ffd570d4d0cd4b7e89abe03e87320d8a2db46b GIT binary patch literal 1362 zcmV-Y1+DstP)Px)3`s;mRA@u(nQLrRMHI*XGkbSwyW7Pm)(0dO8;iVrRNJcbwN?`)K1tAEG*L*D zHlcjN4?;}}C5j;$f;3eVHIW!Kk*HrVu`gP&p)FL3DGy6Ap(RRN=(e!1-Mw?nY`e>@ zZFi@4+g^e@-*)er|2e;VX3jh=!wuHh4aS26(Dk0tM22EzD7&FBn-P1+0%);p1(DDR z7j>_wX`{O)S_OQBO#lW7CWtt%{L z;Cn{B5x`0T@s)+&yZM^n&#^dMtrsh=y|F6%2Xg@dks^|smZxTXvsNDM>;3s z!AHcIjS*gDjAs#1k53aDF@oc<0xgXc+G9b%t_vEh&|ksvUepJDG2SHsV- z^yG78pvAS1-Q{G~eE`pzsG}S@@@?xx?Lug-!%x<@RRYMaD=g#0cCjcKC6HU^RMA#+ z;GueCTF4?#2fXY=zUB8lipG(~CC_l?3XH&h-s#uBMOU z2Fk80Eak-Z$YHS|b3LA$zjB=Bh#0|^j!Lv&JUUwC6sBj;YM~;H+ z53e+@3rG^EtflzC?pXnnPDX?eO?}Piba&#i-xF*8f-#PJotY@QH4k%b&I#>J1&T>v zz#svn^3qi1kcy5G8&fjm7k&)-1_MiLJT28~M-oqpkeGEK9XfWO{1krGusdKS;K+^M7;YH2gbxIdk(XuFy68AVV5@kF54Jhp<|989X zc#FYxSGHw9gFZJnLU)gb80}gLEG+WYXV%NMjQqWY zyeik{9l*QCwxeq}{^NtBkjIB-=Ra*8kWcvW;i=uIIoA-l`HZKf+tab_zAd;tDa||} z=~+SzcrQe3S&V?m^N?M$C)T0FI+R#gjZC0P`pnEa^h(~ z=k3Ru-_{16`AIK3T--Dbm-Y2UFLPqw$c^9QX$5#~;hKo=Lo*3=)cpr`ou~@1%a1+rYj@m0QXsdkU@aF~6>++D zX*QE2VcK%J7Nl=#EpFTy%cW9=f+E>9c~3E>t+QIJk6IX?Qr}pCO!Qpn0wZkXAc4Mb zbv1sgqG2egCG|@j=)1N(QE_C<<~%xAcV3nwPPM-wAXRZQ>=Hm`y!EO0yx}tRFWvt@ UVi4U6pa1{>07*qoM6N<$f^2$!t^fc4 literal 0 HcmV?d00001 diff --git a/store/user.js b/store/user.js index 9f36be7..779bcdc 100644 --- a/store/user.js +++ b/store/user.js @@ -23,9 +23,9 @@ const useUserStore = defineStore("user", () => { uni.setStorageSync('token', data) } + // token.value = "18b6683cd772261fd119c813705ee0f1" // #ifdef H5 - - token.value = "6429c7999c9cb3935a3db2ccabb8a706" + // token.value = "3bff209b32d1f1c36e293b9f166bfa0b" // token.value = "95b24dd6d2dda836fe07854b08ba0944" userInfo.value = { avatar: "https://lihaiim.oss-cn-chengdu.aliyuncs.com/image/admin/default_avatar.png", diff --git a/utils/request.js b/utils/request.js index 5400a00..061aad8 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,5 +1,5 @@ import { - config + config } from '@/config/app'; import useUserStore from '@/store/user'; @@ -7,72 +7,89 @@ import useUserStore from '@/store/user'; const userStore = useUserStore(); function baseRequest(url, method, data, { - noAuth = false, - noVerify = false, - onReLogin = false + noAuth = false, + noVerify = false, + onReLogin = false }) { - let Url = config.HTTP_REQUEST_URL, - header = config.HEADER; - if (userStore.userInfo) { - header.TOKEN = userStore.token - } + let Url = config.HTTP_REQUEST_URL, + header = config.HEADER; + if (userStore.userInfo) { + header.TOKEN = userStore.token + } - return new Promise((reslove, reject) => { - uni.request({ - url: Url + '/api' + url, - method: method || 'GET', - header: { - ...header - }, - data: method != 'GET' ? data || {} : {}, - params: method == 'GET' ? data : {}, - success: (res) => { - // console.log(res, 'res') + return new Promise((reslove, reject) => { + uni.request({ + url: Url + '/api' + url, + method: method || 'GET', + header: { + ...header + }, + data: method != 'GET' ? data || {} : {}, + params: method == 'GET' ? data : {}, + success: (res) => { + // console.log(res, 'res') - if (res.data.show) { - uni.showToast({ - title: res.data.msg || '操作成功', - icon: 'none', - }) - } - if (noVerify) - reslove(res.data); - else if (res.data.code == -1) { - if (res.data.msg == "登录超时,请重新登录") { - userStore.setToken(''); - userStore.setUserInfo({}); - uni.reLaunch({ - url: '/pages/login/login' - }) - } - } else if (res.data.code == 0) { - reject(res.data); - } else if (res.data.code == 1) { - reslove(res.data); - } else if (res.data.code == 200) { - reslove(res.data.data); - } else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) { - reject(res.data); - } else if (res.data.code == 501) { - reject(res.data); - } else { - reject(res.data.msg || '请检查网络'); - } - }, - fail: (message) => { - console.log(message, '错误信息') - uni.showToast({ - title: '网络错误', - icon: 'none' - }) - reject('请求失败'); - } - }) - }); + if (res.data.show) { + uni.showToast({ + title: res.data.msg || '操作成功', + icon: 'none', + }) + } + if (noVerify) + reslove(res.data); + else if (res.data.code == -1) { + if (res.data.msg == "登录超时,请重新登录" && !noAuth) { + userStore.setToken(''); + userStore.setUserInfo({}); + uni.showModal({ + content: '您需要先登录才可使用该功能, 是否前去登录', + success: (e) => { + if (e.confirm) uni.navigateTo({ + url: '/pages/login/login' + }) + } + }) + } + } else if (res.data.code == 0) { + if (res.data.msg == "请求参数缺token" && !noAuth) { + userStore.setToken(''); + userStore.setUserInfo({}); + uni.showModal({ + content: '您需要先登录才可使用该功能, 是否前去登录', + success: (e) => { + if (e.confirm) uni.navigateTo({ + url: '/pages/login/login' + }) + } + }) + } + reject(res.data); + } else if (res.data.code == 1) { + reslove(res.data); + } else if (res.data.code == 200) { + reslove(res.data.data); + } else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) { + reject(res.data); + } else if (res.data.code == 501) { + reject(res.data); + } else { + reject(res.data.msg || '请检查网络'); + } + }, + fail: (message) => { + console.log(message, '错误信息') + uni.showToast({ + title: '网络错误', + icon: 'none' + }) + reject('请求失败'); + } + }) + }); } const syhttp = {}; ['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => { - syhttp[method] = (api, data, opt) => baseRequest(api, method, data, opt || {}) + syhttp[method] = (api, data, opt) => baseRequest(api, method, data, opt || {}) }); export default syhttp; \ No newline at end of file