Просмотр исходного кода

feat:weixin-java from 4.7.2.B => 4.7.4.B
feat:微信支付 v3 从平台证书切换成微信支付公钥
feat:微信支付 v3 增加 header 解析

YunaiV 9 месяцев назад
Родитель
Сommit
45e3667b38
1 измененных файлов с 64 добавлено и 4 удалено
  1. 64 4
      src/views/pay/app/components/channel/WeixinChannelForm.vue

+ 64 - 4
src/views/pay/app/components/channel/WeixinChannelForm.vue

@@ -71,11 +71,12 @@
           >
             <el-input
               v-model="formData.config.keyContent"
-              :autosize="{ minRows: 8, maxRows: 8 }"
+              :autosize="{ minRows: 2, maxRows: 4 }"
               :style="{ width: '100%' }"
               placeholder="请上传 apiclient_cert.p12 证书"
               readonly
               type="textarea"
+              :rows="2"
             />
           </el-form-item>
           <el-form-item label="" label-width="180px">
@@ -108,11 +109,12 @@
           >
             <el-input
               v-model="formData.config.privateKeyContent"
-              :autosize="{ minRows: 8, maxRows: 8 }"
+              :autosize="{ minRows: 2, maxRows: 4 }"
               :style="{ width: '100%' }"
               placeholder="请上传 apiclient_key.pem 证书"
               readonly
               type="textarea"
+              :rows="2"
             />
           </el-form-item>
           <el-form-item label="" label-width="180px" prop="privateKeyContentFile">
@@ -145,6 +147,47 @@
               前往微信商户平台查看证书序列号
             </a>
           </el-form-item>
+          <el-form-item label="public_key.pem 证书" label-width="180px" prop="config.publicKeyContent">
+            <el-input
+              v-model="formData.config.publicKeyContent"
+              :autosize="{ minRows: 2, maxRows: 4 }"
+              :style="{ width: '100%' }"
+              placeholder="请上传 public_key.pem 证书"
+              readonly
+              type="textarea"
+              :rows="2"
+            />
+          </el-form-item>
+          <el-form-item label="" label-width="180px" prop="publicKeyContentFile">
+            <el-upload
+              ref="publicKeyContentFile"
+              :before-upload="pemFileBeforeUpload"
+              :http-request="publicKeyContentUpload"
+              :limit="1"
+              accept=".pem"
+              action=""
+            >
+              <el-button type="primary">
+                <Icon class="mr-5px" icon="ep:upload" />
+                点击上传
+              </el-button>
+            </el-upload>
+          </el-form-item>
+          <el-form-item label="公钥 ID" label-width="180px" prop="config.publicKeyId">
+            <el-input
+              v-model="formData.config.publicKeyId"
+              clearable
+              placeholder="请输入公钥 ID"
+            />
+          </el-form-item>
+          <el-form-item label-width="180px">
+            <a
+              href="https://pay.weixin.qq.com/doc/v3/merchant/4012153196"
+              target="_blank"
+            >
+              微信支付公钥产品简介及使用说明
+            </a>
+          </el-form-item>
         </div>
         <el-form-item label="备注" label-width="180px" prop="remark">
           <el-input v-model="formData.remark" :style="{ width: '100%' }" />
@@ -184,7 +227,9 @@ const formData = ref<any>({
     keyContent: '',
     privateKeyContent: '',
     certSerialNo: '',
-    apiV3Key: ''
+    apiV3Key: '',
+    publicKeyContent: '',
+    publicKeyId: ''
   }
 })
 const formRules = {
@@ -201,6 +246,8 @@ const formRules = {
     { required: true, message: '请上传 apiclient_key.pem 证书', trigger: 'blur' }
   ],
   'config.certSerialNo': [{ required: true, message: '请输入证书序列号', trigger: 'blur' }],
+  'config.publicKeyContent': [{ required: true, message: '请上传 public_key.pem 证书', trigger: 'blur' }],
+  'config.publicKeyId': [{ required: true, message: '请输入公钥 ID', trigger: 'blur' }],
   'config.apiV3Key': [{ required: true, message: '请上传 api V3 密钥值', trigger: 'blur' }]
 }
 const formRef = ref() // 表单 Ref
@@ -267,7 +314,9 @@ const resetForm = (appId, code) => {
       keyContent: '',
       privateKeyContent: '',
       certSerialNo: '',
-      apiV3Key: ''
+      apiV3Key: '',
+      publicKeyContent: '',
+      publicKeyId: ''
     }
   }
   formRef.value?.resetFields()
@@ -318,4 +367,15 @@ const keyContentUpload = async (event) => {
   }
   readFile.readAsDataURL(event.file) // 读成 base64
 }
+
+/**
+ * 读取 public_key.pem 到 publicKeyContent 字段
+ */
+const publicKeyContentUpload = async (event) => {
+  const readFile = new FileReader()
+  readFile.onload = (e: any) => {
+    formData.value.config.publicKeyContent = e.target.result
+  }
+  readFile.readAsText(event.file)
+}
 </script>