dingdong-mall/pages/product/shop-detail.vue

289 lines
9.6 KiB
Vue
Raw Normal View History

2022-04-01 16:54:10 +08:00
<template>
<view>
<!-- 顶部操作条 -->
2022-04-23 23:13:29 +08:00
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
2022-04-01 16:54:10 +08:00
<block slot="backText">返回</block>
<block slot="content">店铺主页</block>
</cu-custom>
<!-- 店铺介绍 -->
2022-04-23 23:13:29 +08:00
<view class="bg-white padding solid-bottom">
2022-06-25 17:31:17 +08:00
<view class="flex justify-start">
<view class="cu-avatar round"
:style="'background-image:url(' + shopInfo.workerLogoUrl + '); width: 130rpx; height: 130rpx;'">
</view>
<view class="margin-left-sm flex-column-between text-beside-avatar">
2022-06-25 17:31:17 +08:00
<view class="text-black text-xl">{{shopInfo.name}}</view>
<view>
<view>
<text class="cuIcon-form margin-right-xs text-main-color"></text>
<text class="margin-right-xs">企业认证</text>
</view>
<view>
<text class="cuIcon-location margin-right-xs text-main-color"></text>
<text class="margin-right-xs">服务范围:</text>
<text v-for="(area, areaArrIndex) in shopInfo.workerAreas">
<text>{{getLastSplitAreaName(area.mergerName)}}</text>
<text v-if="areaArrIndex !== shopInfo.workerAreas.length - 1"></text>
</text>
</view>
</view>
</view>
</view>
2022-04-01 16:54:10 +08:00
</view>
<!-- 店铺评分 -->
2022-06-25 17:31:17 +08:00
<view class="bg-white padding text-sm padding-top-xs solid-bottom">
2022-04-01 16:54:10 +08:00
<view class="flex justify-between">
2022-06-25 17:31:17 +08:00
<text>总评分<text class="text-red text-xl">5.0</text> / 5.0</text>
<uni-rate :readonly="true" allow-half :value="5" />
2022-04-01 16:54:10 +08:00
</view>
<view>
2022-06-25 17:31:17 +08:00
<text>准时</text><text class="margin-lr-xs">5.0</text>
<text>态度</text><text class="margin-lr-xs">5.0</text>
<text>技能</text><text class="margin-lr-xs">5.0</text>
2022-04-01 16:54:10 +08:00
</view>
2022-06-25 17:31:17 +08:00
</view>
2022-04-01 16:54:10 +08:00
<!-- 店铺服务说明 -->
<view class="padding bg-white text-sm">
<view>
2022-06-25 17:31:17 +08:00
<text>服务类目</text>
<text v-for="(skill, skillArrIndex) in shopInfo.goodsCategories">
<text>{{skill.goodsCategoryName}}</text>
<text v-if="skillArrIndex !== shopInfo.goodsCategories.length - 1"></text>
</text>
</view>
<view>
<text>附加服务</text>
2022-04-01 16:54:10 +08:00
<radio-group @change="changeAdditionalServId">
2022-06-25 17:31:17 +08:00
<label class="radio margin-right-sm" v-for="(item, index) in additionalServ">
<radio style="transform:scale(0.7)" class="main-color" :value="item.id" disabled/>
2022-04-01 16:54:10 +08:00
<text class="margin-left-xs">{{item.name}}</text>
</label>
</radio-group>
</view>
2022-06-25 17:31:17 +08:00
<view>
<text>特殊技能</text>
<text v-for="(sSkill, sSkillArrIndex) in shopInfo.specialSkills">
<text>{{sSkill.specialSkillName}}</text>
<text v-if="sSkillArrIndex !== shopInfo.specialSkills.length - 1"></text>
</text>
</view>
2022-04-01 16:54:10 +08:00
</view>
<!-- 本店铺服务列表 -->
<view class="bg-white">
<view class="margin-top-sm sticky-bar" :style="[{top: stickyTop + 'px'}]">
<!-- 搜索栏 -->
<view class="cu-bar bg-white search solid-bottom margin-bottom-sm">
2022-06-25 17:31:17 +08:00
<view class="action">
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<text class="cuIcon-location"></text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[1].areaName : areaList[1][0].areaName}}</text>
2022-06-25 17:31:17 +08:00
</picker>
2022-04-01 16:54:10 +08:00
</view>
<view class="search-form round">
<text class="cuIcon-search"></text>
2022-06-25 17:31:17 +08:00
<input v-model="searchInfo.goodsName" @confirm="searchGoods" :adjust-position="true" type="text" placeholder="搜索本店铺"
confirm-type="search"></input>
2022-04-01 16:54:10 +08:00
</view>
2022-06-25 17:31:17 +08:00
<!-- <view class="action">
2022-04-01 16:54:10 +08:00
<text>筛选</text>
<text class="cuIcon-filter"></text>
2022-06-25 17:31:17 +08:00
</view> -->
2022-04-01 16:54:10 +08:00
</view>
</view>
<!-- 服务列表 -->
<view class="padding-lr padding-bottom">
<view class="solid-bottom margin-bottom-sm padding-bottom-sm" @click="showDetails(item)"
2022-06-25 17:31:17 +08:00
v-for="(item, index) in productList">
2022-04-01 16:54:10 +08:00
<horizontal-goods-card :ifShowServArea="true" :product="item"></horizontal-goods-card>
</view>
</view>
</view>
</view>
</template>
<script>
2022-06-25 17:31:17 +08:00
// import horizontalNameCard from '@/components/common-card/horizontal-name-card.vue';
2022-04-01 16:54:10 +08:00
import horizontalGoodsCard from '@/components/goods-card/horizontal-goods-card.vue';
export default {
components: {
2022-06-25 17:31:17 +08:00
// horizontalNameCard,
2022-04-01 16:54:10 +08:00
horizontalGoodsCard
},
data() {
return {
shopInfo: {},
2022-06-25 17:31:17 +08:00
productList: [],
additionalServ: [{
id: 1,
name: '58速运'
}, {
id: 2,
name: '货拉拉'
}, {
id: 3,
name: '搬货服务'
}],
searchInfo: {},
areaList: [],
areaMultiIndex: [0, 0],
categoryList: [],
2022-04-01 16:54:10 +08:00
stickyTop: this.CustomBar
}
},
2022-06-25 17:31:17 +08:00
onLoad(option) {
const params = JSON.parse(decodeURIComponent(option.shopInfo));
this.loadData(params);
2022-04-01 16:54:10 +08:00
},
methods: {
async loadData(params) {
2022-06-25 17:31:17 +08:00
// this.shopInfo = await this.$api.data('shopInfo');
let res = await this.$request.getWorkerAllDetailById({
workerId: params.workerId
})
this.shopInfo = res.data;
2022-06-25 17:31:17 +08:00
this.loadCategoryList();
// 获取当前定位
await this.getCurAreaArr();
await this.loadRegionList();
2022-06-25 17:31:17 +08:00
this.searchGoods();
2022-04-01 16:54:10 +08:00
},
async getCurAreaArr() {
let areaArr = await this.$request.getCurArea();
if (areaArr) {
this.searchInfo.area = [areaArr[1], areaArr[2]];
}
},
2022-06-25 17:31:17 +08:00
async loadProductData(params = {}) {
params = {
status: 0,
...params
}
if (this.searchInfo.area[this.searchInfo.area.length - 1].isAll) {
params.areaId = null;
params.areaIds = this.searchInfo.area[this.searchInfo.area.length - 1].areaIds;
}
2022-06-25 17:31:17 +08:00
let res = await this.$request.qryProductPage(params);
this.productList = res[1].data.rows;
2022-04-01 16:54:10 +08:00
},
2022-06-25 17:31:17 +08:00
async loadCategoryList(idArr) {
let typeList = await this.$request.listByStep();
typeList = typeList.data;
let col1Id = idArr ? idArr[0] : typeList[0].goodsCategoryId;
let subTypeList = await this.$request.listByStep({
goodsCategoryId: col1Id
});
subTypeList = subTypeList.data;
let col2Id = idArr ? idArr[1] : subTypeList[0].goodsCategoryId;
let subSubTypeList = await this.$request.listByStep({
goodsCategoryId: col2Id
2022-04-01 16:54:10 +08:00
});
2022-06-25 17:31:17 +08:00
subSubTypeList = subSubTypeList.data;
this.categoryList.push(typeList);
this.categoryList.push(subTypeList);
this.categoryList.push(subSubTypeList);
},
async loadRegionList() {
// let regionList = await this.$request.areaListByStep();
// regionList = regionList.data;
let subRegionList = [this.searchInfo.area[0]];
2022-06-25 17:31:17 +08:00
let subSubRegionList = [];
// if (regionList && regionList.length > 0) {
// subRegionList = await this.$request.areaListByStep({
// parentCode: regionList[0].areaCode
// });
// subRegionList = subRegionList.data;
// }
2022-06-25 17:31:17 +08:00
if (subRegionList && subRegionList.length > 0) {
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
let allAreaIdsOfSubSubRegionList = [];
subSubRegionList.forEach(region => {
allAreaIdsOfSubSubRegionList.push(region.areaId)
})
let subSubRegionListWithAll = [{
areaIds: allAreaIdsOfSubSubRegionList,
areaId: subRegionList[0].areaId,
isAll: true,
areaName: subRegionList[0].areaName
}].concat(subSubRegionList);
subSubRegionList = subSubRegionListWithAll;
2022-06-25 17:31:17 +08:00
}
// this.areaList.push(regionList);
2022-06-25 17:31:17 +08:00
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0]];
2022-06-25 17:31:17 +08:00
},
regionChange(e) {
this.areaMultiIndex = e.detail.value;
let chosenArea = [];
for (let i = 0; i < this.areaList.length; i++) {
chosenArea.push(this.areaList[i][this.areaMultiIndex[i]]);
}
this.searchInfo.area = chosenArea;
this.searchGoods();
},
async regionColChange(e) {
// let colObj = e.detail;
// if (colObj.column == 0) {
// // 通过一级查二级
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[0][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// let subSubAreaList = [];
// if (subAreaList.length) {
// subSubAreaList = await this.$request.areaListByStep({
// parentCode: subAreaList[0].areaCode
// });
// subSubAreaList = subSubAreaList.data;
// }
// this.areaList.pop();
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaList.push(subSubAreaList);
// this.areaMultiIndex = [colObj.value, 0, 0];
// } else if (colObj.column == 1) {
// // 通过二级查三级
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[1][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
// }
2022-06-25 17:31:17 +08:00
},
searchGoods() {
let params = {
areaId: this.searchInfo.area[this.searchInfo.area.length - 1].areaId,
2022-06-27 17:30:14 +08:00
goodsName: this.searchInfo.goodsName,
workerId: this.shopInfo.workerId
2022-06-25 17:31:17 +08:00
};
this.loadProductData(params);
},
showDetails(productItem) {
let params = {
goodsId: productItem.goodsId
}
uni.navigateTo({
url: '/pages/product/product-detail?params=' + encodeURIComponent(JSON.stringify(params))
2022-06-25 17:31:17 +08:00
});
},
getLastSplitAreaName(mergeName) {
let arr = mergeName.split(",");
return arr[arr.length - 1];
2022-04-01 16:54:10 +08:00
}
}
}
</script>
<style scoped>
.text-beside-avatar {
width: 75%;
}
2022-04-01 16:54:10 +08:00
</style>