|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="payment">
|
|
|
+ <div class="payment" v-if="data">
|
|
|
<ul class="payment-left">
|
|
|
<li v-for="(itemP,indexP) in payList" :key="indexP" @click="handleChangePay(itemP.type)" :class="[payType===itemP.type?'active':'']">
|
|
|
<img :src="itemP.img" />
|
|
@@ -8,20 +8,21 @@
|
|
|
</ul>
|
|
|
<div class="payment-right">
|
|
|
<i class="el-icon-close" @click="closeDialogue"></i>
|
|
|
- <h2>{{data.title}}</h2>
|
|
|
- <h3>{{data.org}}</h3>
|
|
|
- <p class="price">¥{{data.price|cutMoneyFiter}}</p>
|
|
|
+ <h2>{{data.name}}</h2>
|
|
|
+ <h3>{{data.org_name}}</h3>
|
|
|
+ <p class="price">¥{{data.price_discount|cutMoneyFiter}}</p>
|
|
|
<template v-if="payType==='dui'">
|
|
|
<el-input class="code" placeholder="在此输入兑换码" v-model="codeValue"></el-input>
|
|
|
<a class="exchange" @click="handleExchange">兑换</a>
|
|
|
<b class="tips">输入兑换码</b>
|
|
|
</template>
|
|
|
- <template v-else-if="payType==='wei'">
|
|
|
- <img class="img-code" src="../../../assets/img-code.png" />
|
|
|
+ <template v-else>
|
|
|
+ <canvas id="QRCode_header" style="width: 338px; height: 338px; cursor: pointer;" @click="handleRefresh"></canvas>
|
|
|
+ </template>
|
|
|
+ <template v-if="payType==='wei'">
|
|
|
<b class="tips">请使用微信扫一扫</b>
|
|
|
</template>
|
|
|
<template v-else-if="payType==='zhi'">
|
|
|
- <img class="img-code" src="../../../assets/img-code.png" />
|
|
|
<b class="tips">请使用支付宝扫一扫</b>
|
|
|
</template>
|
|
|
</div>
|
|
@@ -32,10 +33,12 @@
|
|
|
//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
//例如:import 《组件名称》from ‘《组件路径》';
|
|
|
import { cutMoneyFiter } from '@/utils/defined';
|
|
|
+import { getLogin } from "@/api/ajax";
|
|
|
+import QRCode from "qrcode";
|
|
|
export default {
|
|
|
//import引入的组件需要注入到对象中才能使用
|
|
|
components: { },
|
|
|
- props: ["data", "payWay"],
|
|
|
+ props: ["data", "payWay", "qr_code_url", "orderId"],
|
|
|
filters:{
|
|
|
cutMoneyFiter
|
|
|
},
|
|
@@ -61,19 +64,73 @@ export default {
|
|
|
], // 支付方式
|
|
|
payType: 'dui',
|
|
|
codeValue: '', // 兑换码的值
|
|
|
+ codeImg: '',
|
|
|
+ payCode:{
|
|
|
+ wei: 'http://localhost:9970/#/people_manage',
|
|
|
+ zhi: 'http://localhost:9970/#/organize_manage'
|
|
|
+ },
|
|
|
+ opts: {
|
|
|
+ errorCorrectionLevel: "H", //容错级别
|
|
|
+ type: "image/png", //生成的二维码类型
|
|
|
+ quality: 1, //二维码质量
|
|
|
+ margin: 0, //二维码留白边距
|
|
|
+ width: 330, //宽
|
|
|
+ height: 330, //高
|
|
|
+ text: "", //二维码内容
|
|
|
+ color: {
|
|
|
+ dark: "#333333", //前景色
|
|
|
+ light: "#fff", //背景色
|
|
|
+ },
|
|
|
+ },
|
|
|
+ timer: null,
|
|
|
}
|
|
|
},
|
|
|
//计算属性 类似于data概念
|
|
|
computed: {},
|
|
|
//监控data中数据变化
|
|
|
watch: {
|
|
|
-
|
|
|
+ // data:{
|
|
|
+ // handler(val, oldVal) {
|
|
|
+ // const _this = this;
|
|
|
+ // if (val) {
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // // 深度观察监听
|
|
|
+ // deep: true,
|
|
|
+ // },
|
|
|
},
|
|
|
//方法集合
|
|
|
methods: {
|
|
|
// 支付方式
|
|
|
handleChangePay(type){
|
|
|
this.payType = type;
|
|
|
+ if(type==='dui'){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let MethodName = "/ShopServer/Client/OrderManager/UpdateOrderPayType";
|
|
|
+ let data = {
|
|
|
+ id: this.orderId,
|
|
|
+ pay_type: this.payType==='wei'?3:this.payType==='zhi'?4:null
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status === 1){
|
|
|
+ this.payCode[this.payType] = res.qr_code_url
|
|
|
+ this.createQRCode()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ createQRCode(){
|
|
|
+ let msg = document.getElementById("QRCode_header");
|
|
|
+ setTimeout(() => {
|
|
|
+ QRCode.toCanvas(msg, this.payCode[this.payType], this.opts, function (error) {
|
|
|
+ if (error) {
|
|
|
+ console.log("二维码加载失败", error);
|
|
|
+ this.$message.error("二维码加载失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 1000);
|
|
|
},
|
|
|
closeDialogue(){
|
|
|
this.$emit("handleClose")
|
|
@@ -81,6 +138,40 @@ export default {
|
|
|
// 兑换
|
|
|
handleExchange(){
|
|
|
|
|
|
+ },
|
|
|
+
|
|
|
+ handleRefresh(){
|
|
|
+ let MethodName = "/ShopServer/Client/OrderManager/GetOrderNewPayQRCode";
|
|
|
+ let data = {
|
|
|
+ id: this.orderId,
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status === 1){
|
|
|
+ this.payCode[this.payType] = res.qr_code_url
|
|
|
+ this.createQRCode()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // this.payCode = {
|
|
|
+ // wei: 'https://baidu.com',
|
|
|
+ // zhi: 'https://xdf.cn'
|
|
|
+ // }
|
|
|
+ // this.createQRCode()
|
|
|
+ },
|
|
|
+ getOrderStatus(){
|
|
|
+ let MethodName = "/ShopServer/Client/OrderManager/GetOrderPayStatus";
|
|
|
+ let data = {
|
|
|
+ id: this.orderId,
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status === 1){
|
|
|
+ if(res.is_success==='true'){
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.$emit("handleClose")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
@@ -89,7 +180,14 @@ export default {
|
|
|
},
|
|
|
//生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted() {
|
|
|
-
|
|
|
+ if(this.qr_code_url){
|
|
|
+ this.payCode[this.payType] = this.qr_code_url
|
|
|
+ this.createQRCode()
|
|
|
+ this.timer = null;
|
|
|
+ this.timer = setInterval(() => {
|
|
|
+ this.getOrderStatus()
|
|
|
+ }, 5000);
|
|
|
+ }
|
|
|
},
|
|
|
//生命周期-创建之前
|
|
|
beforeCreated() { },
|
|
@@ -210,7 +308,7 @@ export default {
|
|
|
display: block;
|
|
|
margin-top: 40px;
|
|
|
}
|
|
|
- .img-code{
|
|
|
+ #QRCode_header{
|
|
|
border: 1px solid #EBEBEB;
|
|
|
padding: 8px;
|
|
|
}
|