发现及检测报告产品推荐

This commit is contained in:
2023-11-17 09:26:58 +08:00
parent a3ee59adda
commit e594b340e5
29 changed files with 1255 additions and 29 deletions

132
pages/found/index.js Normal file
View File

@@ -0,0 +1,132 @@
Page({
data: {
page : 1,
has_more: true,
lists : [],
share_id: '',
loading : true,
},
onLoad(e){
this.setData({
share_id : e.share_id || ''
})
getApp().globalData.inviteText = e.invite || ''
this.getList()
},
onHide(){
if(this.data.share_id){
this.setData({
share_id:''
})
}
},
onShow(){
if( this.data.lists.length>0 && this.data.share_id){
this.setData({
page:1,
has_more:true,
lists:[]
})
this.getList()
}
},
getList(){
let params = {
page:this.data.page,
share_id:this.data.share_id
}
wx.$api.found.foundIndex(params).then(res => {
let lists = this.data.lists
if(this.data.page == 1){lists = []}
lists = this.data.lists.concat(res.data.data)
this.setData({
lists : lists,
has_more: res.data.page.has_more,
})
this.setData({
loading:false
})
setTimeout(()=>{
wx.hideLoading()
wx.stopPullDownRefresh()
},3000)
}).catch(err=>{
wx.showToast({
title: err.message,
icon :'none',
mask :true,
duration:2000
})
})
},
onPullDownRefresh(){
this.setData({
page:1,
has_more:true,
lists:[],
loading:true
})
this.getList()
},
onReachBottom(){
if(this.data.has_more){
this.setData({
page:this.data.page +1
})
this.getList()
wx.showLoading({
title: '疯狂加载中..',
})
}else{
wx.showToast({
title: '没有更多',
icon:'none',
mask:true,
duration:2000
})
}
},
// 预览图片
preImg(e){
let current = e.currentTarget.dataset.idx
console.log(current)
let urls = e.currentTarget.dataset.urls
wx.previewImage({
urls,
current:urls[current]
})
},
// 收藏
doSubscribeFavorite(e){
let index= e.currentTarget.dataset.index
let type = e.currentTarget.dataset.type
let item = this.data.lists[index]
let lists = this.data.lists
wx.$api.found.foundSubscribeFavorite(item.id,type).then(res => {
lists[index].is[`${type}`] = res.data.res
lists[index].count[`${type}`] = res.data.count
this.setData({
lists:lists
})
}).catch(err=>{
wx.showToast({
title: err.message,
icon :'none',
mask :true,
duration:2000
})
})
},
onShareAppMessage(e){
let {describe,id,share_cover}= e.target.dataset.obj
return {
title : describe,
imageUrl: share_cover,
path : "/pages/found/index?share_id=" + id + '&invite=' + wx.getStorageSync("invite")
}
},
})

9
pages/found/index.json Normal file
View File

@@ -0,0 +1,9 @@
{
"usingComponents": {},
"navigationBarTitleText": "发现",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#5283ea",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark",
"backgroundColor": "#eeeeee"
}

60
pages/found/index.wxml Normal file
View File

