sendallsome.vue 12 KB

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