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: '' // 微信会自动使用页面截图
|
||||
}
|
||||
}
|
||||
})
|
||||
10
pages/tabpages/index/index.json
Normal file
10
pages/tabpages/index/index.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-notice-bar": "@vant/weapp/notice-bar/index",
|
||||
"article-card": "/components/articlecard/articlecard",
|
||||
"van-tag": "@vant/weapp/tag/index",
|
||||
"van-empty": "@vant/weapp/empty/index"
|
||||
},
|
||||
"navigationBarTitleText": "Feastcoding"
|
||||
}
|
||||
40
pages/tabpages/index/index.wxml
Normal file
40
pages/tabpages/index/index.wxml
Normal file
@@ -0,0 +1,40 @@
|
||||
<!-- 轮播图区域 -->
|
||||
<view class="card-blank">
|
||||
<swiper indicator-dots autoplay interval="3000">
|
||||
<block wx:for="{{carouselImgs}}" wx:key="index">
|
||||
<swiper-item bindtap="leavFor" data-path="{{item.carouselArticle}}" style="border-radius: 4px;">
|
||||
<image src="{{item.carouselPic}}" style="width: 100%;" />
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<!-- 系统通知 -->
|
||||
<!-- <view class=".card-blank">
|
||||
<van-notice-bar left-icon="volume-o" background="#fff" color="#333" scrollable text="{{notice}}" />
|
||||
</view> -->
|
||||
|
||||
<!-- 功能导航 -->
|
||||
<!-- 功能列表 -->
|
||||
<!-- <view class="card func">
|
||||
<view class="func_item" wx:for="{{funcList}}" wx:key="index" bindtap="leavFor" data-path="{{item.path}}">
|
||||
<view class="func_item_icon" style="background-color: {{item.color}};" >
|
||||
<van-icon name="{{item.icon}}"/>
|
||||
</view>
|
||||
<text class="func_item_name">{{item.name}}</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="card-blank new-article">
|
||||
<view>
|
||||
<van-icon name="new-arrival" size="26px" color="#3C9CFF" />
|
||||
<text style="margin-left: 10px;">最新文章</text>
|
||||
</view>
|
||||
<text bindtap="leavFor" data-path="/pages/tabpages/find/find" class="more">查看更多</text>
|
||||
</view>
|
||||
|
||||
<view class="card" wx:for="{{latestArticles}}" wx:key="index">
|
||||
<article-card data="{{item}}" />
|
||||
</view>
|
||||
|
||||
<van-empty wx:if="{{latestArticles.length==0}}" description="没有更多文章了~" />
|
||||
56
pages/tabpages/index/index.wxss
Normal file
56
pages/tabpages/index/index.wxss
Normal file
@@ -0,0 +1,56 @@
|
||||
swiper{
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.new-article{
|
||||
margin: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.new-article>view{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.func{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.func_item{
|
||||
width: 25%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.func_item .func_item_icon{
|
||||
height: 46px;
|
||||
width: 46px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.func_item .van-icon{
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.func_item_name{
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.more{
|
||||
color: #707070;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.van-icon-volume-o{
|
||||
color: #3C9CFF;
|
||||
}
|
||||
Reference in New Issue
Block a user