pageO.vue 5.6 KB

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