pageP.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="pagep">
  3. <view class="msgitem" v-for="(msgitem,msgidx) in dataList" :key = "msgidx">
  4. <uni-swipe-action style="width: 100%;">
  5. <uni-swipe-action-item :right-options="options" @click="deleteMsg(msgidx,msgitem)" >
  6. <view class="itemwrap" @click = "goDetail(msgitem)">
  7. <view class="msgtitle">
  8. <view class="titletext">
  9. <text class="tag" v-if="msgitem.params!='read' && !msgitem.readStatus"></text>
  10. <text class="tag" v-if="msgitem.readStatus!='read' && !msgitem.params"></text>
  11. <text class="title">{{msgitem.title}}</text>
  12. </view>
  13. <view class="date">{{formatDate(msgitem.createDate)}}</view>
  14. </view>
  15. <view class="content">{{msgitem.content}}</view>
  16. </view>
  17. </uni-swipe-action-item>
  18. </uni-swipe-action>
  19. </view>
  20. <!-- 页面优化提示 -->
  21. <view class="loading" v-if="showLoading">
  22. <u-loadmore :status="status" iconType="flower" :load-text="{loading: $t('common.Loading')}"/>
  23. </view>
  24. <view class="nodata" v-if="!showLoading && dataList.length==0" style="text-align: center;margin-top: 120upx;">
  25. <view style="height:600upx;margin-bottom:60upx">
  26. <image src="../../static/img/public/7.png" style="width: 80%;margin:0 10%" mode="widthFix"></image>
  27. </view>
  28. <text style="font-size: 30upx;color:#ccc">{{$t('common.Nodata')}}</text>
  29. </view>
  30. <u-toast ref="uToast" />
  31. </view>
  32. </template>
  33. <script>
  34. import uniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue'
  35. export default {
  36. components: {
  37. uniSwipeAction
  38. },
  39. data() {
  40. return {
  41. token:'',
  42. userId:'',
  43. pageSize:50,
  44. pageNo:1,
  45. msgType:'',
  46. dataList: [],
  47. Botcurrent:0,
  48. showLoading:true,
  49. status:'loading',
  50. BotMenuList: [
  51. {
  52. id: "tab01",
  53. name: this.$t('common.All'),
  54. msgid: 0
  55. },
  56. {
  57. id: "tab02",
  58. // name: '活动消息',
  59. name:this.$t('common.ActiveMessage'),
  60. msgid: 23
  61. },
  62. {
  63. id: "tab03",
  64. // name: '服务消息',
  65. name:this.$t('common.ServiceMessage'),
  66. msgid: 223
  67. }, {
  68. id: "tab04",
  69. // name: '审核消息',
  70. name:this.$t('common.ReviewMessage'),
  71. msgid: 221
  72. }
  73. ],
  74. options:[
  75. {
  76. text:this.$t('common.Delete'),
  77. style: {
  78. fontSize:'12px',
  79. height:'30px',
  80. backgroundColor:'#f2a059',
  81. height:'60px'
  82. }
  83. }
  84. ],
  85. }
  86. },
  87. onLoad(e){
  88. },
  89. created(){
  90. this.loadData()
  91. },
  92. onShow(){
  93. this.loadingText = this.$i18n.locale=='en'?'Loading ...':'加载中...';
  94. this.token=uni.getStorageSync('Auth-Token')?'Bearer '+uni.getStorageSync('Auth-Token'):'';
  95. this.userId = uni.getStorageSync('user')? JSON.parse(uni.getStorageSync('user')).id:'';
  96. },
  97. onReachBottom(){
  98. this.loadMore()
  99. },
  100. methods: {
  101. //加载数据
  102. async loadData(loadmore) {
  103. let params = {
  104. query:'',
  105. size:this.pageSize,
  106. page:this.pageNo
  107. }
  108. let res = await this.$myRequest({
  109. url:'/uc/platformNotify/findAll/',
  110. header:{token:this.token},
  111. data:params
  112. })
  113. if(res.status==200){
  114. let data =res.data
  115. if(data.list){
  116. if(data.list && Array.isArray(data.list) && data.list.length>0){
  117. if (!loadmore) {
  118. this.dataList =data.list;
  119. } else {
  120. this.dataList = this.dataList.concat(data.list);
  121. }
  122. }else{
  123. this.isNoData = true;
  124. }
  125. }
  126. }else{
  127. this.isNoData = true;
  128. }
  129. this.showLoading=false;
  130. },
  131. loadMore(e) {
  132. this.pageNo++;
  133. this.loadData('loadmore');
  134. },
  135. // 删除数据
  136. async deleteMsg(index,item){
  137. let res = await this.$myRequest({
  138. 'method':'delete',
  139. url:'uc/sysPushMessages/deleteMsg',
  140. data:{ids:item.id}
  141. })
  142. if(res.status==200){
  143. this.$refs.uToast.show({
  144. title: this.$i18n.locale=='en'?'Delete Success ...':'删除成功',
  145. type: 'success',
  146. })
  147. if(this.dataList.length>0){
  148. this.dataList.splice(index,1)
  149. }
  150. }else{
  151. this.$refs.uToast.show({
  152. title: this.$i18n.locale=='en'?'Delete Fail ...':'删除失败',
  153. type: 'error',
  154. })
  155. }
  156. },
  157. goDetail(item) {
  158. uni.setStorageSync('MsgDetail',item)
  159. uni.navigateTo({
  160. url:'/pages/message/msgDetail?msgId='+item.id+'&msgType=0'
  161. })
  162. },
  163. }
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. .msgitem{
  168. margin:20upx;
  169. padding:20upx 0;
  170. border-bottom:1px solid #eee;
  171. .itemwrap{
  172. width:100%;
  173. .msgtitle{
  174. display:flex;
  175. flex:1;
  176. justify-content:space-between;
  177. width:100%;
  178. .titletext{
  179. flex:1;
  180. .title{
  181. font-size:28upx;
  182. color:#333;
  183. }
  184. .tag{
  185. width:0;
  186. height:0;
  187. padding:8upx;
  188. border-radius:50%;
  189. background:#C50606;
  190. margin-right:8upx;
  191. }
  192. }
  193. .date{
  194. color:#aaa;
  195. margin-right:20upx;
  196. }
  197. }
  198. .content{
  199. margin-top:10upx;
  200. line-height:50upx;
  201. color:#999;
  202. }
  203. }
  204. }
  205. </style>