index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. 消息 <text @click="clearNews" class="iconfont icon-qingli"></text>
  17. </view>
  18. </view>
  19. <view class="container-notice">
  20. <view class="notice-cell" @click="navigator('/pages/notice/club/notice-order?messageType=1')">
  21. <view class="notice-cell-icon">
  22. <image class="icon-image" :src="StaticUrl + 'icon/icon-notice-order@2x.png'" mode=""></image>
  23. </view>
  24. <view class="notice-cell-text"> 交易物流 <text class="cell-text">官方</text> </view>
  25. <view class="notice-cell-badge" v-if="tradeCount > 0">
  26. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  27. {{ tradeCount | BadgeType }}
  28. </text>
  29. </view>
  30. </view>
  31. <view class="notice-cell" @click="navigator('/pages/notice/club/notice-users?messageType=2')">
  32. <view class="notice-cell-icon">
  33. <image class="icon-image" :src="StaticUrl + 'icon/icon-notice-users@2x.png'" mode=""></image>
  34. </view>
  35. <view class="notice-cell-text"> 账户通知 <text class="cell-text">官方</text> </view>
  36. <view class="notice-cell-badge" v-if="accountCount > 0">
  37. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  38. {{ accountCount | BadgeType }}
  39. </text>
  40. </view>
  41. </view>
  42. <view class="notice-cell" @click="navigator('/pages/notice/club/notice-serve?messageType=3')">
  43. <view class="notice-cell-icon">
  44. <image class="icon-image" :src="StaticUrl + 'icon/icon-notice-serve@2x.png'" mode=""></image>
  45. </view>
  46. <view class="notice-cell-text"> 服务通知 <text class="cell-text">官方</text> </view>
  47. <view class="notice-cell-badge" v-if="notificationCount > 0">
  48. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  49. {{ notificationCount | BadgeType }}
  50. </text>
  51. </view>
  52. </view>
  53. <view class="notice-cell" @click="navigator('/pages/notice/club/notice-coupon?messageType=4')">
  54. <view class="notice-cell-icon">
  55. <image class="icon-image" :src="StaticUrl + 'icon/icon-notice-coupon@2x.png'" mode=""></image>
  56. </view>
  57. <view class="notice-cell-text"> 优惠促销 <text class="cell-text">官方</text> </view>
  58. <view class="notice-cell-badge" v-if="promotionCount > 0">
  59. <text class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  60. {{ promotionCount | BadgeType }}
  61. </text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import { mapState, mapMutations } from 'vuex'
  70. export default {
  71. data() {
  72. return {
  73. CustomBar: this.CustomBar,
  74. StatusBar: this.StatusBar,
  75. StaticUrl: this.$Static,
  76. skeletonShow: true,
  77. clubId: 0,
  78. allCount:0,
  79. tradeCount: 0,
  80. accountCount: 0,
  81. notificationCount: 0,
  82. promotionCount: 0
  83. }
  84. },
  85. onLoad() {},
  86. filters: {
  87. BadgeType(value) {
  88. if (value) {
  89. return value > 99 ? '99+' : value
  90. }
  91. }
  92. },
  93. computed: {
  94. ...mapState(['hasLogin', 'userInfo'])
  95. },
  96. methods: {
  97. ...mapMutations(['updateNoticeNum']),
  98. async initData() {
  99. const userInfo = await this.$api.getStorage()
  100. this.skeletonShow = true //预加载圆圈
  101. this.clubId = userInfo.clubId ? userInfo.clubId : 0
  102. this.updateNoticeNum()
  103. this.getUserAuthClubMessageCount()
  104. },
  105. clearNews() {
  106. // 标记消息已读
  107. if(this.allCount == 0){
  108. this.$util.msg('暂无未读消息', 2000)
  109. return
  110. }
  111. this.UserService.authUpdateMessageAsRead({ commonId:this.clubId,messageType: '' })
  112. .then(response => {
  113. uni.vibrateShort({
  114. success: function() {
  115. console.log('success')
  116. }
  117. })
  118. this.initData()
  119. this.$util.msg('已将所有消息标记为已读', 2000)
  120. })
  121. .catch(error => {
  122. console.log('标记通知消息已读', error.msg)
  123. })
  124. },
  125. getUserAuthClubMessageCount() {
  126. //供应商详情
  127. this.UserService.getUserAuthClubMessageCount({ commonId: this.clubId })
  128. .then(response => {
  129. this.allCount = response.data.count
  130. this.tradeCount = response.data.tradeCount // 交易物流
  131. this.accountCount = response.data.account // 账户通知
  132. this.notificationCount = response.data.notificationCount // 服务通知
  133. this.promotionCount = response.data.promotionCount // 优惠促销
  134. this.skeletonShow = false //预加载圆圈隐藏
  135. })
  136. .catch(error => {
  137. this.$util.msg(error.msg, 2000)
  138. })
  139. this.skeletonShow = false
  140. },
  141. initLogin() {
  142. this.$api.redirectTo('/pages/login/login')
  143. },
  144. navigator(url) {
  145. this.$api.navigateTo(url)
  146. }
  147. },
  148. onPullDownRefresh() {
  149. //下拉刷新
  150. this.initData()
  151. uni.stopPullDownRefresh()
  152. },
  153. onShow() {
  154. if (this.hasLogin) {
  155. this.initData()
  156. } else {
  157. this.initLogin()
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .navbar-wrap {
  164. position: fixed;
  165. width: 100%;
  166. top: 0;
  167. z-index: 100000;
  168. box-sizing: border-box;
  169. background: #ffffff;
  170. .navbar-text {
  171. font-size: 30rpx;
  172. color: #000000;
  173. font-weight: 500;
  174. text-align: center;
  175. .iconfont {
  176. display: inline-block;
  177. width: 48rpx;
  178. height: 48rpx;
  179. border-radius: 50%;
  180. background-color: #f5f5f5;
  181. text-align: center;
  182. line-height: 48rpx;
  183. color: #666666;
  184. font-size: 30rpx;
  185. margin-left: 20rpx;
  186. }
  187. }
  188. }
  189. .container-notice {
  190. width: 100%;
  191. height: auto;
  192. box-sizing: border-box;
  193. padding: 0 24rpx;
  194. padding-top: 20rpx;
  195. .notice-cell {
  196. width: 100%;
  197. height: 130rpx;
  198. box-sizing: border-box;
  199. padding: 19rpx 0;
  200. border-bottom: 1px solid #e1e1e1;
  201. .notice-cell-icon {
  202. width: 92rpx;
  203. height: 92rpx;
  204. float: left;
  205. .icon-image {
  206. width: 92rpx;
  207. height: 92rpx;
  208. display: block;
  209. }
  210. }
  211. .notice-cell-text {
  212. width: 400rpx;
  213. height: 100%;
  214. line-height: 92rpx;
  215. font-size: 34rpx;
  216. text-align: left;
  217. margin-left: 24rpx;
  218. float: left;
  219. .cell-text {
  220. display: inline-block;
  221. height: 32rpx;
  222. padding: 0 11rpx;
  223. line-height: 32rpx;
  224. border-radius: 20rpx;
  225. text-align: center;
  226. border: 1px solid #F3B574;
  227. font-size: 24rpx;
  228. color: #F3B574;
  229. margin-left: 10rpx;
  230. }
  231. }
  232. .notice-cell-badge {
  233. width: 92rpx;
  234. height: 92rpx;
  235. float: right;
  236. box-sizing: border-box;
  237. padding: 25rpx 15rpx;
  238. text-align: right;
  239. }
  240. }
  241. }
  242. .uni-badge--small {
  243. -webkit-transform: scale(0.8);
  244. -ms-transform: scale(0.8);
  245. transform: scale(0.8);
  246. -webkit-transform-origin: center center;
  247. -ms-transform-origin: center center;
  248. transform-origin: center center;
  249. }
  250. .uni-badge {
  251. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  252. -webkit-box-sizing: border-box;
  253. box-sizing: border-box;
  254. font-size: 12px;
  255. line-height: 1;
  256. display: inline-block;
  257. padding: 3px 6px;
  258. color: #333;
  259. border-radius: 100px;
  260. background-color: #f1f1f1;
  261. }
  262. .uni-badge-error {
  263. color: #fff;
  264. background-color: #ff2a2a;
  265. }
  266. </style>