智慧保安互联网APP
liuyg
2021-08-03 7df5dc2411b541492e0263ad24b4f5ef9ca092dd
pages/dispatch/look.vue
@@ -2,38 +2,50 @@
   <view class="container">
      <u-tabs :list="list" :is-scroll="false" :current="current" active-color="#14B9C8" inactive-color="#595959"
         height="100" @change="change"></u-tabs>
      <u-search v-model="keyword" shape="round" class="u-search" input-align="center" height="70"></u-search>
      <u-search v-model='keyValue' placeholder='请输入指令内容' shape="round" class="u-search" input-align="center"
         height="70" @search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'>
      </u-search>
      <view class="inTmain" v-for="(item,index) in receiveDataList" v-show="current == 0">
         <u-card :title="item.content" @click="goDetail(item)">
            <view class="" slot="body">
               <view>
                  <view style="margin-bottom: 10px;" class="u-body-item-title u-line-2">
                     发送指令人:{{item.sendName}}</view>
      <view v-show="current == 0 && newsList.length > 0">
         <view class="inTmain" v-for="(item,index) in newsList">
            <u-card :title="item.content" @click="goDetail(item)">
               <view class="" slot="body">
                  <view>
                     <view style="margin-bottom: 10px;" class="u-body-item-title u-line-2">
                        发送指令人:{{item.sendName}}</view>
                  </view>
                  <view>
                     <view class="u-body-item-title u-line-2">接受指令人:{{item.receiveName}}</view>
                  </view>
               </view>
               <view>
                  <view class="u-body-item-title u-line-2">接受指令人:{{item.receiveName}}</view>
               </view>
            </view>
            <view class="" slot="foot">
               </u-icon>发送指令时间:{{item.sendTime}}</view>
         </u-card>
               <view class="" slot="foot">
                  </u-icon>发送指令时间:{{item.sendTime}}</view>
            </u-card>
         </view>
         <u-loadmore class='msg' :status="status" />
      </view>
      <view class="inTmain" v-for="(item,index) in issueDataList" v-show="current == 1">
         <u-card :title="item.content" @click="goDetail(item)">
            <view class="" slot="body">
               <view>
                  <view style="margin-bottom: 10px;" class="u-body-item-title u-line-1">
                     发送指令人:{{item.sendName}}</view>
      <view v-show="current == 1 && newsList.length > 0">
         <view class="inTmain" v-for="(item,index) in newsList">
            <u-card :title="item.content" @click="goDetail(item)">
               <view class="" slot="body">
                  <view>
                     <view style="margin-bottom: 10px;" class="u-body-item-title u-line-2">
                        发送指令人:{{item.sendName}}</view>
                  </view>
                  <view>
                     <view class="u-body-item-title u-line-2">接受指令人:{{item.receiveName}}</view>
                  </view>
               </view>
               <view>
                  <view class="u-body-item-title u-line-1">接受指令人:{{item.receiveName}}</view>
               </view>
            </view>
            <view class="" slot="foot">
               </u-icon>发送指令时间:{{item.sendTime}}</view>
         </u-card>
               <view class="" slot="foot">
                  </u-icon>发送指令时间:{{item.sendTime}}</view>
            </u-card>
         </view>
         <u-loadmore class='msg' :status="status" />
      </view>
      <view class="msg" v-show='newsList.length == 0'>
         暂无数据
      </view>
   </view>
