notice.vue 5.3 KB

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