asking.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <!-- pages/fuwu/fuwu.wxml -->
  3. <view class="contain">
  4. <!-- 问答类别 -->
  5. <ul class="wendaFL" v-for="(e,idx) in typeList" :key="idx" style="width: 48%;">
  6. <li class="sanNong" style="width: 100%;">
  7. <image :src="loadImgSrcLocalhost(e.path)" class="lbBj" @tap="goType(e.id,e.type)"></image>
  8. <h2>{{e.type}}</h2>
  9. <span>{{e.questionNum}}</span>
  10. </li>
  11. </ul>
  12. <!-- 问答列表 -->
  13. <view class="rnwdList" v-for="(item, index) in hotQuestionList" :key="index" @tap="goDetails(item.id)">
  14. <span class="lb">{{ item.type }}</span>
  15. <view class="list">
  16. <span class="listTitle">{{ item.title }}</span>
  17. <view class="jlSj">
  18. <span class="jf">
  19. {{ item.score }}
  20. <em class="iconfont icon-jifen"></em>
  21. </span>
  22. <view class="ck">
  23. <span>
  24. <em class="iconfont icon-pinglun"></em>
  25. {{ item.comment }}
  26. </span>
  27. <span>
  28. <em class="iconfont icon-chakan"></em>
  29. {{ item.browse }}
  30. </span>
  31. <span>
  32. <em class="iconfont icon-shoucang"></em>
  33. {{ item.collect }}
  34. </span>
  35. </view>
  36. </view>
  37. </view>
  38. <em class="iconfont icon-xiangyoujiantou"></em>
  39. </view>
  40. <button type="primary" @click="goAddQuestion()" v-if="form.id==null">新增</button>
  41. </view>
  42. </template>
  43. <script>
  44. import upload from '@/components/upload/index.vue'
  45. import {getTypeList,getHotQuestionList} from '@/api/asking/asking.js'
  46. export default {
  47. components: {
  48. upload
  49. },
  50. data() {
  51. return {
  52. imageList:[
  53. '/profile/upload/2024/03/02/D5hjxYkldNxIef093ae65b2128b1293b86a7b537ed98_20240302170757A001.png',
  54. '/profile/upload/2024/03/02/D5hjxYkldNxIef093ae65b2128b1293b86a7b537ed98_20240302170757A001.png'
  55. ],
  56. typeList: [
  57. {
  58. type: null,
  59. path: null
  60. }
  61. ],
  62. hotQuestionList: [{}],
  63. // 查询参数
  64. queryParams: {
  65. pageNum: 1,
  66. pageSize: 6,
  67. },
  68. };
  69. }
  70. /**
  71. * 生命周期函数--监听页面加载
  72. */,
  73. onLoad(options) {
  74. this.getTypeList();
  75. this.getHotQuestionList();
  76. },
  77. methods: {
  78. //获取类型列表
  79. getTypeList(){
  80. getTypeList(this.queryParams).then(res =>{
  81. this.typeList = res.rows
  82. })
  83. },
  84. //获取热门问答列表
  85. getHotQuestionList(){
  86. getHotQuestionList().then(res =>{
  87. this.hotQuestionList = res.rows
  88. })
  89. },
  90. //按类型跳转问题列表
  91. goType(id,type) {
  92. uni.setStorageSync('id', id)
  93. uni.navigateTo({
  94. url: '/pages/asking/questionlist?type='+type
  95. });
  96. },
  97. //新增问题
  98. goAddQuestion() {
  99. uni.navigateTo({
  100. url: '/pages/asking/addquestion'
  101. });
  102. },
  103. goDetails(id) {
  104. uni.navigateTo({
  105. url: '/pages/asking/questiondetails?id=' + id
  106. });
  107. },
  108. updateImg(imgList){
  109. this.imageList = imgList;
  110. }
  111. }
  112. };
  113. </script>
  114. <style scoped>
  115. @import '@/pages/asking/asking.css';
  116. .contain {
  117. height: 100%;
  118. display: flex;
  119. justify-content: space-between;
  120. padding: 0rpx 20rpx;
  121. box-sizing: border-box;
  122. flex-wrap: wrap;
  123. }
  124. </style>