| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <div class="card-situation">
- <div class="card-title">{{ model.title }}</div>
- <div class="card-text" :class="{ isfold: isfold }">
- <u-parse :content="model.text" @navigate="navigateUrl" />
- </div>
- <div class="fold" v-if="isFold && localIsFold" @click="changeFoldState">
- 点击{{ foldText }}
- </div>
- </div>
- </template>
- <script>
- import uParse from '@/components/gaoyia-parse/parse.vue'
- export default {
- components: {
- uParse
- },
- props: ["model", "isFold"],
- data() {
- return {
- isfold: false,
- height: 0,
- foldText: "展开",
- scrollTop: 0,
- localIsFold: true,
- };
- },
- mounted() {
- let query = uni.createSelectorQuery().in(this);
- let cardText = query.select(".card-text");
- cardText
- .boundingClientRect((res) => {
- this.height = res.height;
- })
- .exec(() => {
- if (this.height < 500) {
- this.localIsFold = false;
- } else {
- this.isfold = true;
- }
- });
- },
- watch: {
- isfold(newValue, oldValue) {
- if (newValue) {
- this.foldText = "展开";
- } else {
- this.foldText = "收起";
- }
- },
- },
- methods: {
- navigateUrl(href, e) {
- uni.setClipboardData({
- data:href,//要被复制的内容
- success:()=>{//复制成功的回调函数
- uni.showToast({//提示
- title:'复制成功'
- })
- }
- });
- },
- changeFoldState() {
- let poor = 0,
- Bheight = 0,
- Eheight = 0;
- let query = uni.createSelectorQuery().in(this);
- let con = query.select(".card-situation");
- con
- .fields({ size: true }, (e) => {
- Bheight = e.height;
- })
- .exec(() => {
- console.log("开始高度", Bheight);
- });
- this.isfold = !this.isfold;
- con
- .fields({ size: true }, (e) => {
- Eheight = e.height;
- })
- .exec(() => {
- // this.$emit("changeScroll", Bheight - Eheight);
- console.log("结束高度", Eheight);
- });
- this.$emit("changeScroll");
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .card-situation {
- // margin-top: 20rpx;
- padding: 20rpx;
- border-top: 8rpx solid #f2f2f2;
- box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
- border-radius: 32rpx;
- .card-title {
- font-weight: 600;
- padding: 20rpx 20rpx 0rpx 20rpx;
- }
- .card-text {
- padding: 20rpx;
- margin-top: 20rpx;
- font-size: 32rpx;
- letter-spacing: 1rpx;
- line-height: 50rpx;
- overflow: hidden;
- }
- .fold {
- display: flex;
- justify-content: center;
- align-items: center;
- color: $uni-color-primary;
- }
- }
- .isfold {
- max-height: 340rpx;
- }
- </style>
|