cancel.js 2.08 KB
// components/book/reserveCancel/cancel.js
import util from '../../../../utils/util';
import App from '../../../../utils/api';
const {regeneratorRuntime} = global
const items=[{name:'顾客取消'},{name:'顾客行程有变'},{name:'信息填写有误'},{name:'操作失误'},{name:'其他原因'}];

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    bookInfo:{
      type:Object,
      value:{},
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    hidden: true,
    otherInputHidden:true,
    items:JSON.parse(JSON.stringify(items)),
    _cause:'',
    cause:'',
  },
  /**
   * 组件的方法列表
   */
  methods: {
    show(){
      this.setData({
        hidden:false,
      })
    },
    hide(){
      this.setData({
        hidden:true,
      })
    },
    radioChange(e){
      let val=util.val(e);
      if(val=='其他原因'){
        this.setData({
          otherInputHidden:false,
          _cause:val
        })
      }else{
        this.setData({
          otherInputHidden:true,
          _cause:val
        })
      }
    },
    otherInput(e){
      let val=util.val(e);
      this.setData({
        cause:val
      })
    },
    async submit(e){
      console.log(e,);
      let cause=this.data._cause;
      let hasInput=false;
      if(cause=='其他原因'){
        cause=this.data.cause;
        hasInput=true;
      }
      cause=cause.trim();
      if(!cause){
        return util.toast(hasInput?'请填写原因':'请选择原因','none')
      }

      let enter_params=util.cache('enter_params');
      let sc=(await App.Reserve.SellerInfo(enter_params)).data
      cause={desc:cause}
      if(enter_params){
        cause.uid=enter_params.manager_id;
      }
      if(sc.seller_user){
        cause.uname=(sc.seller_user.nick_name||sc.seller_user.nickname)
      }
      App.Reserve.SetReserveStatus({
        rid:this.data.bookInfo.id,
        status:4,
        cause:JSON.stringify(cause),
      }).then(()=>{
        this.hide()
        this.triggerEvent('reserveCancel',{hasCancel:true});
        //this.getDetail(this.data.bookInfo.id,true);
      })
    }
  }
})