message.vue 6.2 KB

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