| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- <template>
- <div>
- <el-dialog title="选择支付方式" :visible.sync="dialogPay" width="878px" class="dialog_pay" @closed="goBack">
- <div>
- <el-form label-width="106px" style="padding-left:140px;">
- <el-form-item label="支付金额">
- <span class="col_red">¥ {{money}}</span>
- </el-form-item>
- <el-form-item label="打赏课程" v-if="from === 'course'">
- <span class="col_red">{{pay_sn}}</span>
- </el-form-item>
- <el-form-item label="赞赏用户" v-if="from === 'micro'">
- <span class="col_red">{{pay_sn}}</span>
- </el-form-item>
- <el-form-item label="付费文章" v-if="from === 'notice'">
- <span class="col_red">{{pay_sn}}</span>
- </el-form-item>
- <el-form-item label="支付流水号" v-if="from === 'pay'">
- <span>{{pay_sn}}</span>
- </el-form-item>
- <el-form-item label="支付方式" class="spe" style="min-height:60px;">
- <div class="flex pay_way" style="flex-wrap:wrap;">
- <div style="margin-bottom:10px;" class="flex flex-a-c flex-j-c way" @click="changeIndex(item)"
- :class="[item.value==pay_select?'border_spe':'']" v-for="(item,index) in pay_way" :key="index">
- <div class="radio_button" :class="[item.value==pay_select?'radio':'']"></div>
- <img src="~/assets/images/icon/coin.png" style="margin-right:5px;width:28px;height:28px;"
- v-if="item.value==3">
- <img src="~/assets/images/icon/wechat_pay.png" style="margin-right:5px;"
- v-if="item.value==28||item.value==57 || item.value==50">
- <img src="~/assets/images/icon/ali_pay.png" style="margin-right:5px;"
- v-if="item.value==2||item.value==29||item.value ==85">
- {{item.name}}
- </div>
- </div>
- </el-form-item>
- </el-form>
- <div class="btn_wrap flex">
- <el-button class="flex flex-a-c flex-j-c" @click="dialogPay=false">关闭</el-button>
- <el-button type="primary" class="flex flex-a-c flex-j-c" style="margin-left:56px;" v-if="from === 'notice'"
- @click="payNoticeMoney">立即支付
- </el-button>
- <el-button type="primary" class="flex flex-a-c flex-j-c" style="margin-left:56px;" v-if="!from || from === 'pay'"
- @click="payMoney">立即支付
- </el-button>
- <el-button type="primary" class="flex flex-a-c flex-j-c" style="margin-left:56px;" v-if="from === 'course'"
- @click="payPost">立即打赏
- </el-button>
- <el-button type="primary" class="flex flex-a-c flex-j-c" style="margin-left:56px;" v-if="from === 'micro'"
- @click="payMicroPost">立即赞赏
- </el-button>
- </div>
- </div>
- </el-dialog>
- <el-dialog title="提示" :visible.sync="show_qrcode" width="450px" class="dialog_qr" :close-on-click-modal="false" @closed="goBack">
- <div class="qr_content" v-show="!show_pay_status">
- <div style="margin-bottom: 25px;">请在2小时内完成支付</div>
- <div class="qr_code m-auto">
- <canvas id="qrccode-canvas2"></canvas>
- </div>
- <div style="margin-bottom: 34px;">{{pay_select == 85?'支付宝扫码支付':'微信扫码支付' }}</div>
- </div>
- <div class="pay-status-box" v-show="show_pay_status && pay_success">
- <div><i class="el-icon-success"></i></div>
- <p class="pay-tips">支付成功</p>
- <el-button type="primary" plain @click="toUrl('order')">查看订单列表</el-button>
- </div>
- <div class="pay-status-box" v-show="show_pay_status && !pay_success">
- <div><i class="el-icon-error"></i></div>
- <p class="pay-tips">支付失败</p>
- <el-button type="danger" plain @click="toUrl('order')">查看订单列表</el-button>
- </div>
- </el-dialog>
- <el-dialog title="请输入余额支付密码" :visible.sync="popupSpecs" width="878px" class="dialog_pay" @closed="goBack">
- <el-form>
- <el-form-item label="余额支付密码" class="flex flex-j-c">
- <el-input v-model="balancePwd" type="password" placeholder="请输入密码"></el-input>
- </el-form-item>
- </el-form>
- <div style="margin-top:50px;" class="flex flex-j-c">
- <el-button class="flex flex-a-c flex-j-c" @click="popupSpecs=false">关闭</el-button>
- <el-button type="primary" class="flex flex-a-c flex-j-c" style="margin-left:56px;" @click="getVerifyPassword">
- 立即支付
- </el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import QRCode from "qrcode";
- var canvas = "";
- export default {
- name: "payBox",
- props: {
- orderPayId: Number,
- money: String,
- pay_sn: String,
- order_pay_id: Number,
- pay_way: Array,
- from: String,
- noJump: {
- type: Boolean,
- default: false
- },
- rewardTypes: Number,
- trick_id: Number
- },
- data() {
- return {
- interval: null,
- balancePwd: "",
- popupSpecs: false,
- show_qrcode: false,
- pay_select: 1,
- pay_name: "",
- dialogPay: false,
- show_pay_status: false,
- pay_success: false,
- };
- },
- methods: {
- showPay() {
- if (this.interval) {
- clearInterval(this.interval);
- }
- this.dialogPay = true;
- },
- toUrl(url, params) {
- if(!this.from) {
- this.goBack();
- return
- }
- this.$router.push(this.fun.getUrl(url, params));
- },
- createQrc(_url) {
- // this.init()
- this.$nextTick(function () {
- // DOM操作
- canvas = document.getElementById("qrccode-canvas2");
- QRCode.toCanvas(canvas, _url, error => {
- if (error) {
- console.log(error);
- }
- });
- });
- },
- goBack() {
- this.show_qrcode = false;
- this.popupSpecs = false;
- this.balancePwd = "";
- if (this.interval) {
- clearInterval(this.interval);
- }
- if (this.from === "pay" && !this.noJump) {
- this.$router.push(this.fun.getUrl("order"));
- } else {
- this.dialogPay = false;
- this.$emit("paySuccess", true);
- }
- // this.$router.go(-1)
- },
- // 微社区打赏支付
- payMicroPost() {
- if (this.pay_select != 3 && this.pay_select != 2 && this.pay_select != 6) {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- return
- }
- let url = "plugin.micro-communities.api.reward-log.index";
- let json = {
- pay_method: this.pay_select,
- amount: this.money,
- pay_name: this.pay_name,
- };
- if (this.rewardTypes == 0) {
- // 帖子打赏
- json.trick_id = this.trick_id;
- } else {
- // 评论打赏
- url = "plugin.micro-communities.api.reward-log.commentPay";
- json.comment_id = this.trick_id;
- }
- this.fun
- .$get(url, json, "..")
- .then(response => {
- if (response.result == 1) {
- if (this.pay_select == 3) {
- if (this.need_password) {
- this.popupSpecs = true;
- this.balancePwd = "";
- } else {
- this.dialogPay = false;
- this.$message.success(response.msg);
- this.$emit("paySuccess", true);
- }
- } else if (this.pay_select == 2) {
- // 支付宝
- window.location.href = response.data;
- // window.open(response.data, "_blank");
- } else if (this.pay_select == 6) {
- // 微信
- window.location.href = response.data;
- } else {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- }
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- // 课程打赏支付
- payPost() {
- if (this.pay_select != 3 && this.pay_select != 2 && this.pay_select != 6) {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- return
- }
- let json = {
- pay_method: this.pay_select,
- amount: this.money,
- pay_name: this.pay_name,
- goods_id: this.order_pay_id // 商品id
- };
- this.fun
- .$get("plugin.video-demand.api.lecturer-reward.run-reward-pay", json, "..")
- .then(response => {
- if (response.result == 1) {
- if (this.pay_select == 3) {
- if (this.need_password) {
- this.popupSpecs = true;
- this.balancePwd = "";
- } else {
- this.dialogPay = false;
- this.$message.success(response.msg);
- this.$emit("paySuccess", true);
- }
- } else if (this.pay_select == 2) {
- // 支付宝
- window.location.href = response.data;
- // window.open(response.data, "_blank");
- } else if (this.pay_select == 6) {
- // 微信
- window.location.href = response.data;
- } else {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- }
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- // 付费文章
- payNoticeMoney() {
- if (this.pay_select != 3 && this.pay_select != 2 && this.pay_select != 6) {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- return
- }
- let json = {
- pay_id: this.pay_select,
- money: this.money,
- pay_name: this.pay_name,
- id: this.order_pay_id, // 文章id
- art: 'pay'
- };
- this.fun
- .$get("plugin.article-pay.api.index.orderPay", json, "..")
- .then(response => {
- if (response.result == 1) {
- if (this.pay_select == 3) {
- if (this.need_password) {
- this.popupSpecs = true;
- this.balancePwd = "";
- } else {
- this.dialogPay = false;
- this.$message.success(response.msg);
- this.$emit("paySuccess", true);
- }
- } else if (this.pay_select == 2) {
- // 支付宝
- window.location.href = response.data;
- // window.open(response.data, "_blank");
- } else if (this.pay_select == 6) {
- // 微信
- window.location.href = response.data;
- } else {
- this.$message.error("PC端目前不支持该付款方式,请在移动端支付");
- }
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- // 商城订单付费
- payMoney() {
- if (this.pay_select == 3) {
- if (this.need_password) {
- this.popupSpecs = true;
- this.balancePwd = "";
- } else {
- this.balancePay();
- }
- } else if (this.pay_select == 2) {
- this.aliPayOrder();
- } else if (this.pay_select == 17) {
- this.payNoMoney();
- } else if (this.pay_select == 29) {
- this.getwechatPayAili();
- } else if (this.pay_select == 28) {
- this.getwechatPay();
- } else if (this.pay_select == 57) {
- this.pcweixin();
- } else if (this.pay_select == 85){
- this.Otherleshua_Alipay();
- } else {
- this.$message.error('PC端暂不支持该支付方式!')
- }
- },
- changeIndex(item) {
- if (item.need_password) {
- this.need_password = item.need_password;
- }
- this.pay_select = item.value;
- this.pay_name = item.name;
- },
- balancePay(password) {
- let json = {
- order_pay_id: this.order_pay_id
- };
- if (!this.fun.isTextEmpty(password)) {
- json = {
- order_pay_id: this.order_pay_id,
- payment_password: password
- };
- }
- this.fun
- .$get("order.credit-merge-pay.credit2", json, "")
- .then(response => {
- if (response.result == 1) {
- this.$message.success(response.msg);
- this.dialogPay = false;
- this.$emit("paySuccess", true);
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- aliPayOrder() {
- let payUrl = "order.merge-pay.alipay";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "支付中"
- )
- .then(response => {
- if (response.result == 1) {
- window.location.href = response.data;
- this.$message.success(response.msg);
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- payNoMoney() {
- let payUrl = "order.mergePay.COD";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "支付中"
- )
- .then(response => {
- if (response.result == 1) {
- this.$message.success(response.msg);
- this.show_pay_status = true;
- this.pay_success = true;
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- // 乐刷支付宝
- Otherleshua_Alipay(){
- let payUrl = "order.merge-pay.leshua-alipay";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "支付中"
- )
- .then(response => {
- if (response.result == 1) {
- console.log(response.data.pay_msg.link,'ddddd')
- this.createQrc(response.data.pay_msg.link);
- this.show_qrcode = true;
- if (this.orderPayId) {
- this.interval = setInterval(() => {
- this.getOrderStatus();
- }, 3000);
- }
- // window.location.href = response.data.data.rc_Result;
- // this.$message.success(response.msg);
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- //汇聚阿里支付
- getwechatPayAili() {
- let payUrl = "order.merge-pay.alipay-pay-hj";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "支付中"
- )
- .then(response => {
- if (response.result == 1) {
- window.location.href = response.data.data.rc_Result;
- this.$message.success(response.msg);
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- getOrderStatus() {
- this.fun
- .$get(
- 'payment.pc-scan.index',
- {
- order_ids: this.orderPayId
- },
- )
- .then(response => {
- if (response.result == 1) {
- if (response.data.pay_status) {
- // if (response.data.redirect) {
- // setTimeout(() => {
- // window.location.href = response.data.redirect
- // }, 3000);
- // }
- clearInterval(this.interval);
- this.show_pay_status = true;
- this.pay_success = true;
- }
- } else {
- clearInterval(this.interval);
- this.show_pay_status = true;
- this.pay_success = false;
- this.$message.error(response.msg);
- }
- });
- },
- pcweixin() {
- let payUrl = "order.merge-pay.wechat-native";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "加载中"
- )
- .then(response => {
- if (response.result == 1) {
- this.createQrc(response.data.code_url);
- this.show_qrcode = true;
- if (this.orderPayId) {
- this.interval = setInterval(() => {
- this.getOrderStatus();
- }, 3000);
- }
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- // 第三方支付 微信支付-汇聚
- getwechatPay() {
- let payUrl = "order.merge-pay.wechat-pay-hj";
- this.fun
- .$get(
- payUrl,
- {
- order_pay_id: this.order_pay_id
- },
- "加载中"
- )
- .then(response => {
- if (response.result == 1) {
- this.createQrc(response.data.data.rc_Result);
- this.show_qrcode = true;
- } else {
- this.$message.error(response.msg);
- }
- });
- },
- getVerifyPassword() {
- this.fun
- .$get("payment.password.check", {password: this.balancePwd}, "")
- .then(response => {
- if (response.result == 1) {
- this.balancePay(this.balancePwd);
- this.popupSpecs = false;
- } else {
- this.$message.error(response.msg);
- this.popupSpecs = false;
- this.dialogPay = false;
- }
- });
- }
- }
- };
- </script>
- <style lang="scss" rel="stylesheet/scss" scoped>
- .dialog_pay {
- :deep(.el-input) {
- width: 336px;
- height: 42px;
- }
- :deep(.el-dialog__body) {
- padding: 40px 0 30px 0;
- }
- :deep(.el-dialog__header) {
- border-bottom: solid 1px #f2f2f2;
- }
- :deep(.el-form-item__label) {
- text-align: left !important;
- }
- :deep(.el-form-item__label) {
- text-align: left !important;
- font-size: 16px;
- }
- }
- .pay_way {
- flex-wrap: wrap;
- .way {
- cursor: pointer;
- min-width: 120px;
- min-height: 60px;
- border-radius: 5px;
- border: solid 1px #cacaca;
- margin: 10px;
- padding: 0 10px;
- .radio_button {
- margin-right: 10px;
- border-radius: 50%;
- width: 10px;
- height: 10px;
- background-color: #e1e1e1;
- }
- }
- }
- .border_spe {
- border: solid 1px var(--color) !important;
- }
- .radio {
- background-color: var(--color) !important;
- }
- .btn_wrap {
- margin-top: 50px;
- padding-left: 270px;
- .el-button {
- width: 134px;
- height: 43px;
- border-radius: 4px;
- font-size: 16px;
- }
- }
- .dialog_qr {
- :deep(.el-dialog__header) {
- padding: 0;
- height: 56px;
- background-color: #f5f8fa;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- :deep(.el-dialog__body) {
- padding: 0;
- }
- }
- .qr_content {
- padding-top: 33px;
- padding-bottom: 27px;
- text-align: center;
- .qr_code {
- width: 220px;
- height: 220px;
- margin-bottom: 20px;
- #qrccode-canvas2 {
- width: 220px !important;
- height: 220px !important;
- }
- }
- }
- .pay-status-box {
- text-align: center;
- padding-bottom: 20px;
- i {
- font-size: 80px;
- color: var(--color);
- margin: 10px auto;
- }
- .el-icon-error {
- color: $red;
- }
- .pay-tips {
- font-size: 16px;
- font-weight: bold;
- margin: 10px auto 20px auto;
- }
- }
- </style>
|