notice.vue 5.1 KB

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