From 6cea5aeb427400a8b27163ad9a441750c950bf7e Mon Sep 17 00:00:00 2001 From: wwz <1144797966@qq.com> Date: Mon, 10 Feb 2025 15:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=90=86=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/0-conf.js | 1 - framework/11-api.js | 13 +- framework/apis.js | 66 +++++ manifest.json | 23 +- pages/index/components/advertisement.vue | 4 +- pages/index/components/category.vue | 2 +- pages/index/components/diamond.vue | 2 +- pages/index/components/swiper.vue | 2 +- pages/index/components/todaylist.vue | 12 +- pages/index/index.vue | 312 ++++++++++++++++------- pages/index/indexs.vue | 201 +++++++++++++++ vite.config.js | 19 ++ 12 files changed, 519 insertions(+), 138 deletions(-) create mode 100644 framework/apis.js create mode 100644 pages/index/indexs.vue create mode 100644 vite.config.js diff --git a/framework/0-conf.js b/framework/0-conf.js index 5d0ebde..195733c 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -13,7 +13,6 @@ const proxyApi = "/api" const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上 const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 // #endif - // #ifdef H5 const baseUrl = debug ? proxyApi + '/cashierService' : "https://cashier.sxczgkj.cn/cashierService" const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService' diff --git a/framework/11-api.js b/framework/11-api.js index a088390..c5ccd54 100644 --- a/framework/11-api.js +++ b/framework/11-api.js @@ -46,7 +46,7 @@ async function request(options) { environment: 'app', // #endif // #ifdef H5 - environment: 'h5', + environment: 'H5', // #endif // #ifdef MP-WEIXIN environment: 'wx', @@ -57,8 +57,6 @@ async function request(options) { token: uni.cache.get('token'), openId: uni.cache.get('miniAppOpenId'), id: uni.cache.get('userInfo').id, - loginName: "", - clientType: '' } } else { @@ -67,15 +65,6 @@ async function request(options) { let res = await requestrequest(options); if (res.code != 0) { if (res.code == -4) { - // uni.showToast({ - // title: res.message || res.msg, - // icon: "none", - // success: () => { - // // setTimeout(res => { - // // store.dispatch("loginEvent"); //获取shapid - // // }, 1000) - // } - // }) } else if (res.code == 482) { diff --git a/framework/apis.js b/framework/apis.js new file mode 100644 index 0000000..3694bd0 --- /dev/null +++ b/framework/apis.js @@ -0,0 +1,66 @@ +export function request(options) { + return new Promise((resolve, reject) => { + uni.request({ + url: uni.conf.baseUrl + options.url, + data: options.data || {}, + method: options.method, + // 设置请求头,添加版本号 + header: { + 'Content-Type': 'application/json;charset=UTF-8', + version: uni.conf.version, + type: uni.getSystemInfoSync().platform, + // #ifdef APP-PLUS + environment: 'app', + // #endif + // #ifdef H5 + environment: 'h5', + // #endif + // #ifdef MP-WEIXIN + environment: 'wx', + // #endif + // #ifdef MP-ALIPAY + environment: 'alipay', + // #endif + token: uni.cache.get('token'), + openId: uni.cache.get('miniAppOpenId'), + id: uni.cache.get('userInfo').id, + loginName: "", + }, + success(res) { + const data = res.data || res; + // 根据项目返回的code判断 + if (data.code != 0){ + switch (data.code) { + case '200': + resolve(data.data); + break; + case '500': + uni.showToast({ + title: data.message, + icon: "none" + }); + reject(false); + break; + case '400': + uni.showToast({ + title: data.message, + icon: "none" + }); + // 跳转到登录页面等操作 + reject(false); + break; + default: + reject(false); + break; + } + }else{ + resolve(data.data); + } + }, + fail(res) { + // 失败处理 + reject(res); + } + }); + }); +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 472f83c..5494759 100644 --- a/manifest.json +++ b/manifest.json @@ -67,28 +67,7 @@ "requiredPrivateInfos": ["getLocation", "onLocationChange", "chooseLocation", "chooseAddress"] }, "h5": { - "devServer": { - "https": false, - "disableHostCheck": false, - "proxy": { - "/api": { - // "target": "https://wxcashiertest.sxczgkj.cn", - // "target" : "https://ky.sxczgkj.cn", - "target": "https://cashier.sxczgkj.cn", - "ws": false, - "changeOrigin": true, //是否跨域 - "secure": false, // 设置支持https协议的代理 - "pathRewrite": { - "^/api": "" //需要rewrite重写的, - } - } - } - }, - "template": "template.h5.html", - "router": { - "mode": "history", - "base": "/h5/" - } + }, "mp-alipay": { "usingComponents": true diff --git a/pages/index/components/advertisement.vue b/pages/index/components/advertisement.vue index cc08235..5210af0 100644 --- a/pages/index/components/advertisement.vue +++ b/pages/index/components/advertisement.vue @@ -1,13 +1,13 @@