312 lines
7.4 KiB
Vue

<template>
<view class="whole">
<view class="item" v-for="item in infoList" :key="item.id">
<view class="oneBox" @click="toDetail(item.id)">
<image :src="item.user.avatar"></image>
<view class="right">
<view class="flex1">
<view class="name">{{item.user.nickname}}</view>
<view class="time">{{item.created_at}}</view>
</view>
<view class="sku">购买商品:{{item.item.goods_name}}
<text v-if="item.item.sku_name">【{{item.item.sku_name}}】</text>
</view>
</view>
</view>
<view class="desc" @click="toDetail(item.id)">{{item.comment}}</view>
<view class="box_zong" v-if="item.material.length">
<view class="box_imgs" v-for="(it, index) in item.material" :key="index">
<image :src="it.url" v-if="it.type === 1" @click="preView(it, item.material)" mode="aspectFill"></image>
<template v-else>
<image :src="it.img_video" mode="aspectFill"></image>
<view class="play" @click="preView(it)"><up-icon name="play-right-fill" color="#fff" size="40" /></view>
</template>
</view>
</view>
<view v-if="item.group_goods" class="twoBox" @click="toGroups(item.group_goods.id)">
<view class="face_img">
<image class="img" :src="item.group_goods.face_img" mode="aspectFill"></image>
<view class="out flex" v-if="item.group_goods.sold_status === 2">
<image src="https://ct-upimg.yx090.com/ju8hn6/shop/image/2024/01/16/Cr6cRRhhqYNhScigxIyumyV9hXXMI3vKvsE1jgt0.png" class="out_img" mode="widthFix"></image>
</view>
<view class="out flex" v-else-if="item.group_goods.sold_status === 0">
<image src="../../../static/image/presale.png" class="out_img" mode="widthFix"></image>
</view>
<view class="out flex" v-else-if="item.group_goods.total_stock === 0">
<image src="../../../static/image/soldout.png" class="out_img" mode="widthFix"></image>
</view>
</view>
<view class="box">
<view class="tit">{{item.group_goods.title}}</view>
<view class="text">{{item.group_goods.visitor}}人看过 | {{item.group_goods.order_count}}人跟团</view>
<view class="flex1">
<view class="price" v-if="item.group_goods.min_price == item.group_goods.max_price">{{item.group_goods.min_price}}</view>
<view class="price" v-else>{{item.group_goods.min_price}}-{{item.group_goods.max_price}}</view>
<view class="buy flex">立即跟团</view>
</view>
</view>
</view>
</view>
<view class="bottom" v-if="page >= lastPage && !loading && infoList.length">- 到底啦 -</view>
<view class="bottom" v-if="loading">加载中...</view>
<view v-if="!loading && !infoList.length">
<up-empty icon="https://ct-upimg.yx090.com/g.ii090/images/sprite/empty/comment.png" mode="comment" text="暂无数据喔" />
</view>
<video-dialog :url="videoUrl" :show="showVideo" @close="showVideo = false"></video-dialog>
</view>
</template>
<script>
import { ref, reactive, toRefs } from 'vue'
import { get, post } from '@/api/request.js'
import { Style } from '@/utils/list.js'
import videoDialog from '@/components/videoDialog/index.vue'
export default {
components: {
videoDialog
},
setup() {
const data = reactive({
infoList: [],
page: 1,
lastPage: 0,
loading: false,
Color: '',
priceColor: '',
showVideo: false,
videoUrl: ''
})
const fetchList = () => {
data.loading = true
get(`/api/v1/orderComment/recommend`, {
page: data.page,
pageSize: 20
}).then((res) => {
data.infoList = data.infoList.concat(res.data)
data.lastPage = res.last_page
data.loading = false
}).catch(() => {
data.loading = false
})
}
const toGroups = (id) => {
uni.navigateTo({
url: '/pages/groups/index?id=' + id
})
}
const toDetail = (id) => {
uni.navigateTo({
url: '/pages/mine/other/grassShare?id=' + id
})
}
const preView = (it, imgs) => {
var img = []
imgs && imgs.forEach((res) => {
if (res.type == 1) {
img.push(res.url)
}
})
if (it.type === 1) {
uni.previewImage({
current: it.url,
urls: img
})
} else {
data.showVideo = true
data.videoUrl = it.url
}
}
return {
...toRefs(data),
fetchList,
toGroups,
preView,
toDetail
}
},
async onLoad(options) {
// await this.$onLaunched
this.fetchList()
this.Color = uni.getStorageSync('theme_color')
this.role = uni.getStorageSync('role')
this.priceColor = Style[uni.getStorageSync('theme_index') * 1].priceColor
},
onReachBottom() {
if (this.page < this.lastPage) {
this.page ++
this.fetchList()
}
}
}
</script>
<style lang="scss" scoped>
.flex{
display: flex;
align-items: center;
justify-content: center;
}
.flex1{
display: flex;
align-items: center;
justify-content: space-between;
}
.whole{
width: 100%;
.item{
background-color: #fff;
margin-bottom: 20rpx;
box-sizing: border-box;
padding: 24rpx;
.oneBox{
display: flex;
image{
width: 70rpx;
height: 70rpx;
border-radius: 8rpx;
background: #666;
margin-right: 20rpx;
}
.right{
width: calc(100% - 90rpx);
.name{
font-size: 28rpx;
color: #333;
line-height: 1;
}
.time{
font-size: 24rpx;
color: #999;
}
.sku{
color: #999;
margin-top: 10rpx;
font-size: 24rpx;
}
}
}
.desc{
font-size: 28rpx;
line-height: 48rpx;
margin-top: 14rpx;
}
.pic{
margin-top: 14rpx;
image{
width: 48%;
vertical-align: bottom;
margin-right: 4%;
&:nth-child(2n+2) {
margin-right: 0;
}
}
}
.twoBox{
margin-top: 20rpx;
background-color: #F7F7F7;
border-radius: 10rpx;
display: flex;
justify-content: space-between;
.face_img{
width: 180rpx;
height: 180rpx;
position: relative;
.img{
width: 100%;
height: 100%;
vertical-align: bottom;
}
.out{
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
.out_img{
width: 100rpx;
height: 100rpx;
}
}
}
.box{
padding: 16rpx;
box-sizing: border-box;
flex: 1;
}
.tit{
font-size: 28rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
white-space: break-spaces;
}
.text{
font-size: 24rpx;
margin: 6rpx 0 10rpx;
color: #999;
}
.price{
color: v-bind('priceColor');
font-size: 30rpx;
font-weight: 600;
}
.buy{
color: #fff;
font-size: 26rpx;
width: 150rpx;
height: 54rpx;
background: v-bind('Color');
border-radius: 10rpx;
}
}
}
.bottom {
text-align: center;
font-size: 24rpx;
color: #999999;
margin: auto;
line-height: 80rpx;
}
.box_zong{
display: flex;
flex-wrap: wrap;
.box_imgs{
margin: 20rpx 20rpx 0 0;
position: relative;
width: calc(50% - 13rpx);
height: 340rpx;
&:nth-child(2n+2) {
margin-right: 0;
}
image{
width: 100%;
height: 100%;
vertical-align: bottom;
}
.play{
position: absolute;
left: 0;
top: 0;
background-color: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 1;
}
}
}
}
</style>