<style>
  .wexinappconfig .mimitBody {
    padding: 20px;
    background-color: #fff;
    margin: 10px 0 20px 0;
    display: table;
    width: 100%;
  }

  .wexinappconfig .mimitList {
    margin-bottom: 15px;
    display: flex;
    flex-direction: row;
  }

  .wexinappconfig .mimitBody .el-tag {
    min-width: 120px;
    padding-right: 50px;
  }

  .wexinappconfig .el-button--small {
    padding: 9px 25px;
  }

</style>
<template>
  <div class="wexinappconfig">
    <div class="CommonHeader">微信小程序配置</div>
    <div class="mimitBody">
      <el-form :model="appConfig" ref="appConfig" label-width="150px">
        <el-form-item label="小程序AppId">
          <el-input type="text" style="width:250px" size="small" maxlength="200" v-model="appConfig.MiniAppId">
          </el-input>
        </el-form-item>
        <el-form-item label="小程序appSecret">
          <el-input type="text" style="width:250px" size="small" maxlength="200" v-model="appConfig.MiniAppSecret">
          </el-input>
        </el-form-item>
        <el-form-item label="微信支付商户号">
          <el-input type="text" style="width:250px" size="small" maxlength="200" v-model="appConfig.WeChatPayMerchants">
          </el-input>
        </el-form-item>
        <el-form-item label="微信支付Api密钥">
          <el-input type="text" style="width:250px" size="small" maxlength="200" v-model="appConfig.WeChatApiSecret">
          </el-input>
        </el-form-item>
        <el-form-item label="微信支付apiclient_cert.pem">
          <el-input type="textarea" :rows="2" style="width:250px" size="small" maxlength="1000"
            v-model="appConfig.WeChatPayCertificate">
          </el-input>
        </el-form-item>
        <el-form-item label="微信支付apiclient_key.pem">
          <el-input type="textarea" :rows="2" style="width:250px" size="small" maxlength="1000"
            v-model="appConfig.WeChatPayPrivateKey">
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="UpdateAppConfig()">确 定</el-button>
      </span>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        //修改配置MSG
        appConfig: {
          MallBaseId: 0, //小程序Id
          MiniAppId: "", //小程序AppId
          MiniAppSecret: "", //小程序AppSecret
          WeChatPayMerchants: "", //微信支付商户号
          WeChatApiSecret: "", //微信支付Api密钥
          WeChatPayCertificate: "", //微信支付证书
          WeChatPayPrivateKey: "", //微信支付私钥
        },
      };
    },
    created() {

    },
    methods: {
      //版权信息
      GetWeiXinAppConfig() {
        this.appConfig.MallBaseId = this.getLocalStorage().MallBaseId;
        this.apipost("/api/Tenant/GetMiniPrograme", {
          MallBaseId: this.appConfig.MallBaseId,
        }, res => {
          if (res.data.resultCode == 1) {
            this.appConfig.MiniAppId = res.data.data.MiniAppId;
            this.appConfig.MiniAppId = res.data.data.MiniAppId;
            this.appConfig.MiniAppSecret = res.data.data.MiniAppSecret;
            this.appConfig.WeChatPayMerchants = res.data.data.WeChatPayMerchants;
            this.appConfig.WeChatApiSecret = res.data.data.WeChatApiSecret;
            this.appConfig.WeChatPayCertificate = res.data.data.WeChatPayCertificate;
            this.appConfig.WeChatPayPrivateKey = res.data.data.WeChatPayPrivateKey;
          } else {
            this.Info(res.data.message);
          }
        })
      },
      //修改版权
      UpdateAppConfig() {
        this.apipost("/api/Tenant/SetMiniProgramAppConfig", this.appConfig, res => {
          if (res.data.resultCode == 1) {
            this.GetWeiXinAppConfig();
            this.Success("操作成功!");
          } else {
            this.Info(res.data.message);
          }
        })
      },
    },
    mounted() {
      this.GetWeiXinAppConfig();
    }
  };

</script>
