<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"> <div class="el-col el-col-12"> <el-form :model="appConfig" :rules="rules" ref="appConfig" label-width="150px"> <el-form-item label="小程序AppId" prop="MiniAppId" size="small"> <el-input type="text" size="small" maxlength="200" v-model="appConfig.MiniAppId"> </el-input> </el-form-item> <el-form-item label="小程序appSecret" prop="MiniAppSecret" size="small"> <el-input v-if="isShowAppSecret" type="text" @focus="isShowAppSecret=false" size="small" placeholder="已隐藏内容,点击查看或编辑"> </el-input> <el-input v-else type="text" size="small" maxlength="200" v-model="appConfig.MiniAppSecret"> </el-input> </el-form-item> <el-form-item label="微信支付商户号" prop="WeChatPayMerchants" size="small"> <el-input type="text" size="small" maxlength="200" v-model="appConfig.WeChatPayMerchants"> </el-input> </el-form-item> <el-form-item label="微信支付Api密钥" prop="WeChatApiSecret" size="small"> <el-input v-if="isShowApi" type="text" @focus="isShowApi=false" size="small" placeholder="已隐藏内容,点击查看或编辑"> </el-input> <el-input v-else type="text" size="small" maxlength="200" v-model="appConfig.WeChatApiSecret"> </el-input> </el-form-item> <!--<el-form-item label="微信支付apiclient_cert.pem" size="small">--> <!--<el-input v-if="isShowClientOne" type="textarea" @focus="isShowClientOne=false" :rows="5" size="small" placeholder="已隐藏内容,点击查看或编辑">--> <!--</el-input>--> <!--<el-input v-else type="textarea" :rows="5" size="small" maxlength="1000"--> <!--v-model="appConfig.WeChatPayCertificate">--> <!--</el-input>--> <!--</el-form-item>--> <!--<el-form-item label="微信支付apiclient_key.pem" size="small">--> <!--<el-input v-if="isShowClientTwo" type="textarea" @focus="isShowClientTwo=false" :rows="5" size="small" placeholder="已隐藏内容,点击查看或编辑">--> <!--</el-input>--> <!--<el-input v-else type="textarea" :rows="5" size="small" maxlength="1000"--> <!--v-model="appConfig.WeChatPayPrivateKey">--> <!--</el-input>--> <!--</el-form-item>--> <el-form-item label="微信支付证书" prop="WeChatPayCertificateUrl" size="small"> <template> <el-upload class="upload-demo" accept='doc,.docx,.xlsx,.xls,.pdf,.pem,.p12' :action="importFileUrl" :multiple="false" :on-success="successUpload" :file-list="fileList" :on-remove="handleRemove" > <el-button size="small" type="primary">点击上传</el-button> </el-upload> </template> </el-form-item> </el-form> </div> </div> <el-button size="small" type="primary" @click="submitForm('appConfig')">保存</el-button> </div> </template> <script> export default { data() { return { //是否显示小程序appSecret isShowAppSecret:true, //是否显示微信支付Api密钥 isShowApi:true, //是否显示微信支付 isShowClientOne:true, isShowClientTwo:true, //修改配置MSG appConfig: { MallBaseId: 0, //小程序Id MiniAppId: "", //小程序AppId MiniAppSecret: "", //小程序AppSecret WeChatPayMerchants: "", //微信支付商户号 WeChatApiSecret: "", //微信支付Api密钥 WeChatPayCertificate: "", //微信支付证书 WeChatPayPrivateKey: "", //微信支付私钥 WeChatPayCertificateUrl:'',//微信支付证书 }, fileList:[], importFileUrl: this.domainManager().UploadBlob, rules: { MiniAppId: [{ required: true, message: "请输入appid", trigger: "blur" }], MiniAppSecret: [{ required: true, message: "请输入appsecret", trigger: "blur" }], WeChatPayMerchants: [{ required: true, message: "请输入mchid", trigger: "blur" }], WeChatApiSecret: [{ required: true, message: "请输入key", trigger: "blur" }], WeChatPayCertificateUrl: [{ required: true, message: "请上传微信支付证书", trigger: "blur" }] } }; }, created() { }, methods: { //版权信息 GetWeiXinAppConfig() { this.fileList=[]; 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; if(res.data.data.WeChatPayCertificateUrl!=null){ this.appConfig.WeChatPayCertificateUrl = res.data.data.WeChatPayCertificateUrl; this.fileList.push({ name:res.data.data.WeChatPayCertificateUrl, url:res.data.data.WeChatPayCertificateUrl, }) } } else { this.Info(res.data.message); } }) }, submitForm(msg) { //提交创建、修改表单 this.$refs[msg].validate(valid => { if (valid) { this.UpdateAppConfig(); } else { return false; } }); }, //修改版权 UpdateAppConfig() { this.apipost("/api/Tenant/SetMiniProgramAppConfig", this.appConfig, res => { if (res.data.resultCode == 1) { this.GetWeiXinAppConfig(); this.Success("操作成功!"); } else { this.Info(res.data.message); } }) }, successUpload(file){ let list = []; list.push({ name:file.data.Path.split('WeChatApp')[1].replace(/[\\]/g, ''), url:file.data.Path.split('WeChatApp')[1].replace(/[\\]/g, ''), }) this.fileList = list; this.appConfig.WeChatPayCertificateUrl = file.data.Path.split('WeChatApp')[1].replace(/[\\]/g, '') }, handleRemove(file, fileList) { this.fileList = fileList; if(this.fileList.length==0){ this.appConfig.WeChatPayCertificateUrl=''; } }, }, mounted() { this.GetWeiXinAppConfig(); }, }; </script>