123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <view class="service">
- <view class="recommend">
- <view
- class="recommend-item"
- @click="onrecommend(index, item.value, '')"
- :class="{ red: activeIndex == index }"
- v-for="(item, index) in choice"
- :key="index"
- >
- {{ item.name }}
- </view>
- <view
- class="recommend-item"
- @click="onrecommend(index + 3, '', item.id)"
- :class="{ red: activeIndex == index + 3 }"
- v-for="(item, index) in cate"
- :key="index + 3"
- >
- {{ item.name }}
- </view>
- </view>
- <view class="content" v-if="good && good.length > 0">
- <view class="content-item" v-for="item in good" :key="item.id" @click="
- goProductDetails(item.id)
- ">
- <image :src="item.cover" mode="" class="neironga2"></image>
- <view class="name"> {{ item.title }} </view>
- <view class="number">
- <view class="large">
- <rich-text
- :nodes="$mUtil.priceBigSmall(item.sale_price)"
- ></rich-text>
- </view>
- <view class="small">¥{{ item.market_price }}</view>
- </view>
- <view class="sell"> 已售{{ item.result_sale_num }}件 </view>
- </view>
- </view>
- <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- choice: [
- {
- id: 1,
- name: "推荐",
- value: "recommend",
- },
- {
- id: 2,
- name: "热销",
- value: "hot",
- },
- {
- id: 3,
- name: "新品",
- value: "new",
- },
- ],
- activeIndex: -1,
- };
- },
- props: {
- cate: {
- type: Array,
- default: [],
- },
- good: {
- type: Array,
- default: [],
- },
- isActive:{
- type:Number,
- default:0
- }
- },
- watch: {
- cate(e){
- this.activeIndex =-1;
- },
-
- },
- onLoad() {
- this.activeIndex = this.initNum;
- },
- methods: {
- goProductDetails(id){
- uni.navigateTo({
- url: this.isActive==0?'/pages/product/goods/serviceGood?id='+id:'/pages/product/goods/goods?id='+id,
- });
-
- },
- onrecommend(index, type, groupId) {
- this.activeIndex = index;
- this.$emit("typeChange", { type: type, groupId: groupId });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .content {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- padding: 30rpx;
- background-color: #f5f5f5;
- .content-item {
- background-color: #ffffff;
- border-radius: 18rpx;
- overflow: hidden;
- margin-bottom: 30rpx;
- image {
- width: 336rpx;
- height: 336rpx;
- background-color: red;
- }
- .number {
- display: flex;
- align-items: center;
- padding: 0 30rpx;
- .large {
- color: #ed3d07;
- font-size: 20rpx;
- font-weight: Medium;
- text {
- font-size: 36rpx;
- font-weight: Bold;
- }
- }
- .small {
- font-size: 22rpx;
- color: #999999;
- font-weight: 400;
- text-decoration: line-through;
- margin-left: 16rpx;
- }
- }
- .sell {
- padding: 0 30rpx;
- font-size: 22rpx;
- font-weight: 400;
- color: #999999;
- margin-bottom: 36rpx;
- margin-top: 8rpx;
- }
- .name {
- width: 276rpx;
- padding: 0 30rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- word-wrap: break-word;
- word-break: break-all;
- white-space: normal !important;
- }
- }
- }
- .recommend {
- display: flex;
- background-color: #f5f5f5;
- border-radius: 40rpx 40rpx 0 0;
- .recommend-item {
- font-weight: 500;
- padding: 15rpx 30rpx;
- background-color: #ffffff;
- margin: 40rpx 0 30rpx 30rpx;
- border-radius: 34rpx;
- }
- .red {
- background: #00321e;
- color: #d5c49b;
- }
- }
- </style>
|