sendall.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view class="page">
  3. <view class="checkall" @click="checkall()">全选</view>
  4. <!-- <view class="recurrence" @click="goPath('../push/circle')"><返回</view> -->
  5. <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight + 'px'}">
  6. <uni-search-bar ref="searchBar2" placeholder="搜索好友" :show="false" @confirm="search" @search="search">
  7. </uni-search-bar>
  8. <view class="uni-list">
  9. <block>
  10. <view class="header" v-if="0">
  11. <navigator :url="'phone-search'" hover-class="none" class="input-view">
  12. <uni-icon type="search" size="22" color="#666666"></uni-icon>
  13. <input class="input" type="text" placeholder="搜索我的朋友" :disabled="true" />
  14. </navigator>
  15. </view>
  16. <uni-list>
  17. <uni-list-item title="标签" :show-arrow="false"
  18. thumb="../../static/theme/default/friend/label.png" @click="goPath('')" v-if="0" />
  19. <uni-list-item title="小程序" :show-arrow="false"
  20. thumb="../../static/theme/default/friend/program.png" @click="goPath('')" v-if="0" />
  21. </uni-list>
  22. </block>
  23. <checkbox-group @change="checkboxGroupChange">
  24. <block v-for="(list, key) in list_data" :key="key">
  25. <view class="uni-list-cell-divider" :id="list.letter">
  26. {{list.letter}}
  27. </view>
  28. <view class="uni-list-cell" hover-class="none"
  29. :class="list.data.length -1 == index ? 'uni-list-cell-last' : ''"
  30. v-for="(item,index) in list.data" :key="isKey(key,index)">
  31. <uni-data-checkbox v-model="value" />
  32. <uni-swipe-action :options="[ {text: '备注'} ]" @tap="swipeAction(item.user_id + '')">
  33. <view class="uni-media-list">
  34. <label style="display: flex;flex-direction: row;font-size: 28upx;">
  35. <checkbox :checked="item.checked" :value="item.list_id+''" />
  36. </label>
  37. <view class="uni-media-list-logo">
  38. <image :src="photo(item.photo+'')" :lazy-load="true"
  39. style="border-radius: 10px;" />
  40. </view>
  41. <view class="uni-media-list-body">
  42. <view class="uni-list-cell-navigate">{{item.name}}</view>
  43. </view>
  44. </view>
  45. </uni-swipe-action>
  46. </view>
  47. </block>
  48. </checkbox-group>
  49. </view>
  50. </scroll-view>
  51. <view class="uni-indexed-list-bar" :class="touchmove ? 'active' : ''" @touchstart="touchStart"
  52. @touchmove.stop.prevent="touchMove" @touchend="touchEnd" @touchcancel="touchCancel"
  53. :style="{height:winHeight + 'px'}">
  54. <text v-for="(list,key) in key_data" :key="key" class="uni-indexed-list-text"
  55. :class="touchmoveIndex == key ? 'active' : ''"
  56. :style="{height:itemHeight + 'px',lineHeight:itemHeight + 'px'}">
  57. {{list}}
  58. </text>
  59. </view>
  60. <view class="uni-indexed-list-alert" v-if="touchmove">
  61. {{key_data[touchmoveIndex]}}
  62. </view>
  63. <view class="found-list">
  64. <view class="new-built" @click="goPath('../chat/messagemore')">新建群发</view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
  70. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  71. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  72. import uniSwipeAction from '../../components/uni-ui/uni-swipe-action/uni-swipe-action.vue'
  73. import _get from '../../common/_get';
  74. import _hook from '../../common/_hook';
  75. import _data from '../../common/_data';
  76. import _action from '../../common/_action';
  77. import uniSearchBar from '@/components/mehaotian-search/mehaotian-search.vue'
  78. export default {
  79. components: {
  80. uniIcon,
  81. uniList,
  82. uniListItem,
  83. uniSwipeAction,
  84. uniSearchBar
  85. },
  86. data() {
  87. return {
  88. ids: [],
  89. list_data: [],
  90. new_friend_tips: 0,
  91. new_group_tips: 0,
  92. title: 'grid',
  93. touchmove: false,
  94. touchmoveIndex: -1,
  95. itemHeight: 0,
  96. winHeight: 0,
  97. scrollViewId: "A",
  98. titleHeight: 0,
  99. search_list: [],
  100. keyword: '',
  101. key_data: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  102. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
  103. ]
  104. }
  105. },
  106. onShow() {
  107. _hook.routeTabBarHook();
  108. let _this = this,
  109. frien_list = _data.localData('frien_list'),
  110. tips_num = _data.data('new_friend_tips_num'),
  111. tips_group_apply = _data.data('new_group_tips_num');
  112. /** 监听最新数据 */
  113. uni.$on('data_friend_list', function(data) {
  114. _this.list_data = data;
  115. _this.search_list = data;
  116. });
  117. /** 监听新的朋友提示 */
  118. uni.$on('data_new_friend_tips', function(data) {
  119. _this.new_friend_tips = data;
  120. console.log(_this.new_friend_tips);
  121. });
  122. /** 监听群认证消息 */
  123. uni.$on('data_new_group_apply_tips', function(data) {
  124. _this.new_group_tips = data;
  125. });
  126. _this.new_friend_tips = tips_num;
  127. _this.new_group_tips = tips_group_apply;
  128. /** 加载本地缓存数据,让页面秒速渲染出来 */
  129. if (frien_list) {
  130. _this.list_data = frien_list;
  131. } else {
  132. _get.getFriendList();
  133. }
  134. },
  135. onLoad() {
  136. let winHeight = uni.getSystemInfoSync().windowHeight;
  137. this.itemHeight = winHeight / 26;
  138. console.log(winHeight)
  139. this.winHeight = winHeight;
  140. },
  141. onHide() {
  142. uni.$off('data_friend_list');
  143. uni.$off('data_new_friend_tips');
  144. uni.$off('data_new_group_apply_tips');
  145. //清空search框
  146. if (this.keyword) {
  147. this.$refs.searchBar2.clear();
  148. this.list_data = this.search_list;
  149. }
  150. },
  151. computed: {
  152. staticPhoto() {
  153. return _data.staticPhoto();
  154. },
  155. },
  156. methods: {
  157. onmsg() {
  158. },
  159. checkall() {
  160. var that = this
  161. console.log(this.list_data)
  162. // Object.keys(this.list_data).forEach(function(key){
  163. // this.list_data[key].data.map((res,index)=>{
  164. // this.list_data[key].data[index].checked = true
  165. // })
  166. // })
  167. var ids = [];
  168. for (var i in this.list_data) {
  169. console.log(this.list_data[i]);
  170. if (this.list_data[i].data) {
  171. for (var j in this.list_data[i]['data']) {
  172. this.list_data[i]['data'][j].checked = true;
  173. ids.push(this.list_data[i]['data'][j].list_id);
  174. }
  175. }
  176. }
  177. this.ids = ids;
  178. console.log(this.ids)
  179. },
  180. goPath(path) {
  181. if (path && this.ids.length > 0) {
  182. uni.navigateTo({
  183. url: path + '?ids=' + this.ids.join(',')
  184. });
  185. }
  186. },
  187. checkboxGroupChange(e) {
  188. console.log(e.detail.value)
  189. this.ids = e.detail.value;
  190. },
  191. search(keyword) {
  192. this.keyword = keyword.trim();
  193. let _this = this;
  194. if (!keyword) {
  195. console.log(1111)
  196. console.log(_this.search_list)
  197. _this.list_data = _this.search_list;
  198. return true;
  199. }
  200. _get.searchFriends({
  201. 'keyword': keyword
  202. }, function(data) {
  203. _this.list_data = data.data;
  204. })
  205. },
  206. photo(path) {
  207. return this.staticPhoto + path;
  208. },
  209. swipeAction(user_id) {
  210. uni.navigateTo({
  211. url: './remarks?user_id=' + user_id,
  212. animationType: 'slide-in-bottom',
  213. });
  214. },
  215. goDetails(user_id) {
  216. if (user_id) {
  217. uni.navigateTo({
  218. url: '../details/index?user_id=' + user_id,
  219. });
  220. }
  221. },
  222. isKey(key, index) {
  223. return key + '' + index;
  224. },
  225. touchStart(e) {
  226. this.touchmove = true;
  227. let pageY = e.touches[0].pageY;
  228. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  229. console.log("index", index)
  230. let item = this.list_data[index];
  231. console.log("list_data", this.list_data)
  232. console.log("item", item)
  233. if (item) {
  234. this.scrollViewId = item.letter;
  235. }
  236. this.touchmoveIndex = index;
  237. },
  238. touchMove(e) {
  239. let pageY = e.touches[0].pageY;
  240. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  241. let item = this.list_data[index];
  242. if (item) {
  243. this.scrollViewId = item.letter;
  244. this.touchmoveIndex = index;
  245. }
  246. },
  247. touchEnd() {
  248. this.touchmove = false;
  249. //this.touchmoveIndex = -1;
  250. },
  251. touchCancel() {
  252. this.touchmove = false;
  253. //this.touchmoveIndex = -1;
  254. },
  255. },
  256. watch: {
  257. },
  258. onNavigationBarButtonTap(e) {
  259. let _path = e.index ? './phone-search' : './add';
  260. uni.navigateTo({
  261. url: _path,
  262. });
  263. }
  264. }
  265. </script>
  266. <style scoped>
  267. .checkall {
  268. position: absolute;
  269. bottom: 100rpx;
  270. right: 50rpx;
  271. z-index: 999999999;
  272. width: 80rpx;
  273. height: 80rpx;
  274. background-color: #2da2fd;
  275. color: white;
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. color: white;
  280. border-radius: 50%;
  281. }
  282. .page {
  283. display: flex;
  284. flex-direction: row;
  285. }
  286. .search .content {
  287. padding-left: 20upx;
  288. height: 60upx;
  289. }
  290. .scrollList {
  291. flex: 1;
  292. height: 100vh;
  293. }
  294. .uni-indexed-list-bar {
  295. width: 40upx;
  296. height: 100vh;
  297. background-color: #ffffff;
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .uni-indexed-list-bar.active {
  302. /* background-color: rgb(200, 200, 200); */
  303. }
  304. .uni-indexed-list-text {
  305. font-size: 22upx;
  306. text-align: center;
  307. }
  308. .uni-indexed-list-bar.active .uni-indexed-list-text {
  309. color: #333;
  310. }
  311. .uni-indexed-list-text.active,
  312. .uni-indexed-list-bar.active .uni-indexed-list-text.active {
  313. color: #2da2fd;
  314. }
  315. .uni-indexed-list-alert {
  316. position: absolute;
  317. z-index: 20;
  318. width: 160upx;
  319. height: 160upx;
  320. left: 50%;
  321. top: 50%;
  322. margin-left: -80upx;
  323. margin-top: -80upx;
  324. border-radius: 80upx;
  325. text-align: center;
  326. line-height: 160upx;
  327. font-size: 70upx;
  328. color: #fff;
  329. background-color: rgba(0, 0, 0, 0.5);
  330. }
  331. .header {
  332. display: flex;
  333. flex-direction: row;
  334. padding: 10px 15px;
  335. align-items: center;
  336. }
  337. .input-view {
  338. display: flex;
  339. align-items: center;
  340. flex-direction: row;
  341. background-color: #e7e7e7;
  342. height: 30px;
  343. border-radius: 5px;
  344. padding: 0 10px;
  345. flex: 1;
  346. }
  347. .input {
  348. flex: 1;
  349. padding: 0 5px;
  350. height: 24px;
  351. line-height: 24px;
  352. font-size: 16px;
  353. }
  354. .uni-list-cell-navigate {
  355. padding: 0;
  356. }
  357. .uni-media-list-body {
  358. height: auto;
  359. }
  360. .uni-media-list image {
  361. border-radius: 10px;
  362. }
  363. .uni-swipe-action {
  364. width: 710upx !important;
  365. }
  366. .btm_border {
  367. position: relative;
  368. display: flex;
  369. flex-direction: row;
  370. justify-content: space-between;
  371. align-items: center;
  372. }
  373. .btm_border::after {
  374. position: absolute;
  375. z-index: 3;
  376. right: 0;
  377. bottom: 0;
  378. left: 115upx;
  379. height: 1px;
  380. content: "";
  381. -webkit-transform: scaleY(0.5);
  382. transform: scaleY(0.5);
  383. background-color: #e7e6ef;
  384. }
  385. .img-icon {
  386. width: 85upx;
  387. height: 85upx;
  388. border-radius: 10upx;
  389. }
  390. .uni-media-list-logo {
  391. height: 85upx;
  392. width: 85upx;
  393. margin-right: 20upx;
  394. }
  395. .red_num {
  396. background-color: #f43530;
  397. width: 35upx;
  398. border-radius: 18upx;
  399. text-align: center;
  400. height: 35upx;
  401. line-height: 35upx;
  402. color: #ffffff;
  403. font-size: 23upx !important;
  404. }
  405. .found-list {
  406. width: 230px;
  407. height: 40px;
  408. background: #2da2fd;
  409. position: absolute;
  410. bottom: 50px;
  411. right: 90px;
  412. border-radius: 20px;
  413. color: #fff;
  414. /* z-index: 999999999; */
  415. }
  416. .new-built {
  417. text-align: center;
  418. line-height: 40px;
  419. }
  420. </style>