| common/api/index.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| common/http.interceptor.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| common/util.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| main.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| pay/login.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| pay/scanpay.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
common/api/index.js
@@ -20,12 +20,15 @@ export const getOpenIdBase = (params, config = {}) => http.get(URL + '/payfour-merchant/v1/web/aggregatePayAllin/getOpenIdBase', params, config = {}); /*统一登录*/ /*统一授权*/ export const userLogin = (params, config = {}) => { let path = '/payfour-merchant/v1/web/aggregatePayAllin/getOpenId' let path = '/payfour-merchant/v1/web/aggregatePayAllin/getOpenId' //微信授权 if(params.platform==5){ //支付宝授权 path = '/payfour-merchant/v1/web/h5PayAli/getUserIdByCode' } if (params.platform == 15) { //云闪付授权 path = '/service-merchant/v1/web/h5PayUnionPay/getUserIdByCode' } return http.get(URL + path, params, config = {}) }; common/http.interceptor.js
@@ -1,53 +1,77 @@ import { ACCESSTOKEN, config, DEBUG ACCESSTOKEN, config, DEBUG } from '@/common/config.js'; import { getPlat getPlat } from 'common/util.js'; module.exports = (vm) => { uni.$u.http.setConfig((x) => { return x = { // baseURL: config.baseURL, dataType: 'json', timeout: 60000, showLoading: false, //是否显示全局loading timer: null, loadingTime: 800, //多少秒无返回再显示loading header: { 'Clientid': '944c6aade52ebbffc015478e6ce51b5a', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Access-Control-Allow-Origin': '*' } } }) // 请求拦截 uni.$u.http.interceptors.request.use((x) => { DEBUG && console.log('请求参数', x); // 引用token const TOKEN = uni.getStorageSync(ACCESSTOKEN); if (TOKEN) { x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN; } return x; }, x => { return Promise.reject(x) }) // 响应拦截 uni.$u.http.interceptors.response.use((x) => { DEBUG && console.log('返回结果', x); let res = x.data if (res.code == 10000) { return res.data; } else if (res.code == 10002) { return Promise.reject(res) } else { vm.$u.toast(res.description || res.msg ||res.info || "请求异常!"); //错误提示信息 return Promise.reject(res) } }, (response) => { vm.$u.toast("请求异常!"); //错误提示信息 return Promise.reject(response) }) uni.$u.http.setConfig((x) => { return x = { // baseURL: config.baseURL, dataType: 'json', timeout: 60000, showLoading: false, //是否显示全局loading timer: null, loadingTime: 800, //多少秒无返回再显示loading header: { 'Clientid': '944c6aade52ebbffc015478e6ce51b5a', 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Access-Control-Allow-Origin': '*' } } }) // 请求拦截 uni.$u.http.interceptors.request.use((x) => { DEBUG && console.log('请求参数', x); // 引用token const TOKEN = uni.getStorageSync(ACCESSTOKEN); if (TOKEN) { x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN; } const plat = getPlat() if (plat == 2) { //微信 const OPENID = uni.getStorageSync('OPENID' + plat) || null const UNIONID = uni.getStorageSync('UNIONID' + plat) || null if (OPENID) { x.header['Openid'] = OPENID; } if (UNIONID) { x.header['Unionid'] = UNIONID; } } if (plat == 5) { //支付宝 const ALIUSERID = uni.getStorageSync('ALIUSERID' + plat) || null if (ALIUSERID) { x.header['Aliuserid'] = ALIUSERID; } } if (plat == 15) { //云闪付 const UNIONPAYID = uni.getStorageSync('UNIONPAYID ' + plat) || null if (UNIONPAYID) { x.header['Unionpayid '] = UNIONPAYID; } } return x; }, x => { return Promise.reject(x) }) // 响应拦截 uni.$u.http.interceptors.response.use((x) => { DEBUG && console.log('返回结果', x); let res = x.data if (res.code == 10000) { return res.data; } else if (res.code == 10002) { return Promise.reject(res) } else { vm.$u.toast(res.description || res.msg || res.info || "请求异常!"); //错误提示信息 return Promise.reject(res) } }, (response) => { vm.$u.toast("请求异常!"); //错误提示信息 return Promise.reject(response) }) } common/util.js
@@ -836,6 +836,10 @@ if (ua.match(/AlipayClient/i) == 'alipayclient') { return 5; } //判断是不是云闪付 if (ua.indexOf('unionpay/1.0') !== -1) { return 15; } // #endif // #ifdef MP-WEIXIN return 2; main.js
@@ -1,5 +1,7 @@ import App from './App' import Vue from 'vue' import Vconsole from 'vconsole'; new Vconsole(); import uView from '@/uni_modules/uview-ui' Vue.use(uView) pay/login.vue
@@ -20,7 +20,11 @@ }, onShow() { let redirect_uri = `${config.webURL}/pay/scanpay?cid=${this.opt.cid||''}&shopId=${this.opt.shopId||''}&activityQrcodeId=${this.opt.activityQrcodeId||''}&smoney=${this.opt.smoney||''}` if(uni.getStorageSync('OPENID'+this.platform)){ if(this.platform==2&&uni.getStorageSync('OPENID'+this.platform)){ window.location.href = redirect_uri return } if(this.platform==5&&uni.getStorageSync('ALIUSERID'+this.platform)){ window.location.href = redirect_uri return } @@ -31,6 +35,9 @@ } else if (this.platform == 5) { window.location.href = `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${config.ali_appid}&scope=auth_base&redirect_uri=${redirect_uri}&state=STATE` } else if (this.platform == 15) { window.location.href = `https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=${redirect_uri}` } else { uni.reLaunch({ url: `/pay/scanpay?cid=${this.opt.cid}` pay/scanpay.vue
@@ -228,16 +228,19 @@ this.cid = opt.cid this.init() } if (opt.code || opt.auth_code) { if (opt.code || opt.auth_code || opt.userAuthCode) { let params = { code: opt.code } let code = opt.code if (this.payWay == 2&&opt.state == 1 ) { if (this.payWay == 2&&opt.state == 1 ) { //微信 params.getUserInfo = 1 } if (this.payWay == 5) { if (this.payWay == 5) { //支付宝 params.code = opt.auth_code } if (this.payWay == 15) { //云闪付 code = opt.userAuthCode } const cd = uni.getStorageSync('cd') if (code === cd) { @@ -290,6 +293,9 @@ if (res.unionid) { uni.setStorageSync('UNIONID' + this.payWay, res.unionid) } if (res.aLiUserId) { uni.setStorageSync('ALIUSERID' + this.payWay, res.aLiUserId) } this.UNIONID = res.unionid uni.setStorageSync(ACCESSTOKEN, res.token) uni.setStorageSync('IS_NEW', res.isNew)