活动按钮状态流转

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

View File

@@ -0,0 +1,468 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| 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 :showBack="true" title="问卷详情"></title-bar>
<!-- 内容区 -->
<view class="container-main">
<block v-if="loadEnd">
<!-- 问卷信息 -->
<view class="main-question-info">
<view class="question-info-title text-ellipsis-more">{{questionDetails.data.title}}</view>
<view class="question-info-person flex align-items-center">
<image :src="questionDetails.data.avatar" mode="aspectFill" class="info-person-img"></image>
<view class="info-person-item">
<view class="flex align-items-center">
<view class="info-person-item-name">{{questionDetails.data.member_name}}</view>
<view class="info-person-item-level" :style="{ color: themeColor }">{{questionDetails.data.level_name}}</view>
</view>
<view class="info-person-item-time">{{questionDetails.data.createtime}}</view>
</view>
<!-- #ifdef MP-WEIXIN -->
<button open-type="share" class="info-person-button flex align-items-center" :style="{ background: themeColor }">
<image src="/static/invite.png" mode="aspectFill" class="info-person-button-icon"></image>邀请填写
</button>
<!-- #endif -->
</view>
<view class="question-info-time">结束时间{{questionDetails.data.end_time}}</view>
<view class="question-info-introduce">
<text>{{questionDetails.data.content}}</text>
</view>
</view>
<!-- 问卷列表 -->
<question-problem ref="questionProblem" :show-data="questionDetails.topic" @onChange="pageChange"></question-problem>
<empty top="26%" title="暂无问题~" v-if="questionDetails.topic.length == 0"></empty>
<!-- 提交按钮 -->
<view class="main-bottom">
<view class="harmless-content-button" style="background: #bbb" v-if="questionDetails.data.non_member_answer_sheet_status == 2">仅会员可填写</view>
<view class="harmless-content-button" :style="{ background: themeColor }" @click="handleSubmit()" v-else>完成填写</view>
<view class="safe-padding"></view>
</view>
</block>
<view class="main-login" v-else-if="showLogin">
<image class="login-image" :src="loginImg" mode="aspectFit"></image>
<view class="login-tips">小程序需要登录注册才能使用相关功能请登录后查看该页面</view>
<view class="login-btn" @click="toLogin()">前往登录</view>
</view>
</view>
</view>
</template>
<script>
import { mapState } from "vuex"
import questionProblem from "@/pagesTools/component/questionnaire/problem.vue"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
components: {
questionProblem
},
data() {
return {
// 加载完成
loadEnd: false,
// 问卷id
questionId: null,
// 问卷详情
questionDetails: {},
// 页面是否阻止滚动
pageShow: false,
// 是否显示登录提示
showLogin: false,
// 延时器
delayer: null,
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
questionnaireImg: state => state.app.questionnaireImg,
loginImg: state => state.app.loginImg,
})
},
onLoad(option) {
uni.showLoading({
title: "加载中"
})
this.questionId = option.id || option.scene
this.getQuestionDetails(() => {
uni.hideLoading()
this.loadEnd = true
// #ifdef H5
this.initConfig()
// #endif
})
},
onUnload() {
clearTimeout(this.delayer)
},
onShareAppMessage() {
return {
title: this.questionDetails.data.title,
path: '/pagesTools/questionnaire/details?id=' + this.questionId,
imageUrl: this.questionnaireImg,
}
},
onShareTimeline() {
return {
title: this.questionDetails.data.title,
path: '/pagesTools/questionnaire/details?id=' + this.questionId,
imageUrl: this.questionnaireImg,
}
},
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.questionDetails.data.title,
desc: "",
link: window.location.href,
imgUrl: this.questionnaireImg,
});
wx.updateTimelineShareData({
title: this.questionDetails.data.title,
link: window.location.href,
imgUrl: this.questionnaireImg,
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 完成填写
handleSubmit() {
uni.showLoading({
title: "提交中",
mask: true
})
this.$refs.questionProblem.getApplyField((data) => {
let fileList = []
for (let i in data) {
// 判断必填项是否为空
if (data[i].must == 1) {
let isEmpty = false
if (data[i].type == "text") {
if (!data[i].value) isEmpty = true
} else if (data[i].type == "checkbox") {
if (!data[i].value || !data[i].value.length) isEmpty = true
} else if (data[i].type == "images") {
if (!data[i].value || !data[i].value.length) isEmpty = true
} else {
if (!data[i].value && data[i].value !== 0) isEmpty = true
}
if (isEmpty) {
uni.hideLoading()
uni.showToast({
icon: "none",
title: data[i].topic + "不能为空"
})
return
}
}
// 设置字段值格式
if (data[i].type == "number") {
data[i].value = (data[i].value || data[i].value === 0) ? Number(data[i].value) : data[i].value
} else if (data[i].type == "images") {
for (let j in data[i].value) {
fileList.push({
index: i,
number: j,
value: data[i].value[j]
})
}
}
}
if (fileList.length) {
this.uploadFiles(fileList, (files) => {
for (let i in fileList) {
if (data[fileList[i].index].type == "images") {
data[fileList[i].index].value[fileList[i].number] = files[i]
}
}
this.submitQuestion(data)
})
} else {
this.submitQuestion(data)
}
})
},
// 提交事件
submitQuestion(data) {
data.forEach(item => {
if (item.value) {
item.content = item.value;
} else {
item.content = ''
}
if (item.explain) {
item.explain = item.explain;
} else {
item.explain = ''
}
if (item.type == 'images' || item.type == 'checkbox') {
item.content = item.content.toString()
}
});
this.$util.request("questionnaire.questionAdd", {
questionnaire_id: this.questionId,
content: JSON.stringify(data)
}).then(res => {
uni.hideLoading()
if (res.code == 1) {
uni.showToast({
title: "提交成功",
icon: "success",
mask: true,
duration: 1500
})
this.delayer = setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
})
}
}).catch(error => {
uni.hideLoading()
console.error('提交问卷', error)
})
},
// 上传文件
uploadFiles(list, fn) {
this.$util.uploadFileMultiple(list.map(item => item.value)).then(result => {
fn(result)
}).catch(error => {
console.error('上传文件 ', error)
})
},
// 获取问卷详情
getQuestionDetails(fn) {
this.$util.request("questionnaire.questionDetails", {
id: this.questionId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.questionDetails = res.data
if (res.data.data.non_member_answer_sheet_status == 2) {
uni.showToast({
title: "该问卷仅会员可填写",
icon: "none",
duration: 2000
})
}
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (error == 401) {
this.showLogin = true
} else {
if (fn) fn()
console.error('获取问卷列表 ', error)
}
})
},
// 改变页面滚动状态
pageChange(state) {
this.pageShow = state
},
// 前往登录
toLogin() {
uni.redirectTo({
url: `/pagesTools/questionnaire/details?id=${this.questionId}`,
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding: 32rpx 32rpx 144rpx 32rpx;
.main-question-info {
padding: 32rpx;
margin-bottom: 32rpx;
border-radius: 12rpx;
background: #FFFFFF;
.question-info-title {
margin-bottom: 32rpx;
font-size: 32rpx;
line-height: 44rpx;
font-weight: 600;
color: #5A5B6E;
}
.question-info-person {
margin-bottom: 32rpx;
.info-person-img {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
}
.info-person-item {
flex: 1;
padding-left: 16rpx;
.info-person-item-name {
font-size: 28rpx;
line-height: 40rpx;
color: #5A5B6E;
}
.info-person-item-level {
padding-left: 8rpx;
font-size: 28rpx;
line-height: 40rpx;
}
.info-person-item-time {
font-size: 24rpx;
line-height: 34rpx;
color: #8D929C;
}
}
.info-person-button {
padding: 12rpx;
font-size: 24rpx;
line-height: 34rpx;
border-radius: 8rpx;
color: #FFFFFF;
.info-person-button-icon {
padding-right: 8rpx;
width: 32rpx;
height: 32rpx;
}
}
}
.question-info-time {
margin-bottom: 32rpx;
padding: 16rpx 0rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #5A5B6E;
border-radius: 8rpx;
text-align: center;
background: #EEF2FF;
}
.question-info-introduce {
font-size: 28rpx;
line-height: 40rpx;
color: #8D929C;
}
}
.main-bottom {
padding-top: 16rpx;
padding-bottom: 16rpx;
position: fixed;
bottom: 0;
left: 0;
right: 0;
width: 100%;
text-align: center;
background: #FFF;
z-index: 99;
.harmless-content-button {
margin-left: 26rpx;
margin-right: 26rpx;
width: 700rpx;
height: 80rpx;
background: rgba(50, 93, 255, 1);
color: rgba(255, 255, 255, 1);
text-align: center;
line-height: 80rpx;
border-radius: 16rpx;
}
.safe-padding {
width: 100%;
padding-bottom: constant(safe-area-inset-bottom);
/* 兼容 iOS < 11.2 */
padding-bottom: env(safe-area-inset-bottom);
/* 兼容 iOS >= 11.2 */
}
}
.main-login {
padding: 96rpx 60rpx 0;
.login-image {
width: 100%;
height: 500rpx;
}
.login-tips {
color: #585858;
font-size: 36rpx;
line-height: 50rpx;
margin-top: 48rpx;
text-align: center;
}
.login-btn {
margin-top: 56rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 28rpx;
border-radius: 16rpx;
text-align: center;
background: var(--theme-color);
color: #ffffff;
}
}
}
}
</style>

View File

@@ -0,0 +1,316 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| 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="调查问卷"></title-bar>
<!-- 内容区 -->
<view class="container-main">
<block v-if="loadEnd">
<view class="main-category" :style="{top: titleBarHeight + 'px'}">
<scroll-view scroll-x style="white-space: nowrap;">
<view class="category-item" @click="changeCategory(0)">
<view class="text" :class="{active: selectCategory == 0}">全部</view>
</view>
<view class="category-item" v-for="item in categoryList" :key="item.id" @click="changeCategory(item.id)">
<view class="text" :class="{active: selectCategory == item.id}">{{item.name}}</view>
</view>
</scroll-view>
</view>
<view class="main-column">
<question-item :show-data="questionList" @setShareData="setShareData"></question-item>
<empty top="36%" title="暂无问卷调查~" v-if="questionList.length == 0"></empty>
</view>
</block>
<view class="main-login" v-else-if="showLogin">
<image class="login-image" :src="loginImg" mode="aspectFit"></image>
<view class="login-tips">小程序需要登录注册才能使用相关功能请登录后查看该页面</view>
<view class="login-btn" :style="{background: themeColor}" @click="toLogin()">前往登录</view>
</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import questionItem from "@/pagesTools/component/questionnaire/index.vue"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
components: {
questionItem
},
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 分类列表
categoryList: [],
// 已选分类
selectCategory: 0,
// 问卷列表
questionList: [],
// 分类查询参数
page: 1,
limit: 20,
hasMore: false,
// 分享数据
shareData: {},
// 是否显示登录提示
showLogin: false,
};
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad() {
uni.showLoading({
title: "加载中"
})
this.getQuestionCategory()
this.getQuestionList()
// #ifdef H5
this.initConfig()
// #endif
},
onShow() {
if (this.loadEnd) {
uni.pageScrollTo({
scrollTop: 0,
duration: 0
});
this.page = 1
this.getQuestionList()
}
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
shareImage: state => state.app.shareImage,
shareTitle: state => state.app.shareTitle,
loginImg: state => state.app.loginImg,
})
},
onPullDownRefresh() {
this.page = 1
this.getQuestionList(() => {
uni.stopPullDownRefresh();
})
},
onReachBottom() {
if (this.hasMore) {
this.page++
this.getQuestionList();
}
},
onShareAppMessage(res) {
if (res.from == "button") {
return {
title: this.shareData.title,
path: this.shareData.path,
imageUrl: this.shareData.imageUrl || this.shareImage,
}
} else if (res.from == "menu") {
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
// 获取问卷分类
getQuestionCategory() {
this.$util.request("questionnaire.questionCategory").then(res => {
if (res.code == 1) {
this.categoryList = res.data;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取问卷分类', error)
})
},
// 获取问卷列表
getQuestionList(fn) {
let data = {
page: this.page,
limit: this.limit,
}
if (this.selectCategory) data.questionnaire_category_id = this.selectCategory
this.$util.request("questionnaire.questionList", 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.questionList = this.page == 1 ? list : [...this.questionList, ...list];
uni.hideLoading()
this.loadEnd = true
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (error == 401) {
this.showLogin = true
} else {
console.error('获取问卷列表', error)
}
})
},
// 更改分类
changeCategory(id) {
this.selectCategory = id
this.page = 1
this.getQuestionList()
},
// 设置分享数据
setShareData(data) {
this.shareData = data
},
// 前往登录
toLogin() {
uni.redirectTo({
url: "/pagesTools/questionnaire/index",
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
.main-category {
background: #ffffff;
position: sticky;
top: 0;
z-index: 99;
padding: 0 32rpx;
.category-item {
padding: 0 32rpx;
display: inline-flex;
justify-content: center;
.text {
padding: 36rpx 0 32rpx;
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-column {
padding: 32rpx;
}
.main-login {
padding: 96rpx 60rpx 0;
.login-image {
width: 100%;
height: 500rpx;
}
.login-tips {
color: #585858;
font-size: 36rpx;
line-height: 50rpx;
margin-top: 48rpx;
text-align: center;
}
.login-btn {
margin-top: 56rpx;
height: 88rpx;
line-height: 88rpx;
font-size: 28rpx;
border-radius: 16rpx;
text-align: center;
background: var(--theme-color);
color: #ffffff;
}
}
}
}
</style>

View File

@@ -0,0 +1,89 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| 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="问卷反馈详情"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<question-info :show-data="questionDetails" v-if="questionDetails.length"></question-info>
<empty top="26%" title="暂无问题~" v-else></empty>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import questionInfo from "@/pagesTools/component/questionnaire/info.vue"
export default {
components: {
questionInfo
},
data() {
return {
// 加载完成
loadEnd: false,
// 问卷id
questionId: 0,
// 问卷详情
questionDetails: [],
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
onLoad(option) {
uni.showLoading({
title: "加载中"
})
this.questionId = option.id
this.getQuestionDetails(() => {
uni.hideLoading()
this.loadEnd = true
})
},
methods: {
// 获取问卷详情
getQuestionDetails(fn) {
this.$util.request("questionnaire.renderDetails", {
questionnaire_id: this.questionId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.questionDetails = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取问卷详情', error)
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding: 32rpx;
}
}
</style>