question.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view>
  3. <scroll-view scroll-x class="bg-white nav text-center echo-fixed-top">
  4. <view class="cu-item" :class="item.id==cateid?'text-green cur':''" v-for="(item, index) in allcate" :key="item.id" @tap="tabSelect" :data-id="item.id">
  5. {{item.title}}
  6. </view>
  7. </scroll-view>
  8. <view class="echo-fixed-top-empty"></view>
  9. <view class="uni-list echo-media-list">
  10. <block v-for="(item,index) in plist" :key="index">
  11. <view class="uni-list-cell" hover-class="uni-list-cell-hover" @click="goDetail(item.id)">
  12. <view class="uni-media-list">
  13. <view class="uni-media-list-body">
  14. <view class="uni-media-list-text-top text-cut">{{item.title}}</view>
  15. <view class="uni-media-list-text-bottom flex justify-between">
  16. <text>{{item.createtime_text}}</text>
  17. <text class="text-red" v-if="item.priority>0">置顶</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </block>
  23. </view>
  24. <uni-load-more :status="pstatus"></uni-load-more>
  25. </view>
  26. </template>
  27. <script>
  28. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  29. var _this;
  30. export default {
  31. components: {
  32. uniLoadMore
  33. },
  34. data() {
  35. return {
  36. cateid: 0,
  37. allcate: [],
  38. pstatus: 'more',
  39. ppage: 1,
  40. psize: 20,
  41. plist: []
  42. };
  43. },
  44. onLoad: function(option){
  45. _this = this;
  46. _this.cateid = option.cateid || 0;
  47. _this.$req.ajax({
  48. path: "question/allcate"
  49. }).then((data) => {
  50. _this.allcate = data.allcate;
  51. _this.getMore();
  52. }).catch((err) => {
  53. uni.showModal({
  54. title: '信息提示',
  55. content: err,
  56. showCancel: false
  57. });
  58. });
  59. },
  60. onShareAppMessage: function(res) {
  61. return {
  62. title: "常见问题",
  63. path: "/pages/question/question"
  64. }
  65. },
  66. onPullDownRefresh: function() {
  67. _this.ppage = 1;
  68. _this.pstatus = 'more';
  69. _this.plist = [];
  70. _this.getMore();
  71. },
  72. onReachBottom: function() {
  73. if (_this.pstatus !== 'more') {
  74. return;
  75. }
  76. _this.getMore();
  77. },
  78. methods: {
  79. tabSelect: function(e) {
  80. _this.cateid = e.currentTarget.dataset.id;
  81. _this.pageRefresh();
  82. },
  83. pageRefresh: function() {
  84. _this.pstatus = 'more';
  85. _this.ppage = 1;
  86. _this.plist = [];
  87. _this.getMore();
  88. },
  89. getMore: function() {
  90. _this.$req.ajax({
  91. path: "question/listquestion",
  92. data: {
  93. ppage: _this.ppage,
  94. psize: _this.psize,
  95. cateid: _this.cateid
  96. }
  97. }).then((data) => {
  98. _this.pstatus = data.pstatus;
  99. _this.plist = _this.plist.concat(data.plist);
  100. _this.ppage += 1;
  101. uni.stopPullDownRefresh();
  102. }).catch((err) => {
  103. uni.showModal({
  104. title: '信息提示',
  105. content: err,
  106. showCancel: false
  107. });
  108. });
  109. },
  110. goDetail: function(questionid) {
  111. uni.navigateTo({
  112. url: '/pages/question/detail?questionid=' + questionid
  113. });
  114. }
  115. }
  116. }
  117. </script>
  118. <style>
  119. </style>