select_friend.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="page">
  3. <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight + 'px'}">
  4. <view class="scrollList-top">
  5. <image src="/static/img/arrow-down.png" mode="" @click="closePop"></image>
  6. <text>选择提醒的人</text>
  7. </view>
  8. <view class="uni-list">
  9. <view class="uni-list-cell">
  10. <uni-swipe-action>
  11. <view class="uni-media-list">
  12. <uni-search-bar ref="searchBar2" placeholder="搜索" :show="false" @confirm="search"
  13. @search="search" radius="4">
  14. </uni-search-bar>
  15. </view>
  16. </uni-swipe-action>
  17. </view>
  18. </view>
  19. <view class="uni-list">
  20. <view>
  21. <view class="uni-list-cell">
  22. <uni-swipe-action>
  23. <view class="uni-media-list" @tap="toChat({user_id:'all',name:'所有人'})">
  24. <view class="uni-media-list-logo">
  25. <image src="@/static/theme/default/friend/group.png" :lazy-load="true"
  26. style="border-radius: 10px;" />
  27. </view>
  28. <view class="uni-media-list-body">
  29. <view class="uni-list-cell-navigate">所有人</view>
  30. </view>
  31. </view>
  32. </uni-swipe-action>
  33. </view>
  34. </view>
  35. <view v-for="(list, key) in list_data" :key="key">
  36. <view class="uni-list-cell-divider" :id="list.letter">
  37. {{list.letter}}
  38. </view>
  39. <view class="uni-list-cell" hover-class="none"
  40. :class="list.data.length -1 == index ? 'uni-list-cell-last' : ''"
  41. v-for="(item,index) in list.data" :key="isKey(key,index)">
  42. <uni-swipe-action>
  43. <view class="uni-media-list" @tap="toChat(item)">
  44. <view class="uni-media-list-logo">
  45. <image :src="photo(item.photo+'')" :lazy-load="true" style="border-radius: 10px;" />
  46. </view>
  47. <view class="uni-media-list-body">
  48. <view class="uni-list-cell-navigate">{{item.name}}</view>
  49. </view>
  50. </view>
  51. </uni-swipe-action>
  52. </view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. <view class="uni-indexed-list-bar" :class="touchmove ? 'active' : ''" @touchstart="touchStart"
  57. @touchmove.stop.prevent="touchMove" @touchend="touchEnd" @touchcancel="touchCancel"
  58. :style="{height:winHeight + 'px',paddingTop:'10px'}">
  59. <text v-for="(item,index) in key_data" :key="index" class="uni-indexed-list-text"
  60. :class="touchmoveIndex == index ? 'active' : ''"
  61. :style="{height:itemHeight + 'px',lineHeight:itemHeight + 'px'}">
  62. {{item}}
  63. </text>
  64. </view>
  65. <view class="uni-indexed-list-alert" v-if="touchmove">
  66. {{key_data[touchmoveIndex]}}
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
  72. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  73. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  74. import uniSwipeAction from '../../components/uni-ui/uni-swipe-action/uni-swipe-action.vue'
  75. import _get from '../../common/_get';
  76. import _hook from '../../common/_hook';
  77. import _data from '../../common/_data';
  78. import uniSearchBar from '../../components/mehaotian-search/mehaotian-search.vue'
  79. export default {
  80. components: {
  81. uniIcon,
  82. uniList,
  83. uniListItem,
  84. uniSwipeAction,
  85. uniSearchBar
  86. },
  87. props: {
  88. list_id: ''
  89. },
  90. data() {
  91. return {
  92. list_data: [],
  93. new_friend_tips: 0,
  94. new_group_tips: 0,
  95. title: 'grid',
  96. touchmove: false,
  97. touchmoveIndex: -1,
  98. itemHeight: 200,
  99. winHeight: 0,
  100. scrollViewId: "A",
  101. titleHeight: 110,
  102. search_list: [],
  103. keyword: '',
  104. // list_id: '',
  105. key_data: ['↑', '#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
  106. 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  107. ]
  108. }
  109. },
  110. onShow() {
  111. },
  112. mounted() {
  113. this.initData();
  114. },
  115. onHide() {
  116. //清空search框
  117. if (this.keyword) {
  118. this.$refs.searchBar2.clear();
  119. this.list_data = this.search_list;
  120. }
  121. },
  122. computed: {
  123. staticPhoto() {
  124. return _data.staticPhoto();
  125. },
  126. },
  127. methods: {
  128. initData() {
  129. _hook.routeTabBarHook();
  130. let _this = this;
  131. _get.getMemberList({
  132. list_id: this.list_id
  133. }, function(data) {
  134. console.log(data.data)
  135. _this.list_data = data.data;
  136. // todo 有用的letter
  137. let obj = _this.list_data;
  138. let arr = [];
  139. for (let key in obj) {
  140. arr.push(obj[key].letter);
  141. }
  142. _this.key_data = Array.from(new Set(arr));
  143. console.log("_this.key_data", _this.key_data);
  144. _this.search_list = data.data;
  145. let winHeight = uni.getSystemInfoSync().windowHeight - 100;
  146. // todo键盘弹起兼容手机H5
  147. // #ifdef H5
  148. winHeight = winHeight - 150;
  149. _this.titleHeight = _this.titleHeight + 150;
  150. // #endif
  151. _this.itemHeight = winHeight / _this.key_data.length;
  152. _this.winHeight = winHeight;
  153. });
  154. },
  155. closePop() {
  156. this.$emit("close");
  157. },
  158. search(keyword) {
  159. this.keyword = keyword.trim();
  160. let _this = this;
  161. if (!keyword) {
  162. _this.list_data = _this.search_list;
  163. return true;
  164. }
  165. _get.searchGroupFriends({
  166. 'keyword': keyword,
  167. 'list_id': _this.list_id
  168. }, function(data) {
  169. _this.list_data = data;
  170. })
  171. },
  172. photo(path) {
  173. return this.staticPhoto + path;
  174. },
  175. toChat(item) {
  176. console.log("item", item);
  177. uni.$emit('update_text_msg', {
  178. msg: item.name + ' ',
  179. user_id: item.user_id,
  180. })
  181. // uni.navigateBack()
  182. },
  183. isKey(key, index) {
  184. return key + '' + index;
  185. },
  186. touchStart(e) {
  187. this.touchmove = true;
  188. let pageY = e.touches[0].pageY;
  189. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  190. let item = this.key_data[index];
  191. if (item) {
  192. this.scrollViewId = item;
  193. this.touchmoveIndex = index;
  194. }
  195. },
  196. touchMove(e) {
  197. let pageY = e.touches[0].pageY;
  198. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  199. let item = this.key_data[index];
  200. if (item) {
  201. this.scrollViewId = item;
  202. this.touchmoveIndex = index;
  203. }
  204. },
  205. touchEnd() {
  206. this.touchmove = false;
  207. //this.touchmoveIndex = -1;
  208. },
  209. touchCancel() {
  210. this.touchmove = false;
  211. //this.touchmoveIndex = -1;
  212. },
  213. },
  214. watch: {
  215. },
  216. }
  217. </script>
  218. <style scoped>
  219. .scrollList-top {
  220. position: relative;
  221. height: 80rpx;
  222. display: flex;
  223. align-items: center;
  224. box-sizing: border-box;
  225. padding: 0 20rpx;
  226. }
  227. .scrollList-top text {
  228. position: absolute;
  229. left: 50%;
  230. top: 50%;
  231. font-size: 32rpx;
  232. transform: translate(-50%, -50%);
  233. }
  234. .scrollList-top image {
  235. width: 40rpx;
  236. height: 40rpx;
  237. }
  238. .uni-list-cell-divider {
  239. background-color: #f1f1f1;
  240. box-sizing: border-box;
  241. padding-left: 22px;
  242. }
  243. .page {
  244. display: flex;
  245. flex-direction: row;
  246. flex: 1;
  247. background-color: #fff;
  248. border-radius: 20rpx 20rpx 0 0;
  249. overflow: hidden;
  250. position: relative;
  251. }
  252. .search .content {
  253. padding-left: 20upx;
  254. height: 60upx;
  255. }
  256. .scrollList {
  257. flex: 1;
  258. height: 100%;
  259. }
  260. .uni-indexed-list-bar {
  261. width: 40upx;
  262. height: 100vh;
  263. background-color: transparent;
  264. display: flex;
  265. flex-direction: column;
  266. position: absolute;
  267. right: 0;
  268. top: 0;
  269. }
  270. .uni-indexed-list-bar.active {
  271. /* background-color: rgb(200, 200, 200); */
  272. }
  273. .uni-indexed-list-text {
  274. font-size: 22upx;
  275. text-align: center;
  276. }
  277. .uni-indexed-list-bar.active .uni-indexed-list-text {
  278. color: #333;
  279. }
  280. .uni-indexed-list-text.active,
  281. .uni-indexed-list-bar.active .uni-indexed-list-text.active {
  282. color: #02b300;
  283. }
  284. .uni-indexed-list-alert {
  285. position: absolute;
  286. z-index: 20;
  287. width: 160upx;
  288. height: 160upx;
  289. left: 50%;
  290. top: 50%;
  291. margin-left: -80upx;
  292. margin-top: -80upx;
  293. border-radius: 80upx;
  294. text-align: center;
  295. line-height: 160upx;
  296. font-size: 70upx;
  297. color: #fff;
  298. background-color: rgba(0, 0, 0, 0.5);
  299. }
  300. .header {
  301. display: flex;
  302. flex-direction: row;
  303. padding: 10px 15px;
  304. align-items: center;
  305. }
  306. .input-view {
  307. display: flex;
  308. align-items: center;
  309. flex-direction: row;
  310. background-color: #e7e7e7;
  311. height: 30px;
  312. border-radius: 5px;
  313. padding: 0 10px;
  314. flex: 1;
  315. }
  316. .input {
  317. flex: 1;
  318. padding: 0 5px;
  319. height: 24px;
  320. line-height: 24px;
  321. font-size: 16px;
  322. }
  323. .uni-list-cell-navigate {
  324. padding: 0;
  325. }
  326. .uni-media-list-body {
  327. height: auto;
  328. }
  329. .uni-media-list image {
  330. border-radius: 10px;
  331. }
  332. .uni-swipe-action {
  333. /* width: 710upx !important; */
  334. width: 100vw;
  335. }
  336. .btm_border {
  337. position: relative;
  338. display: flex;
  339. flex-direction: row;
  340. justify-content: space-between;
  341. align-items: center;
  342. }
  343. .btm_border::after {
  344. position: absolute;
  345. z-index: 3;
  346. right: 0;
  347. bottom: 0;
  348. left: 115upx;
  349. height: 1px;
  350. content: "";
  351. -webkit-transform: scaleY(0.5);
  352. transform: scaleY(0.5);
  353. background-color: #e7e6ef;
  354. }
  355. .img-icon {
  356. width: 85upx;
  357. height: 85upx;
  358. border-radius: 10upx;
  359. }
  360. .uni-media-list-logo {
  361. height: 85upx;
  362. width: 85upx;
  363. margin-right: 20upx;
  364. }
  365. .title-info {
  366. padding: 0 15px;
  367. }
  368. </style>