cc_list.js 4.85 KB
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')


Page({
    data: {
        loading:true,
        scrollHeight:0,
        isscroll:true,
        dtn_ishidden:true,
        numNo_ishidden:true,
        clearlist:[],
        spe:[],
        specs :[],
        sellerid:'',
        savelist:[]      //用于取消估清时的规格存储
    },
    onLoad: function () {
        var that=this;

        //获取系统信息
        var sys=wx.getSystemInfo({
            success:function(res){
                that.setData({
                    scrollHeight:res.windowHeight,
                    scrollHeight1:res.windowHeight-93,
                    scrollHeight2:res.windowHeight-200,
                    windowWidth:res.windowWidth,
                    margin:(res.windowWidth*0.92-228)/10
                });
            }
        });
        wx.setNavigationBarTitle({
            title:'商品沽清',
        })

        this.setData({
          sellerid: util.cache("sellerid"),
        });
    },
    onReady () {
      this.setData({ loading:false })
    },
    onShow:function(){
        var that=this;
        this.alert=this.selectComponent('#alert');
        that.clearlist();
        util.postSuccessFun=function(json,uri_code){
            switch(uri_code){
                case uri.CGI__USER_GETCLEARCOOKBOOKBYSELLERID__CODE:            //获取商家所有估清菜品列表(估清管理)
                    if(json.ret==200){
                        var thisdata=json.data[0]['list'];
                        that.setData({
                            clearlist:thisdata,

                        })
                    }
                break
                case uri.CGI__USER_SETCLEARCOOKBOOKBYID__CODE:                  //设置商家菜品估清(估清管理)
                    console.log(json)
                    that.setData({
                        numNo_ishidden:true,
                    })
                    if(json.ret==200){
                        console.log(json)
                        that.onShow();
                    }

                break
            }
        }

    },

    clearlist:function(){
        util.post(uri.CGI__USER_GETCLEARCOOKBOOKBYSELLERID,{sellerid:this.data.sellerid},uri.CGI__USER_GETCLEARCOOKBOOKBYSELLERID__CODE)
    },

    //对无规格菜品的弹出框取消
    onlyCancelModel:function(){
        this.setData({
            atn_ishidden:true,
        })
    },
    //取消无规格估清的点击事件,有弹出框
    deleteOnlyClear:function(e){
        if(util.powercontro('取消沽清')==false){
            this.alert.show('您暂没有权限取消沽清菜品')
        }else{
            this.setData({
                dtn_ishidden:false,
                title:e.currentTarget.dataset.name,
                cookbookid:e.currentTarget.dataset.id
            })
        }
    },
    //取消弹出框的取消
    deleteCancelModel:function(e){
        this.setData({
            dtn_ishidden:true,
            ltn_ishidden:true
        })
    },

    //取消无规格弹出框的确认
    deleteConfirmModel:function(e){
            util.post(uri.CGI__USER_SETCLEARCOOKBOOKBYID,{cookbookid:this.data.cookbookid,clear_num:'cancel'},uri.CGI__USER_SETCLEARCOOKBOOKBYID__CODE)
        this.setData({
            dtn_ishidden:true,
        })
    },
    nospecs:function(e){
        if(util.powercontro('修改菜品')==false){
            this.alert.show('您暂没有权限修改沽清菜品')
        }else{
            this.setData({
                numNo_ishidden:false,
                title:e.currentTarget.dataset.name,
                cookbookid:e.currentTarget.dataset.id,
                clear_num:e.currentTarget.dataset.clear_num
            })
        }

    },
    //对无规格菜品的弹出框取消
    onlyCancelModel:function(){
        this.setData({
            numNo_ishidden:true,
        })
    },
    //对无规格菜品的弹出框确认
    onlyConfirmModel:function(e){
        util.post(uri.CGI__USER_SETCLEARCOOKBOOKBYID,{cookbookid:this.data.cookbookid,clear_num:this.data.clear_num},uri.CGI__USER_SETCLEARCOOKBOOKBYID__CODE)
    },

    //获取无规格菜品输入框数据
    onlyModalInput:function(e){
        console.log(e);
        this.setData({
            clear_num:e.detail.value
        })
    },
    addClear:function(){
        if(util.powercontro('添加沽清')==false){
            this.alert.show('您暂没有权限添加沽清菜品')
        }else{
            wx.navigateTo({
                url:'ck_list'
            })
        }

    },
    netchange:function(){
        this.onShow();
    },
    editcook:function(e){
        if(util.powercontro('修改沽清')==false){
            this.alert.show('您暂没有权限修改沽清菜品')
        }else{
            wx.navigateTo({
                url:'../cookbook/cb_sadd?id='+e.currentTarget.dataset.id
            })
        }
    }
})