123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <view class="container theme-vote-container">
- <block v-if="Object.keys(detailDate).length > 0">
- <view class="content-top">
- <view class="title">
- <mp-html :content="detailDate.Content" />
- </view>
- <view class="time">
- <view class=""> 最多可选{{ detailDate.MaxChooseTotal }}项</view>
- <view class="">截止时间:{{ detailDate.EndTime }} </view>
- </view>
- <view class="radio-content">
- <van-checkbox-group v-model="result" @change="onChange">
- <view
- :class="['radio-li', result.includes(item.QuestionnaireThemeId + '') && 'act-item', item.DisabledRadio && 'disable-item']"
- v-for="(item, index) in listTheme"
- :key="item.QuestionnaireThemeId"
- >
- <van-checkbox :class="[`checkboxes${index}`]" :disabled="item.DisabledRadio" :name="item.QuestionnaireThemeId" checked-color="#FBD979"> {{ item.ActivityTheme }} </van-checkbox>
- </view>
- </van-checkbox-group>
- </view>
- </view>
- <view class="text-box">
- <textarea v-model="advice_content" :clearable="false" placeholder="点击输入其余感兴趣的主题活动" class="ipt" />
- </view>
- <view class="sed-btn" @click="submitBtn"> 提交 </view>
- </block>
- <Loading />
- </view>
- </template>
- <script>
- import { purchaserApi } from "@/config/modules/purchaser.js";
- export default {
- data() {
- return {
- advice_content: "",
- result: [],
- listTheme: [],
- detailDate: {},
- id: "",
- };
- },
- methods: {
- onChange(event) {
- if (event.detail.length >= this.detailDate.MaxChooseTotal) {
- this.listTheme.forEach((item) => {
- if (!event.detail.includes(item.QuestionnaireThemeId + "")) {
- item.DisabledRadio = true;
- }
- });
- this.result = event.detail;
- } else {
- this.result = event.detail;
- this.listTheme.forEach((item) => {
- item.DisabledRadio = false;
- });
- }
- },
- //
- async submitBtn() {
- if (!this.$store.state.isAuth && !this.$store.state.isBind) {
- //已授权已绑定
- const res = await purchaserApi.questionnaireVote_add({
- QuestionnaireId: this.detailDate.QuestionnaireId ? this.detailDate.QuestionnaireId : "",
- QuestionnaireThemeIds: this.result.map((item) => Number(item)),
- Content: this.advice_content,
- });
- if (res.Ret === 200) {
- uni.navigateBack({
- fail() {
- uni.switchTab({
- url: "/pages/index/index",
- });
- },
- });
- }
- } else {
- this.pleaseGoLogin();
- }
- },
- // 获取详情
- async getDetails() {
- const res = await purchaserApi.questionnaireDetail({
- IsBestNew: this.id ? false : true,
- QuestionnaireId: +this.id,
- });
- if (res.Ret === 200) {
- this.detailDate = res.Data.Detail;
- this.listTheme = res.Data.Detail.ListTheme || [];
- }
- },
- },
- onLoad(options) {
- this.id = options.id || "";
- this.getDetails();
- },
- /** 用户点击分享 */
- onShareAppMessage: function (res) {
- return {
- title: "研选专栏",
- path: "/pages-purchaser/themeVote/themeVote?id=" + this.id,
- };
- },
- };
- </script>
- <style lang="scss" scoped>
- .theme-vote-container {
- background-color: #376cbb;
- padding: 60rpx 35rpx 35rpx;
- .content-top {
- width: 100%;
- height: 854rpx;
- border-radius: 16rpx;
- background-color: #fff;
- padding: 30rpx;
- overflow: hidden;
- overflow-y: auto;
- .title {
- font-size: 34rpx;
- font-weight: 500;
- line-height: 42rpx;
- margin-bottom: 8rpx;
- }
- .time {
- display: flex;
- justify-content: space-between;
- color: #999;
- font-size: 28rpx;
- }
- .radio-content {
- .radio-li {
- display: flex;
- align-items: center;
- width: 100%;
- height: 74rpx;
- border: 2rpx solid #ffe8a8;
- margin-top: 20rpx;
- padding-left: 15rpx;
- }
- .act-item {
- border: none;
- background-color: #fff8e4;
- }
- .disable-item {
- border: 2rpx solid #F0F1F3;
- color: #999999;
- background-color: #f8f8fa;
- }
- /deep/ .van-checkbox__icon {
- border: 1px solid #ffe8a8 !important;
- }
- }
- }
- .text-box {
- margin: 30rpx 0;
- padding: 30rpx 40rpx;
- height: 297rpx;
- width: 100%;
- border: 2rpx solid #ffe8a8;
- background-color: #fff;
- border-radius: 16rpx;
- .ipt {
- height: 100%;
- border: 2px solid #ffe8a8;
- padding: 20rpx;
- box-sizing: border-box;
- }
- }
- .sed-btn {
- width: 100%;
- height: 80rpx;
- border-radius: 16rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #fbd879;
- font-size: 28rpx;
- font-weight: 600;
- }
- view {
- box-sizing: border-box;
- }
- }
- </style>
|