list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view>
  3. <uni-nav-bar statusBar backgroundColor="#fafafa" fixed title="新的朋友" left-icon="left" @clickLeft="utils.navigateBack()">
  4. <view slot="right" @tap="tapOpen" data-url="add">
  5. <image style="width: 30px;" src="/static/img/add_friend.png" mode="widthFix"></image>
  6. </view>
  7. </uni-nav-bar>
  8. <view class="lists">
  9. <u-swipe-action>
  10. <u-swipe-action-item @click="tapSwipe" :item="item" :options="options" v-for="item in data">
  11. <view class="item fx-r fx-bc" @tap="tapOpen" :data-url="'sqInfo?id=' + item.id" >
  12. <image :src="item.img == '' ? '/static/img/logo.png' : item.img" mode="aspectFill"></image>
  13. <view class="info fx-h fx-ac">
  14. <view class="title">{{item.name}}</view>
  15. <view class="tag">{{item.content}}</view>
  16. </view>
  17. <view class="fx-g1"></view>
  18. <view class="sub-btn" v-if="item.status == 0">查看</view>
  19. <view class="flg" v-if="item.status == 1">已通过</view>
  20. <view class="flg" v-if="item.status == 2">已拒绝</view>
  21. <view class="flg" v-if="item.status == -1">已过期</view>
  22. </view>
  23. </u-swipe-action-item>
  24. </u-swipe-action>
  25. </view>
  26. <u-loadmore :height="40" :status="page.status"
  27. loading-text="努力加载中'"
  28. loadmore-text="努力加载中"
  29. nomore-text="实在没有了"
  30. />
  31. </view>
  32. </template>
  33. <style lang="scss" scoped>
  34. .lists{margin-top: 10px;}
  35. .lists .item{background: #fff;padding:0 10px;position: relative;border-bottom: 1px solid #f1f1f1;}
  36. .lists .item:active{background: #f1f1f1;}
  37. .lists .item image{width: 40px;height: 40px;border-radius: 50%;}
  38. .lists .item .info{width: calc(100% - 120px);margin-left: 10px;font-size: 14px;color:$ic-default-text;height: 60px;}
  39. .lists .item .info .title{font-size: 14px;color: #000;}
  40. .lists .item .info .tag{font-size: 12px;}
  41. .lists .item:last-child{border-bottom: 0;}
  42. .lists .item .flg{font-size: 12px;color: $ic-default-text;}
  43. .lists .item .sub-btn{background: $ic-appcolor;padding:6px 10px;color: #fff;font-size: 12px;border-radius: 6px;}
  44. </style>
  45. <script>
  46. import {mapState,mapMutations } from 'vuex';
  47. export default {
  48. computed: mapState(['txbagenum']),
  49. data() {
  50. return {
  51. data : [],
  52. page:{
  53. page:1,
  54. isLoad:false,
  55. isFoot:false,
  56. status : "loadmore"
  57. },
  58. options:[{text: '忽略'},{text: '删除',style: {backgroundColor: '#f56c6c'}}]
  59. }
  60. },
  61. onLoad(option){
  62. this.getData(true);
  63. uni.$on('checkInvite',this.checkInvite);
  64. },
  65. onUnload() {
  66. uni.$off('checkInvite',this.checkInvite);
  67. },
  68. onReachBottom() {
  69. if(this.page.isFoot || this.page.isLoad) {
  70. return;
  71. }
  72. this.page.page ++;
  73. this.getData();
  74. },
  75. methods: {
  76. ...mapMutations(['setTxbagenum']),
  77. /**
  78. * 获取get数据
  79. */
  80. getData:function(isPull = false){
  81. if (this.page.isLoad) return;
  82. this.page.isLoad = true;
  83. if (isPull) {
  84. uni.showLoading({ title: '获取数据中..'});
  85. }
  86. this.page.status = 'loading';
  87. var post = {};
  88. post.page = this.page.page;
  89. this
  90. .request
  91. .post("FriendApplyList",post)
  92. .then(res => {
  93. uni.hideLoading();
  94. if (isPull) {
  95. this.data = res.data.list;
  96. uni.stopPullDownRefresh();
  97. this.getTxbagenum();
  98. } else {
  99. this.data = this.data.concat(res.data.list);
  100. }
  101. this.page.isLoad = false;
  102. //是否到底
  103. if (res.data.list.length != res.data.pageSize) {
  104. this.page.status = 'nomore';
  105. this.page.isFoot = true;
  106. }
  107. })
  108. .catch(res=>{
  109. console.log(res);
  110. uni.hideLoading();
  111. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  112. });
  113. },
  114. /**
  115. *
  116. */
  117. checkInvite:function(data){
  118. for(var i in this.data) {
  119. if(this.data[i].id == data.id) {
  120. this.$set(this.data[i],"status",data.type);
  121. }
  122. }
  123. },
  124. /**
  125. * 打开其他页面
  126. * @param {Object} ev
  127. */
  128. tapOpen: function(ev) {
  129. let url = ev.currentTarget.dataset.url
  130. uni.navigateTo({
  131. url: url
  132. });
  133. },
  134. tapSwipe:function(ev){
  135. console.log(ev);
  136. uni.showLoading({ title: '获取数据中..'});
  137. this
  138. .request
  139. .post("FriendApplyAction",{
  140. type : ev.index,
  141. id : ev.item.id
  142. })
  143. .then(res => {
  144. uni.hideLoading();
  145. if(res.code == 200) {
  146. this.getData(true);
  147. } else {
  148. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  149. }
  150. })
  151. .catch(res=>{
  152. console.log(res);
  153. uni.hideLoading();
  154. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  155. });
  156. },
  157. /**
  158. * 获取当前消息角标数量
  159. */
  160. getTxbagenum:function(){
  161. this.request.get("chatBagenum")
  162. .then(res=>{
  163. if(res.code == 200) {
  164. this.setTxbagenum(res.data);
  165. }
  166. }).catch((err)=>{
  167. });
  168. }
  169. }
  170. }
  171. </script>