123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import Vue from "vue";
- import $wxApi from "./wxapi.js";
- import $http from "./uview-ui/libs/request"
- export default {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- wxPay(obj = {}, url = '/client/pay/wechat', jumpUrl) {
- uni.showLoading({
- title: '支付中'
- });
- return new Promise(r => {
- $http.post(url, obj)
- .then(res => {
-
- if (res.data.needPay && !res.data.monthId) {
-
- $wxApi.JSAPI(res.data.wx, jumpUrl).then(r);
-
- } else if (res.data.monthId) {
-
- $wxApi.JSAPI(res.data.wx, jumpUrl).then(r);
-
- } else {
- uni.showToast({
- title: "无需支付",
- icon: "none",
- duration: 2000
- });
- setTimeout(() => {
-
- if (jumpUrl) {
- window.location.href = jumpUrl;
- } else {
- window.location.reload();
- }
-
- }, 1500)
- }
- })
- });
- },
-
- wechatPay(obj = {}, url = '/client/pay/wechat', jumpUrl) {
- uni.showLoading({
- title: '支付中'
- });
- return new Promise(r => {
- $http.post(url, obj)
- .then(res => {
-
- if (res.data.needPay && !res.data.monthId) {
-
- $wxApi.JSAPI(res.data.wx, jumpUrl).then(r);
-
- } else if (res.data.monthId) {
-
- $wxApi.JSAPI(res.data.wx, jumpUrl).then(r);
-
- } else {
- uni.showToast({
- title: "无需支付",
- icon: "none",
- duration: 2000
- });
- setTimeout(() => {
-
- if (jumpUrl) {
- window.location.href = jumpUrl;
- } else {
- window.location.reload();
- }
-
- }, 1500)
- }
- this.payError(res);
- }).catch(err => {
-
- console.log('pay err', err);
- })
- });
- },
-
- payError(res) {
- uni.hideLoading();
- if (res.code == 623) {
- setTimeout(i => {
- new Vue().$api.goto("/pages/userCenter/myOrder/myOrder");
- }, 2000);
- uni.showToast({
- title: res.msg + " 即将跳转到订单页",
- icon: "none",
- duration: 2000
- });
- }
- }
- }
|