notice.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <!-- 消息 -->
  2. <template>
  3. <view class="container">
  4. <view class="notice_content_wrap" v-if="!no_data && noticeList && noticeList.length > 0">
  5. <view class="notice_item" v-for="(item,index) in noticeList" :key="index" @click="goNoticeDetail(item.receiveId,item.msgLinkInfo)">
  6. <view class="notice_time">{{item.msgSendTime}}</view>
  7. <view class="notice_content">
  8. <view class="notice_title_wrap">
  9. <view class="notice_title_left">
  10. <view v-if="item.msgState==0" class="circle"></view>
  11. <view v-else class="circle have_read"></view>
  12. <view class="notice_title">{{item.tplName}}</view>
  13. </view>
  14. <view class="notice_title_right">
  15. <image :src="rightUrl" mode=""></image>
  16. </view>
  17. </view>
  18. <view class="notice_text">{{item.msgContent}}</view>
  19. </view>
  20. </view>
  21. <loadingState :state='loadingState' v-if="loadingState == 'first_loading'||noticeList.length > 0"/>
  22. </view>
  23. <!-- <view class="no_data" v-if="no_data" :style="{ width: windowWidth + 'rpx', 'height': windowHeight + 'rpx' }"> -->
  24. <view class="no_data" v-if="no_data">
  25. <image :src="imgUrl+'empty_msg.png'" mode=""></image>
  26. <text>{{$L('暂无消息')}}~</text>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import loadingState from "@/components/loading-state.vue";
  32. import {
  33. mapState
  34. } from 'vuex';
  35. export default {
  36. data(){
  37. return {
  38. imgUrl: getApp().globalData.imgUrl,
  39. rightUrl:getApp().globalData.imgUrl+'member/right.png',
  40. tplType:'', //消息类型
  41. current:1, //当前页数
  42. noticeList:[], //消息列表
  43. loadingState:'first_loading', //是否第一次加载
  44. stopPullDownRefresh: false, //是否下拉刷新中
  45. no_data:false,
  46. windowHeight:'', //屏幕的高
  47. windowWidth:'', //屏幕的宽
  48. }
  49. },
  50. components: {
  51. loadingState
  52. },
  53. computed:{
  54. ...mapState(['userInfo'])
  55. },
  56. onPullDownRefresh() {
  57. this.loadingState = 'first_loading';
  58. this.noticeList = [];
  59. this.current = 1;
  60. this.stopPullDownRefresh = true; //下拉刷新状态
  61. this.loadData(this.tplType);
  62. },
  63. onReachBottom(){
  64. this.loadData(this.tplType);
  65. },
  66. onLoad(option){
  67. this.tplType = option.tplType
  68. // this.loadData(this.tplType)
  69. const {windowWidth,windowHeight} = uni.getSystemInfoSync();
  70. this.windowWidth = windowWidth * 2;
  71. this.windowHeight = windowHeight * 2;
  72. },
  73. onShow(){
  74. this.loadingState=''
  75. this.noticeList=[]
  76. this.current=1
  77. this.loadData(this.tplType);
  78. },
  79. methods:{
  80. //点击消息时设置消息已读
  81. readMessage(receiveId){
  82. let param = {}
  83. param.url = 'v3/msg/front/msg/read'
  84. param.method = 'POST'
  85. param.data = {
  86. receiveIds:receiveId
  87. }
  88. this.$request(param).then(res=>{
  89. if(res.state == 200){
  90. }else {
  91. this.$api.msg(res.msg);
  92. }
  93. })
  94. },
  95. loadData(tplType){
  96. if(this.loadingState == 'loading'){
  97. return
  98. }
  99. if(this.loadingState == 'no_more_data'){
  100. return
  101. }
  102. let param = {}
  103. param.url = 'v3/msg/front/msg/msgList'
  104. param.method = 'GET'
  105. param.data = {
  106. tplType,
  107. pageSize:10,
  108. current:this.current,
  109. }
  110. this.loadingState = this.loadingState == 'first_loading'?this.loadingState:'loading'
  111. this.$request(param).then(res=>{
  112. if(res.state == 200){
  113. if(res.data.list && res.data.list.length > 0){
  114. this.noticeList = this.noticeList.concat(res.data.list);
  115. let hasMore = this.$checkPaginationHasMore(res.data.pagination); //是否还有数据
  116. if (hasMore) {
  117. this.current++;
  118. this.loadingState = 'allow_loading_more';
  119. } else {
  120. this.loadingState = 'no_more_data';
  121. }
  122. this.no_data = false;
  123. }else{
  124. this.no_data = true;
  125. }
  126. }else {
  127. this.$api.msg(res.msg);
  128. }
  129. if (this.stopPullDownRefresh) {
  130. this.stopPullDownRefresh = false;
  131. uni.stopPullDownRefresh();
  132. }
  133. })
  134. },
  135. //消息跳转
  136. goNoticeDetail(receiveId,info){
  137. let msgLinkInfo = JSON.parse(info);
  138. this.readMessage(receiveId)
  139. if(msgLinkInfo.type == 'order_new' || msgLinkInfo.type == 'order_news'){ // 商品出库提醒 || 付款成功提醒 进入订单详情
  140. uni.navigateTo({
  141. url:'/pages/order/detail?orderSn=' + msgLinkInfo.orderSn
  142. })
  143. }else if(msgLinkInfo.type == 'balance_change'){ //余额变动提醒 进入我的钱包
  144. uni.navigateTo({
  145. url:'/pages/balance/list'
  146. })
  147. }else if(msgLinkInfo.type == 'coupon_news'){ //优惠券过期提醒 进入我的优惠券
  148. uni.navigateTo({
  149. url:'/pages/coupon/myCoupon'
  150. })
  151. }else if(msgLinkInfo.type == 'return_news' || msgLinkInfo.type == 'refund_news'){ //售后提醒 return_news(退货退款) refund_news(仅退款 ) 进入我的售后列表 (afsSn)
  152. uni.navigateTo({
  153. url:'/pages/order/returnAndRefundList?state=0'
  154. })
  155. }else if(msgLinkInfo.type == 'integral_change'){ //积分变动提醒 进入我的积分
  156. uni.navigateTo({
  157. url:'/pages/user/myIntegral'
  158. })
  159. }else if(msgLinkInfo.type == 'appointment_news'){//预约消息跳转详情
  160. uni.navigateTo({
  161. url:'/pages/product/detail?productId='+msgLinkInfo.productId+'&goodsId='+msgLinkInfo.goodsId
  162. })
  163. }
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss">
  169. page,.container{
  170. width:750rpx;
  171. height:100%;
  172. background: #f5f5f5;
  173. margin: 0 auto;
  174. .notice_content_wrap{
  175. padding:0 20rpx;
  176. .notice_item{
  177. margin-top:38rpx;
  178. .notice_time{
  179. text-align: center;
  180. font-size: 24rpx;
  181. color:#666;
  182. }
  183. .notice_content{
  184. width:100%;
  185. background-color: #fff;
  186. margin-top:20rpx;
  187. .notice_title_wrap{
  188. width:100%;
  189. height:70rpx;
  190. padding:0 20rpx;
  191. box-sizing: border-box;
  192. display:flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. border-bottom:1rpx solid rgba(0,0,0,0.05);
  196. .notice_title_left{
  197. display:flex;
  198. align-items: center;
  199. .circle{
  200. width:10rpx;
  201. height:10rpx;
  202. border-radius: 50%;
  203. background: #FF1212;
  204. margin-right:20rpx;
  205. }
  206. .have_read{
  207. background-color: #999999;
  208. }
  209. .notice_title{
  210. font-size:32rpx;
  211. color:#333;
  212. font-weight: 600;
  213. }
  214. }
  215. .notice_title_right{
  216. image{
  217. width:14rpx;
  218. height:24rpx;
  219. }
  220. }
  221. }
  222. .notice_text{
  223. font-size:28rpx;
  224. line-height: 1.5em;
  225. color:#666;
  226. font-weight: 600;
  227. padding:20rpx;
  228. }
  229. }
  230. }
  231. }
  232. .no_data{
  233. width: 750rpx;
  234. display: flex;
  235. // justify-content: center;
  236. padding-top: 200rpx;
  237. align-items: center;
  238. flex-direction: column;
  239. image{
  240. width: 212rpx;
  241. height: 210rpx;
  242. }
  243. text{
  244. font-size: 26rpx;
  245. font-family: Source Han Sans CN;
  246. font-weight: 400;
  247. color: #999999;
  248. margin-top: 30rpx;
  249. }
  250. }
  251. }
  252. </style>