完成商品分类、商品详情展示

This commit is contained in:
TOP糯米 2023-03-08 11:40:04 +08:00
parent 155713faae
commit 6a891ae24b
5 changed files with 165 additions and 40 deletions

View File

@ -3,10 +3,8 @@
<image class="cover-image" mode="aspectFill" :src="data.icon" @click="clickItem(data.id)"></image>
<view class="item-box" @click="clickItem(data.id)">
<view class="title limit-line clamp-1">{{ data.name }}</view>
<view class="text-box">
{{ "已服务113256次" }}
</view>
<view class="price">¥158元起</view>
<view class="text-box"> 已服务{{ data.times }} </view>
<view class="price">¥ {{ data.price }}</view>
</view>
</view>
</template>

View File

@ -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",
}
},
}

View File

@ -60,6 +60,42 @@ export default {
x: x - this.$utils.rpx2px(20),
y: y - this.$utils.rpx2px(40),
};
//
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",
})
@ -83,11 +119,6 @@ export default {
})
.catch((e) => {});
},
onShow() {},
onReady() {},
onReachBottom() {},
onPullDownRefresh() {},
methods: {
clickItem(id) {
this.$utils.toPage("/pages/service/list?id=" + id);
},

View File

@ -36,7 +36,7 @@
<text class="text">空调安装</text>
</view>
<view class="text-box">
<text class="text">已服务812121</text>
<text class="text">已服务{{ detail.times }}</text>
</view>
<view class="share-icon" @click="share">
<text class="iconfont icon-fenxiang"></text>
@ -63,7 +63,7 @@
</swiper>
<view class="common-bottom-components" v-if="tabIndex == 0" :style="{ bottom: config.safeAreaInsets.bottom + 'px' }">
<view class="price">
<text class="text">¥306.00</text>
<text class="text">¥{{ detail.price }}</text>
</view>
<view class="btn-group">
<view class="cart">
@ -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:
"<p>这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容这是服务内容</p>",
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: "分享",

View File

@ -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");
},