1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /**
- * 支付
- */
- import Vue from "vue";
- //#ifdef H5
- import $wxApi from "./wxapi.js";
- //#endif
- import $http from "uview-ui/libs/request"
- export default {
- //微信支付
- wechatPay(obj = {}) {
- uni.showLoading({
- title: '支付中'
- });
- return new Promise(r => {
- // 支付接口对应自己的url
- $http.post('url', obj)
- .then(res=>{
- //#ifdef H5
- $wxApi.JSAPI(res.data.wx).then(r);
- //#endif
- this.payError(res);
- }).catch(err =>{
- console.log('pay err',err);
- })
- });
- },
- // 支付错误处理
- payError(res){
- uni.hideLoading();
- if(res.code == 623){
- setTimeout(i=>{
- new Vue().$api.goto("/xx/xx");
- }, 2000);
- uni.showToast({
- title: res.msg + "即将跳转到xx页",
- icon: "none",
- duration: 2000
- });
- }
- }
- }
|