catalogue.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(255, 255, 255, 0.6);" :is-shadow="false">
  4. <view class="ezy-catalogue-dialog">
  5. <uni-icons @click="handleClose" class="catalogue-close-btn"></uni-icons>
  6. <!-- 目录区域 -->
  7. <uni-collapse v-model="activeCollapse" class="ezy-catalogue-collapse" accordion>
  8. <uni-collapse-item title-border="none" :border="false" :name="index+''" v-for="(item,index) in list"
  9. class="collapse-item-box" :class="{ 'collapse-active': activeCollapse === index+''}">
  10. <template v-slot:title>
  11. <view @click.stop="handleSelectZhang(item,index)" class="collapse-title">
  12. <view class="collapse-num-box">{{index+1}}</view>
  13. <!-- 章名 -->
  14. <text class="collapse-name">{{item.zhangName}}</text>
  15. <!-- 锁 -->
  16. <template v-if="AuthCode !== 'VIP'">
  17. <view class="collapse-lock" v-if="index!=0"></view>
  18. </template>
  19. </view>
  20. </template>
  21. <view class="collapse-content-box">
  22. <view v-for="(jie,cindex) in item.jieList" class="collapse-content-item">
  23. <text class="jie-index">{{`${index+1}.${cindex+1}`}}</text>
  24. <text class="text">{{jie.jieName}}</text>
  25. </view>
  26. </view>
  27. </uni-collapse-item>
  28. </uni-collapse>
  29. <tip-small-dialog ref="confirmDialogRef" @confirm-btn="handleConfirmPay" :content="Message"></tip-small-dialog>
  30. <tip-middle-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :content="MESSAGE_VISITER_TO_LOGIN"></tip-middle-dialog>
  31. </view>
  32. </uni-popup>
  33. </template>
  34. <script setup>
  35. import {
  36. useCatalogue
  37. } from './useCatalogue';
  38. import {
  39. ref
  40. } from "vue";
  41. import {
  42. toast
  43. } from "@/utils/common.js"
  44. import {getUserIdentity} from "@/utils/common.js"
  45. import {MESSAGE_VISITER_TO_LOGIN,MESSAGE_BEFORE_PAY} from "@/utils/constant.js"
  46. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
  47. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  48. import {
  49. onShow
  50. } from '@dcloudio/uni-app';
  51. const growthType = ref(null);
  52. const AuthCode = ref(null);
  53. onShow(() => AuthCode.value = getUserIdentity()); // 用户身份
  54. const $emit = defineEmits(['change-zhang'])
  55. const { getCatalogue} = useCatalogue();
  56. const popupRef = ref(null); // 索引
  57. const confirmDialogRef = ref(null);
  58. const activeCollapse = ref('');
  59. const Message = MESSAGE_BEFORE_PAY;
  60. const youkeDialogRef = ref(null);
  61. const props = defineProps({
  62. list: {
  63. type: Array,
  64. }
  65. })
  66. function ykConfirm() {
  67. uni.redirectTo({
  68. url: '/pages/login/index'
  69. });
  70. }
  71. /**
  72. * @summary 展示弹窗 暴露函数
  73. */
  74. async function showPopup() {
  75. handleShow();
  76. }
  77. /**
  78. * @summary 展示目录弹窗
  79. */
  80. function handleShow() {
  81. popupRef.value.open('center');
  82. }
  83. /**
  84. * @summary 关闭目录弹窗
  85. */
  86. function handleClose() {
  87. popupRef.value.close();
  88. }
  89. /**
  90. * @summary 选中
  91. * @param({zhangId:string}) data
  92. */
  93. function handleSelectZhang(data,index) {
  94. if(index !=0 && AuthCode.value == 'Visitor'){
  95. // 游客
  96. youkeDialogRef.value.handleShow();
  97. return;
  98. }
  99. if(index !=0 && AuthCode.value == 'Not-Vip'){
  100. // 非VIP
  101. popupRef.value.close();
  102. confirmDialogRef.value.handleShow();
  103. return;
  104. }
  105. $emit('change-zhang', Object.assign({}, data));
  106. handleClose();
  107. }
  108. function handleConfirmPay() {
  109. uni.redirectTo({ url: '/pages/pay/svip' })
  110. }
  111. defineExpose({
  112. showPopup
  113. })
  114. </script>