message.vue 6.3 KB

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