123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- <template>
- <view class="page">
- <headerline issearch="true" :showsearch="showsearch" searchtips="请输入搜索内容" @clicksearch='clicksearch' :shownav="false" :title="navtitle" :menuitem="menuitem" :statusbarheight='statusBarHeight' :islogo="false" @tapmenu="tapmenu" rightmenu="true"></headerline>
-
- <block v-if="!showsearch">
- <view class="friends">
-
- <view class="avatar" @tap="href('group.list',{method:0})" >
- <image src="../../static/img/group_add.png" style="height: 40px;width:40px ;"></image>
- </view>
- <view class="showname" style="padding-left: 10px;" @tap="href('group.list',{method:0})">
- 我创建的群组
- </view>
- </view>
-
- <view class="friends" style="margin-top: 5px;" >
-
- <view class="avatar" @tap="href('group.list',{method:1})">
- <image src="../../static/img/mygroup.png" style="height: 40px;width:40px ;"></image>
- </view>
- <view class="showname" style="padding-left: 10px;" @tap="href('group.list',{method:1})">
- 我加入的群组
- </view>
- </view>
-
- <view class="friends" style="margin-top: 5px;" @tap="href('index.backlist',{})" >
-
- <view class="avatar">
- <image src="../../static/img/icon/backlist.png" style="height: 40px;width:40px ;"></image>
- </view>
- <view class="showname" style="padding-left: 10px;">
- 黑名单
- </view>
- </view>
-
- <view style="height: 8px;"></view>
- <view class="pinyin" v-if="kefunum>0">官方</view>
- <block v-if="friends.length>0">
-
- <block v-for="(item, index) in friends" :key="item.id" >
- <view class="friends" v-if=" item.iskefu!=0" @tap="open_detail(item)">
-
- <view class="avatar">
- <image :src="image_cache(item.avatar)"></image>
- </view>
- <view class="showname">
- {{item.nickname}} <view v-if="item.iskefu==1" class="btn_green">客服</view>
- <view v-if="item.iskefu==2" class="btn_blue">官方</view>
- <view v-if="item.iskefu==3" class="btn_green">上级</view>
- </view>
- </view>
-
- </block>
- <block v-for="(item1, index1) in pinyin" :key="item1" >
- <block v-if="ispinyin(item1)">
- <view class="pinyin" :id="'char_'+item1">{{item1}}</view>
- <block v-for="(item, index) in friends" :key="item.id" >
- <view class="friends" v-if="item.pinyin.substr(0,1).toUpperCase()==item1 && item.iskefu==0" @tap="open_detail(item)">
-
- <view class="avatar">
- <image :src="image_cache(item.avatar)"></image>
- </view>
- <view class="showname">
- {{item.nickname}} <view v-if="item.iskefu==1" class="btn_green">客服</view>
- <view v-if="item.iskefu==2" class="btn_blue">官方</view>
- <view v-if="item.iskefu==3" class="btn_green">上级</view>
- </view>
- </view>
-
- </block>
- </block>
-
- </block>
- <view class="nodata" >
- {{friends.length}}位好友
- </view>
- <view class="pinyin_right">
- <block v-for="(item1, index1) in pinyin" :key="index1" >
- <view @tap="gotochar(item1)" :class="{'active':item1==char_select}">{{item1}}</view>
- </block>
- </view>
- </block>
- <view v-else class="nodata" >您还没有添加任何好友 </view>
-
-
-
- </block>
-
- <yk-authpup ref="authpupCAMERA" type="top" @changeAuth="changeAuth"
- permissionID="CAMERA"></yk-authpup>
- </view>
- </template>
- <script>
- import ykAuthpup from "@/components/yk-authpup/yk-authpup";
- import scode from "../../library/scode.js"
- import api from "../../library/index.js"
- import chat from "../../library/chat.js"
- import http from "../../library/http.js"
- import message from "../../library/message.js"
- import action from "../../library/action.js"
- import headerline from '../../components/header.vue'
-
- var windowHeight= uni.getSystemInfoSync().windowHeight;
- var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
- var contenttop=statusBarHeight+45;
- var conentheight=windowHeight-contenttop;
- var lottHeight= conentheight-30;
- var lottTop= contenttop + 30;
- export default {
- components: {
- headerline,
- ykAuthpup
- },
- data() {
- return {
- statusBarHeight: statusBarHeight+ 'px',
- contenttop:contenttop+'px',
- contentheight:conentheight+'px',
- lottHeight:lottHeight+'px',
- lottTop:lottTop+'px',
- shownav:false,
- navtitle:'通信录',
-
- user:uni.getStorageSync('userInfo'),
- showsearch:false,
- friends:uni.getStorageSync(uni.getStorageSync('access_token')+'_frienddata'),
- pinyin:[],
- char_select:false,
- };
- },
- methods:{
-
- friendlist(){
- this.friends = uni.getStorageSync(uni.getStorageSync('access_token')+'_frienddata')
- this.setfrriends_data();
-
- http.setWait(false).get('user.php?act=getMyFriend',{userid:uni.getStorageSync('access_token')}).then(res=>{
-
- //console.log(res.data.length)
- this.friends=res.data;
- // this.friends = this.friends.filter(item => {
- // return item.id
- // })
- uni.setStorageSync(uni.getStorageSync('access_token')+'_frienddata',res.data);
- this.setfrriends_data();
- })
-
- },
- setfrriends_data(){
- this.kefunum=0;
- for(var i=0;i<this.friends.length;i++){
- if(this.friends[i].iskefu>0) this.kefunum++;
- }
- },
-
- pinyin_init(){
- var py="ABCDEFGHIJKLMNOPQRSTUVWXYZ#";
- var pinyin=[];
- for(var i=0;i<py.length;i++){
- pinyin.push(py[i]);
- }
- this.pinyin=pinyin;
- },
- ispinyin(char){
- for(var i=0;i<this.friends.length;i++){
- var pinyin=this.friends[i]['pinyin'];
-
- if(pinyin.substr(0,1).toUpperCase()==char.toUpperCase() && this.friends[i]['iskefu']<1) return true;
- }
- return false;
- },
- gotochar(char){
- this.char_select=char;
- uni.createSelectorQuery().select('#char_' + char).boundingClientRect(data=>{//目标节点
- uni.createSelectorQuery().select('.page' ).boundingClientRect((res)=>{//最外层盒子节点
-
- uni.pageScrollTo({
- duration: 0,//过渡时间必须为0,否则运行到手机会报错
- scrollTop: data.top - res.top - 45- statusBarHeight//滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离(如res.top - data.top)
- })
- }).exec()
- }).exec()
- },
- href(path,opts){
-
- if(!opts || opts==undefined || opts == null) opts={};
- this.$jump(path,opts);
-
- },
- open_detail(item){
-
- this.$jump('friend.detail',{id:item.id});
- },
- clicksearch(e){
- this.showsearch=e;
- },
-
- tapmenu(num){
- console.log(num,'num')
- if(this.$action.loginTips('未登录用户,无法完成此操作','/pages/game/index') ==false) return false;
- if(this.$action.check_userlock()==false) return false;
-
- if(num==0){
-
- if(this.user.nickname=='' || this.user.nickname==this.user.name){
- this.$action.profileTips('未设置昵称,不能创建群','/pages/group/create') ;
- return false;
- }
- else
- this.$jump('group.create');
- }
- else if(num==1){
- this.$jump('group.list',{method:0});
- }
- else if(num==2){
- this.$jump('group.list',{method:1});
- }
- else if(num==3){
- this.$jump('mine.note');
- }
- else if(num==4){
- if(plus.os.name == 'Android') {
- return this.$refs['authpupCAMERA'].open()
- }else {
- return uni.scanCode({
- success(res) {
- scode.getScode(res)
- },
- fail(e) {
- console.log(JSON.stringify(e));
- console.log('扫码失败')
- }
- });
- }
-
- }
- },
- changeAuth() {
- uni.scanCode({
- success(res) {
- scode.getScode(res)
- },
- fail(e) {
- console.log(JSON.stringify(e));
- console.log('扫码失败')
- }
- });
- },
- setrightmenu(){
- var action=[
-
- {
- title: '新建群组',
- icon: 'plus'
- },
- {
- title: '创建的群',
- icon: 'personadd'
- },
- {
- title: '加入的群',
- icon: 'person'
- },
-
- // #ifdef APP-PLUS
- {
- title: '通知设置',
- icon: 'gear'
- },
- {
- title: '扫一扫',
- icon: 'scan'
- },
- // #endif
- ]
- this.menuitem=action;
- },
-
-
- },
- onShow() {
- uni.hideKeyboard();
- var userid=parseInt(uni.getStorageSync('access_token'));
- if(userid>0) {
- this.friendlist();
-
- }else{
-
- uni.setStorageSync('gourl','/pages/contact/index');
-
- this.$jump('login.index');
- }
- },
- onLoad() {
- this.pinyin_init();
- this.setrightmenu();
- uni.$on('toChat',message=>{
- //console.log('index')
- this.$action.toChat(message);
- })
- }
- }
- </script>
- <style lang="scss">
- .btn_yellow{
- background-color: yellow;
- color: #000;
- font-size: 12px;
- display: inline-block;
- height:18px;
- line-height: 18px;
- padding: 0px 5px;
- border-radius: 5px;
- text-align: center;
- margin: 0px 2px;
- }
- .btn_green{
- background-color: #0aad6c;
- color: #fff;font-size: 12px;
- display: inline-block;
- height: 18px;
- line-height: 18px;
- padding: 0px 5px;
- border-radius: 5px;
- text-align: center;
-
- margin: 0px 2px;
- }
- .btn_blue{
- background-color: #2319dc;
- color: #fff;font-size: 12px;
- display: inline-block;
- height: 18px;
- line-height: 18px;
- padding: 0px 5px;
- border-radius: 5px;
- text-align: center;
- margin: 0px 2px;
- }
-
- .btn_grey{
- background-color: #ddd;
- color: #000;font-size: 12px;
- display: inline-block;
- height: 18px;
- line-height: 18px;
- padding: 0px 5px;
- border-radius: 5px;
- text-align: center;
- margin: 0px 2px;
- }
- .nodata{
- height: 35px;
- line-height: 35px;
- color: #666;
- font-size: 12px;
- text-align: center;
- }
- .pinyin{
- font-size: 14px;
- height: 25px;
- line-height: 25px;
- width: calc(100% - 20px);
- background-color:#eee;
- padding:0px 10px;
- margin-top: 5px;
- }
- .istop{
- background-color: #fdfdfd;
- }
- .pinyin_right{
- position: fixed;
- right: 7px;
- top:100px;
- height: auto;
- width: 18px;
- line-height: 20px;
- text-align: center;
- font-size: 12px;
- color: #333;
- min-height: 400px;
- }
- .pinyin_right view{
- height: 18px;
- line-height: 18px;
- text-align: center;
- }
- .pinyin_right view.active{
- background-color: #3388ff;
- border-radius: 50%;
- color: #fff;
- }
- .friends{
- padding: 5px 0px;
-
- height: 35px;
- line-height: 35px;
- display: table;
- table-layout: fixed;
- width: calc(100% - 0px);
-
- margin-bottom: 1px;
- }
- .friends .avatar{
- display: table-cell;
- width: 60px;
- text-align: center;
- }
- .friends .avatar image{
- height: 35px;
- width: 35px;
- border-radius: 5px;;
- vertical-align: middle;
- }
- .friends .showname {
- text-align:left;
- display: table-cell;
- font-size: 16px;
-
- color: #333;
- line-height: 35px;;
- vertical-align: middle;
- margin: 0px 0px;
- padding: 0px 0px;
- border-bottom: 1upx #EFEFEF solid;
- }
- </style>
|