message.vue 5.9 KB

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