123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div class="contentBody pageAnswerSpecial">
- <van-nav-bar title="专项答题" left-arrow @click-left="handleBackFun" />
- <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
- <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad()">
- <van-cell class="vanCell" v-for="(item, index) in specialAnswerList" :key="index">
- <div slot="default" class="contentItemDiv">
- <div class="contentItemTitle">{{ item.name }}</div>
- <div class="createdTime" style="margin-top: 0.5rem">
- {{
- item.createdTime
- ? formateDatesFun(item.createdTime)
- : item.createdTime
- }}
- </div>
- <div v-if="!item.available" style="color: #696969">已作答</div>
- <div class="startAnswerBox" @click="clickAnswer(item)">
-
- <div class="createdTime">
- {{ formateDatesFun(item.createdTime) }}
- </div>
- <div
- :class="{
- startButtonBox: item.available,
- disableButtonBox: !item.available,
- }"
- >
- <span class="startText">开始答题</span>
- </div>
- </div>
- </div>
- </van-cell>
- </van-list>
- </van-pull-refresh>
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- import { Toast } from "vant";
- export default {
- name: "page-answer-special",
- components: {},
- data() {
- return {
- specialAnswerList: [],
- loading: false,
- finished: false,
- specialPage: 0,
- specialSize: 10,
- specialFlag: true,
- isLoading: false
- };
- },
- created() {
- this.getSpecialAnswerList();
- },
- destroyed() {},
- activated() {},
- computed: {
- ...mapState({
- userInfo: state => state.user.userInfo,
- chooseEngneeringWork: state => state.user.chooseEngneeringWork
- })
- },
- methods: {
- getSpecialAnswerList() {
- this.loading = true;
- this.loading = false;
- let params = {
- page: this.specialPage,
- size: this.specialSize,
- engineertypeid: this.chooseEngneeringWork.id,
- username: this.userInfo.userName
- };
- if (this.specialFlag) {
- this.specialFlag = false;
- this.$_http
- .get(this.$_API.GET_JTXT_SPECIAL_QUESTIONS, { params })
- .then(res => {
- this.specialAnswerList = [
- ...this.specialAnswerList,
- ...res.data.content
- ];
-
- this.finished = res.data.last;
- this.specialPage++;
- this.loading = false;
- this.specialFlag = true;
- })
- .catch(() => {
- this.$store.commit("toggleLoading", false);
- });
- }
- },
- clickAnswer(item) {
- if (!item.available) {
- Toast("已经完成答题");
- return;
- }
- this.$store.commit("updateAnswerItemStore", {
- field: "answerRecruitId",
- value: "special-questions"
- });
- this.$store.commit("updateAnswerItemStore", {
- field: "questionId",
- value: item.id
- });
- this.$router.push({ name: "answerRecruit" });
- },
- onLoad() {
- this.getSpecialAnswerList();
- },
-
- handleBackFun() {
- this.$router.back();
- },
- onRefresh() {
- this.specialPage = 0;
- this.getSpecialAnswerList();
- setTimeout(() => {
- Toast("刷新成功");
- this.isLoading = false;
- }, 500);
- }
- }
- };
- </script>
- <style lang="scss">
- .pageAnswerSpecial {
- .van-cell__value {
- box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
- }
- }
- </style>
- <style lang="scss" scoped>
- .contentBody {
- .vanCell {
- background-color: #f4f4f4;
- .contentItemDiv {
- background-color: #fff;
- padding: 0.5rem 0.5rem;
- border-radius: 0.2rem;
- .contentItemTitle {
- font-size: 0.65rem;
- font-weight: bold;
- }
- .createdTime {
- color: #696969;
- }
- .startAnswerBox {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 0.5rem;
- .startButtonBox {
- border-radius: 2px;
- background-color: #1890ff;
- padding: 2px 8px;
- .startText {
- color: #fff;
- }
- }
- .disableButtonBox {
- border-radius: 2px;
- background-color: gray;
- padding: 2px 8px;
- .startText {
- color: #fff;
- }
- }
- }
- }
- }
- }
- </style>
|