Commit 1ff2ddb7 authored by 郭志伟's avatar 郭志伟

fix: 问题修复

parent 7791f6fc
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<div id="app"> <div id="app">
<cr-nav-bar v-if="header" :title="title" left-text="" @click-left="backFun" /> <cr-nav-bar v-if="header" :title="title" left-text="" @click-left="backFun" />
<div class="app"> <div class="app">
<router-view /> <transition :name="transitionName">
<router-view />
</transition>
</div> </div>
<div v-if="loading" class="loading-container"> <div v-if="loading" class="loading-container">
<cr-loading class="loading" size="24px">加载中...</cr-loading> <cr-loading class="loading" size="24px">加载中...</cr-loading>
...@@ -13,13 +15,16 @@ ...@@ -13,13 +15,16 @@
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import NetError from '@/components/NetError'; import NetError from '@/components/NetError';
import { routerStorage } from '@/service/routerStorage';
export default { export default {
name: 'App', name: 'App',
components: { components: {
NetError NetError
}, },
data() { data() {
return {}; return {
transitionName: 'slide-right'
};
}, },
computed: { computed: {
...mapState({ ...mapState({
...@@ -36,6 +41,19 @@ export default { ...@@ -36,6 +41,19 @@ export default {
document.body.className = val ? 'has-header' : ''; document.body.className = val ? 'has-header' : '';
} }
} }
},
$route(to, from) {
routerStorage(to.path, from.path);
const firstPath = ['/home', '/orderDetail', '/payWaiting'];
if (
[to.path, from.path].every(v => firstPath.includes(v)) ||
[to.path, from.path].includes('/')
) {
this.transitionName = '';
return;
}
this.transitionName = this.$router.isBack ? 'slide-right' : 'slide-left';
this.$router.isBack = false;
} }
}, },
methods: { methods: {
...@@ -95,4 +113,33 @@ export default { ...@@ -95,4 +113,33 @@ export default {
.b-t:after { .b-t:after {
top: 0; top: 0;
} }
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
will-change: transform;
transition: all 500ms;
position: absolute;
}
.slide-right-enter {
opacity: 0;
transform: translate3d(-100%, 0, 0);
}
.slide-right-leave-active {
opacity: 0;
transform: translate3d(100%, 0, 0);
}
.slide-left-enter {
opacity: 0;
transform: translate3d(100%, 0, 0);
}
.slide-left-leave-active {
opacity: 0;
transform: translate3d(-100%, 0, 0);
}
</style> </style>
export default { export default {
1: {
title: '温馨提示',
content: `<p>充值类商品售出后无法进行退换,非充值用户请谨慎购买。</p>`
},
2: {
title: '温馨提示',
content: `<p>充值类商品售出后无法进行退换,非充值用户请谨慎购买。</p>`
},
401: { 401: {
title: '使用方法', title: '使用方法',
content: `<p>1. 进入猫眼APP,登陆后打开“我的”,点击“优惠券”;</p> content: `<p>1. 进入猫眼APP,登陆后打开“我的”,点击“优惠券”;</p>
......
...@@ -26,6 +26,14 @@ saService.init(router); ...@@ -26,6 +26,14 @@ saService.init(router);
Vue.config.productionTip = false; Vue.config.productionTip = false;
window.addEventListener(
'popstate',
() => {
router.isBack = true;
},
false
);
new Vue({ new Vue({
router, router,
store, store,
......
import localStorage from '@/service/localStorage.service';
export function routerStorage(toPath, fromPath) {
let storage = localStorage.get('history') || { isBack: false, paths: [], fromPath: '' };
// 初始化
if (fromPath === '/') storage.paths = [];
if (storage.paths.includes(toPath)) {
const toPathIndex = storage.paths.indexOf(toPath);
storage = { ...storage, isBack: true, fromPath };
storage.paths.splice(toPathIndex + 1);
} else {
storage = { ...storage, isBack: false, fromPath };
storage.paths.push(toPath);
}
localStorage.set('history', storage);
}
export function isBack(excludeFromPath = '') {
let storage = localStorage.get('history') || { isBack: false, paths: [], fromPath: '' };
if (storage.isBack && excludeFromPath !== storage.fromPath) {
return true;
}
return false;
}
...@@ -298,7 +298,7 @@ export const isIOS = /iphone|ipad|ipod/.test(ua); ...@@ -298,7 +298,7 @@ export const isIOS = /iphone|ipad|ipod/.test(ua);
export const isAndroid = /android/.test(ua); export const isAndroid = /android/.test(ua);
// 判断 // 判断
export const appVersion = ua.match(/xyqb\/([\d|.]+)/); export const appVersion = ua.match(/xyqb\/([\d|.]+)/) && ua.match(/xyqb\/([\d|.]+)/)[1];
export const isQQ = ua.match(/QQ/i) == 'qq'; export const isQQ = ua.match(/QQ/i) == 'qq';
......
...@@ -50,7 +50,7 @@ export default { ...@@ -50,7 +50,7 @@ export default {
phoneRecharge: {}, phoneRecharge: {},
userPhoneInfo: {}, userPhoneInfo: {},
rechargeType: 'recharge', rechargeType: 'recharge',
historyRecordList: ['17611682272', '222222222'], historyRecordList: [],
rechargePhoneInfo: {}, rechargePhoneInfo: {},
selectedRechargeInfo: {} selectedRechargeInfo: {}
}; };
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
微信支付金额:<span>{{ orderInfo.payDetail.wxPayAmt || '' }}</span> 微信支付金额:<span>{{ orderInfo.payDetail.wxPayAmt || '' }}</span>
</div> </div>
<div v-if="orderInfo.orderDetail.payType" class="Od__info-item"> <div v-if="orderInfo.orderDetail.payType" class="Od__info-item">
支付方式:<span>{{ payType }}</span> 支付方式:<span>{{ orderInfo.orderDetail.payType }}</span>
</div> </div>
</div> </div>
<div class="Od__bottom"> <div class="Od__bottom">
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
提醒发货 提醒发货
</cr-button> </cr-button>
<cr-button <cr-button
v-if="orderInfo.orderStatusInfo.orderStatus === 31" v-if="orderInfo.orderStatusInfo.orderStatus === 41"
size="small" size="small"
plain plain
type="primary" type="primary"
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
<script> <script>
import ListItem from '../orderList/components/ListItem.vue'; import ListItem from '../orderList/components/ListItem.vue';
import { setClipboardData } from '@/service/utils.service'; import { setClipboardData } from '@/service/utils.service';
import { isBack } from '@/service/routerStorage';
import orderApi from '@/api/order.api'; import orderApi from '@/api/order.api';
import img11 from '@/assets/images/order/11.png'; import img11 from '@/assets/images/order/11.png';
import img21 from '@/assets/images/order/21.png'; import img21 from '@/assets/images/order/21.png';
...@@ -162,13 +163,17 @@ export default { ...@@ -162,13 +163,17 @@ export default {
orderNo: this.orderNo orderNo: this.orderNo
}; };
}, },
payType() {
return this.orderInfo.orderDetail.payType === 1 ? '微信' : '支付宝';
},
isKeyChange() { isKeyChange() {
return this.currentOrder.virtualChargeAttrs && this.currentOrder.virtualChargeAttrs.cardKey; return this.currentOrder.virtualChargeAttrs && this.currentOrder.virtualChargeAttrs.cardKey;
} }
}, },
beforeRouteLeave(from, to, next) {
if (isBack() || from.path.indexOf('pay') > -1) {
window.location.href = window.location.origin;
} else {
next();
}
},
mounted() { mounted() {
this.orderNo = this.$route.query.orderNo; this.orderNo = this.$route.query.orderNo;
this.getDetail(); this.getDetail();
......
...@@ -27,7 +27,7 @@ export const goUrlExtends = { ...@@ -27,7 +27,7 @@ export const goUrlExtends = {
window.location.replace = `${toBHost}/orderDetail?orderNo=${orderNo}`; window.location.replace = `${toBHost}/orderDetail?orderNo=${orderNo}`;
return; return;
} }
this.$router.replace({ this.$router.push({
name: 'orderDetail', name: 'orderDetail',
query: { orderNo } query: { orderNo }
}); });
......
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
}, },
goSuccess() { goSuccess() {
// 支付成功 // 支付成功
this.$router.replace({ name: 'paySuccess' }); this.$router.push({ name: 'paySuccess' });
}, },
goPay() { goPay() {
this.$router.replace({ name: 'pay', query: { orderNo: this.orderNo } }); this.$router.replace({ name: 'pay', query: { orderNo: this.orderNo } });
...@@ -81,7 +81,7 @@ export default { ...@@ -81,7 +81,7 @@ export default {
async query() { async query() {
const [data, error] = await queryPayStatus({ orderNo: this.orderNo }); const [data, error] = await queryPayStatus({ orderNo: this.orderNo });
if (error) { if (error) {
this.$router.replace({ this.$router.push({
name: 'payFail', name: 'payFail',
query: { reason: error.message, orderNo: this.orderNo } query: { reason: error.message, orderNo: this.orderNo }
}); });
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<div <div
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
ref="spuItem"
class="Vl__spu-item" class="Vl__spu-item"
:class="{ 'Vl__spu-item_active': info.spuNos === item.spuNos }" :class="{ 'Vl__spu-item_active': info.spuNos === item.spuNos }"
@click="handleSpuClick($event, item, index)" @click="handleSpuClick($event, item, index)"
...@@ -48,15 +49,26 @@ export default { ...@@ -48,15 +49,26 @@ export default {
}, },
computed: { computed: {
contentWidth() { contentWidth() {
return ITEM_WIDTH * (this.list.length + 2.34); this.listWrapper &&
this.$nextTick(() => {
this.listWrapper.scrollTo(0, 0);
this.listWrapper.refresh();
});
return ITEM_WIDTH * (this.list.length + 2.28);
} }
}, },
watch: { watch: {
contentWidth() { info: {
this.$nextTick(() => { deep: true,
this.listWrapper.scrollTo(0, 0); handler(val) {
this.listWrapper.refresh(); if (Object.hasOwnProperty.call(val, 'index')) {
}); const itemIndex = this.list.findIndex(item => item.index === val.index);
if (itemIndex === -1) return;
this.$nextTick(() => {
this.handleSpuClick(this.$refs.spuItem[itemIndex], val, itemIndex);
});
}
}
} }
}, },
...@@ -84,7 +96,7 @@ export default { ...@@ -84,7 +96,7 @@ export default {
}, },
handleSpuClick(e, item, index) { handleSpuClick(e, item, index) {
this.$parent.handleSpuSelected(item, index); this.$parent.handleSpuSelected(item, index);
const target = e.path.find(item => item.className.indexOf('Vl__spu-item') > -1); const target = e.path ? e.path.find(item => item.className.indexOf('Vl__spu-item') > -1) : e;
this.listWrapper.scrollToElement(target, 500, -10, 0); this.listWrapper.scrollToElement(target, 500, -10, 0);
} }
} }
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
<div class="Vl__panel-title">{{ tips.title }}</div> <div class="Vl__panel-title">{{ tips.title }}</div>
<div class="Vl__panel-tips" v-html="tips.content" /> <div class="Vl__panel-tips" v-html="tips.content" />
</template> </template>
<div class="Vl__panel-title">温馨提示</div>
<div class="Vl__panel-tips">
<p>充值类商品售出后无法进行退换,非充值用户请谨慎购买。</p>
</div>
</div> </div>
<div class="Vl__bottom"> <div class="Vl__bottom">
<cr-button type="primary" block shape="circle" :disabled="disabled" @click="goOrder"> <cr-button type="primary" block shape="circle" :disabled="disabled" @click="goOrder">
...@@ -61,12 +65,15 @@ export default { ...@@ -61,12 +65,15 @@ export default {
return (this.spuInfo.rechargeAccountType !== 2 && !this.account) || !this.skuList.length; return (this.spuInfo.rechargeAccountType !== 2 && !this.account) || !this.skuList.length;
}, },
spuList() { spuList() {
return this.spuData[this.currentTab - 1] ? this.spuData[this.currentTab - 1].itemList : []; let spuList = [];
this.spuData.forEach((item, index) => {
item.itemList[0].index = index;
spuList = [...spuList, ...item.itemList];
});
return spuList;
}, },
tips() { tips() {
return this.spuInfo.type return this.spuInfo.type ? tipsData[this.spuInfo.type] : {};
? tipsData[this.spuInfo.type] || tipsData[+('' + this.spuInfo.type)[0]] || {}
: {};
} }
}, },
mounted() { mounted() {
...@@ -104,6 +111,7 @@ export default { ...@@ -104,6 +111,7 @@ export default {
async getList() { async getList() {
const [res] = await rechargeApi.getSpuList(); const [res] = await rechargeApi.getSpuList();
if (res) { if (res) {
this.account = res.userPhoneInfo.phoneNo;
this.spuData = res.vipLife; this.spuData = res.vipLife;
this.updateSpuInfo(this.spuData[this.currentTab - 1].itemList[0]); this.updateSpuInfo(this.spuData[this.currentTab - 1].itemList[0]);
this.getSkuListDebounce(); this.getSkuListDebounce();
......
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