page-answer-week.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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
  11. v-for="(item, index) in weekAnswerList"
  12. :key="index"
  13. >
  14. <div slot="default" class="contentItemDiv">
  15. <div>
  16. <div class="contentItemTitle">
  17. {{ item.name}}
  18. </div>
  19. <div class="contentItemDescription">
  20. <!-- <span>{{
  21. formateDatesFun(item.addedTime)
  22. }}</span> -->
  23. </div>
  24. <div class="startAnswerBox" @click="clickAnswer(item)">
  25. <div class="startButtonBox">
  26. <span class="startText">开始答题</span>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </van-cell>
  32. </van-list>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapState } from "vuex";
  37. export default {
  38. name: "page-answer-week",
  39. components: {},
  40. data() {
  41. return {
  42. weekAnswerList: [],
  43. loading: false,
  44. finished: false,
  45. weeklyPage: 0,
  46. weeklySize: 10
  47. };
  48. },
  49. created() {
  50. this.getWeekAnswerList();
  51. },
  52. destroyed () {
  53. },
  54. activated() {
  55. },
  56. computed: {
  57. ...mapState({
  58. chooseEngneeringWork: state => state.user.chooseEngneeringWork
  59. })
  60. },
  61. methods: {
  62. getWeekAnswerList() {
  63. console.log("-------------" + JSON.stringify(this.chooseEngneeringWork));
  64. this.loading = true;
  65. let params = {
  66. page: this.weeklyPage,
  67. size: this.weeklySize,
  68. engineertypeid: this.chooseEngneeringWork.id
  69. };
  70. this.$_http
  71. .get(this.$_API.GET_JTXT_WEEKLY_QUESTIONS, { params })
  72. .then(res => {
  73. this.weekAnswerList = [...this.weekAnswerList, ...res.data.content];
  74. console.log("------", +JSON.stringify(this.weekAnswerList));
  75. this.finished = res.data.last;
  76. this.weeklyPage++;
  77. this.loading = false;
  78. })
  79. .catch(() => {
  80. this.$store.commit("toggleLoading", false);
  81. });
  82. },
  83. clickAnswer(item) {
  84. this.$store.commit("updateAnswerItemStore", {
  85. field: "answerRecruitId",
  86. value: "weekly-questions"
  87. });
  88. this.$store.commit("updateAnswerItemStore", {
  89. field: "questionId",
  90. value: item.id
  91. });
  92. this.$router.push({ name: "answerRecruit" });
  93. },
  94. onLoad() {
  95. this.getWeekAnswerList();
  96. },
  97. // 操作:返回
  98. handleBackFun() {
  99. this.$router.back();
  100. }
  101. }
  102. };
  103. </script>
  104. <style lang="scss" scoped>
  105. .contentBody {
  106. background-color: #fff;
  107. .contentItemDiv {
  108. .contentItemTitle {
  109. font-size: 0.65rem;
  110. font-weight: bold;
  111. }
  112. .contentItemDescription {
  113. margin-top: 0.5rem;
  114. color: #696969;
  115. span {
  116. margin-left: 0.5rem;
  117. }
  118. }
  119. .startAnswerBox {
  120. width:100%;
  121. display: flex;
  122. justify-content: flex-end;
  123. .startButtonBox{
  124. border-radius: 2px;
  125. background-color: #696969;
  126. }
  127. .startText{
  128. margin: 10px 5px;
  129. color: #fff;
  130. }
  131. }
  132. }
  133. }
  134. </style>