Commit 37a2320e authored by FE-安焕焕's avatar FE-安焕焕 👣

增加跳转页面逻辑

parent ad359b42
...@@ -1159,9 +1159,9 @@ ...@@ -1159,9 +1159,9 @@
} }
}, },
"@qg/ui-request": { "@qg/ui-request": {
"version": "0.0.8", "version": "0.0.15",
"resolved": "http://npmprivate.quantgroups.com/@qg%2fui-request/-/ui-request-0.0.8.tgz", "resolved": "http://npmprivate.quantgroups.com/@qg%2fui-request/-/ui-request-0.0.15.tgz",
"integrity": "sha512-BeS7fWiTM5uI/FzGpZ5phuU0ZQXWsjX5LDiMq6FhMz5IXQthd3gMn+Q1DyYF6YyQI6rG9eDq18CMvWMdkbtt/Q==", "integrity": "sha512-ZYR/7NMFDY0NBU0B71D3/ENdI29YTKhmk0BE68IFlt63rPwKXeUWzUtmfsA1Wgx/iMkNE8qfJMKt7lPLreYYWA==",
"requires": { "requires": {
"axios": "^0.19.2" "axios": "^0.19.2"
} }
......
...@@ -26,9 +26,6 @@ export default { ...@@ -26,9 +26,6 @@ export default {
components: { components: {
Items Items
}, },
// props: {
// list: Array
// },
data() { data() {
return { return {
finished: true, finished: true,
...@@ -55,7 +52,7 @@ export default { ...@@ -55,7 +52,7 @@ export default {
async onLoad() { async onLoad() {
this.loading = true; this.loading = true;
const [data = {}] = await getGoodsList({ pageNo: 1, pageSize: 10 }); const [data = {}] = await getGoodsList({ pageNo: 1, pageSize: 10 });
this.list = [...this.list, ...data?.goodsList]; this.list = [...this.list, ...(data?.goodsList ?? [])];
this.loading = false; this.loading = false;
} }
} }
......
...@@ -16,4 +16,5 @@ let payHost = protocol + '//mapi-qa.liangkebang.net/pay'; ...@@ -16,4 +16,5 @@ let payHost = protocol + '//mapi-qa.liangkebang.net/pay';
let shenceHost = 'https://bn.xyqb.com/sa?project=default'; // 测试地址 let shenceHost = 'https://bn.xyqb.com/sa?project=default'; // 测试地址
let talosHost = 'http://talos-vcc2.liangkebang.net'; // 电商分期测试环境服务地址 let talosHost = 'http://talos-vcc2.liangkebang.net'; // 电商分期测试环境服务地址
let operatorHost = 'https://operator.liangkebang.com'; let operatorHost = 'https://operator.liangkebang.com';
export default { talosHost, operatorHost, payHost, shenceHost, test: true }; const toBHost = 'https://tob.liangkebang.net';
export default { talosHost, operatorHost, payHost, shenceHost, test: true, toBHost };
...@@ -4,11 +4,13 @@ const operatorHost = protocol + '//auth.quantgroup.cn'; ...@@ -4,11 +4,13 @@ const operatorHost = protocol + '//auth.quantgroup.cn';
// const payHost = protocol + '//mapi.q-gp.com/pay'; // const payHost = protocol + '//mapi.q-gp.com/pay';
const payHost = protocol + '//payapi.xyqb.com'; const payHost = protocol + '//payapi.xyqb.com';
const shenceHost = 'https://bn.xyqb.com/sa?project=production'; const shenceHost = 'https://bn.xyqb.com/sa?project=production';
const toBHost = 'https://tob.liangkebang.net';
export default { export default {
// apiHost, // apiHost,
test: false, test: false,
shenceHost, shenceHost,
talosHost, talosHost,
payHost, payHost,
toBHost,
operatorHost operatorHost
}; };
...@@ -14,6 +14,7 @@ const localStorageParams = [ ...@@ -14,6 +14,7 @@ const localStorageParams = [
'formXcxPage' 'formXcxPage'
]; ];
const cookiesParams = ['h']; const cookiesParams = ['h'];
const sessionStorageParams = ['target'];
export default { export default {
// token校验,整个流程都是登陆后的 // token校验,整个流程都是登陆后的
...@@ -28,7 +29,9 @@ export default { ...@@ -28,7 +29,9 @@ export default {
cookiesParams.forEach(item => { cookiesParams.forEach(item => {
to.query[item] && Cookies.set(item, to.query[item]); to.query[item] && Cookies.set(item, to.query[item]);
}); });
sessionStorageParams.forEach(item => {
to.query[item] && localStorage.set(item, to.query[item], 'sessionStorage');
});
(isWechat || isApp || Cookies.get('h') === '0') && store.commit('CHANGE_HEADER', false); // 改变header (isWechat || isApp || Cookies.get('h') === '0') && store.commit('CHANGE_HEADER', false); // 改变header
document.body.className = store.state.pay.header ? 'has-header' : ''; document.body.className = store.state.pay.header ? 'has-header' : '';
store.commit('CHANGE_TITLE', meta?.title); // 改变title store.commit('CHANGE_TITLE', meta?.title); // 改变title
......
export default { export default {
get(key) { get(key, storageType = 'localStorage') {
let result = window.localStorage.getItem(key); let result = window[storageType].getItem(key);
try { try {
return JSON.parse(result); return JSON.parse(result);
} catch (e) { } catch (e) {
return result; return result;
} }
}, },
set(key, value) { set(key, value, storageType = 'localStorage') {
let toString = Object.prototype.toString; let toString = Object.prototype.toString;
if (toString.call(value) === '[object Array]' || toString.call(value) === '[object Object]') { if (toString.call(value) === '[object Array]' || toString.call(value) === '[object Object]') {
value = JSON.stringify(value); value = JSON.stringify(value);
} }
return window.localStorage.setItem(key, value); return window[storageType].setItem(key, value);
}, },
remove(key) { remove(key, storageType = 'localStorage') {
return window.localStorage.removeItem(key); return window[storageType].removeItem(key);
}, },
clear() { clear(storageType = 'localStorage') {
return window.localStorage.clear(); return window[storageType].clear();
} }
}; };
import localStorage from '@/service/localStorage.service';
import config from '@/config/index';
const { toBHost } = config;
export const goUrlExtends = {
methods: {
goHome() {
// 商城地址
const tob = this.getTarget();
if (tob) {
window.location.replace = `${toBHost}`;
return;
}
this.$router.replace({ name: 'home' });
},
goOrderList() {
const tob = this.getTarget();
if (tob) {
window.location.replace = `${toBHost}/orderList`;
return;
}
this.$router.replace({ name: 'orderList' }, 'sessionStorage');
},
goOrderDetail() {
const tob = this.getTarget();
const orderNo = localStorage.get('orderNo')?.orderNo;
if (tob) {
window.location.replace = `${toBHost}/orderDetail?orderNo=${orderNo}`;
return;
}
this.$router.replace({
name: 'orderDetail',
query: { orderNo }
});
},
getTarget() {
const tob = localStorage.get('target', 'sessionStorage');
return tob;
}
}
};
...@@ -46,17 +46,12 @@ ...@@ -46,17 +46,12 @@
v-model="isCheckAgreement" v-model="isCheckAgreement"
:contract-list="payContractInfo.contractInfos" :contract-list="payContractInfo.contractInfos"
/> />
<cr-button <cr-button type="primary" class="btn-primary" :disabled="!payType" @click="nextAction">
type="primary"
class="btn-primary"
:disabled="!payType || (isShowProtocol && !isCheckAgreement)"
@click="nextAction"
>
{{ accountS.text }} {{ accountS.text }}
</cr-button> </cr-button>
</p> </p>
<p v-if="overtime" class="btn"> <p v-if="overtime" class="btn">
<cr-button type="default" class="btn-default" @click="goOrderDetail">我的订单</cr-button> <cr-button type="default" class="btn-default" @click="goOrderList">我的订单</cr-button>
<cr-button type="primary" class="btn-primary" @click="goHome">返回商城</cr-button> <cr-button type="primary" class="btn-primary" @click="goHome">返回商城</cr-button>
</p> </p>
<p class="placeholder" /> <p class="placeholder" />
...@@ -101,6 +96,7 @@ import { encryptByDESModeEBC } from '@/service/encrypt'; ...@@ -101,6 +96,7 @@ import { encryptByDESModeEBC } from '@/service/encrypt';
import { registeredEvents } from '@/service/sa.service'; import { registeredEvents } from '@/service/sa.service';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import { throttle } from '@/service/utils.service'; import { throttle } from '@/service/utils.service';
import { goUrlExtends } from './extends';
import { import {
codeArr, codeArr,
payTypeE, payTypeE,
...@@ -142,6 +138,7 @@ export default { ...@@ -142,6 +138,7 @@ export default {
pay: this pay: this
}; };
}, },
extends: goUrlExtends,
data() { data() {
return { return {
error: '', error: '',
...@@ -215,7 +212,10 @@ export default { ...@@ -215,7 +212,10 @@ export default {
/* 查询支付信息 */ /* 查询支付信息 */
async queryPayInfo() { async queryPayInfo() {
const [data, error] = await queryPayInfo({ orderNo: this.orderNo }); const [data, error] = await queryPayInfo({ orderNo: this.orderNo });
if (error) return; if (error) {
this.payResult('Fail');
return;
}
this.isReady = true; this.isReady = true;
const { displayInfo = {}, payMethods } = data || {}; const { displayInfo = {}, payMethods } = data || {};
this.overtime = displayInfo.periodSeconds <= 0; this.overtime = displayInfo.periodSeconds <= 0;
...@@ -368,7 +368,7 @@ export default { ...@@ -368,7 +368,7 @@ export default {
this.payCouponList.push({ this.payCouponList.push({
...item, ...item,
id: item.pickupId, id: item.pickupId,
pickupAble: 1, // 需要判断是否可用 pickupAble: 1,
limitAmount: item.limitDesc limitAmount: item.limitDesc
}); });
} }
...@@ -382,6 +382,10 @@ export default { ...@@ -382,6 +382,10 @@ export default {
async pay(params) { async pay(params) {
// 组合支付的提示和享花卡支付逻辑 // 组合支付的提示和享花卡支付逻辑
this.error = ''; this.error = '';
if (this.isShowProtocol && !this.isCheckAgreement) {
this.$toast('请仔细阅读并同意相关协议');
return;
}
if (!params && !this.isDetention && IS_THIRD_PAY(this.payType)) { if (!params && !this.isDetention && IS_THIRD_PAY(this.payType)) {
this.isDetention = true; this.isDetention = true;
isDetentionFn.call(this); isDetentionFn.call(this);
...@@ -409,6 +413,20 @@ export default { ...@@ -409,6 +413,20 @@ export default {
const [data, error] = params ? await pay(paramsData) : await prepay(paramsData); const [data, error] = params ? await pay(paramsData) : await prepay(paramsData);
/* 支付失败 */ /* 支付失败 */
if (error) { if (error) {
if (error?.response?.businessCode === '3001') {
/* 有享花卡未支付的订单 */
this.$dialog({
message: '您的享花卡额度被其他订单占用,暂时不可使用享花卡支付哦!',
confirmButtonText: '重新选择',
showCancelButton: false,
confirmButtonColor: '#EC1500'
});
return;
}
if (error?.response?.businessCode === '3005') {
/* 已锁定组合支付,不能切换其他支付方式 */
return;
}
if (codeArr.indexOf(error.response.businessCode) < 0) { if (codeArr.indexOf(error.response.businessCode) < 0) {
this.payResult('Fail', error.message); this.payResult('Fail', error.message);
return; return;
...@@ -451,13 +469,12 @@ export default { ...@@ -451,13 +469,12 @@ export default {
? this.displayInfo.orderAmt || '0.00' ? this.displayInfo.orderAmt || '0.00'
: (this.displayInfo.orderAmt - this.selectedCoupon.faceValue || 0).toFixed(2); : (this.displayInfo.orderAmt - this.selectedCoupon.faceValue || 0).toFixed(2);
const freeAmount = this.showCoupon ? this.selectedCoupon.faceValue || '0.00' : '0.00'; const freeAmount = this.showCoupon ? this.selectedCoupon.faceValue || '0.00' : '0.00';
localStorage.set('amount', { finalAmt, freeAmount });
/* 跳转支付结果页面 */ /* 跳转支付结果页面 */
this.$router.replace({ this.$router.replace({
name: `pay${type}`, name: `pay${type}`,
query: { query: {
freeAmount,
reason: error, reason: error,
amount: finalAmt,
orderNo: this.orderNo orderNo: this.orderNo
} }
}); });
...@@ -477,7 +494,6 @@ export default { ...@@ -477,7 +494,6 @@ export default {
}, },
/* 选取优惠券 */ /* 选取优惠券 */
handleSelectCoupon(id, selectedCoupon) { handleSelectCoupon(id, selectedCoupon) {
console.log(id, selectedCoupon);
registeredEvents('PD_YXMMACP_UserClickCouponPopupWindowComfirmBtn'); registeredEvents('PD_YXMMACP_UserClickCouponPopupWindowComfirmBtn');
this.selectedCoupon = selectedCoupon || {}; this.selectedCoupon = selectedCoupon || {};
const status = this.checkStatus(this.creditPayInfo, this.displayInfo); const status = this.checkStatus(this.creditPayInfo, this.displayInfo);
...@@ -522,7 +538,7 @@ export default { ...@@ -522,7 +538,7 @@ export default {
async getKaGetNextUrl() { async getKaGetNextUrl() {
const [{ nextUrl }] = await kaGetNextUrl(); const [{ nextUrl }] = await kaGetNextUrl();
if (!nextUrl) return; if (!nextUrl) return;
window.location.href = nextUrl; window.location.href = `${nextUrl}&returnUrl=${window.location.href}`;
}, },
/* 走h5活体流程 */ /* 走h5活体流程 */
async goOcr() { async goOcr() {
...@@ -552,14 +568,6 @@ export default { ...@@ -552,14 +568,6 @@ export default {
url = url.replace('{token}', localStorage.get('vccToken')); url = url.replace('{token}', localStorage.get('vccToken'));
window.location.href = url; window.location.href = url;
}, },
goHome() {
// 商城地址
this.$router.replace({ name: 'home' });
},
goOrderDetail() {
this.$router.replace({ name: 'orderList' });
// 订单详情地址
},
getObjectKey(obj) { getObjectKey(obj) {
return Object.keys(obj); return Object.keys(obj);
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<cr-button shape="circle" class="actions__back" :plain="true" type="primary" @click="goHome" <cr-button shape="circle" class="actions__back" :plain="true" type="primary" @click="goHome"
>返回首页</cr-button >返回首页</cr-button
> >
<cr-button shape="circle" type="primary" @click="goOrderDetail">查看订单</cr-button> <cr-button shape="circle" type="primary" @click="goOrderList">查看订单</cr-button>
</div> </div>
</div> </div>
<div v-else class="card"> <div v-else class="card">
...@@ -47,8 +47,11 @@ ...@@ -47,8 +47,11 @@
<script> <script>
import { registeredEvents } from '@/service/sa.service'; import { registeredEvents } from '@/service/sa.service';
import RecoGoods from '@/components/RecoGoods.vue'; import RecoGoods from '@/components/RecoGoods.vue';
import localStorage from '@/service/localStorage.service';
import { goUrlExtends } from './extends';
export default { export default {
components: { RecoGoods }, components: { RecoGoods },
extends: goUrlExtends,
data() { data() {
return { return {
money: '00.00', money: '00.00',
...@@ -58,26 +61,16 @@ export default { ...@@ -58,26 +61,16 @@ export default {
}; };
}, },
created() { created() {
const { amount = null, orderNo, freeAmount = null, reason } = this.$route.query; const { orderNo, reason } = this.$route.query;
const { success } = this.$route.meta; const { success } = this.$route.meta;
this.money = amount; const amount = localStorage.get('amount');
this.money = amount.finalAmt;
this.orderNo = orderNo; this.orderNo = orderNo;
this.reason = reason || ''; this.reason = reason || '';
this.isSuccess = success || false; this.isSuccess = success || false;
this.freeAmount = freeAmount; this.freeAmount = amount.freeAmount;
}, },
methods: { methods: {
goHome() {
// 去页面
this.$router.push({ name: 'home' });
},
goOrderDetail() {
registeredEvents('PD_YXMMAEC_UserClickCashierCheckOrderBtn', {
order_id: this.orderNo
});
// 去订单详情页面
this.$router.replace({ name: 'orderList' });
},
goPay() { goPay() {
registeredEvents('PD_YXMMAEC_UserClickCashierPaymentAgainBtn', { registeredEvents('PD_YXMMAEC_UserClickCashierPaymentAgainBtn', {
order_id: this.orderNo order_id: this.orderNo
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
class="info__image" class="info__image"
src="../../assets/images/paying.png" src="../../assets/images/paying.png"
/> />
<div class="info__desc"> <div v-if="init" class="info__desc">
<p class="info__text">{{ time }}s)支付中...</p> <p class="info__text">{{ time }}s)支付中...</p>
</div> </div>
</div> </div>
...@@ -25,49 +25,61 @@ ...@@ -25,49 +25,61 @@
<script> <script>
import { queryPayStatus } from '@/api/pay.api'; import { queryPayStatus } from '@/api/pay.api';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import { goUrlExtends } from './extends';
export default { export default {
components: {}, components: {},
extends: goUrlExtends,
data() { data() {
return { return {
orderNo: null, orderNo: null,
timer: null, timer: null,
time: 10 time: 10,
init: false
}; };
}, },
created() { created() {
this.orderNo = this.$route.query.orderNo || localStorage.get('orderNo')?.orderNo; this.orderNo = this.$route.query.orderNo || localStorage.get('orderNo')?.orderNo;
}, },
mounted() { mounted() {
// eslint-disable-next-line space-before-function-paren this.$dialog({
this.timer = setInterval(async () => { message: '请确认订单已完成支付',
this.time -= 1; confirmButtonText: '已完成支付',
if (this.time % 2 === 0) { cancelButtonText: '重新支付',
this.query(); confirmButtonColor: '#EC1500',
onCancel: () => {
this.goPay();
},
onConfirm: () => {
this.init = true;
this.loop();
} }
if (this.time < 1) { });
clearInterval(this.timer);
}
}, 2000);
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.timer); clearInterval(this.timer);
}, },
methods: { methods: {
goHome() { loop() {
// 去首页 this.query();
this.$router.replace({ name: 'home' }); this.timer = setInterval(() => {
this.time -= 1;
if (this.time % 2 === 0) {
this.query();
}
if (this.time < 1) {
clearInterval(this.timer);
}
}, 2000);
}, },
goSuccess() { goSuccess() {
// 支付成功 // 支付成功
this.$router.replace({ name: 'paySuccess' }); this.$router.replace({ name: 'paySuccess' });
}, },
goOrderDetail() { goPay() {
this.$router.replace({ name: 'orderDetail', query: { orderNo: this.orderNo } }); this.$router.replace({ name: 'pay', query: { orderNo: this.orderNo } });
// 去订单详情页面
}, },
async query() { async query() {
const [data, error] = await queryPayStatus({ orderNo: this.orderNo }); const [data, error] = await queryPayStatus({ orderNo: this.orderNo });
console.log(this.orderNo);
if (error) { if (error) {
this.$router.replace({ this.$router.replace({
name: 'payFail', name: 'payFail',
...@@ -78,18 +90,6 @@ export default { ...@@ -78,18 +90,6 @@ export default {
if (+data?.payStatus === 3) { if (+data?.payStatus === 3) {
this.goSuccess(); this.goSuccess();
} }
// else if (+data?.payStatus === 1) {
// this.$dialog({
// message: '是否支付成功?',
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// confirmButtonColor: '#EC1500',
// onCancel: () => {},
// onConfirm: () => {
// this.query();
// }
// });
// }
} }
} }
}; };
......
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