码迷,mamicode.com
首页 > 其他好文 > 详细

vue-scroller

时间:2019-03-07 18:02:59      阅读:585      评论:0      收藏:0      [点我收藏+]

标签:finish   $set   hash   gis   val   header   绑定   dex   label   

           <scroller
            class="scroller" 
            :on-infinite="infinite"
            ref="scroller"
            >
            <div v-for="(item,index) in list" :key="index"  class="list">
                    <span>
                        <!-- 价格为空并且不是在编辑模式下 绑定上disabled -->
                        <input type="checkbox" :disabled="!showSetPrice&&!item.price" :id="‘a‘+index" v-model="item.checked">
                        <label :for="‘a‘+index" @click="dialogTip(item)"></label>
                    </span>
                    <span class="company">
                        {{item.trademark_name}}
                    </span>
                    <span class="type">
                        {{item.trademark_type}}
                    </span>
                    <span v-if="item.price" class="price">
                        {{item.price}}
                    </span>
                    <span v-else class="pricing" @click="openDialog(1,item)">
                        定价
                    </span>
            </div>
            <div style="height:200px">
            </div>
            </scroller>
    methods:{
        getData(){
            let form = this.formData
            registrantsGet(form).then((res)=>{
                if(form.page == ‘1‘){
                    this.list = res.data
                    this.list.forEach(item=>{
                        this.$set(item,"checked",false)
                    })
                    this.initScroll = true
                    this.$refs.scroller.finishInfinite()
                    if(this.list.length< 20){
                       this.emptyData = true
                        return 
                    }
                }else{
                    this.$refs.scroller.finishInfinite()
                    let resArr = res.data
                    if(resArr.length == 0){
                        this.emptyData = true
                        return
                    }
                    resArr.forEach(item=>{
                        this.$set(item,"checked",false)
                    })
                    this.list = [...this.list,...resArr]
                }
                if(this.initRegistrants){
                    this.registrants = res.registrants
                    this.registrants.unshift({registrant_hash:‘0‘,company_name:‘全部申请人‘})
                    this.initRegistrants = false
                }
            })
        },
        // 初始化搜索字段
        initSearch(){
            this.initScroll = false
            this.emptyData = false
            this.formData.page = 1
            // this.list=[]
            this.$refs.scroller.scrollTo(0,0,true) //滚动到scrooler这个模块内容的顶部
        },
        // 接受popup组件 emit的申请人
        getApplicant(item){
            this.initSearch()
            this.formData.registrant_hash=item.registrant_hash
            this.getData()
        },
        // 接受popup组件 emit的商标类别
        getBrandType(item){
            this.initSearch()
            this.formData.trademark_type=item.id
            this.getData()
        },  
        // 接受Header组件搜索emit 的内容
        getSearchContent(val){
            this.initSearch()
            this.formData.keyword=val
            this.getData()
        },
        // 接受Header组件 点击编辑emit 的内容
        editHandle(bol){
            if(bol){
               this.list.forEach((item)=>{
                   item.checked=true
               })
            }else{
                  this.list.forEach((item)=>{
                   if(!item.price){
                       item.checked=false
                   }
               })
            }
            this.showSetPrice= bol
        },
        // 调起设定价格弹框
        openDialog(id,item){
            this.dialogItem = item
            console.log(item,"item")
            this.dialogType = id
            this.hidMask = true
        },
        confirm(){
            if(this.dialogType == ‘1‘){
                this.dialogItem.price = this.inputPrice
            }else{
                this.list.forEach(item=>{
                    if(item.checked){
                        item.price = this.inputPrice
                    }
                })
            }
            this.inputPrice= ‘‘
            this.hidMask = false
        },
        // 发布商标
        publish(){
            var publishList = this.list.filter(item=>{
                return item.checked
            })
            // this.publishMask = true
            console.log(publishList)
            released(publishList).then((res)=>{
                console.log(res,"res")
            })
        },
        infinite: function (done) {
            if(this.emptyData){ 
                this.$refs.scroller.finishInfinite(true)
                return;
            }
            if(!this.initScroll){
                return
            }
            this.formData.page++;
            this.getData()
        },
        // 返回我的商标
        rebackMyBrand(){

        },
        // 查看发布商标
        watchPublishBrand(){

        },
        dialogTip(item){
            // 不在编辑模式下并且价格为空
            if(!item.price&&!this.showSetPrice){
                this.toast = true
                setTimeout(()=>{
                    this.toast = false
                },1500)
            }
        }
    }

 

vue-scroller

标签:finish   $set   hash   gis   val   header   绑定   dex   label   

原文地址:https://www.cnblogs.com/MR-cui/p/10490980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!