<template>
  <div class="app-container">
    <el-form :model="firminfoForm" >
      <el-form-item label="头像" prop="pass">
        <userAvatar/>
      </el-form-item>
      <el-form-item label="姓名" prop="pass">
        <span>{{firminfoForm.nickName}}</span>
      </el-form-item>
      <el-form-item label="手机号" prop="pass">
        <span>{{firminfoForm.phonenumber}}</span>
      </el-form-item>
      <el-form-item label="企业（团队）名称" prop="pass">
        <span>{{firminfoForm.firmTem}}</span>
      </el-form-item>
      <el-form-item label="姓名" prop="pass">
        <span>{{firminfoForm.names}}</span>
      </el-form-item>
      <el-form-item label="职位" prop="pass">
        <span>{{firminfoForm.position}}</span>
      </el-form-item>
      <el-form-item label="公司所在省市区" prop="pass">
        <span>{{firminfoForm.firmRegion}}</span>
      </el-form-item>
      <el-form-item label="公司详细地址" prop="pass">
        <span>{{firminfoForm.firmFrom}}</span>
      </el-form-item>
      <el-form-item label="统一社会信用代码" prop="pass">
        <span>{{firminfoForm.socialReputation}}</span>
      </el-form-item>
      <el-form-item label="营业执照" prop="pass">
        <span>{{firminfoForm.businessLicense}}</span>
      </el-form-item>
      <el-form-item label="余额" prop="pass">
        <span>{{firminfoForm.firmScore}}</span>
      </el-form-item>
    </el-form>

    <el-button  @click="dialogFormVisible = true">充值</el-button>

    <el-dialog title="充值" :visible.sync="dialogFormVisible">
      <el-form :model="pay">
        <el-form-item label="金额" >
          <el-input v-model="pay.totalAmount" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <button @click="topup()">充值</button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listFirminfo, getFirminfo, delFirminfo, addFirminfo, updateFirminfo, edit} from "/src/api/firminfo/firminfo";
import firminfo from "./index.vue";
import userAvatar from "../../system/user/profile/userAvatar.vue";
import {pay} from "../../../api/market/apitype";

export default {
  name: "Firminfo",
  components: {userAvatar},
  computed: {
    firminfo() {
      return firminfo
    }
  },
  data() {
    return {
      dialogFormVisible:false,
      firminfoForm:{},
      pay:{},
      firminfo:{},
    };
  },
  created() {
    this.getFirminfo()
  },
  methods: {
    getFirminfo() {
      getFirminfo().then(response => {
        this.firminfoForm = response.data;
      });
    },
    async topup(){
      this.pay.subject=this.firminfoForm.firmTem
      const url  = `http://10.0.2.1:8080/pay/alipay/pay?subject=${this.pay.subject}&totalAmount=${this.pay.totalAmount}`;
      window.open(url, '_self');
      this.firminfo.firmId=this.firminfoForm.firmId
      this.firminfo.firmScore=this.pay.totalAmount
      edit(this.firminfo).then(res=>{
        console.log(res)
      })
    }
  }
};
</script>
