Browse Source

商家原生微信支付宝支付模式配置功能业务完善

master
dy-hu 4 months ago
parent
commit
f7005b4195
  1. 50
      src/api/business.js
  2. 313
      src/views/business/businessList/index.vue

50
src/api/business.js

@ -187,3 +187,53 @@ export function changeBusinessPayMode(data) {
data
})
}
// 商家新增原生微信支付配置信息
export function wxPaySave(data) {
return request({
url: '/bwxpay/save',
method: 'post',
data
})
}
// 商家修改原生微信支付配置信息
export function wxPayUpdate(data) {
return request({
url: '/bwxpay/update',
method: 'post',
data
})
}
export function getWxPayInfo(businessId) {
return request({
url: '/bwxpay/getBusinessWxpay/' + businessId,
method: 'get'
})
}
// 商家新增原生支付宝支付配置信息
export function aliPaySave(data) {
return request({
url: '/balipay/save',
method: 'post',
data
})
}
// 商家修改原生支付宝支付配置信息
export function aliPayUpdate(data) {
return request({
url: '/balipay/update',
method: 'post',
data
})
}
export function getAliPayInfo(businessId) {
return request({
url: '/balipay/getBusinessAlipay/' + businessId,
method: 'get'
})
}

313
src/views/business/businessList/index.vue

