首先上标签代码 //最主要的是这一行 img
<el-form
:model="Recharge"
:label-position="labelPosition"
ref="Recharge"
v-show="soupass"
:class="{'nameoopage':soupass}"
>
<el-form-item
:label="$t('myaccount.Transactionnumber1')"
prop="AccountBalance"
width="185px"
>
<!-- <el-form-item label="请及时付款,以便订单及时处理" prop="AccountBalance" width="185px"> -->
</el-form-item>
<el-form-item :label="$t('myaccount.Transactionnumber')" prop="AccountBalance">
<!-- <el-form-item label="交易号:" prop="AccountBalance" :label-width="formLabelWidth"> -->
<p style="padding: 1px;">{{currentdate}}</p>
</el-form-item>
<div>
{{$t('myaccount.Pleasebe')}}
<span>{{$t('myaccount.branch')}}</span>
{{$t('myaccount.branch1')}}
<!-- 请在 <span>28分钟</span>内付款,否则交易会被取消 -->
</div>
<div style="width:100%;text-align: right;">
<!-- 实付: -->
{{$t('myaccount.genepage')}}
<span
style="color: #FF756E;font-size: 20px;"
>{{Recharge.RechargeAmount}}</span>
</div>
<el-form-item width="100%">
<div style="text-align: center; position: relative;">
<div v-show="lessname" class="lessname" style="text-align: center;">
<div class="laseebake">{{$t('myaccount.Dimensional')}}</div>
<!-- <div class="laseebake">二维码已失效</div> -->
<el-button
:class="{'nameback':true,'pageback':isEn}"
@click="skname"
>{{$t('myaccount.Dimensional1')}}</el-button>
<!-- <el-button class="nameback" @click="skname">点击刷新</el-button> -->
</div>
<img
v-if="soupass == true?true:false"
:src="this.base + '/finance/wxpay/precreate/order?username=' + this.username + '&userId=' + this.userId + '&rechargeAmount=' + this.Recharge.RechargeAmount + '&userType=卖家' + '&productCode=CZ' + '&rechargeNo=' + this.currentdate"
>
</div>
</el-form-item>
</el-form>
下面上方法
方法第一步
skname() {
clearInterval(this.timer);
this.lessname = false;
this.submitsrs();
},
第二步
//充值方法
souename() {
// 微信充值 username
this.anamepas();
// localStorage.setItem('goodnamepak','0');
if (this.Recharge.PaymentMethod === "1") {
if (this.Recharge.RechargeAmount) {
if (
this.Recharge.RechargeAmount > 0.009 &&
this.Recharge.RechargeAmount < 1000000
) {
this.submibage();
} else {
this.$message({
showClose: true,
message: this.$t("payment.iqhfqwe"),
type: "warning"
});
}
} else {
this.$message({
showClose: true,
message: this.$t("myaccount.enterthe"),
type: "warning"
});
}
} else if (this.Recharge.PaymentMethod === "2") {
if (this.Recharge.RechargeAmount) {
if (
this.Recharge.RechargeAmount > 0.009 &&
this.Recharge.RechargeAmount < 1000000
) {
var regP = /^\d+(\.\d+)?$/; //非负浮点数
var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
if (
(regP.test(this.Recharge.RechargeAmount) ||
regNeg.test(this.Recharge.RechargeAmount)) &&
reg.test(this.Recharge.RechargeAmount)
) {
this.submitsrs();
this.soupass = true;
this.souname = false;
} else {
this.$message({
showClose: true,
message: this.$t("payment.bosname"),
type: "warning"
});
}
} else {
this.$message({
showClose: true,
message: this.$t("payment.iqhfqwe"),
type: "warning"
});
}
} else {
this.$message({
showClose: true,
message: this.$t("myaccount.enterthe"),
type: "warning"
});
}
}
},
// 微信充值
submitsrs() {
//微信充值方法封装
// this.souname = false;
this.base = base.baseUrl;
let ysuname = JSON.parse(localStorage.getItem("user"));
this.username = ysuname.user.username;
if(this.thisk.user.topUserId == 0){
this.userId = this.$utils.cookie.getCookie("userId")
}else{
this.userId = this.thisk.user.topUserId
}
// this.userId = ysuname.user.userid;
this.rechargeAmount = this.Recharge.RechargeAmount;
this.userType = "卖家";
this.productCode = "CZ";
this.rechargeNo = this.currentdate;
this.timer = setInterval(refreshCount, 1500);
let that = this;
function refreshCount() {
that.kuoma();
}
},
下面是定时器一直调取接口查看是否充值成功或充值
kuoma() {
let oppo = {
rechargeNo: this.currentdate
};
this.$api.Implementation.goweihover(oppo).then(res => {
this.vivo = res.data;
if (this.vivo.trade_state_desc == "支付成功") {
clearInterval(this.timer);
// clearInterval(this.timer);
//this.timer = null;
setTimeout(() => {
let useid = {};
if(this.thisk.user.topUserId == 0){
useid.sellerId = this.$utils.cookie.getCookie("userId")
}else{
useid.sellerId = this.thisk.user.topUserId
}
this.$api.Implementation.seller(useid).then(res => {
if (res.data) {
const aryboo = res.data;
for (let i = 0; i < aryboo.length; i++) {
if (aryboo[i].coinType == "CNY") {
this.account.naber6 = this.$utils.commonUtils.$money(aryboo[i].freeAmount); //CNY可用余额
}
}
}
});
this.soupass = false;
this.souname = false;
this.RechargeWithdrawalFormVisible = false;
this.CashWithdrawalFormVisible = true;
this.cashForm.naiwack1 = this.rechargeNo;
this.cashForm.naiwack2 = this.rechargeAmount;
this.cashForm.naiwack3 = this.outime;
}, 1500);
} else if (this.vivo.trade_state_desc == "订单未支付") {
this.lessname = false;
} else {
this.souname = false;
this.lessname = true;
}
});
},
所有的充值都有延迟,不可能立马充值成功金额立马就有,数据跑来跑去都还有延迟呢