@@ -43,8 +55,6 @@
   export default {
      data() {
         return {
            receiveDataList: [],
            issueDataList: [],
            list: [{
                  name: '发送指令'
               },
@@ -53,18 +63,56 @@
               }
            ],
            current: 0,
            keyword: ''
            dataList: [],
            newsList: [],
            status: 'loadmore',
            keyValue: '',
            pagelist: 0,
            flag: true
         };
      },
      onLoad() {},
      onLoad() {
      },
      onReachBottom() {
         var that = this;
         if (that.dataList.length - 1 == that.pagelist && this.status != 'nomore' && that.flag == true) {
            that.newsList.push(that.dataList[that.pagelist]);
            this.status = 'nomore';
            that.flag = false;
            return;
         } else {
            if (that.flag == false) {
               this.status = 'nomore';
               return
            }
            // 后续将改为与后端联动
            this.status = 'loading';
            setTimeout(() => {
               var flag = true;
               for (var i = 0; i < 5; i++) {
                  if (that.pagelist <= that.dataList.length - 2 && flag == true) {
                     that.newsList.push(that.dataList[that.pagelist++])
                     if (that.dataList.length - 1 == that.pagelist) flag == false
                  }
               }
            }, 2000);
         }
      },
      mounted() {
         this.getReceive();
      },
      methods: {
         // 接收
         getReceive() {
            var that = this;
            uni.request({
@@ -76,11 +124,35 @@
               },
               success: (res) => {
                  var resdata = res.data.data.records;
                  that.receiveDataList = resdata;
                  that.pagelist = 0;
                  that.newsList = [];
                  that.flag = true;
                  that.dataList = resdata;
                  var flag = true;
                  for (var i = 0; i < 5; i++) {
                     if (that.pagelist <= that.dataList.length - 2) {
                        that.newsList.push(that.dataList[that.pagelist++]);
                     } else {
                        if (that.dataList.length - 1 == that.pagelist && flag == true) {
                           that.newsList.push(that.dataList[that.pagelist]);
                           flag = false;
                           that.flag = false;
                           this.status = 'nomore';
                        }
                     }
                  }
               }
            });
         },
         // 发送
         getIssue() {
            var that = this;
            uni.request({
@@ -91,8 +163,38 @@
               },
               success: (res) => {
                  var resdata = res.data.data.records;
                  that.issueDataList = resdata;
                  that.pagelist = 0;
                  that.newsList = [];
                  that.flag = true;
                  that.dataList = resdata;
                  var flag = true;
                  for (var i = 0; i < 5; i++) {
                     if (that.pagelist <= that.dataList.length - 2) {
                        that.newsList.push(that.dataList[that.pagelist++]);
                     } else {
                        if (that.dataList.length - 1 == that.pagelist && flag == true) {
                           that.newsList.push(that.dataList[that.pagelist]);
                           flag = false;
                           that.flag = false;
                           this.status = 'nomore';
                        }
                     }
                  }
               }
            });
         },
         goDetail(item) {
            uni.navigateTo({
               url: './lookDetail?detailData=' + JSON.stringify(item)
            });
         },
         change(index) {
@@ -104,10 +206,43 @@
            }
            this.current = index;
         },
         goDetail(item) {
            uni.navigateTo({
               url: './lookDetail?detailData=' + JSON.stringify(item)
            });
         searchValue(value) {
            var that = this;
            var str = value.replace(/\s*/g, "");
            if (str == '') {
               return
            } else {
               that.newsList = [];
               that.dataList.forEach(item => {
                  if (item.content.indexOf(str) != -1) {
                     that.newsList.push(item)
                  }
               })
               that.status = 'nomore';
            }
         },
         clearValue() {
            this.keyValue = ''
            this.newsList = [];
            for (var i = 0; i < this.pagelist; i++) {
               this.newsList.push(this.dataList[i])
            }
            if (this.flag == false) {
               this.newsList.push(this.dataList[this.pagelist]);
            }
         },
         changeValue(value) {
            if (value == '') {
               this.newsList = [];
               for (var i = 0; i < this.pagelist; i++) {
                  this.newsList.push(this.dataList[i])
               }
               if (this.flag == false) {
                  this.newsList.push(this.dataList[this.pagelist]);
               }
            }
         }
      }
   };
@@ -138,4 +273,11 @@
   }
   .inTmain {}
   .msg {
      height: 72rpx;
      line-height: 72rpx;
      text-align: center;
      color: #999;
   }
</style>