123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <Container
- title="法规"
- :scrollY="maskStyle.height < 0"
- @onSafeAreaChange="onSafeAreaChange"
- >
- <uni-collapse
- ref="collapse"
- v-model="value"
- class="class-content"
- @change="onChnage"
- >
- <view class="free-content">
- <uni-collapse-item
- :open="index <= 1"
- :title="`第${numberConvertToUppercase(index + 1)}章 ${item.title}`"
- v-for="(item, index) in chaptersList.slice(0, 2)"
- :key="item.id"
- class="text"
- >
- <view class="-mt-20">
- <view class="content" v-for="(i, ind) in item.children" :key="i.id">
- <view class="text"
- >{{ `第${numberConvertToUppercase(ind + 1)}节` }}
- {{ i.title }}</view
- >
- <view class="buttons">
- <view
- @click="onClickButton(i.isStudied)"
- class="comment"
- v-if="i.isStudied === 0"
- >开始学习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment warning"
- v-if="i.isStudied > 0 && i.isStudied < 100"
- >继续学习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment"
- v-if="i.isStudied === 100"
- >去练习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment success"
- v-if="i.isStudied === 100"
- >已学习</view
- >
- </view>
- </view>
- </view>
- </uni-collapse-item>
- </view>
- <!-- 付费功能 -->
- <view class="pay-content">
- <view
- class="modal-mask"
- :style="{
- height: `${maskStyle.height}px`,
- width: `${maskStyle.width}px`,
- }"
- >
- <uni-icons type="locked" color="#fff" size="35"></uni-icons>
- <view class="modal-wrapper">邀请好友可解锁</view>
- </view>
- <uni-collapse-item
- :title="`第${numberConvertToUppercase(index + 3)}章 ${item.title}`"
- v-for="(item, index) in chaptersList.slice(2)"
- :key="item.id"
- class="text"
- >
- <view class="-mt-20">
- <view class="content" v-for="(i, ind) in item.children" :key="i.id">
- <view class="text"
- >{{ `第${numberConvertToUppercase(ind + 1)}节` }}
- {{ i.title }}</view
- >
- <view class="buttons">
- <view
- @click="onClickButton(i.isStudied)"
- class="comment"
- v-if="i.isStudied === 0"
- >开始学习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment warning"
- v-if="i.isStudied > 0 && i.isStudied < 100"
- >继续学习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment"
- v-if="i.isStudied === 100"
- >去练习</view
- >
- <view
- @click="onClickButton(i.isStudied)"
- class="comment success"
- v-if="i.isStudied === 100"
- >已学习</view
- >
- </view>
- </view>
- </view>
- </uni-collapse-item>
- </view>
- </uni-collapse>
- </Container>
- </template>
- <script setup name="regulations">
- import Container from "../../components/Container/Container.vue";
- import { ref, getCurrentInstance } from "vue";
- import { numberConvertToUppercase, getRect } from "../../utils";
- const collapse = ref(null);
- const value = ref("");
- const instance = getCurrentInstance();
- const safeArea = ref({});
- const maskStyle = ref({
- height: 0,
- width: 0,
- });
- const chaptersList = ref(
- new Array(10)
- .fill({
- title: "测试1",
- id: 1,
- children: new Array(5)
- .fill({
- id: 11,
- })
- .map((item, index) => {
- return {
- title: `测试1-${index + 1}`,
- id: index + item.id,
- isStudied: index === 1 ? 0 : index === 2 ? 20 : 100,
- };
- }),
- })
- .map((iten, index) => {
- return {
- ...iten,
- title: `测试${index + 1}`,
- id: index + 1,
- };
- })
- );
- const onClickButton = (isStudied) => {
- console.log(isStudied);
- };
- const resolveHeight = () =>
- setTimeout(() => {
- getRect({
- name: ".free-content",
- instance,
- onSuccess(res) {
- maskStyle.value.width = safeArea.value?.source?.width || 0;
- maskStyle.value.height = safeArea.value.height - res.height;
- },
- });
- // 动画300需要等待
- }, 300);
- const onSafeAreaChange = (s) => {
- safeArea.value = s;
- resolveHeight();
- };
- const onChnage = () => {
- resolveHeight();
- };
- </script>
- <style scoped lang="scss">
- @import "@/uni.scss";
- .text {
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 28rpx;
- color: #000000;
- }
- .content {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0 20rpx 4rpx 40rpx;
- .buttons {
- display: flex;
- gap: 10rpx;
- }
- .comment {
- width: 132rpx;
- height: 48rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #fff;
- color: $primary;
- border: 1px solid $primary;
- font-family: "PingFang SC, PingFang SC";
- font-weight: 500;
- font-size: 28rpx;
- color: #002fa7;
- border-radius: 4rpx;
- }
- .comment.success {
- color: $success;
- border: 1px solid $success;
- }
- .comment.warning {
- color: $warning;
- border: 1px solid $warning;
- }
- }
- .class-content {
- height: 100%;
- }
- .pay-content {
- flex: 1;
- position: relative;
- .modal-mask {
- background-color: rgba($color: #858585, $alpha: 0.8);
- position: absolute;
- height: 100%;
- z-index: 9999;
- left: -24rpx;
- display: flex;
- align-items: center;
- flex-direction: column;
- justify-content: center;
- gap: 34rpx;
- }
- }
- .modal-wrapper {
- width: 685rpx;
- height: 64rpx;
- background: #dfdfdf;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 28rpx;
- color: #000000;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- </style>
|