镜子功能发现功能

This commit is contained in:
2023-11-24 16:53:50 +08:00
parent 9051ddace1
commit 8f754aea83
35 changed files with 1796 additions and 130 deletions

161
pages/found2/index.js Normal file
View File

@@ -0,0 +1,161 @@
Page({
data: {
page : 1,
has_more: true,
lists : [],
listsIndex : 0,
share_id : '',
loading : true,
swipers : [],
playId : '',
},
onLoad(e){
this.setData({
share_id : e.share_id || ''
})
getApp().globalData.inviteText = e.invite || ''
this.getList()
},
onShow(){
},
onHide(){
if(this.data.share_id){
this.setData({
share_id:''
})
}
},
swiperChange(e){
let { current } = e.detail
console.log(current)
let swipers = this.data.swipers
let item = swipers[current]
let type = item.type
if(item.type == 'video'){
if(current == 0 || this.data.playId == '' || this.data.playId != item.id){
let id = 'myVideo'+item.id
console.log(id)
let videoContext = wx.createVideoContext(`${id}`)
videoContext.play()
this.setData({
playId:item.id
})
}
// if()
}
},
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)
if(this.data.swipers.length == 0){
this.setData({
swipers:res.data.data.splice(0,3)
})
}
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
})
setTimeout(()=>{
this.setData({
loading:false
})
},3000)
})
},
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")
}
},
})