Browse Source

支付接口

yy 3 years ago
parent
commit
8ff10d86a5
1 changed files with 48 additions and 13 deletions
  1. 48 13
      src/views/PersonalCenter/ExaminationPayment.vue

+ 48 - 13
src/views/PersonalCenter/ExaminationPayment.vue

@ -61,15 +61,9 @@
61 61
        <el-form-item label="拟报考点:">
62 62
          <el-input class="myinput" v-model="form.want_place_name" :disabled="true"></el-input>
63 63
        </el-form-item>
64
        <el-form-item label="缴费方式:">
65
          <el-select class="myinput"  v-model="form.year" placeholder="请选择">
66
            <el-option label="11" value="11"></el-option>
67
          </el-select>
68
        </el-form-item>
69 64
      </el-form>
70 65
        <div class="myfooter">
71
            <img src="../../assets/img/erweima.svg">
72
            <el-button type="primary" @click="printChange">已完成缴费</el-button>
66
          <el-button type="primary" @click="toPay" v-if="form.pay_state == '未缴费'">去缴费</el-button>
73 67
        </div>
74 68
    </div>
75 69
    
@ -149,17 +143,58 @@ export default {
149 143
      this.showMain = true;
150 144
    },
151 145
    check(row) {
146
      this.showMain = false;
147
      for(let item in this.tableData){
148
        if(row.uuid == this.tableData[item].uuid){
149
          this.form = this.tableData[item]
150
        }
151
      }
152
    },
153
    toPay() {
152 154
      if(this.payState == 'true'){
153 155
        this.$message("考试缴费还未开启,请稍后操作");
154 156
      }else{
155
        this.showMain = false;
156
        for(let item in this.tableData){
157
          if(row.uuid == this.tableData[item].uuid){
158
            this.form = this.tableData[item]
157
        const serverBaseUrl = window.serverUrl.url;
158
        var xhr = new XMLHttpRequest();
159
        var url = serverBaseUrl+'/easypay/pay';
160
        xhr.open("post", url, true);
161
        xhr.setRequestHeader('content-type', 'application/json;charset=UTF-8')
162
        xhr.setRequestHeader('Authorization', 'Bearer 1');
163
        var data = {
164
            enroll_id:'0b716740f24544939d40685c02333ddb'
165
        };
166
        xhr.send(JSON.stringify(data));
167
168
        xhr.onreadystatechange = function () {
169
          if (xhr.readyState == XMLHttpRequest.DONE) {
170
            console.log('结果0:', xhr.responseText)
171
            try {
172
              if (xhr.responseText) {
173
                const response = JSON.parse(xhr.responseText);
174
                console.log('结果1:', response)
175
                if (xhr.status && xhr.status == 200) {
176
                  if (response.code == 500) {
177
                    //alert(response.msg);
178
                  } else if (response.code == 200) {
179
                    let url = response.data.redirectUrl;
180
                    window.open(url, '_blank').location;
181
                    let con;
182
                    con=confirm("是否已完成支付?"); //在页面上弹出对话框
183
                    if(con==true) window.location.reload();
184
                    else ;
185
                    // alert('信息显示为:是否已经完成支付? 已支付、未支付两个按钮!')
186
                    //TODO 点击"已支付",刷新当前页面。  点击"未支付",什么也不操作,弹框消失
187
                  }
188
                } else {
189
                    alert(response.msg);
190
                }
191
              }
192
            } catch (e) {
193
194
            }
159 195
          }
160
        }
196
        };
161 197
      }
162
      
163 198
    },
164 199
  }
165 200
}