index.vue 8.7 KB

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