李雾月
李雾月
  • 发布:2019-11-12 12:24
  • 更新:2019-11-12 16:35
  • 阅读:943

动态拿到数据不渲染页面

分类:uni-app
<template>  
    <view class="stand">  
        <!-- 待命班长 -->  
        <view class="standby">  
            <view class="every">  
        <view class="" >  
          {{standby}}  
        </view>  
        <view>  
          {{standby.length}}  
        </view>  
                <view class="nolists" v-if="standby.length==0">暂无数据</view>  
                <view class="monitor" v-if="standby.length!=0" v-for="(item,i) in standby" :key='i'>  
                    <image class="avatar" :src="item.avatarUrl"></image>  
                    <view class="tu">  
                        <text class="name">{{item.realname}}</text>  
                        <text class="gradegreen" v-if="item.grade != null">{{item.grade}}</text>  
                        <text @tap="complaint(item.monitor_id)" class="complaint">投诉</text>  
                        <navigator :tel="workInfo.phone"><view class="reservation">立即联系</view></navigator>  
                    </view>  
                    <view class="word">   
                        <text class="left">年龄: {{item.age}}周岁</text>  
                    </view>  
                    <view class="word ability">  
                        <text>店铺名称: {{item.name}}</text>  
                    </view>  
                    <view class="word ability">  
                        <text>工作时间: {{item.work_time1}} {{item.work_time2}}-{{item.closing_time2}}</text>  
                    </view>  
                    <!-- <view class="showmap" @tap="expandmap(i)">  
                        <text v-if="!item.isOpen" v-model="item.isOpen">查看地图</text>  
                        <text v-if="item.isOpen" v-model="item.isOpen">收起</text>  
                        <image src="../../static/images/expand.png" v-if="!item.isOpen" v-model="item.isOpen"></image>  
                        <image src="../../static/images/collapse.png" v-if="item.isOpen" v-model="item.isOpen"></image>  
                    </view> -->  
          <view class="page-body" v-if="item.isOpen" v-model="item.isOpen">  
            <view class="page-section page-section-gap">  
                <map style="width: 100%; height: 300upx;" :latitude="latitude" :longitude="longitude" :markers="item.covers" scale="12">  
                </map>  
            </view>  
          </view>  
                </view>  
            </view>  
        </view>  
    </view>  
</template>
    var app = getApp()  
    export default {  
        props:{  
            shopid:{  
                type:Number,  
                default:0  
            },  
        },  
        data() {  
            return{  
        page:0,//页码  
                standby:[],  
                monitorid:0,  
                title: 'map',  
                latitude:34.223569,  
                longitude:108.94832,  
                covers: [{  
          latitude: 34.223,  
          longitude: 108.9,  
          iconPath: '../../static/images/address.png',  
          width:20,  
          height:22  
                }]  
            }  
        },  
        created(){  
      console.log("standbyMonitor---组件被创建")  
            var that = this  
            // that.photo = that.expand  
            //console.log(this.shopid,119)  
      that.covers[0].latitude = uni.getStorageSync('lat')  
      that.covers[0].longitude = uni.getStorageSync('lon')  
        },  
    mounted(){  
      console.log('mounted ---- 执行了')  
      var that = this;  
      that.shoplistRequest(0);  
    },  
        methods:{  
            expandmap:function(i){  
        console.log("是否点击到")  
                var that = this  
        let isopen = that.standby[i].isOpen  
        that.standby[i].isOpen = !isopen;  
        console.log(that.standby[i].isOpen)  
            },  
            callphono:function(e){  
                uni.makePhoneCall({  
                  phoneNumber:  e  
                });  
            },  
            shoplistRequest:function(page){  
        console.log("shoplistRequest--------------")  
                var that = this  
                let opts={  
                  url: 'shop/standby',  
                  method: 'post'  
                }  
                let param={  
                    shop_id:that.shopid,  
          user_id:uni.getStorageSync('mineInfo').id,  
          userType:1,  
          page:page  
                }  
                console.log(param)  
        app.httpRequest(opts,param).then(res => {  
          console.log(res.data,173)  
          let standby = res.data.data  
          for(var j=0;j < standby.length;j++){  
            standby[j]['photoes']='../../static/images/expand.png'  
            standby[j]['expand']='../../static/images/expand.png'  
            standby[j]['collapse']='../../static/images/collapse.png'  
            standby[j]['covers']=that.covers  
            standby[j]['covers'][1]={}  
            standby[j]['covers'][1]['latitude']=standby[j].latitude  
            standby[j]['covers'][1]['longitude']=standby[j].longitude  
            standby[j]['covers'][1]['iconPath']='../../static/images/address.png'  
            standby[j]['covers'][1]['width']=20  
            standby[j]['covers'][1]['height']=22  
            standby[j]['isOpen'] = false  
          }  
          // that.standby = that.standby.concat(standby);  
          that.standby = standby;  
          console.log(that.standby);  
        },error => {console.log(error)})  
            },  
            //投诉  
            complaint(e){  
                var that = this  
                that.monitorid = e  
                uni.navigateTo({  
                  url: '../../pages/complaint/complaint?id='+that.monitorid  
                })  
            }  
        },  
    watch:{  
        standby(){  
            console.log('监听standby发生改变===>'+this.standby)  
        },  
      shopid(){  
        console.log('监听shopId发生改变'+this.shopid+'~==========>重新调用函数');  
        this.shoplistRequest(0)  
      }  
    },  
    onReachBottom(){  
      console.log('触底~')  
      var that = this;  
      let page = page++;  
      // that.shoplistRequest(page)  
    }  
    }

请大佬指教(づ ̄3 ̄)づ╭❤~

2019-11-12 12:24 负责人:无 分享
已邀请:
李雾月

李雾月 (作者) - 前端菜鸟一枚

uniapp开发的微信公众号

李雾月

李雾月 (作者) - 前端菜鸟一枚

用了替代方案,直接把数据在父组件请求了再传到子组件

该问题目前已经被锁定, 无法添加新回复