init
This commit is contained in:
114
pages/tabpages/index/index.js
Normal file
114
pages/tabpages/index/index.js
Normal file
@@ -0,0 +1,114 @@
|
||||
import articleApi from "../../../api/articleApi"
|
||||
import systemApi from "../../../api/systemApi"
|
||||
import clientConfig from "../../../config/index"
|
||||
|
||||
Page({
|
||||
data: {
|
||||
funcList: [
|
||||
{
|
||||
name: '热门',
|
||||
path: '/pages/subpages/hot/hot',
|
||||
icon: 'fire-o',
|
||||
color: '#E7406B'
|
||||
},
|
||||
{
|
||||
name: '卡密',
|
||||
path: '/pages/subpages/activation/activation',
|
||||
icon: 'star-o',
|
||||
color: '#02DED8'
|
||||
},
|
||||
{
|
||||
name: 'VIP',
|
||||
path: '/pages/subpages/member/member',
|
||||
icon: 'diamond-o',
|
||||
color: '#F7E990'
|
||||
},
|
||||
{
|
||||
name: '全部',
|
||||
path: '/pages/tabpages/find/find',
|
||||
icon: 'points',
|
||||
color: '#47DBBC'
|
||||
}
|
||||
],
|
||||
carouselImgs: [],
|
||||
notice: null,
|
||||
latestArticles: []
|
||||
},
|
||||
|
||||
leavFor(e){
|
||||
const path = e.currentTarget.dataset.path
|
||||
if (path.includes("find")) {
|
||||
wx.switchTab({
|
||||
url: path,
|
||||
})
|
||||
}
|
||||
|
||||
wx.navigateTo({
|
||||
url: path,
|
||||
complete: function(res){
|
||||
console.log(res)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onLoad(){
|
||||
// let clientConfig = tool.data.get('CLIENT_CONFIG')
|
||||
// this.setData({
|
||||
// carouselImgs: [...JSON.parse(clientConfig.CLIENT_CAROUSEL_IMAGES)],
|
||||
// notice: clientConfig.CLIENT_NOTEICE
|
||||
// })
|
||||
|
||||
articleApi.latestArticles().then(res=>{
|
||||
if (res.data) {
|
||||
console.log(res.data)
|
||||
res.data.forEach(i => {
|
||||
if(i.fileList.length > 0){
|
||||
i.cover = i.fileList[0].fileUrl
|
||||
}
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
latestArticles: res.data
|
||||
})
|
||||
})
|
||||
|
||||
systemApi.list().then(res=>{
|
||||
this.setData({
|
||||
carouselImgs: res.data
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 分享给朋友
|
||||
onShareAppMessage(res) {
|
||||
return new Promise((resolve) => {
|
||||
wx.showLoading({
|
||||
title: '生成分享图片...'
|
||||
})
|
||||
// 获取页面截图,选择轮播图区域作为分享图片
|
||||
wx.createSelectorQuery()
|
||||
.select('.card-blank')
|
||||
.fields({
|
||||
size: true,
|
||||
scrollOffset: true
|
||||
})
|
||||
.exec((res) => {
|
||||
wx.hideLoading()
|
||||
resolve({
|
||||
title: '南音源码助手',
|
||||
path: '/pages/tabpages/index/index',
|
||||
imageUrl: '' // 微信会自动使用页面截图
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 分享到朋友圈
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: '南音源码助手',
|
||||
query: '',
|
||||
imageUrl: '' // 微信会自动使用页面截图
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user