Commit bf475a3c authored by 郭志伟's avatar 郭志伟

feat(pay): 路由调整完成

parent 9373addb
...@@ -12,7 +12,7 @@ import Raven from 'raven-js'; ...@@ -12,7 +12,7 @@ import Raven from 'raven-js';
import RavenVue from 'raven-js/plugins/vue'; import RavenVue from 'raven-js/plugins/vue';
import { release } from '../.sentryclirc'; import { release } from '../.sentryclirc';
if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') { if (process.env.SENTRY_ENV !== 'test' && process.env.NODE_ENV === 'production') {
Raven.config('//21779c2dcb594299bdc803c5560cfecd@sentry.q-gp.com/60', { Raven.config('//7b09a4aeffca4a49b37328da6a5468a9@sentry.q-gp.com/83', {
release, release,
environment: process.env.NODE_ENV environment: process.env.NODE_ENV
}) })
......
...@@ -11,6 +11,34 @@ export default [ ...@@ -11,6 +11,34 @@ export default [
}, },
component: () => import('../views/pay') component: () => import('../views/pay')
}, },
{
path: '/payFail',
name: 'payFail',
alias: ['/payFail'],
meta: {
title: '支付失败'
},
component: () => import('../views/pay/payResult')
},
{
path: '/paySuccess',
name: 'paySuccess',
alias: ['/paySuccess'],
meta: {
title: '支付成功',
success: true
},
component: () => import('../views/pay/payResult')
},
{
path: '/payWaiting',
name: 'payWaiting',
meta: {
title: '支付中',
success: true
},
component: () => import('../views/pay/payWaiting')
},
{ {
path: '/error', path: '/error',
name: 'error', name: 'error',
......
import HttpRequest from '@qg/ui-request'; import HttpRequest from '@qg/ui-request';
import { Toast } from '@qg/cherry-ui'; import { Toast } from '@qg/cherry-ui';
import store from '@/store'; import store from '@/store';
import router from '@/router';
import { appVersion, isWxMp } from '@/service/validation.service'; import { appVersion, isWxMp } from '@/service/validation.service';
import { getVccChannel } from './userInfo.service'; import { getVccChannel } from './userInfo.service';
import { parseSearch } from './utils.service';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import sessionStorage from '@/service/sessionStorage.service'; import sessionStorage from '@/service/sessionStorage.service';
...@@ -42,7 +44,12 @@ const http = new HttpRequest( ...@@ -42,7 +44,12 @@ const http = new HttpRequest(
sessionStorage.remove('vccToken'); sessionStorage.remove('vccToken');
const toast = Toast('未登录!'); const toast = Toast('未登录!');
toast.onClose = () => { toast.onClose = () => {
window.location.href = document.referrer; const { returnUrl } = parseSearch(window.location.href);
if (returnUrl) {
window.location.href = returnUrl;
} else {
router.replace({ name: 'error' });
}
}; };
} }
......
...@@ -92,6 +92,25 @@ export function onKeyboardStateChange(callback = () => {}, off = false) { ...@@ -92,6 +92,25 @@ export function onKeyboardStateChange(callback = () => {}, off = false) {
} }
} }
export function json2Query(json) {
function cleanArray(actual) {
const newArray = [];
for (let i = 0; i < actual.length; i++) {
if (actual[i]) {
newArray.push(actual[i]);
}
}
return newArray;
}
if (!json) return '';
return cleanArray(
Object.keys(json).map(key => {
if (json[key] === undefined) return '';
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]);
})
).join('&');
}
export function throttle(fn, wait) { export function throttle(fn, wait) {
let flag = true; let flag = true;
return function() { return function() {
......
import cookies from '@/service/cookieStorage.service'; import localStorage from '@/service/localStorage.service';
export const goUrlExtends = { export const goUrlExtends = {
methods: { methods: {
goHome() { goHome() {
// 商城地址 // 商城地址
setTimeout(() => { setTimeout(() => {
window.location.href = document.referrer; localStorage.remove('redirectUrl');
window.location.href = localStorage.get('redirectUrl');
}, 500); }, 500);
},
goOrderList() {
setTimeout(() => {
this.$router.replace({ name: 'orderList', params: { status: 0 } });
}, 500);
},
goOrderDetail() {
const orderNo = cookies.get('orderNo')?.orderNo;
this.$router.push({
name: 'orderDetail',
query: { orderNo }
});
} }
} }
}; };
...@@ -54,9 +54,6 @@ ...@@ -54,9 +54,6 @@
</cr-button> </cr-button>
</p> </p>
<p v-if="overtime" class="btn"> <p v-if="overtime" class="btn">
<!-- <cr-button v-if="isOrder" type="default" class="btn-default" @click="goOrderList"
>我的订单</cr-button
> -->
<cr-button type="primary" class="btn-primary" @click="navigateBack">返回</cr-button> <cr-button type="primary" class="btn-primary" @click="navigateBack">返回</cr-button>
</p> </p>
<p class="placeholder" /> <p class="placeholder" />
...@@ -104,7 +101,7 @@ import crSmsCodeModal from './components/SmsModal.vue'; ...@@ -104,7 +101,7 @@ import crSmsCodeModal from './components/SmsModal.vue';
import { isWechat } from '@/service/validation.service'; import { isWechat } from '@/service/validation.service';
import { encryptByDESModeEBC } from '@/service/encrypt'; import { encryptByDESModeEBC } from '@/service/encrypt';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import { throttle } from '@/service/utils.service'; import { throttle, json2Query } from '@/service/utils.service';
// import { goUrlExtends } from './extends'; // import { goUrlExtends } from './extends';
import cookies from '@/service/cookieStorage.service'; import cookies from '@/service/cookieStorage.service';
// import { saTrackEvent } from '@/service/sa.service'; // import { saTrackEvent } from '@/service/sa.service';
...@@ -192,7 +189,8 @@ export default { ...@@ -192,7 +189,8 @@ export default {
isCheckAgreement: false, isCheckAgreement: false,
mergePayPretreatmentInfo: {}, mergePayPretreatmentInfo: {},
tradeType: isWechat ? 'JSAPI' : 'MWEB', tradeType: isWechat ? 'JSAPI' : 'MWEB',
amountInfo: {} amountInfo: {},
redirectUrl: ''
}; };
}, },
computed: { computed: {
...@@ -227,6 +225,12 @@ export default { ...@@ -227,6 +225,12 @@ export default {
mounted() { mounted() {
this.getQuery(); this.getQuery();
this.setIsOrder(); this.setIsOrder();
if (this.$route.query.redirectUrl) {
localStorage.set('redirectUrl', this.redirectUrl);
this.redirectUrl = this.$route.query.redirectUrl;
} else {
this.redirectUrl = localStorage.get('redirectUrl');
}
this.orderNo = this.$route.query.orderNo; this.orderNo = this.$route.query.orderNo;
cookies.set('orderNo', this.orderNo); cookies.set('orderNo', this.orderNo);
if (this.$route?.query?.ocrflag) { if (this.$route?.query?.ocrflag) {
...@@ -237,7 +241,8 @@ export default { ...@@ -237,7 +241,8 @@ export default {
this.pay(this.payInfo?.paramsData, 'ocr', cookies.get('ocrflag')); this.pay(this.payInfo?.paramsData, 'ocr', cookies.get('ocrflag'));
} }
const vccToken = localStorage.get('vccToken'); const vccToken = localStorage.get('vccToken');
Current_Url = `${window.location.origin}/payWaiting?vccToken=${vccToken}&orderNo=${this.orderNo}`; Current_Url = `${this.redirectUrl ||
window.location.origin}/payWaiting?vccToken=${vccToken}&orderNo=${this.orderNo}`;
this.queryPayInfo(); this.queryPayInfo();
this.getCouponList(this.orderNo); this.getCouponList(this.orderNo);
}, },
...@@ -532,17 +537,22 @@ export default { ...@@ -532,17 +537,22 @@ export default {
} }
}, },
payResult(type, error) { payResult(type, error) {
/* 跳转支付结果页面 */ const params = {
this.$router.replace({ reason: error,
name: `pay${type}`, orderNo: this.orderNo,
query: { payType: this.payType,
reason: error, amount: this.amountInfo.finalAmt || '',
orderNo: this.orderNo, freeAmount: this.amountInfo.freeAmount || ''
payType: this.payType, };
amount: this.amountInfo.finalAmt || '', if (this.redirectUrl) {
freeAmount: this.amountInfo.freeAmount || '' localStorage.remove('redirectUrl');
} window.location.replace(`${this.redirectUrl}/pay${type}?${json2Query(params)}`);
}); } else {
this.$router.replace({
name: `pay${type}`,
query: params
});
}
}, },
/* 选择支付方式 */ /* 选择支付方式 */
changePayType(type, mergePayPretreatmentInfo) { changePayType(type, mergePayPretreatmentInfo) {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<p v-if="freeAmount > 0" class="info__text info__free">已优惠¥{{ freeAmount }}</p> <p v-if="freeAmount > 0" class="info__text info__free">已优惠¥{{ freeAmount }}</p>
</div> </div>
</div> </div>
<div :class="['actions', 'no-order']"> <div v-if="hasRedirectUrl" :class="['actions', 'no-order']">
<cr-button shape="circle" type="primary" @click="goHome">返回</cr-button> <cr-button shape="circle" type="primary" @click="goHome">返回</cr-button>
</div> </div>
</div> </div>
...@@ -31,21 +31,25 @@ ...@@ -31,21 +31,25 @@
<p class="tips"> <p class="tips">
{{ reason }} {{ reason }}
</p> </p>
<cr-button type="primary" shape="circle" class="info_button" @click="goPay" <cr-button
>重新支付</cr-button v-if="hasRedirectUrl"
type="primary"
shape="circle"
class="info_button"
@click="goPay"
> >
重新支付
</cr-button>
</div> </div>
<RecoGoods v-if="!getReturnUrl()" />
</div> </div>
</template> </template>
<script> <script>
import RecoGoods from '@/components/RecoGoods.vue';
import cookies from '@/service/cookieStorage.service'; import cookies from '@/service/cookieStorage.service';
import localStorage from '@/service/localStorage.service';
import { isApp } from '@/service/validation.service'; import { isApp } from '@/service/validation.service';
import { goUrlExtends } from './extends'; import { goUrlExtends } from './extends';
import { payTypeMap } from './STATIC_DATA'; import { payTypeMap } from './STATIC_DATA';
export default { export default {
components: { RecoGoods },
extends: goUrlExtends, extends: goUrlExtends,
data() { data() {
return { return {
...@@ -54,6 +58,7 @@ export default { ...@@ -54,6 +58,7 @@ export default {
isSuccess: false, isSuccess: false,
freeAmount: 0, freeAmount: 0,
payStatus: '', payStatus: '',
hasRedirectUrl: !!localStorage.get('redirectUrl'),
returnUrl: '' returnUrl: ''
}; };
}, },
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
width="63px" width="63px"
height="63px" height="63px"
class="info__image" class="info__image"
src="../../assets/images/paying.png" src="@/assets/images/pay/paying.png"
/> />
<div v-if="init" class="info__desc"> <div v-if="init" class="info__desc">
<p class="info__text"> <p class="info__text">
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<p class="tips"> <p class="tips">
努力返回支付结果中,请留心查看! 努力返回支付结果中,请留心查看!
</p> </p>
<div :class="['actions', 'no-order']"> <div v-if="hasRedirectUrl" :class="['actions', 'no-order']">
<cr-button shape="circle" type="primary" @click="goHome">返回</cr-button> <cr-button shape="circle" type="primary" @click="goHome">返回</cr-button>
</div> </div>
</div> </div>
...@@ -34,6 +34,7 @@ export default { ...@@ -34,6 +34,7 @@ export default {
timer: null, timer: null,
time: 10, time: 10,
init: false, init: false,
hasRedirectUrl: !!localStorage.get('redirectUrl'),
returnUrl: '' returnUrl: ''
}; };
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment