|
@@ -18,7 +18,11 @@
|
|
|
</span>
|
|
|
<div class="cardContent">
|
|
|
<div class="selectCard">选择油卡</div>
|
|
|
- <el-input v-model="petrifactionCard" placeholder="请输入以1开头的19位中石化加油卡号" />
|
|
|
+ <el-form :model="petrifaction" :rules="petrifactionRule" ref="petrifaction">
|
|
|
+ <el-form-item prop="petrifactionCard">
|
|
|
+ <el-input v-model="petrifaction.petrifactionCard" placeholder="请输入以1开头的19位中石化加油卡号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
<div class="alert">
|
|
|
<img src="@/assets/image/cardAlert@2x.png" alt="">
|
|
|
<span>请仔细核对卡号,避免造成不必要的损失。</span>
|
|
@@ -32,7 +36,11 @@
|
|
|
</span>
|
|
|
<div class="cardContent">
|
|
|
<div class="selectCard">选择油卡</div>
|
|
|
- <el-input v-model="petrifactionCard" placeholder="请输入以9开头的16位中石油加油卡号" />
|
|
|
+ <el-form :model="petroleum" :rules="petroleumRule" ref="petroleum">
|
|
|
+ <el-form-item prop="petroleumCard">
|
|
|
+ <el-input v-model="petroleum.petroleumCard" placeholder="请输入以9开头的16位中石油加油卡号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
<div class="alert">
|
|
|
<img src="@/assets/image/cardAlert@2x.png" alt="">
|
|
|
<span>请仔细核对卡号,避免造成不必要的损失。</span>
|
|
@@ -76,15 +84,48 @@
|
|
|
|
|
|
<script>
|
|
|
import Http from '@/extend/Http';
|
|
|
+import {Message} from "element-ui";
|
|
|
export default {
|
|
|
name: 'oilRecharge',
|
|
|
data() {
|
|
|
+ var validPetrifaction = (rule, value, callback) => {
|
|
|
+ if (!value) {
|
|
|
+ return callback(new Error('油卡不能为空'));
|
|
|
+ } else if (!/^1\d{18}$/.test(value)) {
|
|
|
+ return callback(new Error('请输入合法油卡'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ var validPetroleum = (rule, value, callback) => {
|
|
|
+ if (!value) {
|
|
|
+ return callback(new Error('油卡不能为空'));
|
|
|
+ } else if (!/^9\d{15}$/.test(value)) {
|
|
|
+ return callback(new Error('请输入合法油卡'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
return {
|
|
|
activeName: 'petrifaction',
|
|
|
// 石化
|
|
|
- petrifactionCard: '',
|
|
|
+ petrifaction: {
|
|
|
+ petrifactionCard: '',
|
|
|
+ },
|
|
|
+ petrifactionRule: {
|
|
|
+ petrifactionCard: [
|
|
|
+ { validator: validPetrifaction, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ },
|
|
|
// 石油
|
|
|
- petrifactionCard: '',
|
|
|
+ petroleum: {
|
|
|
+ petroleumCard: ''
|
|
|
+ },
|
|
|
+ petroleumRule: {
|
|
|
+ petroleumCard: [
|
|
|
+ { validator: validPetroleum, trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ },
|
|
|
// 充值面额
|
|
|
oil_amount: [],
|
|
|
// 当前面额
|
|
@@ -111,7 +152,7 @@ export default {
|
|
|
// 获取充值面额
|
|
|
async getDenomination() {
|
|
|
let res = await Http.getInstance().getDenomination();
|
|
|
- console.log('油卡面额', res);
|
|
|
+ // console.log('油卡面额', res);
|
|
|
if (res && res.msg == '请求成功') {
|
|
|
this.oil_amount = res.data.oil_amount
|
|
|
}
|
|
@@ -122,7 +163,57 @@ export default {
|
|
|
this.curAmount = item
|
|
|
},
|
|
|
// 充值按钮
|
|
|
- recharfeBtn() {}
|
|
|
+ recharfeBtn() {
|
|
|
+ if (!this.curAmount) {
|
|
|
+ Message({
|
|
|
+ message: '请选择充值金额', type: "warning"
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.activeName === 'petrifaction') {
|
|
|
+ this.$refs.petrifaction.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ let res = await Http.getInstance().RechargeOrder({
|
|
|
+ cardno: this.petrifaction.petrifactionCard,
|
|
|
+ amount: this.curAmount
|
|
|
+ });
|
|
|
+ console.log('石化充值', res);
|
|
|
+ if (res && res.msg == '请求成功') {
|
|
|
+ localStorage.setItem('order_paying', JSON.stringify(res.data));
|
|
|
+ this.$router.replace({
|
|
|
+ name: 'opayment',
|
|
|
+ params: {
|
|
|
+ order_sn: res.data.order_sn,
|
|
|
+ type: '1',
|
|
|
+ recharfe: 'false'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.activeName === 'petroleum') {
|
|
|
+ this.$refs.petroleum.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ let res = await Http.getInstance().RechargeOrder({
|
|
|
+ cardno: this.petroleum.petroleumCard,
|
|
|
+ amount: this.curAmount
|
|
|
+ });
|
|
|
+ console.log('石油充值', res);
|
|
|
+ if (res && res.msg == '请求成功') {
|
|
|
+ localStorage.setItem('order_paying', JSON.stringify(res.data));
|
|
|
+ this.$router.replace({
|
|
|
+ name: 'opayment',
|
|
|
+ params: {
|
|
|
+ order_sn: res.data.order_sn,
|
|
|
+ type: '1',
|
|
|
+ recharfe: 'false'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -213,6 +304,9 @@ export default {
|
|
|
.selectCard {
|
|
|
margin-bottom: 1.667rem;
|
|
|
}
|
|
|
+ /deep/.el-form-item {
|
|
|
+ margin-bottom: 10px;
|
|
|
+ }
|
|
|
/deep/.el-input__inner {
|
|
|
border: 0;
|
|
|
border-bottom: 1px solid #BFBFBF;
|