123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- <template>
- <view class="page">
- <view class="checkall" @click="checkall()">全选</view>
- <!-- <view class="recurrence" @click="goPath('../push/circle')"><返回</view> -->
- <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight + 'px'}">
- <uni-search-bar ref="searchBar2" placeholder="搜索好友" :show="false" @confirm="search" @search="search">
- </uni-search-bar>
- <view class="uni-list">
- <block>
- <view class="header" v-if="0">
- <navigator :url="'phone-search'" hover-class="none" class="input-view">
- <uni-icon type="search" size="22" color="#666666"></uni-icon>
- <input class="input" type="text" placeholder="搜索我的朋友" :disabled="true" />
- </navigator>
- </view>
- <uni-list>
- <uni-list-item title="标签" :show-arrow="false"
- thumb="../../static/theme/default/friend/label.png" @click="goPath('')" v-if="0" />
- <uni-list-item title="小程序" :show-arrow="false"
- thumb="../../static/theme/default/friend/program.png" @click="goPath('')" v-if="0" />
- </uni-list>
- </block>
- <checkbox-group @change="checkboxGroupChange">
- <block v-for="(list, key) in list_data" :key="key">
- <view class="uni-list-cell-divider" :id="list.letter">
- {{list.letter}}
- </view>
- <view class="uni-list-cell" hover-class="none"
- :class="list.data.length -1 == index ? 'uni-list-cell-last' : ''"
- v-for="(item,index) in list.data" :key="isKey(key,index)">
- <uni-data-checkbox v-model="value" />
- <uni-swipe-action :options="[ {text: '备注'} ]" @tap="swipeAction(item.user_id + '')">
- <view class="uni-media-list">
- <label style="display: flex;flex-direction: row;font-size: 28upx;">
- <checkbox :checked="item.checked" :value="item.list_id+''" />
- </label>
- <view class="uni-media-list-logo">
- <image :src="photo(item.photo+'')" :lazy-load="true"
- style="border-radius: 10px;" />
- </view>
- <view class="uni-media-list-body">
- <view class="uni-list-cell-navigate">{{item.name}}</view>
- </view>
- </view>
- </uni-swipe-action>
- </view>
- </block>
- </checkbox-group>
- </view>
- </scroll-view>
- <view class="uni-indexed-list-bar" :class="touchmove ? 'active' : ''" @touchstart="touchStart"
- @touchmove.stop.prevent="touchMove" @touchend="touchEnd" @touchcancel="touchCancel"
- :style="{height:winHeight + 'px'}">
- <text v-for="(list,key) in key_data" :key="key" class="uni-indexed-list-text"
- :class="touchmoveIndex == key ? 'active' : ''"
- :style="{height:itemHeight + 'px',lineHeight:itemHeight + 'px'}">
- {{list}}
- </text>
- </view>
- <view class="uni-indexed-list-alert" v-if="touchmove">
- {{key_data[touchmoveIndex]}}
- </view>
- <view class="found-list">
- <view class="new-built" @click="goPath('../chat/messagemore')">新建群发</view>
- </view>
- </view>
- </template>
- <script>
- import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
- import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
- import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
- import uniSwipeAction from '../../components/uni-ui/uni-swipe-action/uni-swipe-action.vue'
- import _get from '../../common/_get';
- import _hook from '../../common/_hook';
- import _data from '../../common/_data';
- import _action from '../../common/_action';
- import uniSearchBar from '@/components/mehaotian-search/mehaotian-search.vue'
- export default {
- components: {
- uniIcon,
- uniList,
- uniListItem,
- uniSwipeAction,
- uniSearchBar
- },
- data() {
- return {
- ids: [],
- list_data: [],
- new_friend_tips: 0,
- new_group_tips: 0,
- title: 'grid',
- touchmove: false,
- touchmoveIndex: -1,
- itemHeight: 0,
- winHeight: 0,
- scrollViewId: "A",
- titleHeight: 0,
- search_list: [],
- keyword: '',
- 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'
- ]
- }
- },
- onShow() {
- _hook.routeTabBarHook();
- let _this = this,
- frien_list = _data.localData('frien_list'),
- tips_num = _data.data('new_friend_tips_num'),
- tips_group_apply = _data.data('new_group_tips_num');
- /** 监听最新数据 */
- uni.$on('data_friend_list', function(data) {
- _this.list_data = data;
- _this.search_list = data;
- });
- /** 监听新的朋友提示 */
- uni.$on('data_new_friend_tips', function(data) {
- _this.new_friend_tips = data;
- console.log(_this.new_friend_tips);
- });
- /** 监听群认证消息 */
- uni.$on('data_new_group_apply_tips', function(data) {
- _this.new_group_tips = data;
- });
- _this.new_friend_tips = tips_num;
- _this.new_group_tips = tips_group_apply;
- /** 加载本地缓存数据,让页面秒速渲染出来 */
- if (frien_list) {
- _this.list_data = frien_list;
- } else {
- _get.getFriendList();
- }
- },
- onLoad() {
- let winHeight = uni.getSystemInfoSync().windowHeight;
- this.itemHeight = winHeight / 26;
- console.log(winHeight)
- this.winHeight = winHeight;
- },
- onHide() {
- uni.$off('data_friend_list');
- uni.$off('data_new_friend_tips');
- uni.$off('data_new_group_apply_tips');
- //清空search框
- if (this.keyword) {
- this.$refs.searchBar2.clear();
- this.list_data = this.search_list;
- }
- },
- computed: {
- staticPhoto() {
- return _data.staticPhoto();
- },
- },
- methods: {
- onmsg() {
- },
- checkall() {
- var that = this
- console.log(this.list_data)
- // Object.keys(this.list_data).forEach(function(key){
- // this.list_data[key].data.map((res,index)=>{
- // this.list_data[key].data[index].checked = true
- // })
- // })
- var ids = [];
- for (var i in this.list_data) {
- console.log(this.list_data[i]);
- if (this.list_data[i].data) {
- for (var j in this.list_data[i]['data']) {
- this.list_data[i]['data'][j].checked = true;
- ids.push(this.list_data[i]['data'][j].list_id);
- }
- }
- }
- this.ids = ids;
- console.log(this.ids)
- },
- goPath(path) {
- if (path && this.ids.length > 0) {
- uni.navigateTo({
- url: path + '?ids=' + this.ids.join(',')
- });
- }
- },
- checkboxGroupChange(e) {
- console.log(e.detail.value)
- this.ids = e.detail.value;
- },
- search(keyword) {
- this.keyword = keyword.trim();
- let _this = this;
- if (!keyword) {
- console.log(1111)
- console.log(_this.search_list)
- _this.list_data = _this.search_list;
- return true;
- }
- _get.searchFriends({
- 'keyword': keyword
- }, function(data) {
- _this.list_data = data.data;
- })
- },
- photo(path) {
- return this.staticPhoto + path;
- },
- swipeAction(user_id) {
- uni.navigateTo({
- url: './remarks?user_id=' + user_id,
- animationType: 'slide-in-bottom',
- });
- },
- goDetails(user_id) {
- if (user_id) {
- uni.navigateTo({
- url: '../details/index?user_id=' + user_id,
- });
- }
- },
- isKey(key, index) {
- return key + '' + index;
- },
- touchStart(e) {
- this.touchmove = true;
- let pageY = e.touches[0].pageY;
- let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
- console.log("index", index)
- let item = this.list_data[index];
- console.log("list_data", this.list_data)
- console.log("item", item)
- if (item) {
- this.scrollViewId = item.letter;
- }
- this.touchmoveIndex = index;
- },
- touchMove(e) {
- let pageY = e.touches[0].pageY;
- let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
- let item = this.list_data[index];
- if (item) {
- this.scrollViewId = item.letter;
- this.touchmoveIndex = index;
- }
- },
- touchEnd() {
- this.touchmove = false;
- //this.touchmoveIndex = -1;
- },
- touchCancel() {
- this.touchmove = false;
- //this.touchmoveIndex = -1;
- },
- },
- watch: {
- },
- onNavigationBarButtonTap(e) {
- let _path = e.index ? './phone-search' : './add';
- uni.navigateTo({
- url: _path,
- });
- }
- }
- </script>
- <style scoped>
- .checkall {
- position: absolute;
- bottom: 100rpx;
- right: 50rpx;
- z-index: 999999999;
- width: 80rpx;
- height: 80rpx;
- background-color: #2da2fd;
- color: white;
- display: flex;
- justify-content: center;
- align-items: center;
- color: white;
- border-radius: 50%;
- }
- .page {
- display: flex;
- flex-direction: row;
- }
- .search .content {
- padding-left: 20upx;
- height: 60upx;
- }
- .scrollList {
- flex: 1;
- height: 100vh;
- }
- .uni-indexed-list-bar {
- width: 40upx;
- height: 100vh;
- background-color: #ffffff;
- display: flex;
- flex-direction: column;
- }
- .uni-indexed-list-bar.active {
- /* background-color: rgb(200, 200, 200); */
- }
- .uni-indexed-list-text {
- font-size: 22upx;
- text-align: center;
- }
- .uni-indexed-list-bar.active .uni-indexed-list-text {
- color: #333;
- }
- .uni-indexed-list-text.active,
- .uni-indexed-list-bar.active .uni-indexed-list-text.active {
- color: #2da2fd;
- }
- .uni-indexed-list-alert {
- position: absolute;
- z-index: 20;
- width: 160upx;
- height: 160upx;
- left: 50%;
- top: 50%;
- margin-left: -80upx;
- margin-top: -80upx;
- border-radius: 80upx;
- text-align: center;
- line-height: 160upx;
- font-size: 70upx;
- color: #fff;
- background-color: rgba(0, 0, 0, 0.5);
- }
- .header {
- display: flex;
- flex-direction: row;
- padding: 10px 15px;
- align-items: center;
- }
- .input-view {
- display: flex;
- align-items: center;
- flex-direction: row;
- background-color: #e7e7e7;
- height: 30px;
- border-radius: 5px;
- padding: 0 10px;
- flex: 1;
- }
- .input {
- flex: 1;
- padding: 0 5px;
- height: 24px;
- line-height: 24px;
- font-size: 16px;
- }
- .uni-list-cell-navigate {
- padding: 0;
- }
- .uni-media-list-body {
- height: auto;
- }
- .uni-media-list image {
- border-radius: 10px;
- }
- .uni-swipe-action {
- width: 710upx !important;
- }
- .btm_border {
- position: relative;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- align-items: center;
- }
- .btm_border::after {
- position: absolute;
- z-index: 3;
- right: 0;
- bottom: 0;
- left: 115upx;
- height: 1px;
- content: "";
- -webkit-transform: scaleY(0.5);
- transform: scaleY(0.5);
- background-color: #e7e6ef;
- }
- .img-icon {
- width: 85upx;
- height: 85upx;
- border-radius: 10upx;
- }
- .uni-media-list-logo {
- height: 85upx;
- width: 85upx;
- margin-right: 20upx;
- }
- .red_num {
- background-color: #f43530;
- width: 35upx;
- border-radius: 18upx;
- text-align: center;
- height: 35upx;
- line-height: 35upx;
- color: #ffffff;
- font-size: 23upx !important;
- }
- .found-list {
- width: 230px;
- height: 40px;
- background: #2da2fd;
- position: absolute;
- bottom: 50px;
- right: 90px;
- border-radius: 20px;
- color: #fff;
- /* z-index: 999999999; */
- }
- .new-built {
- text-align: center;
- line-height: 40px;
- }
- </style>
|