mailMessage.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="page">
  3. <view class="mainBody">
  4. <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="0">
  5. <!-- <view class="item" :class="{'active':tab===0}" @click="checkTab(0)">
  6. <text class="left">全部</text>
  7. <view class="line"></view>
  8. </view> -->
  9. <view class="item" :class="{'active':tab===item.id}" @click="checkTab(item.id)"
  10. v-for="(item,index) in cate" :key="index">
  11. <text class="left">{{item.name}}</text>
  12. <view class="line"></view>
  13. </view>
  14. </scroll-view>
  15. </view>
  16. <view class="list_info" v-if="tab === 2">
  17. <block v-for="(item,index) in list" :key="index">
  18. <view class="item" @click="goDetail(item)">
  19. <view class="avator">
  20. <image class="icon" :src="item.image" mode="aspectFill"></image>
  21. </view>
  22. <view class="content">
  23. <view class="tit">
  24. <view class="name">{{item.title}}</view>
  25. <view class="time">{{item.create_time}}</view>
  26. <view class="desc">{{item.content}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </block>
  31. <view class="blankHeight"></view>
  32. <view class="loading-more" v-if="tab === 2">
  33. <text v-if="isLoading">正在加载更多...</text>
  34. <text v-else-if="!hasMore">没有更多内容了</text>
  35. </view>
  36. </view>
  37. <view class="list_article" v-if="tab === 1">
  38. <block v-for="(item,index) in list2" :key="index">
  39. <view class="item" @click="goDetail(item)">
  40. <view class="thumbnail">
  41. <image :src="item.image" mode="aspectFill"></image>
  42. </view>
  43. <view class="title">{{item.title}}</view>
  44. <view class="content">{{item.content}}</view>
  45. <view class="divider"></view>
  46. <view class="time">{{item.create_time}}</view>
  47. </view>
  48. </block>
  49. <view class="blankHeight"></view>
  50. <view class="loading-more" v-if="tab === 1">
  51. <text v-if="isLoading">正在加载更多...</text>
  52. <text v-else-if="!hasMore">没有更多内容了</text>
  53. </view>
  54. </view>
  55. <DialogBox ref="DialogBox"></DialogBox>
  56. <ToastW3 ref="ToastW3"></ToastW3>
  57. <tabbar-view :tabbars="tabbars" :currentIndex="3" ref="tabbar"></tabbar-view>
  58. </view>
  59. </template>
  60. <script>
  61. import tabbarView from "@/components/tabbar/tabbar.vue";
  62. import tabbar from "@/mixins/tabbar";
  63. export default {
  64. components: {
  65. tabbarView,
  66. },
  67. mixins: [tabbar],
  68. data() {
  69. return {
  70. tab: 1,
  71. scrollTop: 0,
  72. old: {
  73. scrollTop: 0
  74. },
  75. list: [],
  76. list2: [],
  77. cate: [{
  78. "name": "消息",
  79. id: 1
  80. }, {
  81. "name": "点赞和评论",
  82. id: 2
  83. }],
  84. offset: 0,
  85. isLoading: false,
  86. hasMore: true,
  87. pageSize: 20,
  88. typeMap: {
  89. 1: 'sms',
  90. 2: 'hudong'
  91. }
  92. }
  93. },
  94. onLoad() {
  95. this.loadData();
  96. },
  97. onShow() {
  98. this.refreshData();
  99. },
  100. onPullDownRefresh() {
  101. this.refreshData();
  102. },
  103. onReachBottom() {
  104. if (this.hasMore && !this.isLoading) {
  105. this.loadMore();
  106. }
  107. },
  108. onNavigationBarButtonTap(e) {
  109. if (e.index === 0) {
  110. // uni.navigateTo({
  111. // url: '/pages/my/wishList'
  112. // });
  113. }
  114. },
  115. methods: {
  116. onBack() {},
  117. checkTab(tab) {
  118. this.tab = tab;
  119. this.refreshData();
  120. },
  121. scroll: function(e) {
  122. console.log(e)
  123. this.old.scrollTop = e.detail.scrollTop
  124. },
  125. goDetail(item) {
  126. },
  127. refreshData() {
  128. this.offset = 0;
  129. this.hasMore = true;
  130. if (this.tab === 1) {
  131. this.list2 = [];
  132. } else {
  133. this.list = [];
  134. }
  135. this.loadData();
  136. },
  137. loadMore() {
  138. this.offset += this.pageSize;
  139. this.loadData();
  140. },
  141. loadData() {
  142. if (this.isLoading) return;
  143. this.isLoading = true;
  144. const type = this.typeMap[this.tab];
  145. if (!type) {
  146. this.isLoading = false;
  147. return;
  148. }
  149. uni.request({
  150. url: this.$apiHost + '/Sms/getlist',
  151. method: 'GET',
  152. data: {
  153. uuid: getApp().globalData.uuid,
  154. skey: getApp().globalData.skey,
  155. type: type,
  156. offset: this.offset
  157. },
  158. header: {
  159. "content-type": "application/json",
  160. 'sign': getApp().globalData.headerSign
  161. },
  162. success: (res) => {
  163. console.log('xx1', res.data);
  164. if (res.data && res.data.success == 'yes' && res.data.list) {
  165. const newData = res.data.list || [];
  166. if (newData.length < this.pageSize) {
  167. this.hasMore = false;
  168. }
  169. if (this.tab === 1) {
  170. this.list2 = this.offset === 0 ? newData : [...this.list2, ...newData];
  171. } else {
  172. this.list = this.offset === 0 ? newData : [...this.list, ...newData];
  173. }
  174. } else {
  175. this.hasMore = false;
  176. this.$refs.ToastW3.show('加载失败,请稍后重试');
  177. }
  178. },
  179. fail: () => {
  180. this.hasMore = false;
  181. this.$refs.ToastW3.show('网络错误,请检查网络连接');
  182. },
  183. complete: () => {
  184. this.isLoading = false;
  185. uni.stopPullDownRefresh();
  186. }
  187. });
  188. },
  189. }
  190. }
  191. </script>
  192. <style scoped lang="scss">
  193. @import 'mailMessage.scss';
  194. </style>