@@ -0,0 +1,60 @@
<view class="pack-center pages-hint grey" wx:if="{{loading}}">
<image src="/static/icons/loadingGif.gif"></image>
<view>疯狂加载中</view>
</view>
<block wx:else>
<view class="found" wx:for="{{lists}}" wx:key="id">
<!-- 用户 -->
<view class="avatar">
<view class="avatar-left">
<image class="cover" src="{{item.user.avatar ? item.user.avatar: '/static/imgs/userHead.png'}}" mode="aspectFill"/>
<view>{{item.user.name || '未知用户'}}</view>
</view>
<view>{{item.created_at}}</view>
</view>
<!-- 文字描述-->
<view class="des">{{item.describe}}</view>
<!-- 主图或视频 -->
<view class="cont">
<!-- 图片汇总 -->
<block wx:if="{{item.type == 'pictures'}}">
<view class="cont-img-list" wx:if="{{item.pictures.length == 1}}">
<block wx:for="{{item.pictures}}" wx:key='idx' wx:for-index="idx" wx:for-item="it">
<image catch:tap="preImg" data-idx="{{idx}}" data-urls='{{item.pictures}}' wx:key="it" src="{{it}}" mode="widthFix"/>
</block>
</view>
<view class="cont-img-list2" wx:if="{{item.pictures.length == 2}}">
<block wx:for="{{item.pictures}}" wx:key='idx' wx:for-index="idx" wx:for-item="it">
<image catch:tap="preImg" data-idx="{{idx}}" data-urls='{{item.pictures}}' wx:key="it" src="{{it}}" mode="aspectFill"/>
</block>
</view>
<view class="cont-img-list" wx:if="{{item.pictures.length>=3}}">
<block wx:for="{{item.pictures}}" wx:key='idx' wx:for-index="idx" wx:for-item="it">
<image catch:tap="preImg" data-idx="{{idx}}" data-urls='{{item.pictures}}' wx:key="it" src="{{it}}" mode="aspectFill"/>
</block>
</view>
</block>
<!-- 视频汇总 -->
<block wx:if="{{item.type == 'video' && item.video!=null}}">
<video class="cont-video" src="{{item.video}}" id='myVideo{{item.id}}'/>
</block>
</view>
<!-- 点赞 收藏 分享 -->
<view class="footer">
<view class="footer-item" catch:tap="doSubscribeFavorite" data-type='favorite' data-index='{{index}}'>
<image src="{{!item.is.favorite?'/static/imgs/icon_un_zan@2x.png':'/static/imgs/icon_zaned@2x.png'}}" mode="widthFix" />{{!item.is.favorite?'点赞':item.count.favorite}}
</view>
<view class="footer-item" catch:tap="doSubscribeFavorite" data-type='subscribe' data-index='{{index}}'>
<image src="{{!item.is.subscribe?'/static/imgs/icon_un_shou@2x.png':'/static/imgs/icon_shoued@2x.png'}}" mode="widthFix" />{{!item.is.subscribe?'收藏':item.count.subscribe}}
</view>
<button class="footer-item" open-type="share" hover-class="none" data-obj='{{item}}'>
<image style="width:28rpx;" src="/static/imgs/icon_share@2x.png" mode="widthFix" />分享
</button>
</view>
</view>
</block>

126
pages/found/index.wxss Normal file
View File

@@ -0,0 +1,126 @@
page {
background-color: #f9f9f9;
padding-bottom: 80rpx;
}
.found{
background-color: #fff;
width: 100vw;
border-radius: 10rpx;
box-sizing: border-box;
margin-bottom: 20rpx;
}
.avatar{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #999999;
padding: 30rpx;
}
.avatar-left {
display: flex;
flex-direction: row;
align-items: center;
justify-content:flex-start;
box-sizing: border-box;
font-size: 36rpx;
font-weight: bold;
color: #111111;
}
.avatar-left .cover{
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 30rpx;
border: solid 10rpx rgba(224, 222, 222, 0.1);
}
.des{
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #111111;
padding: 0 30rpx 30rpx 30rpx;
}
.cont{
padding:0 30rpx 10rpx 30rpx;
}
.cont-img-list{
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
flex-wrap: wrap;
}
.cont-img-list image{
margin-right: 20rpx;
margin-bottom: 20rpx;
border-radius: 10rpx;
width: calc(100vw/3 - 20px);
height: calc(100vw/3 - 20px);
}
.cont-img-list2{
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
flex-wrap: wrap;
}
.cont-img-list2 image{
margin-right: 20rpx;
margin-bottom: 20rpx;
border-radius: 10rpx;
width: calc(100vw/2.2 - 20px);
height: calc(100vw/2.2 - 20px);
}
.cont-video{
width: 100%;
}
.footer{
border-top: solid 1rpx #eee;
font-size: 28rpx!important;
font-family: PingFang SC;
font-weight: 400!important;
color: #666666;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
box-sizing: border-box;
padding: 20rpx 30rpx;
}
.footer-item{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: 20rpx 20rpx;
flex: 1;
background-color: #fff!important;
}
.footer-item image{
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
}
.footer button{
font-size: 28rpx;
color: #666666;
font-weight: normal;
}
.footer button:after {
border: none;
}