apply-list.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="page">
  3. <uni-list v-if="friend_apply_list.length">
  4. <view v-for="(value,key) in friend_apply_list" @longtap.stop="listAction(value.id+'',key+0)" :key="key">
  5. <view class="uni-media-list btm_border" @tap="goPath(value.user_id)">
  6. <view class="uni-media-list-logo">
  7. <image :src="staticPhoto + value.photo" class="img-icon" />
  8. </view>
  9. <view class="uni-media-list-body">
  10. <view class="uni-list-cell-navigate">{{value.nickname}}</view>
  11. <view class="uni-list-cell-navigate content">{{value.content}}</view>
  12. </view>
  13. <view >
  14. <view class="badge-text"><text>{{value.text}}</text></view>
  15. <view ><text>&nbsp;</text></view>
  16. </view>
  17. </view>
  18. </view>
  19. </uni-list>
  20. <uni-load-more status="noMore" v-if="noMore"/>
  21. </view>
  22. </template>
  23. <script>
  24. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  25. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  26. import uniLoadMore from "../../components/uni-ui/uni-load-more/uni-load-more.vue";
  27. import _get from '../../common/_get';
  28. import _hook from '../../common/_hook';
  29. import _data from '../../common/_data';
  30. export default {
  31. components: {
  32. uniList,
  33. uniListItem,
  34. uniLoadMore,
  35. },
  36. data() {
  37. return {
  38. noMore: 0,
  39. friend_apply_list: [],
  40. action: 0,
  41. }
  42. },
  43. onShow(){
  44. _hook.routeSonHook();
  45. let friend_apply_list = _data.localData('friend_apply_list'),
  46. _this = this;
  47. /** 监听最新数据 */
  48. uni.$on('data_friend_apply_list',function(data){
  49. _this.friend_apply_list = data;
  50. });
  51. /** 加载本地缓存数据,如果有新的朋友申请,更新本地数据 */
  52. if(friend_apply_list && _this.action == 0){
  53. _this.friend_apply_list = friend_apply_list;
  54. }else{
  55. _get.getFriendApplyList((data) => {
  56. if(data.length < 1){
  57. _this.noMore = 1;
  58. }
  59. });
  60. }
  61. },
  62. onLoad(option) {
  63. this.action = option.action;
  64. },
  65. onUnload(){
  66. uni.$off('data_friend_apply_list');
  67. },
  68. computed: {
  69. staticPhoto(){
  70. return _data.staticPhoto();
  71. },
  72. },
  73. methods: {
  74. listAction(id,key){
  75. let _this = this;
  76. uni.showActionSheet({
  77. itemList: [ '删除', ],
  78. success: function (res) {
  79. switch (res.tapIndex){
  80. case 0:
  81. uni.showModal({
  82. title: '提示',
  83. content: '确定删除这条好友申请记录吗?',
  84. success: function (res) {
  85. if (res.confirm) {
  86. _this.$httpSend({
  87. path: '/im/friend/removeApply',
  88. data: { id },
  89. success(res) {
  90. _this.friend_apply_list.splice(key,1);
  91. _data.localData('friend_apply_list',_this.friend_apply_list);
  92. uni.showToast({
  93. title: '删除成功!',
  94. icon: 'none',
  95. })
  96. }
  97. });
  98. }
  99. }
  100. });
  101. break;
  102. case 1:
  103. break;
  104. default:
  105. break;
  106. }
  107. },
  108. fail: function (res) {
  109. //console.log(res.errMsg);
  110. }
  111. });
  112. },
  113. goPath(user_id){
  114. if(user_id){
  115. uni.navigateTo({
  116. url: '../details/index?user_id=' + user_id + '&in=1'
  117. });
  118. }
  119. },
  120. },
  121. watch: {
  122. },
  123. }
  124. </script>
  125. <style>
  126. .img-icon{
  127. width:85upx;
  128. height: 85upx;
  129. border-radius: 10upx;
  130. }
  131. .uni-list-cell-navigate {
  132. padding: 0;
  133. }
  134. .content{
  135. color:#7D7D72;
  136. font-size: 28upx;
  137. }
  138. .badge-text{
  139. background-color: #EEEEEE;
  140. padding: 3upx 10upx 0 10upx;
  141. border-radius: 15upx;
  142. font-size: 22upx;
  143. }
  144. .btm_border{
  145. position: relative;
  146. display: flex;
  147. flex-direction: row;
  148. justify-content: space-between;
  149. align-items: center;
  150. }
  151. .btm_border::after {
  152. position: absolute;
  153. z-index: 3;
  154. right: 0;
  155. bottom: 0;
  156. left: 115upx;
  157. height: 1px;
  158. content: '';
  159. -webkit-transform: scaleY(.5);
  160. transform: scaleY(.5);
  161. background-color: #c8c7cc;
  162. }
  163. </style>