page-answer-week.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div class="contentBody">
  3. <van-nav-bar title="每周答题" left-arrow @click-left="handleBackFun" />
  4. <van-list
  5. v-model="loading"
  6. :finished="finished"
  7. finished-text="没有更多了"
  8. @load="onLoad"
  9. >
  10. <van-cell v-for="(item, index) in weekAnswerList" :key="index">
  11. <div slot="default" class="contentItemDiv">
  12. <div class="contentItemTitle">
  13. {{ item.name }}
  14. </div>
  15. <div class="startAnswerBox" @click="clickAnswer(item)">
  16. <!-- 此处的div不可以注释,否则样式会变,只需要注释时间即可 -->
  17. <div>
  18. {{ formateDatesFun(item.createdTime) }}
  19. </div>
  20. <div class="startButtonBox">
  21. <span class="startText">开始答题</span>
  22. </div>
  23. </div>
  24. </div>
  25. </van-cell>
  26. </van-list>
  27. </div>
  28. </template>
  29. <script>
  30. import { mapState } from "vuex";
  31. export default {
  32. name: "page-answer-week",
  33. components: {},
  34. data() {
  35. return {
  36. weekAnswerList: [],
  37. loading: false,
  38. finished: false,
  39. weeklyPage: 0,
  40. weeklySize: 10
  41. };
  42. },
  43. created() {
  44. this.getWeekAnswerList();
  45. },
  46. destroyed() {},
  47. activated() {},
  48. computed: {
  49. ...mapState({
  50. userInfo: state => state.user.userInfo,
  51. chooseEngneeringWork: state => state.user.chooseEngneeringWork
  52. })
  53. },
  54. methods: {
  55. getWeekAnswerList() {
  56. console.log("-------------" + JSON.stringify(this.chooseEngneeringWork));
  57. this.loading = true;
  58. let params = {
  59. page: this.weeklyPage,
  60. size: this.weeklySize,
  61. engineertypeid: this.chooseEngneeringWork.id,
  62. username: this.userInfo.userName
  63. };
  64. this.$_http
  65. .get(this.$_API.GET_JTXT_WEEKLY_QUESTIONS, { params })
  66. .then(res => {
  67. this.weekAnswerList = [...this.weekAnswerList, ...res.data.content];
  68. console.log("------", +JSON.stringify(this.weekAnswerList));
  69. this.finished = res.data.last;
  70. this.weeklyPage++;
  71. this.loading = false;
  72. })
  73. .catch(() => {
  74. this.$store.commit("toggleLoading", false);
  75. });
  76. },
  77. clickAnswer(item) {
  78. this.$store.commit("updateAnswerItemStore", {
  79. field: "answerRecruitId",
  80. value: "weekly-questions"
  81. });
  82. this.$store.commit("updateAnswerItemStore", {
  83. field: "questionId",
  84. value: item.id
  85. });
  86. this.$router.push({ name: "answerRecruit" });
  87. },
  88. onLoad() {
  89. this.getWeekAnswerList();
  90. },
  91. // 操作:返回
  92. handleBackFun() {
  93. this.$router.back();
  94. }
  95. }
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. .contentBody {
  100. background-color: #fff;
  101. .contentItemDiv {
  102. .contentItemTitle {
  103. font-size: 0.65rem;
  104. font-weight: bold;
  105. }
  106. .startAnswerBox {
  107. width: 100%;
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. color: #696969;
  112. margin-top: 0.5rem;
  113. .startButtonBox {
  114. border-radius: 2px;
  115. background-color: #b3a38c;
  116. padding: 2px 8px;
  117. }
  118. .startText {
  119. color: #fff;
  120. }
  121. }
  122. }
  123. }
  124. </style>