b_detail.js 4.05 KB
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
import App from '../../utils/api';
const {regeneratorRuntime} = global
Page({
    data:{
      actionSheetHidden:true,
      actionSheetItems:['客户取消','客户行程改变']
    },
    onLoad:function (opt) {
        util.setBarTitle('预定详情');
        console.log(opt)
        this.getDetail(opt.id);
        wx.showShareMenu({
            withShareTicket: true,
            success:function(res){
                console.log(res)
            }
        })
        this.chooseManagerInit();
    },
    onShow:function(){
        this.notice=this.selectComponent('#notice');
    },
    noticeCall:function(){
        this.selectComponent('#notice').show();
    },
    onShareAppMessage: function () {
        this.selectComponent('#notice').close();
        var obj=this.data.bookInfo;
        var path='/pages/customer/index?id='+this.data.bookInfo.id;
        let nickname="";
        try{
            nickname='"'+util.cache('sellerInfo').seller_user.nickname+'"';
        }catch(e){}
        let imageUrl=util.cgi('index.php?service=App.Reserve.MakePic&rid=').replace('?s=','')+obj.id
        console.log('App.Reserve.MakePic',imageUrl);
        return {
            title: (nickname||'')+'给你发送了一个订座信息,点击查看详情',
            path: path,
            imageUrl:imageUrl,
            success: function (res) {
                console.log(res,666666)
            },
            fail:function(){
                console.log('ccccc')
            },
            complete:function(){
                console.log('ccccc')
            }
        };
    },
    getcall:function(){
      if(this.data.bookInfo.phone.length<3){
        return util.toast('号码错误','none');
      }
        wx.makePhoneCall({
            phoneNumber: this.data.bookInfo.phone, //仅为示例,并非真实的电话号码
            complete:()=>{
                this.selectComponent('#notice').close();
            }
        })
    },
    chooseManagerInit(){
        try{
            let managers=util.cache('sellerInfo').manager;
            let mans=[];
            if(managers.length>0){
                managers.forEach(man=>{
                    mans.push(man.user_name);
                })
            }
            this.setData({mans:mans})
        }catch(e){
            wx.showToast({
                title:'无客户经理',
                icon:'none'
            });
        }
    },
    chooseManager(e){
        let mansIndex=util.val(e);
        this.setData({mansIndex:mansIndex});
        try{
            let managers=util.cache('sellerInfo').manager;
            let man=managers[mansIndex];
            if(man){
                App.Reserve.SetReserveCusman({
                    rid:this.data.bookInfo.id,
                    cusman_id:man.id,
                    cusman:man.user_name,
                    cusman_phone:man.user_phone?man.user_phone:'',
                    cusman_account:man.user_wechat?man.user_wechat:'',
                }).then(()=>{
                    this.getDetail(this.data.bookInfo.id,true);
                });
            }
        }catch(e){
            console.log(e);
        }
    },
    detailData:null,
    getDetail(id,force=false){
        App.Reserve.Detail({rid:id,openid:''},force).then(res=>{
            res.data.rdateStr=util.unixtoTime(res.data.rdate,"MM月DD日 HH:II")
            this.detailData=res.data;
            this.setData({
                tables:res.data.tables,
                bookInfo:res.data,
            })
        })
    },
    gotoModify(){
        wx.redirectTo({
            url:'./b_addnew?id='+this.data.bookInfo.id
        })
    },
  cancelReserve(){
        util.toast('不能取消预订','none');return;
    this.setData({
      actionSheetHidden:false
    })
  },
  actionSheetChange(e){
    this.setData({
      actionSheetHidden:true
    })
  },
  startDinner(e){
    App.Reserve.SetReserveStatus({
      rid:this.data.bookInfo.id,
      status:util.attr(e,'status'),
    }).then(()=>{
      this.getDetail(this.data.bookInfo.id,true);
    });
  }
})