276 行
12 KiB
HTML
可执行文件
276 行
12 KiB
HTML
可执行文件
<!--[1.5.22]-->
|
|
<div id="paySetRemit" v-cloak>
|
|
<el-card class="box-card" style="min-height: 100%">
|
|
<div slot="header" class="clearfix">
|
|
<span>打款设置</span>
|
|
</div>
|
|
<div v-loading="paySetRemitLoading">
|
|
<el-tabs type="card">
|
|
<el-tab-pane label="微信打款到零钱" name="wxlq"></el-tab-pane>
|
|
</el-tabs>
|
|
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm"
|
|
size="small">
|
|
<el-alert :closable="false"
|
|
type="info">
|
|
<div slot="title">
|
|
<p style="font-weight: 500;font-size: 14px;">1.打款使用微信企业付款到零钱功能</p>
|
|
<br>
|
|
<p style="font-weight: 500;font-size: 14px;">2.微信企业付款到零钱文档
|
|
<el-link :underline="false" target="_blank"
|
|
href="https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_1"
|
|
type="primary">立即进入
|
|
</el-link>
|
|
</p>
|
|
</div>
|
|
</el-alert>
|
|
<br>
|
|
<el-form-item label="小程序appid" prop="mch_appid">
|
|
<el-input v-model="ruleForm.mch_appid" placeholder="小程序appid"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="商户号" prop="mch_id">
|
|
<el-input v-model="ruleForm.mch_id" placeholder="商户号"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="商户秘钥" prop="wx_secret_key">
|
|
<el-input v-model="ruleForm.wx_secret_key" placeholder="商户秘钥"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="证书pem格式" prop="apiclient_cert">
|
|
<el-input type="password" v-model="ruleForm.apiclient_cert" placeholder="证书pem格式" readonly>
|
|
<template slot="append">
|
|
<el-upload
|
|
action="{:U('upload')}"
|
|
class="upload-demo"
|
|
:on-progress="uploadFileIng"
|
|
:on-success="uploadFileSuccess"
|
|
:on-error="uploadFileError"
|
|
:limit="1"
|
|
:show-file-list="false"
|
|
accept="pem"
|
|
:before-upload="beforeUpload"
|
|
@change.native.prevent="chooseFile(1)"
|
|
:file-list="fileList">
|
|
<el-button size="small">点击上传<i v-if="chooseFileType==1&&isUploading"
|
|
class="el-icon-loading el-icon--right"></i><i v-else
|
|
class="el-icon-upload el-icon--right"></i>
|
|
</el-button>
|
|
</el-upload>
|
|
</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
<el-form-item label="证书密钥pem格式" prop="apiclient_key">
|
|
<el-input type="password" v-model="ruleForm.apiclient_key" placeholder="证书密钥pem格式" readonly>
|
|
<template slot="append">
|
|
<el-upload
|
|
action="{:U('upload')}"
|
|
class="upload-demo"
|
|
:on-progress="uploadFileIng"
|
|
:on-success="uploadFileSuccess"
|
|
:on-error="uploadFileError"
|
|
:limit="1"
|
|
:show-file-list="false"
|
|
accept="pem"
|
|
:before-upload="beforeUpload"
|
|
@change.native.prevent="chooseFile(2)"
|
|
:file-list="fileList">
|
|
<el-button size="small">点击上传<i v-if="chooseFileType==1&&isUploading"
|
|
class="el-icon-loading el-icon--right"></i><i v-else
|
|
class="el-icon-upload el-icon--right"></i>
|
|
</el-button>
|
|
</el-upload>
|
|
</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
<el-form-item label="微信打款到零钱">
|
|
<el-switch
|
|
active-value="1"
|
|
inactive-value="0"
|
|
v-model="ruleForm.wx_state"></el-switch>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
</el-card>
|
|
</div>
|
|
<script>
|
|
var paySetRemit = new Vue({
|
|
el: '#paySetRemit',
|
|
data: function () {
|
|
return {
|
|
ruleForm: {
|
|
mch_appid: '',
|
|
mch_id: '',
|
|
apiclient_cert: '',
|
|
apiclient_key: '',
|
|
wx_secret_key: '',
|
|
},
|
|
rules: {
|
|
mch_appid: [
|
|
{required: true, message: '商户账号appid不能为空', trigger: 'blur'},
|
|
],
|
|
mch_id: [
|
|
{required: true, message: '商户号不能为空', trigger: 'blur'}
|
|
],
|
|
apiclient_cert: [
|
|
{required: true, message: '证书pem格式', trigger: 'blur'}
|
|
],
|
|
apiclient_key: [
|
|
{required: true, message: '证书密钥pem格式', trigger: 'blur'}
|
|
],
|
|
wx_secret_key: [
|
|
{required: true, message: '商户秘钥不能为空', trigger: 'blur'}
|
|
],
|
|
},
|
|
chooseFileType: 0,
|
|
fileList: [],
|
|
isUploading: false,
|
|
paySetRemitLoading: false,
|
|
}
|
|
},
|
|
methods: {
|
|
beforeUpload(file) {
|
|
const fileName = file.name;
|
|
const arr = fileName.split('.');
|
|
if (arr[arr.length - 1] != 'pem') {
|
|
this.$message({
|
|
type: 'error',
|
|
message: "请上传后缀为‘pem’的微信证书"
|
|
});
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
},
|
|
uploadFileIng: function (event, file, fileList) {
|
|
this.isUploading = true;
|
|
this.$loading({
|
|
lock: true,
|
|
text: '上传中,请等待',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.7)'
|
|
});
|
|
},
|
|
uploadFileSuccess: function (response, file, fileList) {
|
|
this.$loading().close();
|
|
this.isUploading = false;
|
|
if (response.status == 1) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '上传成功'
|
|
});
|
|
switch (this.chooseFileType) {
|
|
case 1:
|
|
this.ruleForm.apiclient_cert = response.path;
|
|
break;
|
|
case 2:
|
|
this.ruleForm.apiclient_key = response.path;
|
|
break;
|
|
case 3:
|
|
// 应用公钥证书:
|
|
this.ruleForm.aliapp_ert_path = response.path;
|
|
break;
|
|
case 4:
|
|
// 支付宝公钥证书:
|
|
this.ruleForm.alipay_cert_path = response.path;
|
|
break;
|
|
case 5:
|
|
// 支付宝根证书:
|
|
this.ruleForm.aliroot_cert_path = response.path;
|
|
break;
|
|
}
|
|
} else {
|
|
this.$message({
|
|
message: '上传失败,请重试',
|
|
type: 'error',
|
|
duration: 1500
|
|
});
|
|
}
|
|
},
|
|
uploadFileError: function (event, file, fileList) {
|
|
console.log(event, file, fileList);
|
|
this.isUploading = false;
|
|
this.$loading().close();
|
|
this.$message({
|
|
message: '上传失败,请重试',
|
|
type: 'error',
|
|
duration: 1500
|
|
});
|
|
},
|
|
chooseFile: function (type) {
|
|
this.chooseFileType = type;
|
|
},
|
|
getData() {
|
|
this.paySetRemitLoading = true;
|
|
$.ajax({
|
|
url: "{:U('getRemitData')}",
|
|
data: {},
|
|
type: "POST",
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
if (res.data) {
|
|
this.ruleForm = res.data;
|
|
}
|
|
this.paySetRemitLoading = false;
|
|
} else {
|
|
this.$message({
|
|
type: 'error',
|
|
message: res.msg
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
submitForm(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
this.paySetRemitLoading = true;
|
|
const data = {};
|
|
data.mch_appid = this.ruleForm.mch_appid;
|
|
data.mch_id = this.ruleForm.mch_id;
|
|
data.apiclient_cert = this.ruleForm.apiclient_cert;
|
|
data.apiclient_key = this.ruleForm.apiclient_key;
|
|
data.wx_state = this.ruleForm.wx_state;
|
|
data.wx_secret_key = this.ruleForm.wx_secret_key;
|
|
$.ajax({
|
|
url: "{:U('saveRemitData')}",
|
|
data: data,
|
|
type: "POST",
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: res.msg
|
|
})
|
|
} else {
|
|
this.$message({
|
|
type: 'error',
|
|
message: res.msg
|
|
})
|
|
}
|
|
this.paySetRemitLoading = false;
|
|
}
|
|
})
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
},
|
|
created: function () {
|
|
this.getData();
|
|
},
|
|
})
|
|
|
|
</script>
|
|
<style>
|
|
#paySetRemit .el-input--small {
|
|
max-width: 550px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
#paySetRemit .el-link {
|
|
margin-top: -4px;
|
|
margin-left: 8px;
|
|
}
|
|
</style>
|