message.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="page">
  3. <u-sticky zIndex="999">
  4. <view class="tabView">
  5. <view class="item dis f-c a-c " v-for="(item, index) in tabViewList" :key="index"
  6. @click="tabClick(item)">
  7. <view class="iconImage">
  8. <image :src="item.image" mode=""></image>
  9. <view class="badge dis a-c j-c" v-if="item.sum">{{ item.sum > 99 ? '...' : item.sum }}</view>
  10. </view>
  11. <text>{{ item.text }}</text>
  12. </view>
  13. </view>
  14. </u-sticky>
  15. <view class="content" v-show="datalist.length != 0">
  16. <!-- 系统消息列表 -->
  17. <view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '1'" v-for="(item, index) in datalist"
  18. :key="index" @click="detailClick(item)">
  19. <view class="title dis a-c ">
  20. <image src="/static/icon/message/message.png" mode=""></image>
  21. <text class="font-weight ml-1">{{ item.title }}</text>
  22. <text class="time">{{ item.createTime }}</text>
  23. </view>
  24. <view class="message-content">
  25. {{ item.content }}
  26. </view>
  27. </view>
  28. <!-- 订单消息列表 -->
  29. <view class="viewitem dis f-c mb-2 " v-if="pageQuery.type == '2'" v-for="(item, index) in datalist"
  30. :key="index">
  31. <view class="title dis a-c ">
  32. <view class="status ">{{ item.content.orderStatus }}</view>
  33. <text class="font-weight ml-1">{{ item.title }}</text>
  34. </view>
  35. <view class="order-content dis j-s a-end">
  36. <view class="dis f-c ">
  37. <view class="item mb-1">
  38. <text>车牌</text>
  39. <text class="ml-3">{{ item.content.licenseNo }}</text>
  40. </view>
  41. <view class="item">
  42. <text>保费</text>
  43. <text class="ml-3">{{ item.content.amount }}</text>
  44. </view>
  45. </view>
  46. <text class="time">{{ item.createTime }}</text>
  47. </view>
  48. </view>
  49. <!-- 佣金消息列表 -->
  50. <view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '3'" v-for="(item, index) in datalist"
  51. :key="index">
  52. <view class="title dis a-c ">
  53. <image src="/static/icon/message/commission.png" mode=""></image>
  54. <text class="font-weight ml-1">订单佣金到账</text>
  55. </view>
  56. <view class="commission-content dis f-wrap a-end j-s">
  57. <view class="item mb-1">
  58. <text>手续费</text>
  59. <text>+ 236.20元</text>
  60. </view>
  61. <view class="item mb-1">
  62. <text>跟单费</text>
  63. <text>+ 236.20元</text>
  64. </view>
  65. <view class="item">
  66. <text>出单积分</text>
  67. <text style="margin-left: 30rpx;">+ 263</text>
  68. </view>
  69. <text class="time">2022.05.12 12:06</text>
  70. </view>
  71. </view>
  72. <!-- 增员信息列表 -->
  73. <view class="viewitem dis f-c mb-2" v-if="pageQuery.type == '0'" v-for="(item, index) in datalist"
  74. :key="index">
  75. <view class="title dis a-c ">
  76. <image src="/static/icon/message/addmember.png" mode=""></image>
  77. <text class="font-weight ml-1">订单佣金到账</text>
  78. </view>
  79. <view class="commission-content dis f-wrap a-end j-s">
  80. <view class="item mb-1">
  81. <text>姓名</text>
  82. <text>Zhangjie</text>
  83. </view>
  84. <view class="item mb-1">
  85. <text>手机号</text>
  86. <text style="margin-left: 30rpx;">18335592986</text>
  87. </view>
  88. <view class="item">
  89. <text>推荐人</text>
  90. <text style="margin-left: 30rpx;">Zhangjie</text>
  91. </view>
  92. <text class="time">2022.05.12 12:06</text>
  93. </view>
  94. </view>
  95. </view>
  96. <u-loadmore :status="status" />
  97. <u-popup :show="qrcodePopup" mode="center" round="20rpx" closeable mask-close-able @close="qrcodePopup = false">
  98. <div class="popup-content">
  99. <image :src="qrcode" style="width:400rpx;height:400rpx" mode=""></image>
  100. <div class="text">请截图扫码后进行抽奖</div>
  101. </div>
  102. </u-popup>
  103. </view>
  104. </template>
  105. <script>
  106. export default {
  107. data() {
  108. return {
  109. status: 'loadmore',
  110. tabViewList: [{
  111. sum: 0,
  112. text: '系统信息',
  113. image: "/static/icon/message/tab-message.png",
  114. type: "1",
  115. }, {
  116. sum: 0,
  117. text: '订单进度',
  118. image: "/static/icon/message/tab-order.png",
  119. type: "2",
  120. }, {
  121. sum: 0,
  122. text: '佣金消息',
  123. image: "/static/icon/message/tab-commission.png",
  124. type: "3",
  125. }, {
  126. sum: 0,
  127. text: '增员信息',
  128. image: "/static/icon/message/tab-addmember.png",
  129. type: '0',
  130. }],
  131. pageQuery: {
  132. type: '1',
  133. pages: 1,
  134. size: 20,
  135. },
  136. totalPages: 0, //数据总页数
  137. datalist: [], //消息数据列表
  138. qrcodePopup: false, //二维码弹窗
  139. qrcode: '', //二维码
  140. }
  141. },
  142. onShow() {
  143. this.getmessage();
  144. this.getMessageCount();
  145. },
  146. onLoad() { },
  147. onReachBottom() {
  148. if (this.pageQuery.pages >= this.totalPages) return;
  149. this.status = 'loading';
  150. this.pageQuery.pages = ++this.pageQuery.pages;
  151. setTimeout(async () => {
  152. let res = await this.$http.post('/message/messageList', this.pageQuery);
  153. if (res.code == '200') {
  154. this.datalist = [...this.datalist, ...res.data.records]
  155. }
  156. if (this.pageQuery.pages >= this.totalPages) this.status = 'nomore';
  157. else this.status = 'loading';
  158. }, 1000)
  159. },
  160. computed: {
  161. },
  162. methods: {
  163. //获取未读数量
  164. async getMessageCount() {
  165. let res = await this.$http.get('/message/getMessageCount')
  166. if (res.code == 200) {
  167. this.tabViewList.map(item => {
  168. if (res.data.hasOwnProperty(Number(item.type))) {
  169. item.sum = res.data[Number(item.type)];
  170. }
  171. return item;
  172. });
  173. uni.setTabBarBadge({
  174. index: 2,//tabbar的索引
  175. text: res.data['999'] + ''
  176. })
  177. }
  178. },
  179. //获取信息
  180. async getmessage() {
  181. let res = await this.$http.post('/message/messageList', this.pageQuery)
  182. if (res.code == 200) {
  183. res.data.records.map(val => {
  184. const obj = JSON.parse(val.content);
  185. if (['template_13'].includes(val.tplCode)) {
  186. val.content = obj.message
  187. val.activityId = obj.eventId
  188. val.localActivityTableId = obj.localActivityTableId
  189. }
  190. if (['template_14'].includes(val.tplCode)) {
  191. val.content = obj.message
  192. val.qrcode = obj.qrcode
  193. }
  194. return val;
  195. })
  196. this.datalist = res.data.records;
  197. this.totalPages = res.data.pages; //总页数
  198. }
  199. },
  200. //
  201. detailClick(item) {
  202. if (item.tplCode === 'template_13') {
  203. uni.navigateTo({
  204. url: '/pages/lottery/index?activityId=' + item.activityId + '&localActivityTableId=' + item.localActivityTableId,
  205. })
  206. }
  207. if (item.tplCode === 'template_14') {
  208. this.qrcodePopup = true
  209. this.qrcode = item.qrcode
  210. }
  211. },
  212. //设置已读
  213. async markAsRead(type) {
  214. let res = await this.$http.post('/message/readEdit', {
  215. type: type
  216. })
  217. },
  218. //切换消息
  219. tabClick(item) {
  220. this.pageQuery.type = item.type;
  221. this.pageQuery.pages = 1;
  222. this.pageQuery.size = 20;
  223. this.getmessage();
  224. //未读消息>0,设置已读
  225. if (item.sum > 0) {
  226. this.markAsRead(item.type)
  227. }
  228. this.getMessageCount();
  229. },
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. page {
  235. background-color: #f8f8f8;
  236. }
  237. .page {
  238. background-color: #f8f8f8;
  239. padding-bottom: 20rpx;
  240. box-sizing: border-box;
  241. }
  242. .tabView {
  243. width: 100%;
  244. background-color: #fff;
  245. padding: 25rpx 22rpx 20rpx;
  246. box-sizing: border-box;
  247. display: grid;
  248. grid-template-columns: repeat(4, 1fr);
  249. grid-template-rows: auto;
  250. .item {
  251. font-size: 30rpx;
  252. color: #333;
  253. .iconImage {
  254. position: relative;
  255. image {
  256. width: 120rpx;
  257. height: 120rpx;
  258. }
  259. // 徽标数
  260. .badge {
  261. position: absolute;
  262. top: 14rpx;
  263. right: 14rpx;
  264. width: 28rpx;
  265. height: 28rpx;
  266. background: #FF4545;
  267. border-radius: 50%;
  268. font-size: 18rpx;
  269. color: #fff;
  270. line-height: 1;
  271. }
  272. }
  273. }
  274. }
  275. .content {
  276. padding: 20rpx;
  277. box-sizing: border-box;
  278. .viewitem {
  279. width: 100%;
  280. background: #FFFFFF;
  281. padding: 25rpx 30rpx 30rpx;
  282. box-sizing: border-box;
  283. border-radius: 10rpx 10rpx 10rpx 10rpx;
  284. .title {
  285. image {
  286. width: 48rpx;
  287. height: 48rpx;
  288. }
  289. .status {
  290. padding: 5rpx 11rpx;
  291. box-sizing: border-box;
  292. background: linear-gradient(270deg, #FDE935 0%, #F1FF91 100%);
  293. border-radius: 20rpx 20rpx 0rpx 20rpx;
  294. font-size: 22rpx;
  295. color: #1F1F1F;
  296. font-weight: bold;
  297. text-align: center;
  298. }
  299. .time {
  300. font-size: 20rpx;
  301. color: #999;
  302. margin-left: auto;
  303. }
  304. font-size: 32rpx;
  305. color: #333;
  306. font-family: PingFang SC,
  307. PingFang SC;
  308. margin-bottom: 20rpx;
  309. }
  310. .message-content {
  311. font-size: 28rpx;
  312. color: #666;
  313. }
  314. .order-content {
  315. .item {
  316. font-size: 28rpx;
  317. text:first-child {
  318. color: #999;
  319. }
  320. text:last-child {
  321. color: #333;
  322. }
  323. }
  324. .time {
  325. font-size: 20rpx;
  326. color: #999;
  327. }
  328. }
  329. .commission-content {
  330. .item {
  331. width: 50%;
  332. font-size: 28rpx;
  333. text:first-child {
  334. color: #999;
  335. }
  336. text:last-child {
  337. color: #333;
  338. margin-left: 58rpx;
  339. }
  340. }
  341. .time {
  342. font-size: 20rpx;
  343. color: #999;
  344. }
  345. }
  346. }
  347. }
  348. .popup-content {
  349. width: 500rpx;
  350. padding: 40rpx;
  351. border-radius: 20rpx;
  352. background-color: #fff;
  353. display: flex;
  354. flex-direction: column;
  355. align-items: center;
  356. .text {
  357. margin-top: 20rpx;
  358. }
  359. }
  360. </style>