From 19539f49aabc7812c5991f03c520315f45d4fd99 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Tue, 7 Nov 2023 17:51:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86request=20=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + api/page.js | 12 +++++- pages/index/components/banner.vue | 2 +- pages/index/index.vue | 69 ++++++++++++++++++------------- utils/request/index.js | 8 +++- 5 files changed, 61 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 988398f..d51d544 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # 文化云 [uni-app端] +1、[uni-app代理配置 manifest.json](https://blog.csdn.net/qq_36557846/article/details/123686878) #### 如何使用uni-app端 diff --git a/api/page.js b/api/page.js index bc0a519..3bc9371 100644 --- a/api/page.js +++ b/api/page.js @@ -1,8 +1,12 @@ import request from '@/utils/request' +// 生产环境 与测试环境 +const prefix ="AgencyAddress/" + // api地址 const apiUri = { - detail: 'page/detail' + detail: 'page/detail', + pageinfo: prefix+'/logo/logoImag' } // 页面数据 @@ -11,3 +15,9 @@ export function detail(pageId) { pageId }) } + +// 查询全局设置----logo、栏目、底部、轮播图 +export function pageinfo() { + // return request.jsonp(apiUri.pageinfo) + return request.get(apiUri.pageinfo) +} \ No newline at end of file diff --git a/pages/index/components/banner.vue b/pages/index/components/banner.vue index 753fbfd..e09f2f6 100644 --- a/pages/index/components/banner.vue +++ b/pages/index/components/banner.vue @@ -33,7 +33,7 @@ watch:{ dataList:function(e){ - // console.log("datalist",e) + console.log("datalist",e) } }, diff --git a/pages/index/index.vue b/pages/index/index.vue index 16ad3b8..a31694e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -82,49 +82,62 @@ }, mounted() { this.getBannerList(); - - this.getHomeList(); + // + // this.getHomeList(); }, methods: { // 轮播图片 getBannerList(){ - // for demo - for(let i=0;i<3;i++){ - const obj = { - "imgUrl": "http://192.168.66.16:8089/assets/store/img/diy/banner/01.png", - "link": null - } - this.imglist.push(obj) - } - // this.imglist.push(simg) + Api.pageinfo().then((res)=>{ + // console.log("fda",eval(res)) + let ldata = res.data + // 轮播图 + this.imglist = ldata.rotations + }).catch(err=>{ + console.log(err) + }); + + // Api.pageinfo().then(res=>{ + //let aa = eval('(' + res + ')'); + // let aa = JSON.stringify(res) + // console.log(aa.length) + // console.log(aa) + // if(res.resultCode =="00000000"){ + // let ldata = res.data + + // } + // console.log(res) + // }); }, //商品列表 getHomeList(){ - let rqdata={pay_type: 1,record_type: 2,goods_status: 1,page: 1,limit: 6} + // 搜索的内容 + let rqdata = {"pay_type":2,"goods_status":1,"page":1,"limit":6} + //let rqdata={pay_type: 1,record_type: 2,goods_status: 1,page: 1,limit: 6} Gapi.soglist(rqdata).then(res=>{ - if(res.resulteCode=='000000'){ - this.gdlist = res.data + if(res.resulteCode=='00000000'){ + this.gdlist = res.data.data } console.log("sgres:",res) }).catch(err=>{ console.log(err) }); // - for(let i=0;i<5;i++){ - const obj = { - "goods_id": 10002, - "goods_name": "00A02", - "selling_point": "", - "goods_image": "http://192.168.66.16:8089/uploads/10001/20231021/be65b065b633bf469cb7bcfc15385936.jpg", - "goods_price_min": "100.00", - "goods_price_max": "100.00", - "line_price_min": "120.00", - "line_price_max": "120.00", - "goods_sales": 0 - } - this.gdlist.push(obj) - } + // for(let i=0;i<5;i++){ + // const obj = { + // "goods_id": 10002, + // "goods_name": "00A02", + // "selling_point": "", + // "goods_image": "http://192.168.66.16:8089/uploads/10001/20231021/be65b065b633bf469cb7bcfc15385936.jpg", + // "goods_price_min": "100.00", + // "goods_price_max": "100.00", + // "line_price_min": "120.00", + // "line_price_max": "120.00", + // "goods_sales": 0 + // } + // this.gdlist.push(obj) + // } } }, diff --git a/utils/request/index.js b/utils/request/index.js index 7ada68e..b287174 100644 --- a/utils/request/index.js +++ b/utils/request/index.js @@ -109,6 +109,7 @@ $http.dataFactory = async res => { }) } + console.log(res.response) let httpData = res.response.data if (typeof httpData == "string") { try { @@ -124,7 +125,7 @@ $http.dataFactory = async res => { errMsg: "请检查api地址能否访问正常" }) } - + /*********以下只是模板(及共参考),需要开发者根据各自的接口返回类型修改*********/ // 判断数据是否请求成功 @@ -133,6 +134,11 @@ $http.dataFactory = async res => { // 返回正确的结果(then接受数据) return Promise.resolve(httpData) } + + // why 系统专有 + if(httpData.resultCode == '00000000'){ + return Promise.resolve(httpData) + } // 判断是否需要登录 if (httpData.status == 401) {