adds.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="page">
  3. <uni-status-bar></uni-status-bar>
  4. <view class="header">
  5. <view class="input-view">
  6. <image style="width: 16px;height: 16px;" src="/static/img/search.png" mode="widthFix"></image>
  7. <input class="input" type="text" placeholder="搜索" @input="handleInput" :focus="true" />
  8. </view>
  9. <view class="" @click="toBack">
  10. <text>取消</text>
  11. </view>
  12. </view>
  13. <view class="search-main" v-if="keyword">
  14. <view class="search-main-errtitle" v-if="hasNoData" >无搜索结果</view>
  15. <view class="uni-list">
  16. <view class="uni-list-cell" hover-class="none" v-for="(item,index) of list" @tap="handleClick(item)"
  17. :key="index">
  18. <view class="uni-media-list">
  19. <view class="uni-media-list-logo">
  20. <image :src="staticPhoto + item.photo" :lazy-load="true"></image>
  21. </view>
  22. <view class="uni-media-list-body">
  23. <view class="uni-list-cell-navigate">{{item.name}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
  33. import _get from '../../common/_get';
  34. import _hook from '../../common/_hook';
  35. import _data from '../../common/_data';
  36. import uniStatusBar from '@/components/uni-ui/uni-status-bar/uni-status-bar.vue'
  37. export default {
  38. components: {
  39. uniIcon,
  40. uniStatusBar
  41. },
  42. data() {
  43. return {
  44. is_type: 0,
  45. keyword: '',
  46. list: [],
  47. timer: null,
  48. my_data: {}
  49. }
  50. },
  51. onShow() {
  52. _hook.routeSonHook();
  53. this.my_data = _data.data('user_info');
  54. console.log(this.my_data,'this.my_data');
  55. },
  56. computed: {
  57. hasNoData() {
  58. return !this.list.length;
  59. },
  60. staticPhoto() {
  61. return _data.staticPhoto();
  62. },
  63. },
  64. watch: {
  65. keyword(new_val, old_val) {
  66. let _this = this;
  67. if (_this.timer) {
  68. clearTimeout(_this.timer);
  69. }
  70. if (!new_val) {
  71. _this.list = [];
  72. return
  73. }
  74. _this.timer = setTimeout(() => {
  75. _this.$httpSend({
  76. path: '/im/get/searchGroup',
  77. data: {
  78. group_id: new_val
  79. },
  80. success(res) {
  81. console.log(res,'res');
  82. _this.list = res.map(item => {
  83. item.photo = '/group_photo/36F21FB48146249A044B7547C255A412/90.jpg'
  84. return item
  85. });
  86. // _this.is_type = data.is_type;
  87. }
  88. });
  89. }, 100);
  90. }
  91. },
  92. methods: {
  93. toBack() {
  94. uni.navigateBack({
  95. })
  96. },
  97. handleInput(e) {
  98. this.keyword = e.detail.value
  99. },
  100. handleClick(item) {
  101. // uni.navigateTo({
  102. // url: ('../details/index?user_id=' + id + '&is_type=' + this.is_type),
  103. // });
  104. let _this = this
  105. console.log(item,'qun');
  106. uni.showModal({
  107. title:'提示',
  108. content: '是否立即申请加入群聊?',
  109. complete(res) {
  110. if(res.confirm) {
  111. let arr = [0]
  112. arr[0] =_this.my_data.id
  113. console.log(item.main_id,item.list_id,arr);
  114. let req = {
  115. main_id: item.main_id,
  116. list_id: item.list_id,
  117. users: arr,
  118. }
  119. console.log(req,'req');
  120. _this.$httpSend({
  121. path: '/im/Message/addChats',
  122. data: req,
  123. success(res) {
  124. uni.showModal({
  125. content: '已经申请加入群聊,请耐心等待群管理审核',
  126. showCancel: false,
  127. });
  128. },
  129. });
  130. // let params = {
  131. // // user_id: _this.my_data.id,
  132. // action: 'group_add',
  133. // list_id: item.list_id,
  134. // type: 1,
  135. // // add_type: "scan"
  136. // };
  137. // _get.groupAdd(params,function (res) {
  138. // uni.showModal({
  139. // content: '已经申请加入群聊,请耐心等待群管理审核',
  140. // showCancel: false,
  141. // });
  142. // },function (ret) {
  143. // uni.showToast({
  144. // title:ret.msg,
  145. // duration:2000,
  146. // icon:'none'
  147. // })
  148. // })
  149. }
  150. }
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style>
  157. page {
  158. background: #fff;
  159. }
  160. .search-main {
  161. height: 100%;
  162. padding-bottom: 20upx;
  163. background-color: #fff;
  164. overflow: hidden;
  165. }
  166. .search-main-errtitle {
  167. width: 100%;
  168. height: 92upx;
  169. line-height: 92upx;
  170. font-size: 32upx;
  171. padding: 0 20upx;
  172. border-bottom: 1px solid #e5e5e5;
  173. }
  174. .header {
  175. display: flex;
  176. flex-direction: row;
  177. padding: 10px 15px;
  178. align-items: center;
  179. }
  180. .input-view {
  181. display: flex;
  182. align-items: center;
  183. flex-direction: row;
  184. background-color: #f7f7f7;
  185. height: 36px;
  186. border-radius: 18px;
  187. padding: 0 10px;
  188. flex: 1;
  189. margin-right: 10rpx;
  190. }
  191. .input {
  192. flex: 1;
  193. padding: 0 5px;
  194. height: 24px;
  195. line-height: 24px;
  196. font-size: 14px;
  197. }
  198. </style>