Browse Source

支付接口

yy 3 years ago
parent
commit
3c840533e1

+ 66 - 12
src/views/PersonalCenter/ExaminationPayment/PayDetails.vue

@ -26,38 +26,92 @@
26 26
      <el-form-item label="考点:">
27 27
        {{ form.want_place_name }}
28 28
      </el-form-item>
29
      <el-form-item label="缴费方式:" v-if="form.pay_state == '未缴费'">
30
        <el-select v-model="payValue" placeholder="请选择">
31
          <el-option label="微信" value="1">微信</el-option>
32
          <el-option label="支付宝" value="2">支付宝</el-option>
33
        </el-select>
34
      </el-form-item>
35
      <el-form-item label="缴费方式:" v-if="form.pay_state != '未缴费'">
36
        微信
37
      </el-form-item>
38 29
    </el-form>
39 30
    <p slot="footer" class="dialog-footer" style="text-align: center;margin: 0;">
40
      <el-button v-if="form.pay_state == '未缴费'" type="primary" style="border-radius: 3rem;width: 4rem;margin-bottom:.4rem;">缴费</el-button>
31
      <el-button @click="toPay" v-if="form.pay_state == '未缴费'" type="primary" style="border-radius: 3rem;width: 4rem;margin-bottom:.4rem;">缴费</el-button>
41 32
    </p>
42 33
  </div>
43 34
</template>
44 35
45 36
<script>
46 37
import local from "@/utils/local";
38
import {
39
  getMyPayIsClose, //列表
40
} from "@/api/home";
47 41
export default {
48 42
  data() {
49 43
    return {
50 44
      form: {},
51
      payValue: ""
45
      payValue: "",
46
      payState: "",
52 47
    }
53 48
  },
54 49
  created() {
55 50
    this.form = local.get("payDetails");
51
    this.myPayIsClose();
56 52
  },
57 53
  methods: {
54
    // 缴费节点状态
55
    async myPayIsClose() {
56
      let res = await getMyPayIsClose({});
57
58
      // 解构数据
59
      let { code, data, msg } = res;
60
61
      // 赋值渲染
62
      if (code === 200) {
63
        this.payState = msg;
64
      }
65
    },
58 66
    goback() {
59 67
      this.$router.go(-1)
60
    }
68
    },
69
    toPay() {
70
      if(this.payState == 'true'){
71
        this.$message("考试缴费还未开启,请稍后操作");
72
      }else{
73
        const serverBaseUrl = window.serverUrl.url;
74
        var xhr = new XMLHttpRequest();
75
        var url = serverBaseUrl+'/easypay/pay';
76
        xhr.open("post", url, true);
77
        xhr.setRequestHeader('content-type', 'application/json;charset=UTF-8')
78
        xhr.setRequestHeader('Authorization', 'Bearer 1');
79
        var data = {
80
            enroll_id:'0b716740f24544939d40685c02333ddb'
81
        };
82
        xhr.send(JSON.stringify(data));
83
84
        xhr.onreadystatechange = function () {
85
          if (xhr.readyState == XMLHttpRequest.DONE) {
86
            console.log('结果0:', xhr.responseText)
87
            try {
88
              if (xhr.responseText) {
89
                const response = JSON.parse(xhr.responseText);
90
                console.log('结果1:', response)
91
                if (xhr.status && xhr.status == 200) {
92
                  if (response.code == 500) {
93
                    //alert(response.msg);
94
                  } else if (response.code == 200) {
95
                    let url = response.data.redirectUrl;
96
                    window.open(url, '_blank').location;
97
                    let con;
98
                    con=confirm("是否已完成支付?"); //在页面上弹出对话框
99
                    if(con==true) window.location.reload();
100
                    else ;
101
                    // alert('信息显示为:是否已经完成支付? 已支付、未支付两个按钮!')
102
                    //TODO 点击"已支付",刷新当前页面。  点击"未支付",什么也不操作,弹框消失
103
                  }
104
                } else {
105
                    alert(response.msg);
106
                }
107
              }
108
            } catch (e) {
109
110
            }
111
          }
112
        };
113
      }
114
    },
61 115
  }
62 116
}
63 117
</script>

+ 4 - 25
src/views/PersonalCenter/ExaminationPayment/index.vue

@ -17,13 +17,11 @@
17 17
import local from "@/utils/local";
18 18
import {
19 19
  getPayList, //列表
20
  getMyPayIsClose,
21 20
} from "@/api/home";
22 21
export default {
23 22
  data() {
24 23
    return {
25 24
      tableData: [],
26
      payState: "",
27 25
    }
28 26
  },
29 27
  created() {
@ -42,32 +40,13 @@ export default {
42 40
      // 赋值渲染
43 41
      if (code === 200) {
44 42
        this.tableData = data.myEnroll;
45
        this.myPayIsClose();
46
      }
47
    },
48
    // 缴费节点状态
49
    async myPayIsClose() {
50
      let res = await getMyPayIsClose({});
51
52
      // 解构数据
53
      let { code, data, msg } = res;
54
55
      // 赋值渲染
56
      if (code === 200) {
57
        this.payState = msg;
58 43
      }
59 44
    },
60 45
    detail(val) {
61
      if(this.payState == 'true'){
62
        if(val.pay_state == '未缴费'){
63
          this.$message("考试缴费还未开启,请稍后操作");
64
        }
65
      }else{
66
        local.set("payDetails", val);
67
        this.$router.push({
68
          path:"/pay_details",
69
        });
70
      }
46
      local.set("payDetails", val);
47
      this.$router.push({
48
        path:"/pay_details",
49
      });
71 50
    },
72 51
    goback() {
73 52
      this.$router.go(-1)

+ 2 - 2
src/views/home/index.vue

@ -90,7 +90,7 @@ export default {
90 90
    border-bottom: 1px solid #f2f2f2;
91 91
  }
92 92
  .home-search /deep/ .el-input {
93
    width: 75%;
93
    width: 74%;
94 94
    margin: 0 auto;
95 95
  }
96 96
  .home-search /deep/ .el-button {
@ -119,7 +119,7 @@ export default {
119 119
  }
120 120
  .footer_img {
121 121
    width: 100%;
122
    margin: .2rem .15rem;
122
    text-align: center;
123 123
    img {
124 124
      margin: 0 .1rem;
125 125
      width: 170px;