diff --git a/src/api/market/apitype.js b/src/api/market/apitype.js index 724019a..c16edcf 100644 --- a/src/api/market/apitype.js +++ b/src/api/market/apitype.js @@ -1,11 +1,11 @@ import request from '@/utils/request' -export function pay(query) { +export function pay(data) { return request({ - url: '/pay/alipay/pay', - method: 'get', - params: query + url: '/pay/alipay/pay/payZFB', + method: 'post', + data: data }) } // 查询接口列表 diff --git a/src/views/market/apitype/index.vue b/src/views/market/apitype/index.vue index 7ee2ede..7481392 100644 --- a/src/views/market/apitype/index.vue +++ b/src/views/market/apitype/index.vue @@ -94,6 +94,29 @@ @pagination="getList" /> + + + +
+ 确认支付 +
+
+
@@ -109,6 +132,7 @@ export default { data() { return { + dialogTableVisible:false, all:"全部类型", activeNameL:"全部类型", editableTabs: [], @@ -146,23 +170,85 @@ export default { // 表单校验 rules: { }, - pay:{ - - }, + amountVal: '', + disabled: false, + // 同步跳转页面地址 + returnUrl:'http://localhost:80/#/entertainment/payment', + //充值参数 + rechargeParams: { + "totalAmt": '', //金额 + "paymentType": "0", //支付方式[0:微信,1:支付宝,2:余额,3:活动] + "transType": "1" //交易类型[0:充值,1:消费] + } }; }, created() { this.getList(); }, methods: { + paymentTypeChange(val) { + this.rechargeParams.paymentType = val + }, + //确认支付 + async surePay() { + if (this.rechargeParams.totalAmt === '') { + this.$message.warning('请输入金额'); + return; + } + if (this.rechargeParams.paymentType === '0') { + + } else if (this.rechargeParams.paymentType === '1') { + let praem = { + // 生成一个随你的订单号 方便测试 + outTradeNo:this.getProjectNum() + Math.floor(Math.random() * 10000), + // 传递支付金额 + totalAmount:this.rechargeParams.totalAmt, + // 传递同步跳转地址 + returnUrl:this.returnUrl, + // 商品名称 + subject:'支付金额', + // 支付类型 + productCode:'FAST_INSTANT_TRADE_PAY' + } + pay(praem).then(code => { + if (code.code === 200) { + // 支付方式跳转 + this.$message.success('支付宝支付') + const payDiv = document.getElementById('payDiv'); + if (payDiv) { + document.body.removeChild(payDiv); + } + const div = document.createElement('div'); + div.id = 'payDiv'; + div.innerHTML = code.data; + document.body.appendChild(div); + document.getElementById('payDiv').getElementsByTagName('form')[0].submit(); + } + }) + } + }, + // 获取当前日期的方法 + getProjectNum () { + const projectTime = new Date() // 当前中国标准时间 + const Year = projectTime.getFullYear() // 获取当前年份 支持IE和火狐浏览器. + const Month = projectTime.getMonth() + 1 // 获取中国区月份 + const Day = projectTime.getDate() // 获取几号 + var CurrentDate = Year + if (Month >= 10) { // 判断月份和几号是否大于10或者小于10 + CurrentDate += Month + } else { + CurrentDate += '0' + Month + } + if (Day >= 10) { + CurrentDate += Day + } else { + CurrentDate += '0' + Day + } + return CurrentDate + }, gotoMaintained(customer){ - this.pay.subject=customer.sysIntro - this.pay.traceNo=Math.floor(Math.random() * 900000) + 100000 - this.pay.totalAmount=customer.sysNumber - this.pay.returnUrl = `http://47.116.173.119:80/alipay/pay?subject=${this.pay.subject}&traceNo=${this.pay.traceNo}&totalAmount=${this.pay.totalAmount}`; - pay(this.pay).then(res => { - console.log(res); - }) + this.dialogTableVisible=true; + this.rechargeParams.totalAmt=customer.sysNumber; }, getType(activeNameL){ this.activeNameL=activeNameL