diff --git a/api/app/index.js b/api/app/index.js index 416c922..6ad2294 100644 --- a/api/app/index.js +++ b/api/app/index.js @@ -60,6 +60,14 @@ export function getResourceByUserId(id) { }) } +// 查询首页分类内容数量 +export function getHomeCategoryCounts() { + return request({ + url: '/app/article/app/homeCategoryCounts', + method: 'get' + }) +} + // 根据字典类型查询字典数据信息 export function getDicts(dictType) { diff --git a/config.js b/config.js index ab6e4d5..8330f1e 100644 --- a/config.js +++ b/config.js @@ -3,6 +3,10 @@ module.exports = { baseUrl: 'https://feast.yidaima.cn/prod-api', // baseUrl: 'http://127.0.0.1:8080', + // 文章演示视频所属的视频号 + channelsVideo: { + finderUserName: 'sphL4UXLiAs4gH5' + }, //应用信息 appInfo: { // 应用名称(依沫博客已上架微信小程序,搜索名称即可查看演示) diff --git a/pages/blog/bloginfo.vue b/pages/blog/bloginfo.vue index addaf96..4b97f69 100644 --- a/pages/blog/bloginfo.vue +++ b/pages/blog/bloginfo.vue @@ -102,14 +102,11 @@ - - - - - - 点赞 + + + 观看视频 + @@ -370,6 +367,64 @@ }) }) }, + openChannelsVideo() { + const feedIds = [ + this.blogInfo && this.blogInfo.videoFeedId, + this.blogInfo && this.blogInfo.videoFeedId2 + ].map(function(item) { + return item ? String(item).trim() : '' + }).filter(function(item) { + return !!item + }) + if (!feedIds.length) { + uni.showModal({ + title: '温馨提示', + content: '暂无演示视频', + showCancel: false + }) + return + } + if (feedIds.length === 1) { + this.launchChannelsVideo(feedIds[0]) + return + } + const that = this + uni.showActionSheet({ + itemList: ['演示视频一', '演示视频二'], + success: function(result) { + that.launchChannelsVideo(feedIds[result.tapIndex]) + } + }) + }, + launchChannelsVideo(feedId) { + // #ifdef MP-WEIXIN + if (typeof wx === 'undefined' || !wx.openChannelsActivity) { + uni.showToast({ + title: '当前微信版本暂不支持,请升级微信', + icon: 'none' + }) + return + } + wx.openChannelsActivity({ + finderUserName: config.channelsVideo.finderUserName, + feedId: feedId, + fail: function(error) { + console.error('打开视频号视频失败', error) + uni.showToast({ + title: '视频打开失败,请稍后重试', + icon: 'none' + }) + } + }) + return + // #endif + // #ifndef MP-WEIXIN + uni.showToast({ + title: '请在微信小程序中观看视频', + icon: 'none' + }) + // #endif + }, download() { const id = this.blogInfo && this.blogInfo.appResourceId if (!id) { @@ -710,6 +765,13 @@ line-height: unset; } + .channels-video-icon { + color: #6d52f5; + font-size: 56upx; + line-height: 64upx; + text-align: center; + } + button::after { border: none; } diff --git a/pages/index.vue b/pages/index.vue index d95ce11..087602c 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -24,23 +24,31 @@ - - + + + {{formatCategoryCount(categoryCounts.highQuality)}} + 精品源码 - - + + + {{formatCategoryCount(categoryCounts.resource)}} + 资源分享 - - + + + {{formatCategoryCount(categoryCounts.integral)}} + 积分源码 - - + + + {{formatCategoryCount(categoryCounts.free)}} + 免费源码 @@ -135,7 +143,7 @@ getConfigKey } from "@/api/app/public.js" import { - listArticle,newUser,wxLogin,getSysSet + listArticle,newUser,wxLogin,getSysSet,getHomeCategoryCounts } from "@/api/app/index.js" import { getQiniuToken @@ -162,6 +170,12 @@ swiperData: [], noticeStr:"", blogList:[], + categoryCounts: { + highQuality: null, + resource: null, + integral: null, + free: null + }, queryParams: { pageNum: 1, pageSize: 6, @@ -239,6 +253,7 @@ }) //获取文章列表 this.getBlogList() + this.getCategoryCounts() //初始化插屏广告 that.adUnitId = uni.getStorageSync("sysSet").homeAd this.getWxchaAd() @@ -274,6 +289,17 @@ } }, methods: { + getCategoryCounts() { + getHomeCategoryCounts().then(response => { + this.categoryCounts = Object.assign({}, this.categoryCounts, response.data || {}) + }).catch(error => { + console.error('获取首页分类数量失败', error) + }) + }, + formatCategoryCount(count) { + const value = Number(count) || 0 + return value > 999 ? '999+' : String(value) + }, articleImage(item) { if (item && item.imageFallback) { return this.$image.original(item.showImg) @@ -397,6 +423,41 @@