index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="question-detail-page">
  3. <van-sticky>
  4. <view class="" @click="goSearch">
  5. <van-search :value="search_txt" shape="round" placeholder="提问内容" disabled />
  6. </view>
  7. <van-tabs id="tabs" :active="status" title-active-color="#3385FF" color="#3385FF" @change="typeChange">
  8. <van-tab :title="item.label" :name="item.key" v-for="item in tabs" :key="item.key"></van-tab>
  9. </van-tabs>
  10. </van-sticky>
  11. <view class="list-cont">
  12. <question-item
  13. v-for="item in list"
  14. :key="item"
  15. :item="item"
  16. :status="status"
  17. :type="type"
  18. />
  19. </view>
  20. <van-empty description="暂无数据" :image="require('@/static/empty.png')" v-if="finished&&list.length===0"/>
  21. </view>
  22. </template>
  23. <script>
  24. import questionItem from '../components/questionItem.vue'
  25. export default {
  26. data() {
  27. return {
  28. type:'',//页面类型
  29. search_txt: '',
  30. status: '',
  31. tabs: [],
  32. list:[1,2,3,4],
  33. finished: false
  34. };
  35. },
  36. components: { questionItem },
  37. onLoad(options) {
  38. this.initState(options)
  39. },
  40. onShow() {
  41. this.$nextTick(()=>{
  42. this.selectComponent('#tabs').resize();// 解决初始渲染 vant tab 底部条
  43. })
  44. },
  45. methods: {
  46. /* 改变类型 */
  47. typeChange(key) {
  48. },
  49. /* 搜索 */
  50. goSearch() {
  51. console.log(1111)
  52. uni.navigateTo({
  53. url: `/pages-approve/search/index?type=question`
  54. })
  55. },
  56. /* init*/
  57. initState({ type }) {
  58. const titleMap = {
  59. 'question': '分配提问',
  60. 'comment': '评论管理',
  61. }
  62. const tabMap = {
  63. 'question': [
  64. {
  65. label: '待分配',
  66. key: 1
  67. },
  68. {
  69. label: '待回答',
  70. key: 2
  71. },
  72. {
  73. label: '已回答',
  74. key: 3
  75. },
  76. ],
  77. 'comment': [
  78. {
  79. label: '全部',
  80. key: 1
  81. },
  82. {
  83. label: '已精选',
  84. key: 2
  85. },
  86. {
  87. label: '未精选',
  88. key: 3
  89. },
  90. ]
  91. }
  92. this.type = type;
  93. this.tabs = tabMap[type] || tabMap['question'];
  94. uni.setNavigationBarTitle({
  95. title: titleMap[type]
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .list-cont {
  103. padding: 40rpx 20rpx;
  104. }
  105. </style>