liuyg
2021-07-03 9a7d014d8e664042686368ebd18b5daa78e0b6ea
pages/groupChat/groupChat.vue
@@ -3,17 +3,37 @@
   <view class="work">
      <!-- 自定义顶部导航栏 -->
      <!-- <navBarTop :title="'聊天室'"></navBarTop> -->
      <view class="main">
         <div>
            <div class="m-main">
               <!-- <view class="inTitle">{{Task}}</view> -->
               <view class="inTmain">
                  <contacts v-for="(item,index) in dataListP" :key="index" :Pdata="item" :fromW="fromW"
                     @refreshTask="refreshTask"></contacts>
               </view>
            </div>
         </div>
      <view class="tab">
         <u-tabs :list="list" :is-scroll="false" :current="current" active-color="#14B9C8" inactive-color="#595959"
            height="100" @change="change"></u-tabs>
      </view>
      <swiper id="swiperBox" :style="{ height: swiperHeight + 'px' }" :current="current" @change="tabsChange">
         <swiper-item class="swiper-item" v-for="(item, indexs) in list" :key="indexs">
            <view v-if="indexs == 0" class="main">
               <div>
                  <div class="m-main">
                     <!-- <view class="inTitle">{{Task}}</view> -->
                     <view class="inTmain">
                        <contacts v-for="(item,index) in dataListP" :key="index" :Pdata="item" :fromW="indexs"
                           @refreshTask="refreshTask"></contacts>
                     </view>
                  </div>
               </div>
            </view>
            <view v-if="indexs == 1" class="main">
               <div>
                  <div class="m-main">
                     <!-- <view class="inTitle">{{Task}}</view> -->
                     <view class="inTmain">
                        <contacts v-for="(item,index) in dataListQZ" :key="index" :Pdata="item" :fromW="indexs"
                           @refreshTask="refreshTask"></contacts>
                     </view>
                  </div>
               </div>
            </view>
         </swiper-item>
      </swiper>
      
   </view>
</template>
@@ -29,12 +49,22 @@
      },
      data() {
         return {
            list: [{
                  name: '正在聊天'
               },
               {
                  name: '群组'
               },
               {
                  name: '通讯录'
               }
            ],
            swiperHeight: 0,
            zhanwei: '', //因为小程序中底部和顶部栏占位置,uniapp中不占位置
            ingsDB: '#00d1ff 2px solid',
            candoDB: '#fff 2px solid',
            Task: '当前已接任务',
            current: 0,
            show: true,
            dataListP: [],
            dataListQZ: [],
            fromW: '',
            onTop: false, //是否吸顶
            rect: '', //页面滚动距离
@@ -48,7 +78,52 @@
            this.beginObj();
            this.ingss();
          },
         onReady() {
            let that = this;
            uni.getSystemInfo({
               success(e) {
                  console.log(e);
                  let {
                     windowWidth,
                     windowHeight,
                     safeArea
                  } = e;
                  const query = uni.createSelectorQuery().in(that);
                  query
                     .select('#swiperBox')
                     .boundingClientRect(data => {
                        that.swiperHeight = safeArea.bottom - data.top;
                     })
                     .exec();
               }
            });
         },
      methods: {
         change(index) {
            this.current = index;
         },
         tabsChange(e) {
            this.current = e.detail.current;
            if(this.current == 1){
               var that = this;
               uni.request({
                  url:"http://s16s652780.51mypc.cn/api/chatgroup/selectList",
                  method:"POST",
                  data:{
                     senderId: WxStorage.get("ids")
                  },
                  success:(res)=> {
                     var resdata = res.data.data;
                     for (var i = 0; i < resdata.length; i++) {
                        if(resdata[i].avatar == null || resdata[i].avatar == ""){
                           resdata[i].avatar = "http://s16s652780.51mypc.cn/img/bg/qunz.png";
                        }
                     }
                     that.dataListQZ = resdata;
                  }
               })
            }
         },
         beginObj() {
            this.titleTop = '2.6rem';
            this.zhanwei = '3rem';
@@ -74,7 +149,6 @@
            this.getdataList(1);
         },
         getdataList(need) {
            this.fromW = need;
            var that = this;
            uni.request({
               url:"http://s16s652780.51mypc.cn/api/chat-records/getChatListPage",