index.vue 7.0 KB

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