group_list.vue 8.6 KB

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