| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <template>
- <view class="">
- <view class="status_bar"></view>
- <view class="" style="position: relative;top: 64px;">
- <view style="position: fixed;z-index: 100;">
- <uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft" left-icon="back" left-text="返回" right-icon="search"
- title="测报系统"></uni-nav-bar>
- <view>
- <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/cb/banner.jpg'" mode="widthFix"></image>
- </view>
- <view class="tab-box">
- <view v-for="(item,index) in equipArr" :key="item.type" v-if="item.tf" @click="tabClick(index)" :class="['tab-item',active==index?'active':'']">
- <text>{{item.name}}</text>
- <text class="bottom-line"></text>
- </view>
- </view>
- </view>
- <view class="" style="position: absolute;top: 180px;width: 100%;">
- <view class="content">
- <template v-for="(item,index) in equipArr[active].list">
- <equipItem @click.native="itemClick(item)" v-bind:item="item" :key="index">
- <view class="date">
- <p>设备名称:{{item.device_name==""?"无":item.device_name}}</p>
- <p>最新上报时间:{{item.addtime|timeFormat}}</p>
- </view>
- </equipItem>
- </template>
- </view>
- </view>
- </view>
- <view class="top" v-if="isTop" @click="top">
- <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
- </view>
- </view>
- </template>
- <script>
- import equipItem from "../../../components/equip-item/equip-item"
- import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue"
- export default {
- data() {
- return {
- active: 0, //默认选中虫情测报
- equipArr: [{
- name: '虫情测报',
- type: 3, //3虫情测报灯 7孢子仪 4智能性诱
- list: [],
- pageIndex: 1,
- tf:false,
- }, {
- name: '孢子仪',
- type: 7, //3虫情测报灯 7孢子仪 4智能性诱
- list: [],
- pageIndex: 1,
- tf:false,
- }, {
- name: '性诱测报',
- type: 4, //3虫情测报灯 7孢子仪 4智能性诱
- list: [],
- pageIndex: 1,
- tf:false,
- },
- {
- name: '性诱2.0',
- type: 10, //3虫情测报灯 7孢子仪 4智能性诱 性诱2.0
- list: [],
- pageIndex: 1,
- tf:false
- }
- ],
- device_id: '3', //筛选的设备id
- isTop: false,
- }
- },
- onLoad() {
- uni.getStorage({
- key:"jurisdiction",
- success:(res)=>{
- let items = JSON.parse(res.data).filter((item)=>{
- return item.purview_name == "测报系统"
- })
- var arr = items[0].children
- for(var i =0;i<arr.length;i++){
- switch (arr[i].purview_name){
- case "虫情测报灯":
- this.equipArr[0].tf = true
- this.getEquipList(0)
- break
- case "性诱测报":
- this.equipArr[2].tf = true
- this.getEquipList(2)
- break
- case "孢子仪":
- this.equipArr[1].tf = true
- this.getEquipList(1)
- break
- case "性诱2.0":
- this.equipArr[3].tf = true
- this.getxyEquipList(3)
- break
- }
- }
- }
- })
- },
- onShow() {
- },
- onHide() {
- },
- onUnload() {
- },
- onPullDownRefresh() {
- this.equipArr[this.active].pageIndex = 1
- this.equipArr[this.active].list = []
- if(this.active==3){
- this.getxyEquipList(3)
- }else{
- this.getEquipList(this.active)
- }
- setTimeout(() => {
- uni.stopPullDownRefresh()
- }, 1000)
- },
- onReachBottom() {
- let act = this.active
- if (this.equipArr[act].list.length < this.equipArr[act].pageIndex * 10) { //判断是否数据请求完
- return false
- }
- this.equipArr[act].pageIndex++;
- if(this.active==3){
- this.getxyEquipList(3)
- }else{
- this.getEquipList(act)
- }
- },
- onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
- if (e.scrollTop > 200) { //距离大于200时显示
- this.isTop = true
- } else { //距离小于200时隐藏
- this.isTop = false
- }
- },
- onBackPress(options) {
- if (options.from === 'navigateBack') {
- return false;
- }
- this.clickLeft();
- return true;
- },
- methods: {
- async getEquipList(act) {
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
- data: {
- device_type_id: this.equipArr[act].type,
- page: this.equipArr[act].pageIndex,
- page_size: 10,
- }
- })
- console.log(res)
- this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
- console.log(this.equipArr[act].list)
- },
- async getxyEquipList(act) {
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
- data: {
- device_type_id: this.equipArr[act].type,
- page: this.equipArr[act].pageIndex,
- page_size: 10,
- }
- })
- console.log(res)
- this.equipArr[act].list = [...this.equipArr[act].list, ...res.data]
- console.log(this.equipArr[act].list)
- },
- tabClick(index) {
- this.active = index;
- this.device_id = this.equipArr[index].type
- },
- clickRight() {
- uni.navigateTo({
- url: "./search?device_id=" + this.device_id
- })
- },
- itemClick(item) {
- item.type = this.equipArr[this.active].type
- let data = JSON.stringify(item)
- if (item.type == 10) {
- uni.navigateTo({
- url: '/pages/cb/xy2.0/particulars?info=' + data
- });
- } else {
- uni.navigateTo({
- url: '/pages/cb/equip-detail/equip-detail?info=' + data
- });
- }
- },
- clickLeft() {
- uni.switchTab({
- url: "../../index/index"
- })
- },
- top() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 500
- })
- }
- },
- components: {
- equipItem,
- uniNavBar
- }
- }
- </script>
- <style lang="scss">
- page {
- background: $uni-bg-color-grey;
- .content {
- padding: 0 20rpx 20rpx 20rpx;
- box-sizing: border-box;
- }
- }
- image {
- width: 100%;
- }
- .tab-box {
- display: flex;
- justify-content: space-around;
- font-size: 30rpx;
- line-height: 80rpx;
- background-color: #FFFFFF;
- margin-top: -10rpx;
- .tab-item {
- cursor: pointer;
- position: relative;
- }
- ;
- .tab-item.active {
- .bottom-line {
- bottom: 0;
- position: absolute;
- display: inline-block;
- width: 90rpx;
- height: 6rpx;
- left: 0;
- right: 0;
- margin: auto;
- background: $uni-color-success;
- }
- }
- }
- .top {
- position: fixed;
- right: 30px;
- bottom: 100px;
- z-index: 100;
- image {
- width: 100rpx;
- height: 100rpx;
- }
- }
- </style>
|