message.vue 5.1 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'],
  68. iconList: ['task-audit', 'task-do', 'task-stay'],
  69. list: [],
  70. page: 1,
  71. isEnd: false,
  72. }
  73. },
  74. watch: {
  75. },
  76. mounted() {
  77. this.startNotices();
  78. },
  79. methods: {
  80. goToInfo(index) {
  81. let item = this.list[index];
  82. console.log(item)
  83. if (item.type === 1) {
  84. this.list[index].is_read = 1;
  85. //跳转详情
  86. uni.navigateTo({
  87. url: 'pages/notice/module/notice-info?id=' + item.id
  88. });
  89. } else {
  90. this.setRead(index);
  91. //调用已读
  92. if (item.type === 2) {
  93. if (item.relevance_id <= 0) {
  94. tools.error('任务信息异常')
  95. return false;
  96. }
  97. //任务详情
  98. uni.navigateTo({
  99. url: '/page_task/task_details/task_details?taskId=' + item.relevance_id
  100. });
  101. }else if(item.type === 3){
  102. uni.setStorageSync('taskType',1)
  103. uni.switchTab({
  104. url: '/pages/task/task'
  105. });
  106. }else {
  107. //领取列表
  108. uni.navigateTo({
  109. url: '/page_task/gain_task/gain_task'
  110. });
  111. }
  112. }
  113. },
  114. setRead(index) {
  115. setRead({
  116. 'id': this.list[index].id
  117. }).then((res) => {
  118. if (res.code === 1) {
  119. this.list[index].is_read = 1;
  120. }
  121. })
  122. },
  123. startNotices() {
  124. this.list = [];
  125. this.page = 1;
  126. this.isEnd = false;
  127. this.getNotices();
  128. },
  129. getNotices() {
  130. if (this.isEnd) {
  131. return;
  132. }
  133. getNotices({
  134. 'page': this.page,
  135. 'type': this.current
  136. }).then((res) => {
  137. if (res.code === 1) {
  138. if (res.data.items.length <= 0) {
  139. this.isEnd = true;
  140. } else {
  141. this.tabsList[1].name = '未读(' + res.data.unreadNum + ')'
  142. this.tabsList[1].is_dot = res.data.unreadNum>0
  143. res.data.items.forEach((item) => {
  144. item.is_del = false;
  145. this.list.push(item)
  146. })
  147. // this.list.push(...res.data)
  148. tools.hideLoading()
  149. }
  150. ++this.page;
  151. }
  152. })
  153. },
  154. tabsChange(index) {
  155. this.current = index;
  156. this.startNotices()
  157. },
  158. getLeftImg(index) {
  159. return `https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/${this.leftImg[index]}.png`
  160. },
  161. // 下拉刷新
  162. onRefresh() {
  163. tools.showLoading()
  164. this.startNotices()
  165. setTimeout(() => {
  166. // uni.showToast({
  167. // title: '加载完成',
  168. // icon: 'none'
  169. // })
  170. this.$refs.scroll.onEndPulling()
  171. }, 1000)
  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>