b_detail.js 3.83 KB
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
    onLoad:function (opt) {
        util.setBarTitle('预定详情');
        console.log(opt)
        opt.name=opt.name.length>3 ? opt.name.slice(0,3)+'...' : opt.name
        this.setData({
            sellerid:util.cache('sellerid'),
            phoneNumber:opt.phone,
            bookInfo:opt
        })
        wx.showShareMenu({
            withShareTicket: true,
            success:function(res){
                console.log(res)
            }
        })
    },
    onShow:function(){
        this.getsellerInfo();
        this.getdesklist();
        var that=this;
        this.notice=this.selectComponent('#notice');
        util.postSuccessFun=function(json,uri_code){
            switch (uri_code) {
                case uri.CGI__USER_GETSELLERBYID__CODE:
                    console.log(json)
                    if(json.ret==200){
                        that.setData({
                            storeInfo:json.data.data
                        })
                    }
                break;
                case uri.CGI_USER_GETTABLELIST__CODE:
                    var list=json.data;
                    var templist=[];
                    for(var key in list){
                        if(key!='typex' && key!='typey'){
                            list[key].list.forEach(function(v,i){
                                templist.push(v)
                            })

                        }
                    }
                    var tables=that.data.bookInfo.tid.split(',');
                    var selecttable=[];
                    templist.forEach(function (v,i) {
                        tables.forEach(function(r,n){
                            if(r==v.id){
                                v.name=v.name.length>4 ? v.name.slice(0,3)+'...' : v.name;
                                selecttable.push(v)
                            }
                        })
                    })
                    console.log(selecttable)
                    that.setData({
                        selecttable:selecttable
                    })
                break;
            }
        }
    },
    noticeCall:function(){
        this.notice.show();
    },
    getsellerInfo:function(){
        util.post(uri.CGI__USER_GETSELLERBYID,{sellerid:this.data.sellerid},uri.CGI__USER_GETSELLERBYID__CODE);
    },
    getdesklist:function(){
        util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.bookInfo.pnum),rdate:this.data.bookInfo.rdate},uri.CGI_USER_GETTABLELIST__CODE)
    },
    lookLocation:function(){
        wx.openLocation({
            latitude:Number(this.data.storeInfo.lat),
            longitude:Number(this.data.storeInfo.long),
            scale:17,
            address:this.data.storeInfo.map_address,
            success:function (res) {
                console.log(res)
            }
        })
    },
    onShareAppMessage: function () {
        this.notice.close();
        var obj=this.data.bookInfo;
        var path='b_detail?sellerid='+this.data.sellerid;
        for (var key in obj){
            path=path+'&'+key+'='+obj[key]
        }
        path=path+'&code=1'
        return {
            title: '恭喜订座成功,点击查看详情,及时通知用餐人员',
            path: '/pages/book/'+path,
            success: function (res) {
                console.log(res,666666)
            },
            fail:function(){
                console.log('ccccc')
            },
            complete:function(){
                console.log('ccccc')
            }
        };
    },
    getcall:function(){
        var that=this;
        wx.makePhoneCall({
            phoneNumber: this.data.phoneNumber, //仅为示例,并非真实的电话号码
            complete:function(){
                this.notice.close();
            }
        })
    }
})