page-answer-special.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="contentBody pageAnswerSpecial">
  3. <van-nav-bar title="专项答题" left-arrow @click-left="handleBackFun" />
  4. <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
  5. <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad()">
  6. <van-cell class="vanCell" v-for="(item, index) in specialAnswerList" :key="index">
  7. <div slot="default" class="contentItemDiv">
  8. <div class="contentItemTitle">{{ item.name }}</div>
  9. <div class="createdTime" style="margin-top: 0.5rem">
  10. {{
  11. item.createdTime
  12. ? formateDatesFun(item.createdTime)
  13. : item.createdTime
  14. }}
  15. </div>
  16. <div v-if="!item.available" style="color: #696969">已作答</div>
  17. <div class="startAnswerBox" @click="clickAnswer(item)">
  18. <!-- 此处的div不可以注释,否则样式会变,只需要注释时间即可 -->
  19. <div class="createdTime">
  20. <!-- {{ formateDatesFun(item.createdTime) }} -->
  21. </div>
  22. <div
  23. :class="{
  24. startButtonBox: item.available,
  25. disableButtonBox: !item.available,
  26. }"
  27. >
  28. <span class="startText">开始答题</span>
  29. </div>
  30. </div>
  31. </div>
  32. </van-cell>
  33. </van-list>
  34. </van-pull-refresh>
  35. </div>
  36. </template>
  37. <script>
  38. import { mapState } from "vuex";
  39. import { Toast } from "vant";
  40. export default {
  41. name: "page-answer-special",
  42. components: {},
  43. data() {
  44. return {
  45. specialAnswerList: [],
  46. loading: false,
  47. finished: false,
  48. specialPage: 0,
  49. specialSize: 10,
  50. specialFlag: true,
  51. isLoading: false
  52. };
  53. },
  54. created() {
  55. this.getSpecialAnswerList();
  56. },
  57. destroyed() {},
  58. activated() {},
  59. computed: {
  60. ...mapState({
  61. userInfo: state => state.user.userInfo,
  62. chooseEngneeringWork: state => state.user.chooseEngneeringWork
  63. })
  64. },
  65. methods: {
  66. getSpecialAnswerList() {
  67. this.loading = true;
  68. this.loading = false;
  69. let params = {
  70. page: this.specialPage,
  71. size: this.specialSize,
  72. engineertypeid: this.chooseEngneeringWork.id,
  73. username: this.userInfo.userName
  74. };
  75. if (this.specialFlag) {
  76. this.specialFlag = false;
  77. this.$_http
  78. .get(this.$_API.GET_JTXT_SPECIAL_QUESTIONS, { params })
  79. .then(res => {
  80. this.specialAnswerList = [
  81. ...this.specialAnswerList,
  82. ...res.data.content
  83. ];
  84. // 不能上拉了就是加载玩了
  85. this.finished = res.data.last;
  86. this.specialPage++;
  87. this.loading = false;
  88. this.specialFlag = true;
  89. })
  90. .catch(() => {
  91. this.$store.commit("toggleLoading", false);
  92. });
  93. }
  94. },
  95. clickAnswer(item) {
  96. if (!item.available) {
  97. Toast("已经完成答题");
  98. return;
  99. }
  100. this.$store.commit("updateAnswerItemStore", {
  101. field: "answerRecruitId",
  102. value: "special-questions"
  103. });
  104. this.$store.commit("updateAnswerItemStore", {
  105. field: "questionId",
  106. value: item.id
  107. });
  108. this.$router.push({ name: "answerRecruit" });
  109. },
  110. onLoad() {
  111. this.getSpecialAnswerList();
  112. },
  113. // 操作:返回
  114. handleBackFun() {
  115. this.$router.back();
  116. },
  117. onRefresh() {
  118. this.specialPage = 0;
  119. this.getSpecialAnswerList();
  120. setTimeout(() => {
  121. Toast("刷新成功");
  122. this.isLoading = false;
  123. }, 500);
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. .pageAnswerSpecial {
  130. .van-cell__value {
  131. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  132. }
  133. }
  134. </style>
  135. <style lang="scss" scoped>
  136. .contentBody {
  137. .vanCell {
  138. background-color: #f4f4f4;
  139. .contentItemDiv {
  140. background-color: #fff;
  141. padding: 0.5rem 0.5rem;
  142. border-radius: 0.2rem;
  143. .contentItemTitle {
  144. font-size: 0.65rem;
  145. font-weight: bold;
  146. }
  147. .createdTime {
  148. color: #696969;
  149. }
  150. .startAnswerBox {
  151. width: 100%;
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. margin-top: 0.5rem;
  156. .startButtonBox {
  157. border-radius: 2px;
  158. background-color: #1890ff;
  159. padding: 2px 8px;
  160. .startText {
  161. color: #fff;
  162. }
  163. }
  164. .disableButtonBox {
  165. border-radius: 2px;
  166. background-color: gray;
  167. padding: 2px 8px;
  168. .startText {
  169. color: #fff;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. }
  176. </style>