|
@@ -5,13 +5,17 @@ import {getUserIdentity} from "@/utils/common.js"
|
|
|
|
|
|
export function useSwiper(Da, noticeYK) {
|
|
|
|
|
|
- const useCode = getUserIdentity()
|
|
|
+ const userCode = getUserIdentity()
|
|
|
|
|
|
const swiperData = reactive({
|
|
|
startX: 0, // 触摸起点X坐标
|
|
|
- isAllowed: false // 是否允许切
|
|
|
+ isAllowed: true // 是否允许切
|
|
|
})
|
|
|
|
|
|
+ if (userCode!='VIP') {
|
|
|
+ swiperData.isAllowed = false;
|
|
|
+ }
|
|
|
+
|
|
|
// 1. 触摸开始:记录起点
|
|
|
function handleTouchStart(e) {
|
|
|
swiperData.startX = e.touches[0].pageX;
|
|
@@ -27,20 +31,20 @@ export function useSwiper(Da, noticeYK) {
|
|
|
if (absDeltaX > 10 && checkBusinessCondition()) {
|
|
|
swiperData.isAllowed = true;
|
|
|
// 根据方向更新索引
|
|
|
- if (deltaX > 0 && Da.currentIndex > 0) {
|
|
|
- Da.currentIndex--; // 向右滑,上一页
|
|
|
- } else if (deltaX < 0 && Da.currentIndex < swiperData.list.length - 1) {
|
|
|
- Da.currentIndex++; // 向左滑,下一页
|
|
|
+ if (deltaX > 0 && Da.activeIndex > 0) {
|
|
|
+ Da.activeIndex--; // 向右滑,上一页
|
|
|
+ } else if (deltaX < 0 && Da.activeIndex < Da.jieNumberList.length - 1) {
|
|
|
+ Da.activeIndex++; // 向左滑,下一页
|
|
|
}
|
|
|
} else {
|
|
|
swiperData.isAllowed = false;
|
|
|
- noticeYK(useCode)
|
|
|
+ noticeYK(userCode)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 4. 业务条件校验(示例)
|
|
|
function checkBusinessCondition() {
|
|
|
- if (useCode != 'VIP') {
|
|
|
+ if (userCode != 'VIP') {
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
@@ -48,7 +52,8 @@ export function useSwiper(Da, noticeYK) {
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
- swiperData,
|
|
|
+ swiperData,
|
|
|
+ userCode,
|
|
|
handleTouchStart,
|
|
|
handleTouchEnd
|
|
|
}
|