notice.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="notice clearfix" :style="{ paddingTop: CustomBar + 'px' }">
  3. <tui-skeleton
  4. v-if="skeletonShow"
  5. backgroundColor="#fafafa"
  6. borderRadius="10rpx"
  7. :isLoading="true"
  8. :loadingType="5"
  9. ></tui-skeleton>
  10. <view v-else>
  11. <view class="navbar-wrap" :style="{ height: CustomBar + 'px', paddingTop: StatusBar + 'px' }">
  12. <view
  13. class="navbar-text"
  14. :style="{ lineHeight: CustomBar - StatusBar + 'px;', fontSize: fontSizeSetting + 'px;' }"
  15. >
  16. 消息
  17. <image
  18. class="iconfont icon-qingli"
  19. @click="clearNews"
  20. src="@/static/tabBar/clean_notice.png"
  21. ></image>
  22. </view>
  23. </view>
  24. <view class="container-notice">
  25. <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-order?messageType=1')">
  26. <view class="notice-cell-icon">
  27. <image class="icon-image" src="@/static/tabBar/play_notice.png" mode=""></image>
  28. </view>
  29. <view class="notice-cell-text">
  30. 交易物流
  31. <text class="cell-text">官方</text>
  32. </view>
  33. <view class="notice-cell-badge" v-if="tradeCount > 0">
  34. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  35. {{ tradeCount | BadgeType }}
  36. </text>
  37. </view>
  38. </view>
  39. <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-users?messageType=2')">
  40. <view class="notice-cell-icon">
  41. <image class="icon-image" src="@/static/tabBar/user_notice.png" mode=""></image>
  42. </view>
  43. <view class="notice-cell-text">
  44. 账户通知
  45. <text class="cell-text">官方</text>
  46. </view>
  47. <view class="notice-cell-badge" v-if="accountCount > 0">
  48. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  49. {{ accountCount | BadgeType }}
  50. </text>
  51. </view>
  52. </view>
  53. <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-server?messageType=3')">
  54. <view class="notice-cell-icon">
  55. <image class="icon-image" src="@/static/tabBar/server_notice.png" mode=""></image>
  56. </view>
  57. <view class="notice-cell-text">
  58. 服务通知
  59. <text class="cell-text">官方</text>
  60. </view>
  61. <view class="notice-cell-badge" v-if="notificationCount > 0">
  62. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  63. {{ notificationCount | BadgeType }}
  64. </text>
  65. </view>
  66. </view>
  67. <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-coupon?messageType=4')">
  68. <view class="notice-cell-icon">
  69. <image class="icon-image" src="@/static/tabBar/preferential_notice.png" mode=""></image>
  70. </view>
  71. <view class="notice-cell-text">
  72. 优惠促销
  73. <text class="cell-text">官方</text>
  74. </view>
  75. <view class="notice-cell-badge" v-if="promotionCount > 0">
  76. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  77. {{ promotionCount | BadgeType }}
  78. </text>
  79. </view>
  80. </view>
  81. <!-- <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-article?messageType=5')">
  82. <view class="notice-cell-icon">
  83. <image class="icon-image" :src="'https://static.caimei365.com/app/img/' + 'icon/icon-notice-text@2x.png'" mode=""></image>
  84. </view>
  85. <view class="notice-cell-text"> 最新文章 <text class="cell-text">官方</text> </view>
  86. <view class="notice-cell-badge" v-if="articleCount > 0">
  87. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  88. {{ articleCount | BadgeType }}
  89. </text>
  90. </view>
  91. </view>
  92. <view class="notice-cell" @click="navigateTo('/pages/notice/club/notice-activity?messageType=6')">
  93. <view class="notice-cell-icon">
  94. <image class="icon-image" :src="'https://static.caimei365.com/app/img/' + 'icon/icon-notice-active@2x.png'" mode=""></image>
  95. </view>
  96. <view class="notice-cell-text"> 最新活动 <text class="cell-text">官方</text> </view>
  97. <view class="notice-cell-badge" v-if="activityCount > 0">
  98. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  99. {{ activityCount | BadgeType }}
  100. </text>
  101. </view>
  102. </view> -->
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { fetchMessageCount, updateHeheMessageAsRead } from '@/services/api/notice.js'
  109. import { getStorage } from '@/common/storage.js'
  110. import { mapActions } from 'vuex'
  111. export default {
  112. data() {
  113. return {
  114. skeletonShow: true,
  115. CustomBar: '',
  116. StatusBar: '',
  117. fontSizeSetting: '',
  118. StaticUrl: '',
  119. clubId: 0,
  120. allCount: 0,
  121. tradeCount: 0,
  122. accountCount: 0,
  123. notificationCount: 0,
  124. promotionCount: 0,
  125. articleCount: 0,
  126. activityCount: 0,
  127. userId: 0
  128. }
  129. },
  130. filters: {
  131. BadgeType: val => (val && val >= 99 ? '99+' : val) // 红点的提示信息
  132. },
  133. watch: {},
  134. onPullDownRefresh() {
  135. uni.stopPullDownRefresh()
  136. },
  137. onShow() {
  138. this.userId = getStorage('USER_INFO').userId || 0
  139. if (this.userId) {
  140. this.initData()
  141. } else {
  142. this.initLogin()
  143. }
  144. },
  145. methods: {
  146. ...mapActions('user', ['updateNoticeNum']),
  147. initLogin() {
  148. uni.redirectTo({ url: '/pages/authorize/login-custom' })
  149. },
  150. async initData() {
  151. this.getSystomInfo()
  152. const { data } = await fetchMessageCount({ commonId: this.userId })
  153. this.tradeCount = data.tradeCount // 交易物流
  154. this.accountCount = data.account // 账户通知
  155. this.notificationCount = data.notificationCount // 服务通知
  156. this.promotionCount = data.promotionCount // 优惠促销
  157. this.activityCount = data.activityCount // 活动通知
  158. this.articleCount = data.infoCount // 文章通知
  159. this.allCount = data.count // 总数
  160. this.skeletonShow = false //预加载圆圈隐藏
  161. },
  162. getSystomInfo() {
  163. uni.getSystemInfo({
  164. success: e => {
  165. if (e.platform == 'android') {
  166. this.CustomBar = e.statusBarHeight + 50
  167. } else {
  168. this.CustomBar = e.statusBarHeight + 45
  169. }
  170. this.StatusBar = e.statusBarHeight
  171. this.fontSizeSetting = e.fontSizeSetting
  172. }
  173. })
  174. },
  175. async clearNews() {
  176. try {
  177. if (this.allCount > 0) {
  178. await updateHeheMessageAsRead({ commonId: this.userId })
  179. this.initData()
  180. this.updateNoticeNum()
  181. uni.showToast({
  182. title: '清理成功',
  183. icon: 'success'
  184. })
  185. } else {
  186. uni.showToast({
  187. title: '暂无新的消息'
  188. })
  189. }
  190. } catch (e) {
  191. console.log(e)
  192. }
  193. },
  194. navigateTo(url) {
  195. uni.navigateTo({
  196. url: url
  197. })
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss">
  203. .navbar-wrap {
  204. position: fixed;
  205. width: 100%;
  206. top: 0;
  207. z-index: 100000;
  208. box-sizing: border-box;
  209. background: #ffffff;
  210. .navbar-text {
  211. font-size: 30rpx;
  212. color: #000000;
  213. font-weight: 500;
  214. text-align: center;
  215. .iconfont {
  216. display: inline-block;
  217. width: 48rpx;
  218. height: 48rpx;
  219. border-radius: 50%;
  220. background-color: #f5f5f5;
  221. text-align: center;
  222. line-height: 48rpx;
  223. color: #666666;
  224. font-size: 30rpx;
  225. margin-left: 20rpx;
  226. }
  227. }
  228. }
  229. .container-notice {
  230. width: 100%;
  231. height: auto;
  232. box-sizing: border-box;
  233. padding: 0 24rpx;
  234. padding-top: 20rpx;
  235. .notice-cell {
  236. width: 100%;
  237. height: 130rpx;
  238. box-sizing: border-box;
  239. padding: 19rpx 0;
  240. border-bottom: 1px solid #e1e1e1;
  241. .notice-cell-icon {
  242. width: 92rpx;
  243. height: 92rpx;
  244. float: left;
  245. .icon-image {
  246. width: 92rpx;
  247. height: 92rpx;
  248. display: block;
  249. }
  250. }
  251. .notice-cell-text {
  252. width: 400rpx;
  253. height: 100%;
  254. line-height: 92rpx;
  255. font-size: 34rpx;
  256. text-align: left;
  257. margin-left: 24rpx;
  258. float: left;
  259. .cell-text {
  260. display: inline-block;
  261. height: 32rpx;
  262. padding: 0 11rpx;
  263. line-height: 32rpx;
  264. border-radius: 20rpx;
  265. text-align: center;
  266. border: 1px solid #e15616;
  267. font-size: 24rpx;
  268. color: #e15616;
  269. margin-left: 10rpx;
  270. }
  271. }
  272. .notice-cell-badge {
  273. width: 92rpx;
  274. height: 92rpx;
  275. float: right;
  276. box-sizing: border-box;
  277. padding: 25rpx 15rpx;
  278. text-align: right;
  279. }
  280. }
  281. }
  282. .uni-badge--small {
  283. -webkit-transform: scale(0.8);
  284. -ms-transform: scale(0.8);
  285. transform: scale(0.8);
  286. -webkit-transform-origin: center center;
  287. -ms-transform-origin: center center;
  288. transform-origin: center center;
  289. }
  290. .uni-badge {
  291. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  292. -webkit-box-sizing: border-box;
  293. box-sizing: border-box;
  294. font-size: 12px;
  295. line-height: 1;
  296. display: inline-block;
  297. padding: 3px 6px;
  298. color: #333;
  299. border-radius: 100px;
  300. background-color: #f1f1f1;
  301. }
  302. .uni-badge-error {
  303. color: #fff;
  304. background-color: #ff2a2a;
  305. }
  306. </style>