message.vue 6.2 KB

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