From 6a891ae24b06d8e3be0bd6010d83717411c9b69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Wed, 8 Mar 2023 11:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E3=80=81=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/service/preview-item.vue | 6 +- src/core/apis.js | 43 ++++++++++++++ src/pages/service/cate.vue | 75 +++++++++++++++++-------- src/pages/service/detail.vue | 50 ++++++++++++----- src/pages/service/list.vue | 31 ++++++++++ 5 files changed, 165 insertions(+), 40 deletions(-) diff --git a/src/components/service/preview-item.vue b/src/components/service/preview-item.vue index 7164ef6..d2ba16b 100644 --- a/src/components/service/preview-item.vue +++ b/src/components/service/preview-item.vue @@ -3,10 +3,8 @@ {{ data.name }} - - {{ "已服务113256次" }} - - ¥158元起 + 已服务{{ data.times }}次 + ¥ {{ data.price }}元 diff --git a/src/core/apis.js b/src/core/apis.js index 06192df..936ce5a 100644 --- a/src/core/apis.js +++ b/src/core/apis.js @@ -25,12 +25,55 @@ export default { auth: true, } }, + project: { + project: { + url: "/project/applyinfo", + }, + projectList: { + url: "/project/alllist", + }, + business: { + url: "/project/applyinfob", + }, + businessList: { + url: "/project/alllistb", + }, + afterMarket: { + url: "/project/applyguarantee" + }, + afterMarketList: { + url: "/project/allguaranteelist" + }, + distribution: { + config: { + url: "/index/getdistributionmoney" + }, + carType: { + url: "/index/getallcar" + }, + submit: { + url: "/project/distribution" + }, + pay: { + url: "/wxpay/payorderd" + } + } + }, service: { aftermarket: { url: "/index/category2", }, + hotCate: { + url: "/index/hotcategory", + }, cate: { url: "/index/category1", }, + list: { + url: "/index/getcategorybyid" + }, + goodsDetail: { + url: "/index/goodsinfobyid", + } }, } diff --git a/src/pages/service/cate.vue b/src/pages/service/cate.vue index 860bca5..c324e87 100644 --- a/src/pages/service/cate.vue +++ b/src/pages/service/cate.vue @@ -60,34 +60,65 @@ export default { x: x - this.$utils.rpx2px(20), y: y - this.$utils.rpx2px(40), }; - this.$request({ - api: "service.cate", - }) - .then((response) => { - response.data.forEach((item) => { - let child = []; - item.child.forEach((v) => { - child.push({ - id: v.id, - name: v.name, - icon: v.more, - }); - }); - this.data.push({ - id: item.id, - name: item.name, - icon: item.more, - child: child, - }); - }); - }) - .catch((e) => {}); + // 加载分类 + this.loadHot(); + this.loadCate(); }, onShow() {}, onReady() {}, onReachBottom() {}, onPullDownRefresh() {}, methods: { + /** + * 热门推荐 + */ + loadHot() { + this.$request({ + api: "service.hotCate", + }).then((response) => { + let child = []; + response.data.forEach((item) => { + child.push({ + id: item.id, + name: item.name, + icon: item.more, + }); + }); + this.data.push({ + id: 0, + name: "热门推荐", + icon: "", + child: child, + }); + }); + }, + /** + * 分类 + */ + loadCate() { + this.$request({ + api: "service.cate", + }) + .then((response) => { + response.data.forEach((item) => { + let child = []; + item.child.forEach((v) => { + child.push({ + id: v.id, + name: v.name, + icon: v.more, + }); + }); + this.data.push({ + id: item.id, + name: item.name, + icon: item.more, + child: child, + }); + }); + }) + .catch((e) => {}); + }, clickItem(id) { this.$utils.toPage("/pages/service/list?id=" + id); }, diff --git a/src/pages/service/detail.vue b/src/pages/service/detail.vue index 75aecd3..1b1d0f0 100644 --- a/src/pages/service/detail.vue +++ b/src/pages/service/detail.vue @@ -36,7 +36,7 @@ 空调安装 - 已服务812121次 + 已服务{{ detail.times }}次 @@ -63,7 +63,7 @@ - ¥306.00 + ¥{{ detail.price }} @@ -90,15 +90,13 @@ export default { currentBanner: 1, bottom: 0, pageTitle: "服务详情", + id: 0, detail: { - title: "服务标题", - images: [ - require("@/static/temp/cate/5.png"), - require("@/static/temp/cate/5.png"), - require("@/static/temp/cate/5.png"), - ], - content: - "

这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容

", + title: "", + times: 0, + images: [], + content: "", + price: 0, }, }; }, @@ -110,16 +108,40 @@ export default { config: (state) => state.system.config, }), }, - onLoad() { - this.$nextTick(() => { - this.setTabHeight(); - }); + onLoad(e) { + if (e.id) { + this.id = e.id; + } else { + this.$utils.toast("参数错误"); + return; + } + + this.getDetail(); }, onShow() {}, onReady() {}, onReachBottom() {}, onPullDownRefresh() {}, methods: { + getDetail() { + this.$request({ + api: "service.goodsDetail", + data: { + id: this.id, + }, + }).then((response) => { + this.detail = { + title: response.data.goods.post_title, + times: response.data.goods.post_hits, + images: response.data.goods.image, + content: response.data.goods.post_content, + price: response.data.goods.money, + }; + this.$nextTick(() => { + this.setTabHeight(); + }); + }); + }, share() { uni.showToast({ title: "分享", diff --git a/src/pages/service/list.vue b/src/pages/service/list.vue index 86f3b26..b386d82 100644 --- a/src/pages/service/list.vue +++ b/src/pages/service/list.vue @@ -49,12 +49,43 @@ export default { this.$utils.toast("参数错误"); return; } + this.loadList(); }, onShow() {}, onReady() {}, onReachBottom() {}, onPullDownRefresh() {}, methods: { + /** + * 加载列表 + */ + loadList() { + this.$request({ + api: "service.list", + query: "id=" + this.cateId, + }) + .then((response) => { + response.data.forEach((item) => { + let goods = []; + item.goods.forEach((v) => { + goods.push({ + id: v.id, + name: v.post_title, + times: v.post_hits, + icon: v.thumbnail, + price: v.money, + }); + }); + this.data.push({ + id: item.id, + name: item.name, + icon: item.more, + child: goods, + }); + }); + }) + .catch((e) => {}); + }, createOrder() { this.$utils.toPage("/pages/order/create"); },