You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong_qianduan/pages/news/recycling/index.vue

293 lines
6.4 KiB

10 months ago
<template>
<view class="recycling">
<view class="recycling-navbar">
9 months ago
<u-navbar title="旧物回收" :border-bottom="false" :background="isScroll?background:background1"></u-navbar>
10 months ago
</view>
<view class="recycling-hd"></view>
11 months ago
<view class="recycling-notice">
10 months ago
<image :src="$picUrl+'/static/news/icon-volume.png'"></image>
11 months ago
<view class="notice">
<u-notice-bar mode="horizontal" :volume-icon="false" bg-color="#fff" color="#212121" :list="list">
</u-notice-bar>
11 months ago
</view>
</view>
<view class="recycling-bd">
11 months ago
<scroll-view scroll-x class="tab">
<view class="item" v-for="(a,i) in list1" :class="tabIndex==i?'item-on':''" @click="tabItem(i,a)">
<image :src="a.image_url"></image>
{{a.name}}
11 months ago
</view>
11 months ago
</scroll-view>
11 months ago
<view class="list">
<view class="item" v-for="(a,i) in list2" :key="i" @click="openPage(a)">
<image :src="a.recovery_image"></image>
11 months ago
<view class="info">
<view class="title">{{a.recovery_name}}</view>
<view class="desc">{{a.recovery_category}}</view>
11 months ago
<view class="price">
<view class="btn">免支付预约</view>
<view class="num">已售{{a.sold}}+ 好评{{a.comment_rate}}%</view>
11 months ago
</view>
</view>
</view>
</view>
10 months ago
</view>
</view>
</template>
11 months ago
<script>
10 months ago
import * as newFunApi from '@/api/newFun'
import * as Api from '@/api/help'
10 months ago
export default {
data() {
11 months ago
return {
isScroll: true,
10 months ago
tabIndex: 0,
background: {
background: 'transparent',
11 months ago
},
background1: {
background: '#fff',
},
10 months ago
server_name: "",
list: [],
11 months ago
list1: [],
10 months ago
list2: [],
}
11 months ago
},
11 months ago
onLoad(o) {
this.tabIndex = o.index ? o.index : 0
11 months ago
this.getList();
this.getCarousel()
11 months ago
},
onPageScroll(e) {
if (e.scrollTop <= 44) {
11 months ago
this.isScroll = true;
} else {
11 months ago
this.isScroll = false;
}
10 months ago
},
11 months ago
methods: {
// 获取预售规则
getCarousel(type) {
const app = this;
app.list = []
Api.getAgreement({
type: 'serve_notice'
})
.then(result => {
if (result.data.detail.content) {
app.list.push(this.formatRichText(result.data.detail.content))
}
})
.finally(() => app.isLoading = false)
},
formatRichText(value) {
value = value.replace(/\s*/g, ""); //去掉空格
value = value.replace(/<[^>]+>/g, ""); //去掉所有的html标记
value = value.replace(/↵/g, ""); //去掉所有的↵符号
value = value.replace(/[\r\n]/g, "") //去掉回车换行
value = value.replace(/&nbsp;/g, "") //去掉空格
value = this.convertIdeogramToNormalCharacter(value);
return value
},
convertIdeogramToNormalCharacter(val) {
const arrEntities = {
'lt': '<',
'gt': '>',
'nbsp': ' ',
'amp': '&',
'quot': '"'
};
return val.replace(/&(lt|gt|nbsp|amp|quot);/ig, function(all, t) {
return arrEntities[t];
});
},
11 months ago
/**
* 获取列表
*/
async getList() {
let {
status,
message,
data
} = await newFunApi.recoveryCategoryList({});
if (status == 200) {
11 months ago
this.list1 = data.list
this.getGoodsList();
}
},
/**
* 获取商品列表
*/
async getGoodsList() {
let {
status,
message,
data
} = await newFunApi.recoveryRecoveryList({
server_name: this.server_name,
category_id: this.list1.length > 0 ? this.list1[this.tabIndex].category_id : ""
11 months ago
});
if (status == 200) {
11 months ago
this.list2 = data.list
}
},
openPage(a) {
uni.setStorageSync("getInfo", a)
11 months ago
uni.navigateTo({
url: "/pages/news/recycling/detail?type=2&id=" + a.recovery_id
11 months ago
})
10 months ago
},
tabItem(index) {
11 months ago
this.tabIndex = index;
10 months ago
this.getGoodsList();
}
}
}
</script>
<style lang="scss" scoped>
.recycling {
background: url(https://www.royaum.com.cn/static/news/recycling-bg.png) center top no-repeat;
background-size: 100% auto;
&-hd {
9 months ago
height: 300rpx;
11 months ago
}
&-notice {
border-radius: 30rpx 30rpx 0 0;
background-color: #fff;
display: flex;
align-items: center;
padding: 0 30rpx;
image {
width: 50rpx;
height: 50rpx;
display: block;
}
.notice {
width: 500rpx;
flex: 1;
}
11 months ago
}
&-bd {
9 months ago
padding: 20rpx 0 30rpx 36rpx;
overflow: hidden;
background-color: #fff;
.tab {
width: 100%;
white-space: nowrap;
.item {
width: 165rpx;
display: inline-block;
text-align: center;
font-size: 24rpx;
font-weight: 500;
color: #4F4F4F;
position: relative;
padding-bottom: 30rpx;
image {
width: 60rpx;
height: 60rpx;
display: block;
margin: 0 auto;
margin-bottom: 12rpx;
}
&-on {
color: #FF4949;
&::after {
content: "";
width: 50rpx;
height: 6rpx;
background: #FF4949;
border-radius: 6rpx;
position: absolute;
left: 50%;
bottom: 10rpx;
z-index: 1;
margin-left: -25rpx;
}
11 months ago
}
}
}
.list {
width: 100%;
overflow: hidden;
.item {
padding: 28rpx 0;
overflow: hidden;
display: flex;
border-top: 1px solid #F2F2F2;
&:first-child {
border-top-color: #fff;
}
image {
width: 234rpx;
height: 222rpx;
border-radius: 12rpx;
margin-right: 20rpx;
}
.info {
width: 440rpx;
white-space: nowrap;
.title {
overflow: hidden;
font-size: 28rpx;
text-overflow: ellipsis;
font-weight: 600;
color: #2C2C2C;
}
.desc {
overflow: hidden;
font-size: 28rpx;
text-overflow: ellipsis;
margin-top: 10rpx;
color: #888888;
height: 124rpx;
}
.price {
display: flex;
align-items: center;
justify-content: space-between;
11 months ago
font-size: 24rpx;
font-weight: 400;
color: #888888;
.btn {
width: 140rpx;
line-height: 44rpx;
text-align: center;
background: #FFFFFF;
border-radius: 8rpx;
border: 1rpx solid #FF4949;
font-size: 24rpx;
font-weight: 400;
color: #FF4949;
}
}
}
}
11 months ago
}
}
}
</style>