| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | <template>	<uni-popup ref="popupRef" :animation="false" :is-mask-click="false"	 mask-background-color="rgba(255, 255, 255, 0.6);" :is-shadow="false">		<view class="ezy-catalogue-dialog">			<uni-icons @click="handleClose" class="catalogue-close-btn"></uni-icons>			<!-- 目录区域 -->			<uni-collapse v-model="activeCollapse" class="ezy-catalogue-collapse" accordion>				<uni-collapse-item title-border="none" :border="false" :name="index+''" v-for="(item,index) in list" 				class="collapse-item-box" :class="{ 'collapse-active': activeCollapse === index+''}">					<template v-slot:title>							<view @click.stop="handleSelectZhang(item,index)" class="collapse-title">								<view class="collapse-num-box">{{index+1}}</view>								<!-- 章名 -->								<text class="collapse-name">{{item.zhangName}}</text>								<!-- 锁 -->								<template v-if="AuthCode !== 'VIP'">									<view class="collapse-lock" v-if="index!=0"></view>								</template>							</view>					</template>					<view class="collapse-content-box">						<view v-for="(jie,cindex) in item.jieList" class="collapse-content-item">							<text class="jie-index">{{`${index+1}.${cindex+1}`}}</text>							<text class="text">{{jie.jieName}}</text>						</view>					</view>				</uni-collapse-item>			</uni-collapse>			<tip-small-dialog ref="confirmDialogRef" @confirm-btn="handleConfirmPay" :content="Message"></tip-small-dialog>			<tip-middle-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :content="MESSAGE_VISITER_TO_LOGIN"></tip-middle-dialog>		</view>	</uni-popup></template><script setup>	import {		useCatalogue	} from './useCatalogue';	import {		ref	} from "vue";	import {		toast	} from "@/utils/common.js"	import {getUserIdentity} from "@/utils/common.js"	import {MESSAGE_VISITER_TO_LOGIN,MESSAGE_BEFORE_PAY} from "@/utils/constant.js"    import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'	import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';	const $emit = defineEmits(['change-zhang'])	const { getCatalogue} = useCatalogue();	const popupRef = ref(null); // 索引	const confirmDialogRef = ref(null);	const list = ref([]); // 章节	const activeCollapse = ref('');	const Message = MESSAGE_BEFORE_PAY;	const AuthCode = getUserIdentity(); // 用户身份	const youkeDialogRef = ref(null);	function ykConfirm() {		uni.redirectTo({			url: '/pages/login/index'		});	}	/**	 * @summary 展示弹窗 暴露函数	 */	async function showPopup() {		const [err, data] = await getCatalogue();		if (err) {			toast("章节目录数据获取失败");			return;		}		refreshCatalogue(data);		handleShow();	}	/**	 * @param([]) 章节赋值	 */	function refreshCatalogue(data) {		list.value = data;	}	/**	 * @summary 展示目录弹窗	 */	function handleShow() {		popupRef.value.open('center');	}	/**	 * @summary 关闭目录弹窗	 */	function handleClose() {		popupRef.value.close();	}	/**	 * @summary 选中	 * @param({zhangId:string}) data	 */	function handleSelectZhang(data,index) {		if(index !=0 && AuthCode == 'Visitor'){			// 游客			youkeDialogRef.value.handleShow();			return;		}		if(index !=0 && AuthCode == 'Not-Vip'){			// 非VIP			popupRef.value.close();			confirmDialogRef.value.handleShow();			return;		}		$emit('change-zhang', Object.assign({}, data));		handleClose();	}	function handleConfirmPay() {		uni.redirectTo({ url: '/pages/pay/svip' })	}	defineExpose({		showPopup	})</script>
 |