message.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="total-page page-env-20 page-box scroll_content task-bg">
  3. <Nav :title="'消息'" :genre="1" is_fixed></Nav>
  4. <view class="" :style="{top:`${$tools.topHeight()}px`}">
  5. <z-tabs ref="tabs" :list="tabsList" :active-style="{color:'#10B261',fontWeight:'bold',fontSize:'30rpx'}"
  6. :bar-style="{background:'#10B261'}" :inactive-style="{fontWeight:'bold',fontSize:'28rpx'}"
  7. :current="current" :bar-animate-mode="'worm'" @change="tabsChange" />
  8. </view>
  9. <EnScroll ref="scroll" class="main" @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
  10. <view class="m-t20" v-if="list.length <=0">
  11. <Enblank :message="'暂无消息'">
  12. </Enblank>
  13. </view>
  14. <view class="m-lr20 page-env-160">
  15. <view class="row-c page-box-bg-fff m-t20 r-30 p-30 box-shadow-197" @click.stop="goToInfo(index)"
  16. v-for="(item,index) in list" :key="index">
  17. <view class="icon-box">
  18. <view class="read-dot" v-if="item.is_read === 0"></view>
  19. <image class="wh-80" :src="getLeftImg(item.type)" mode=""></image>
  20. </view>
  21. <view class="flex m-l20">
  22. <view class="row-justify-sb center flex">
  23. <text class="text-color-333 sys-weight-400 size-30"> {{item.title}}</text>
  24. <uni-icons type="right" size="18" color="#999999"></uni-icons>
  25. </view>
  26. <view class="row-justify-sb center m-t10">
  27. <text class="size-26 text-color-666"> {{item.content}}</text>
  28. <text class="size-24 text-color-999">{{item.created_date}}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </EnScroll>
  34. </view>
  35. </template>
  36. <script>
  37. // 任务列表
  38. import TaskItem from "@/common/task/task-item.vue";
  39. import {
  40. getNotices,
  41. setRead
  42. } from "@/api/news";
  43. import tools from "@/service/tools";
  44. export default {
  45. components: {
  46. TaskItem
  47. },
  48. data() {
  49. return {
  50. current: 0,
  51. tabsList: [{
  52. name: '全部',
  53. is_dot: false,
  54. dot_color: 'red',
  55. disabled: false
  56. }, {
  57. name: '未读(0)',
  58. is_dot: false,
  59. dot_color: 'red',
  60. disabled: false
  61. }, {
  62. name: '已读',
  63. is_dot: false,
  64. dot_color: '',
  65. disabled: false
  66. }],
  67. leftImg: ['task-house', 'task-house', 'task-business', 'task-repayment', 'task-repayment'],
  68. iconList: ['task-audit', 'task-do', 'task-stay', 'task-stay', 'task-stay'],
  69. list: [],
  70. page: 1,
  71. isEnd: false,
  72. isAJAX:false
  73. }
  74. },
  75. watch: {
  76. },
  77. mounted() {
  78. this.startNotices();
  79. },
  80. methods: {
  81. goToInfo(index) {
  82. let item = this.list[index];
  83. console.log(item)
  84. if (item.type === 1) {
  85. this.list[index].is_read = 1;
  86. //跳转详情
  87. uni.navigateTo({
  88. url: 'pages/notice/module/notice-info?id=' + item.id
  89. });
  90. } else {
  91. this.setRead(index);
  92. //调用已读
  93. if (item.type === 2) {
  94. if (item.relevance_id <= 0) {
  95. tools.error('任务信息异常')
  96. return false;
  97. }
  98. //任务详情
  99. uni.navigateTo({
  100. url: '/page_task/task_details/task_details?taskId=' + item.relevance_id
  101. });
  102. }else if(item.type === 3){
  103. uni.setStorageSync('taskType',1)
  104. uni.switchTab({
  105. url: '/pages/task/task'
  106. });
  107. }else {
  108. //领取列表
  109. uni.navigateTo({
  110. url: '/page_task/gain_task/gain_task'
  111. });
  112. }
  113. }
  114. },
  115. setRead(index) {
  116. setRead({
  117. 'id': this.list[index].id
  118. }).then((res) => {
  119. if (res.code === 1) {
  120. this.list[index].is_read = 1;
  121. }
  122. })
  123. },
  124. startNotices() {
  125. this.list = [];
  126. this.page = 1;
  127. this.isEnd = false;
  128. this.isAJAX = false;
  129. this.getNotices();
  130. },
  131. getNotices() {
  132. if (this.isEnd || this.isAJAX) {
  133. return;
  134. }
  135. this.isAJAX=true
  136. getNotices({
  137. 'page': this.page,
  138. 'type': this.current
  139. }).then((res) => {
  140. this.isAJAX=false
  141. if (res.code === 1) {
  142. if (res.data.items.length <= 0) {
  143. this.isEnd = true;
  144. } else {
  145. this.tabsList[1].name = '未读(' + res.data.unreadNum + ')'
  146. this.tabsList[1].is_dot = res.data.unreadNum>0
  147. res.data.items.forEach((item) => {
  148. item.is_del = false;
  149. this.list.push(item)
  150. })
  151. // this.list.push(...res.data)
  152. tools.hideLoading()
  153. }
  154. ++this.page;
  155. }
  156. })
  157. },
  158. tabsChange(index) {
  159. this.current = index;
  160. this.startNotices()
  161. },
  162. getLeftImg(index) {
  163. return `https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/${this.leftImg[index]}.png`
  164. },
  165. // 下拉刷新
  166. onRefresh() {
  167. tools.showLoading()
  168. this.startNotices()
  169. setTimeout(() => {
  170. this.$refs.scroll.onEndPulling()
  171. }, 200)
  172. console.log("下拉刷新");
  173. },
  174. // 滚动到底部
  175. onScrollBottom() {
  176. // uni.showLoading({
  177. // title: '数据加载中'
  178. // })
  179. tools.showLoading()
  180. this.getNotices()
  181. // setTimeout(() => {
  182. // uni.showToast({
  183. // title: '加载完成',
  184. // icon: 'none'
  185. // })
  186. // }, 1000)
  187. console.log("到底部了");
  188. },
  189. },
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. .icon-box {
  194. position: relative;
  195. .read-dot {
  196. width: 14rpx;
  197. height: 14rpx;
  198. border-radius: 50%;
  199. background-color: #E91919;
  200. position: absolute;
  201. top: 0rpx;
  202. right: 10rpx;
  203. }
  204. }
  205. </style>