活动按钮状态流转

This commit is contained in:
2026-03-25 15:53:37 +08:00
commit 37346e790f
2762 changed files with 240282 additions and 0 deletions

265
pages/article/details.vue Normal file
View File

@@ -0,0 +1,265 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 平台动态-详情 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar :title="pageTitle || '平台动态'"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-title">{{articleInfo.title}}</view>
<view class="main-tag flex justify-content-between align-items-center">
<view class="tag-item flex-item">
<text class="item-name">{{articleInfo.release}}</text>
<text class="item-time">{{articleInfo.createtime}}</text>
</view>
<view class="tag-item flex align-items-center">
<image class="item-icon" src="/static/see.png" mode="aspectFit"></image>
<text class="item-number">{{articleInfo.read_num}}</text>
</view>
</view>
<view class="main-content">
<mp-html :content="articleInfo.content"></mp-html>
</view>
<view class="main-annex">
<view class="annex-file" v-for="(item, index) in annexList" :key="index" @click="handleDownload(item.file, item.name)">
<view class="file-name text-ellipsis">{{item.name}}</view>
<view class="file-btn">下载附件</view>
</view>
</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
data() {
return {
// 加载完成
loadEnd: false,
// 页面标题
pageTitle: "",
// 新闻id
articleId: null,
// 新闻详情
articleInfo: {},
// 附件列表
annexList: [],
}
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
shareTitle: state => state.app.shareTitle,
})
},
onLoad(option) {
this.articleId = option.id
if (option.title) this.pageTitle = decodeURIComponent(option.title)
uni.showLoading({
title: "加载中"
})
this.getArticle(() => {
this.loadEnd = true
uni.hideLoading()
// #ifdef H5
this.initConfig()
// #endif
})
},
onShareAppMessage() {
return {
title: this.articleInfo.title,
imageUrl: this.articleInfo.image,
}
},
onShareTimeline() {
return {
title: this.articleInfo.title,
imageUrl: this.articleInfo.image,
}
},
methods: {
// #ifdef H5
// 微信公众号初始化方法
initConfig() {
this.$util.request("main.WeChatConfig", {
url: location.href.split('#')[0]
}).then(res => {
if (res.code == 1) {
wx.config({
debug: false,
appId: res.data.appId,
timestamp: Number(res.data.timestamp),
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
openTagList: ["updateAppMessageShareData", "updateTimelineShareData"],
})
wx.ready(() => {
wx.updateAppMessageShareData({
title: this.articleInfo.title,
imageUrl: this.articleInfo.image,
desc: "",
link: window.location.href,
});
wx.updateTimelineShareData({
title: this.articleInfo.title,
imageUrl: this.articleInfo.image,
link: window.location.href,
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 获取文章详情
getArticle(fn) {
this.$util.request("main.article.details", {
id: this.articleId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.articleInfo = res.data
this.annexList = res.data?.files || []
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取文章详情 ', error)
})
},
// 下载附件
handleDownload(file, name) {
if (file) {
uni.showLoading({
mask: true,
title: '加载中',
})
this.$util.downloadFile(file, 2, name).then(() => {
uni.hideLoading()
}).catch((error) => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: error?.errMsg || '附件下载失败',
})
})
} else {
uni.showToast({
icon: 'none',
title: '暂无可下载附件',
})
}
},
}
}
</script>
<style lang="scss">
page {
background: #ffffff;
}
.container {
.container-main {
padding: 32rpx;
.main-title {
font-weight: 600;
font-size: 36rpx;
line-height: 60rpx;
color: #5A5B6E;
}
.main-tag {
margin-top: 16rpx;
.tag-item {
.item-name {
color: var(--theme-color);
font-size: 28rpx;
line-height: 40rpx;
}
.item-time {
font-size: 28rpx;
line-height: 40rpx;
color: #8D929C;
margin-left: 16rpx;
}
.item-icon {
width: 32rpx;
height: 32rpx;
margin-left: 16rpx;
}
.item-number {
margin-left: 8rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #8D929C;
}
}
}
.main-content {
margin-top: 32rpx;
}
.main-annex {
.annex-file {
margin-top: 32rpx;
display: flex;
align-items: center;
column-gap: 32rpx;
border-radius: 16rpx;
border: 2rpx dashed var(--theme-color);
padding: 24rpx 32rpx;
.file-name {
flex: 1;
color: var(--theme-color);
font-size: 28rpx;
line-height: 44rpx;
}
.file-btn {
color: var(--theme-color);
font-size: 28rpx;
line-height: 44rpx;
}
}
}
}
}
</style>

271
pages/article/index.vue Normal file
View File

@@ -0,0 +1,271 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 平台动态-列表 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar :title="getPageTitle()"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<!-- 顶部导航 -->
<scroll-view scroll-x class="main-screen" :style="{top: titleBarHeight + 'px'}" v-if="showScreen && screenList.length">
<view class="screen-item" @click="changeScreen(0)">
<view class="text" :class="{active: selectScreen == 0}">全部</view>
</view>
<view class="screen-item" v-for="item in screenList" :key="item.id" @click="changeScreen(item.id)">
<view class="text" :class="{active: selectScreen == item.id}">{{item.name}}</view>
</view>
</scroll-view>
<!-- 新闻列表 -->
<view class="main-list">
<article-item :show-data="articleList" :show-title="getPageTitle()" v-if="articleList.length"></article-item>
<empty top="30%" title="暂无相关内容~" v-else></empty>
</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import articleItem from "@/pages/component/article/index.vue"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
components: {
articleItem,
},
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 是否显示分类筛选
showScreen: true,
// 分类列表
screenList: [],
// 已选分类
selectScreen: 0,
// 页面标题
pageTitle: "",
// 新闻列表
articleList: [],
// 分类查询参数
page: 1,
limit: 20,
hasMore: false,
}
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
shareImage: state => state.app.shareImage,
shareTitle: state => state.app.shareTitle,
})
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad(option) {
uni.showLoading({
title: "加载中"
})
if (option.id) {
this.selectScreen = option.id
this.showScreen = false
} else {
this.showScreen = true
}
this.getArticleCategory()
if (option.title) this.pageTitle = decodeURIComponent(option.title)
this.getArticleList(() => {
uni.hideLoading()
this.loadEnd = true
})
// #ifdef H5
this.initConfig()
// #endif
},
onPullDownRefresh() {
this.page = 1
this.getArticleList(() => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
if (this.hasMore) {
this.page++
this.getArticleList()
}
},
onShareAppMessage() {
return {
title: this.shareTitle,
imageUrl: this.shareImage,
}
},
onShareTimeline() {
return {
title: this.shareTitle,
imageUrl: this.shareImage,
}
},
methods: {
// #ifdef H5
// 微信公众号初始化方法
initConfig() {
this.$util.request("main.WeChatConfig", {
url: location.href.split('#')[0]
}).then(res => {
if (res.code == 1) {
wx.config({
debug: false,
appId: res.data.appId,
timestamp: Number(res.data.timestamp),
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
openTagList: ["updateAppMessageShareData", "updateTimelineShareData"],
})
wx.ready(() => {
wx.updateAppMessageShareData({
title: this.shareTitle,
desc: "",
link: window.location.href,
imgUrl: this.shareImage,
});
wx.updateTimelineShareData({
title: this.shareTitle,
link: window.location.href,
imgUrl: this.shareImage,
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 获取页面标题
getPageTitle() {
if (this.pageTitle) {
return this.pageTitle || "平台动态"
} else {
var pageTitle = "平台动态"
if (this.selectScreen) {
const index = this.screenList.findIndex(item => item.id == this.selectScreen)
if (index > -1) pageTitle = this.screenList[index].name
}
return pageTitle
}
},
// 获取文章分类
getArticleCategory() {
this.$util.request("main.article.category").then(res => {
if (res.code == 1) {
this.screenList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取文章列表 ', error)
})
},
// 获取文章列表
getArticleList(fn) {
let data = {
page: this.page,
limit: this.limit,
}
if (this.selectScreen) data.cat_id = this.selectScreen
this.$util.request("main.article.list", data).then(res => {
if (fn) fn()
if (res.code == 1) {
let list = res.data.data
this.hasMore = this.page < res.data.total / this.limit ? true : false
this.articleList = this.page == 1 ? list : [...this.articleList, ...list];
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取文章列表 ', error)
})
},
// 更改分类
changeScreen(id) {
this.selectScreen = id
this.page = 1
this.getArticleList()
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
.main-screen {
white-space: nowrap;
background: #ffffff;
position: sticky;
top: 0;
z-index: 99;
.screen-item {
padding: 0 24rpx;
display: inline-flex;
justify-content: center;
min-width: 25%;
.text {
padding: 36rpx 0;
color: #5A5B6E;
font-size: 28rpx;
line-height: 40rpx;
text-align: center;
border-bottom: 4rpx solid transparent;
&.active {
color: var(--theme-color);
border-color: var(--theme-color);
}
}
}
}
.main-list {
padding: 32rpx;
}
}
}
</style>