notice.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. />
  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. .notice {
  127. width: 100%;
  128. height: 100%;
  129. position: relative;
  130. background: #FFFFFF;
  131. box-sizing: border-box;
  132. }
  133. .navbar-wrap {
  134. position: fixed;
  135. width: 100%;
  136. top: 0;
  137. z-index: 100000;
  138. box-sizing: border-box;
  139. background: #ffffff;
  140. .navbar-text {
  141. font-size: 30rpx;
  142. color: #000000;
  143. font-weight: 500;
  144. text-align: center;
  145. .iconfont {
  146. display: inline-block;
  147. width: 48rpx;
  148. height: 48rpx;
  149. border-radius: 50%;
  150. background-color: #f5f5f5;
  151. text-align: center;
  152. line-height: 48rpx;
  153. color: #666666;
  154. font-size: 30rpx;
  155. margin-left: 20rpx;
  156. }
  157. }
  158. }
  159. .container-notice {
  160. width: 100%;
  161. height: auto;
  162. box-sizing: border-box;
  163. padding: 0 24rpx;
  164. padding-top: 20rpx;
  165. .notice-cell {
  166. width: 100%;
  167. height: 130rpx;
  168. box-sizing: border-box;
  169. padding: 19rpx 0;
  170. border-bottom: 1px solid #e1e1e1;
  171. .notice-cell-icon {
  172. width: 92rpx;
  173. height: 92rpx;
  174. float: left;
  175. .icon-image {
  176. width: 92rpx;
  177. height: 92rpx;
  178. display: block;
  179. }
  180. }
  181. .notice-cell-text {
  182. width: 400rpx;
  183. height: 100%;
  184. line-height: 92rpx;
  185. font-size: 34rpx;
  186. text-align: left;
  187. margin-left: 24rpx;
  188. float: left;
  189. .cell-text {
  190. display: inline-block;
  191. height: 32rpx;
  192. padding: 0 11rpx;
  193. line-height: 32rpx;
  194. border-radius: 20rpx;
  195. text-align: center;
  196. border: 1px solid #FF5B00;
  197. font-size: 24rpx;
  198. color: #FF5B00;
  199. margin-left: 10rpx;
  200. }
  201. }
  202. .notice-cell-badge {
  203. width: 92rpx;
  204. height: 92rpx;
  205. float: right;
  206. box-sizing: border-box;
  207. padding: 25rpx 15rpx;
  208. text-align: right;
  209. }
  210. }
  211. }
  212. .uni-badge--small {
  213. -webkit-transform: scale(0.8);
  214. -ms-transform: scale(0.8);
  215. transform: scale(0.8);
  216. -webkit-transform-origin: center center;
  217. -ms-transform-origin: center center;
  218. transform-origin: center center;
  219. }
  220. .uni-badge {
  221. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  222. -webkit-box-sizing: border-box;
  223. box-sizing: border-box;
  224. font-size: 12px;
  225. line-height: 1;
  226. display: inline-block;
  227. padding: 3px 6px;
  228. color: #333;
  229. border-radius: 100px;
  230. background-color: #f1f1f1;
  231. }
  232. .uni-badge-error {
  233. color: #fff;
  234. background-color: #ff2a2a;
  235. }
  236. </style>