@ -507,43 +507,93 @@
/>
</div>
<el-form
ref="ruleForm"
:model="ruleForm"
:rules="rules"
label-width="100px"
>
<el-form-item
label="账号"
prop="businessPhone"
<div v-if="wxaliPayOpen" style="display: flex;flex-direction: column">
<el-checkbox
style="margin-bottom: 20px"
v-model="wxPayCanConfig"
:disabled="disabled"
>
<el-input
v-if="businessPhoneShow"
:value="hidden(ruleForm.businessPhone, 3, 4)"
:disabled="disabled"
maxlength="20"
@focus="focusbusinessPhoneInput"
/>
<el-input
v-else
ref="businessPhoneCls"
v-model="ruleForm.businessPhone"
:disabled="disabled"
maxlength="20"
/>
</el-form-item>
<el-form-item
label="密码"
prop="businessPassword"
微信商户配置
</el-checkbox>
<el-form
v-if="wxPayCanConfig"
ref="wxPayForm"
:model="wxPayForm"
:rules="wxPayRules"
label-width="115px"
>
<el-input
v-model="ruleForm.businessPassword"
type="password"
:disabled="disabled"
maxlength="16"
/>
</el-form-item>
</el-form>
<el-form-item label="小程序appid" prop="appId">
<el-input
v-model="wxPayForm.appId" placeholder="请输入支付小程序appid" :disabled="disabled"/>
</el-form-item>
<el-form-item label="App端的appid" prop="appAppId">
<el-input
v-model="wxPayForm.appAppId" placeholder="请输入支付APP端的appid" :disabled="disabled"/>
</el-form-item>
<el-form-item label="商户号" prop="mchId">
<el-input
v-model="wxPayForm.mchId" placeholder="请输入商户号" :disabled="disabled"/>
</el-form-item>
<el-form-item label="商户秘钥" prop="mchKey">
<el-input
v-model="wxPayForm.mchKey" placeholder="请输入商户秘钥" :disabled="disabled"/>
</el-form-item>
<el-form-item label="私钥" prop="secret">
<el-input
v-model="wxPayForm.secret" placeholder="请输入私钥" :disabled="disabled"/>
</el-form-item>
<el-form-item label="证书路径" prop="certUrl">
<el-input
v-model="wxPayForm.certUrl" placeholder="请输入证书路径" :disabled="disabled"/>
</el-form-item>
</el-form>
<el-button v-if="wxPayCanConfig" style="width: 200px;align-self: center" type="primary" size="small" @click="handleWxPay"> </el-button>
</div>
<div v-if="wxaliPayOpen" style="display: flex;flex-direction: column;margin-top: 15px">
<el-checkbox
style="margin-bottom: 20px"
v-model="aliPayCanConfig"
:disabled="disabled"
>
支付宝商户配置
</el-checkbox>
<el-form
v-if="aliPayCanConfig"
ref="aliPayForm"
:model="aliPayForm"
:rules="aliPayRules"
label-width="115px"
>
<el-form-item label="应用appid" prop="appId">
<el-input
v-model="aliPayForm.appId" placeholder="请输入应用appid" :disabled="disabled"/>
</el-form-item>
<el-form-item label="应用私钥" prop="privateKey">
<el-input
v-model="aliPayForm.privateKey" placeholder="请输入应用私钥" :disabled="disabled"/>
</el-form-item>
<el-form-item label="支付宝公钥" prop="publicKey">
<el-input
v-model="aliPayForm.publicKey" placeholder="请输入支付宝公钥" :disabled="disabled"/>
</el-form-item>
<el-form-item label="内容解密key" prop="decryKey">
<el-input
v-model="aliPayForm.decryKey" placeholder="请输入接口内容解密key" :disabled="disabled"/>
</el-form-item>
<el-form-item label="网关地址" prop="gatewayUrl">
<el-input
v-model="aliPayForm.gatewayUrl" placeholder="请输入请求网关地址" :disabled="disabled"/>
</el-form-item>
</el-form>
<el-button v-if="aliPayCanConfig" style="width: 200px;align-self: center" type="primary" size="small" @click="handleAliPay"> </el-button>
</div>
</el-tab-pane>
</el-tabs>
</div>
@ -662,7 +712,7 @@ import {
hnapaySave,
uploadCertInfo,
getHnaPayInfo,
changeBusinessPayMode
changeBusinessPayMode, wxPaySave, aliPaySave, wxPayUpdate, aliPayUpdate, getWxPayInfo, getAliPayInfo
} from '@/api/business'
import SharesettingDialog from '../../../components/Sharesetting';
import DomainSettingDialog from '../../../components/DomainSetting';
@ -711,6 +761,24 @@ export default {
bankBranch: '', //
contactPhone: '' //
},
wxPayForm: {
appId: '', // appid
appAppId: '', // APPappid
mchId: '', //
mchKey: '', //
secret: '', //
certUrl: '', //
},
aliPayForm: {
appId: '', // appid
privateKey: '', //
publicKey: '', //
decryKey: '', //key
gatewayUrl: '', //
},
isForever: false,
validDateDisable: false,
@ -744,6 +812,36 @@ export default {
],
},
wxPayRules: {
appId: [
{ required: true, message: '支付小程序appid不能为空', trigger: 'blur' }
],
appAppId: [
{ required: true, message: '支付APP端的appid不能为空', trigger: 'blur' }
],
mchId: [
{ required: true, message: '商户号不能为空', trigger: 'blur' }
],
mchKey: [
{ required: true, message: '商户秘钥不能为空', trigger: 'blur' }
],
secret: [
{ required: true, message: '私钥不能为空', trigger: 'blur' }
],
},
aliPayRules: {
appId: [
{ required: true, message: '应用appid不能为空', trigger: 'blur' }
],
privateKey: [
{ required: true, message: '应用私钥不能为空', trigger: 'blur' }
],
publicKey: [
{ required: true, message: '支付宝公钥不能为空', trigger: 'blur' }
],
},
showPhone: false,
showAddress: false,
userPhone: '',
@ -875,6 +973,10 @@ export default {
isWxaliPayOpenLoading: false,
//
businessPayMode: '0',
aliPayCanConfig: false,
wxPayCanConfig: true,
wxPayHasSave: false,
aliPayHasSave: false,
}
},
// data
@ -1077,6 +1179,10 @@ export default {
contactPhone: '' //
}
}
this.getWxPayInfo()
this.getAliPayInfo()
this.showPhone = false
this.personPhone = ''
this.userState = 1
@ -1436,6 +1542,33 @@ export default {
})
},
getWxPayInfo(){
let _this = this;
getWxPayInfo(this.currentBusinessId).then(res => {
console.log(res)
if (res.code === '') {
_this.wxPayForm = res.data
if (_this.wxPayForm.id){
console.log('getWxPayInfo-->', _this.wxPayForm)
_this.wxPayHasSave = true
}
}
})
},
getAliPayInfo(){
let _this = this;
getAliPayInfo(this.currentBusinessId).then(res => {
console.log(res)
if (res.code === '') {
_this.aliPayForm = res.data
if (_this.aliPayForm.id){
_this.aliPayHasSave = true
}
}
})
},
async hnapayOpenChange(newVal){
this.isHnaPayOpenLoading = true;
this.lastHnaPayOpen = !newVal;
@ -1469,7 +1602,113 @@ export default {
}else {
this.wxaliPayOpen = this.lastWxaliPayOpen;
}
}
},
handleWxPay() {
if (this.wxPayCanConfig) {
if (this.wxPayHasSave){
this.handleWxPayUpdate()
}else {
this.handleWxPaySave()
}
}
},
handleAliPay() {
if (this.aliPayCanConfig){
if (this.aliPayHasSave){
this.handleAliPayUpdate()
}else {
this.handleAliPaySave()
}
}
},
handleWxPaySave() {
let _this = this;
this.$refs['wxPayForm'].validate((valid) => {
if (valid) {
let param = {
businessId: this.currentBusinessId,
appId: this.wxPayForm.appId,
appAppId: this.wxPayForm.appAppId,
mchId: this.wxPayForm.mchId,
certUrl: this.wxPayForm.certUrl,
mchKey: this.wxPayForm.mchKey,
secret: this.wxPayForm.secret
}
wxPaySave(param).then(res => {
console.log(res)
if (res.code === '') {
_this.wxPayHasSave = true
this.$message({
message: '提交成功',
type: 'success'
})
}
})
}
})
},
handleWxPayUpdate() {
this.$refs['wxPayForm'].validate((valid) => {
if (valid) {
wxPayUpdate(this.wxPayForm).then(res => {
console.log(res)
if (res.code === '') {
this.$message({
message: '修改成功',
type: 'success'
})
}
})
}
})
},
handleAliPaySave() {
let _this = this;
this.$refs['aliPayForm'].validate((valid) => {
if (valid) {
let param = {
businessId: this.currentBusinessId,
appId: this.aliPayForm.appId,
privateKey: this.aliPayForm.privateKey,
publicKey: this.aliPayForm.publicKey,
decryKey: this.aliPayForm.decryKey,
gatewayUrl: this.aliPayForm.gatewayUrl,
}
aliPaySave(param).then(res => {
console.log(res)
if (res.code === '') {
_this.aliPayHasSave = true
this.$message({
message: '提交成功',
type: 'success'
})
}
})
}
})
},
handleAliPayUpdate() {
this.$refs['aliPayForm'].validate((valid) => {
if (valid) {
aliPayUpdate(this.aliPayForm).then(res => {
console.log(res)
if (res.code === '') {
this.$message({
message: '修改成功',
type: 'success'
})
}
})
}
})
},
}
}
</script>

Loading…
Cancel
Save