notice.vue 5.5 KB

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