import { FunctionTrigger } from '$mixins/trigger/class/index';

import popup from "$utils/tool/popup";
import {PopupExportComponent} from "$popup/popup-export/const";

import personalDetail from '$utils/control/personal-detail';

export default [
    {
        label:'聊一聊',
        reverse:true,
        trigger: new FunctionTrigger(function () {
            this.$emit('close');
            return popup.$popup && popup.$popup.open(PopupExportComponent.chat,{
                user:{
                    ...this.config,
                    pid: this.pid,
                }
            });

        })
    },
    {
        label: '立即下单',
        trigger: new FunctionTrigger(function (){

            return personalDetail.placeOrder(this.number,this.config.gameList,this.item);
            let currentItem = {};
            let options = {
              number: this.number,
              gameList: this.config.gameList.map((item)=>{

                  let price = parseFloat(item.price);
                  let intPrice = parseInt(item.price);

                  if (intPrice === price) {
                      price = intPrice;
                  }

                  let target = {
                      label: item.label,
                      value: item.pid,
                      price: price,
                      number: 1
                  };
                  if (item.pid === this.item.pid) {
                      currentItem = target;
                      target.number = this.number;
                  }
                  return target
              }),
              item:currentItem,
              value: this.item.pid,
              user: {
                  header_pic: this.item.head_pic,
                  nick_name: this.item.nick_name
              }
            };

            return popup.$popup && popup.$popup.open(PopupExportComponent.order,{
                option:options
            });
        })
    }
]