73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
// template/projectShowText/projectShowText.js
|
|
var miucms = require('../../utils/miucms.js');
|
|
let app = getApp()
|
|
const util = require('../../utils/util')
|
|
const common = require('../../utils/commonMethod')
|
|
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
className: String,
|
|
titleName: String,
|
|
text: {
|
|
type: String,
|
|
observer(res) {
|
|
if (res && res.length > 20) this.init()
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
text: "",
|
|
height: 0,
|
|
page: [],
|
|
current: 0,
|
|
isswiper: false,
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
init() {
|
|
// const height = util.rpxTopx(510)
|
|
const lineHeight = util.rpxTopx(51)
|
|
const height = lineHeight * 10
|
|
const query = wx.createSelectorQuery();
|
|
query.select(`.main >>> .hide.text.${ this.data.className }`).boundingClientRect(rect => {
|
|
const page = rect.height / height
|
|
// console.log("rect.height", rect.height);
|
|
let arr = []
|
|
|
|
for (let i = 0; i < Math.floor(page); i++) {
|
|
arr.push(height)
|
|
}
|
|
|
|
const decimalPart = parseFloat('0.' + page.toString().split('.')[1]);
|
|
if (decimalPart > 0) arr.push(height * decimalPart)
|
|
|
|
this.setData({
|
|
page: arr,
|
|
height,
|
|
isswiper: true,
|
|
})
|
|
|
|
}).exec();
|
|
},
|
|
|
|
// 招生官 轮播图 修改状态
|
|
bindchange(e) {
|
|
this.setData({
|
|
current: e.detail.current
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
}) |