index.vue 8.9 KB

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