Commit 37d55bc2 by 李嘉林

公告组件动态计算高度

parent db468fbd
...@@ -18,10 +18,12 @@ Component({ ...@@ -18,10 +18,12 @@ Component({
singleImg: '', singleImg: '',
CommonHeight: 0, CommonHeight: 0,
NoticeMargin: 0, NoticeMargin: 0,
NoticePadding: 0 NoticePadding: 0,
imgArr : [],
}, },
ready() { ready() {
console.log("notice---ready");
let { noticeList, singleImage } = this.data.datas.componentData let { noticeList, singleImage } = this.data.datas.componentData
singleImage = DFSImg(singleImage) singleImage = DFSImg(singleImage)
for (let i = 0; i < noticeList.length; i++) { for (let i = 0; i < noticeList.length; i++) {
...@@ -41,6 +43,17 @@ Component({ ...@@ -41,6 +43,17 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
bindload(e) {
let { imageWidth } = this.data.datas.componentData;
let index = e.currentTarget.dataset.index;
let width = e.detail.width
let height = e.detail.height
let useHeight = imageWidth / width * height;
this.setData({
[`imgArr[${index}].height`]: useHeight,
})
},
onclickHandle(e) { onclickHandle(e) {
let item = this.data.datas.componentData.noticeList[e.currentTarget.dataset.index] let item = this.data.datas.componentData.noticeList[e.currentTarget.dataset.index]
app.trackCpn(e, this.data.datas.componentName, item) app.trackCpn(e, this.data.datas.componentName, item)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<view class="container" bindtap="onclickHandle" data-index="{{index}}" style="width: 100%;height:{{CommonHeight}}"> <view class="container" bindtap="onclickHandle" data-index="{{index}}" style="width: 100%;height:{{CommonHeight}}">
<block wx:if="{{item.imageUrl||datas.componentData.singleImage}}"> <block wx:if="{{item.imageUrl||datas.componentData.singleImage}}">
<view wx:if="{{datas.componentData.styleType===1}}"> <view wx:if="{{datas.componentData.styleType===1}}">
<image class="notice-icon" mode="widthFix" style="width:{{datas.componentData.imageWidth}}px !important;" src="{{item.imageUrl}}" /> <image class="notice-icon" style="width:{{datas.componentData.imageWidth}}px !important; height: {{imgArr[index].height}}px" src="{{item.imageUrl}}" bindload="bindload" data-index="{{index}}" />
</view> </view>
<view wx:else> <view wx:else>
<image class="notice-icon" mode="widthFix" style="width:{{datas.componentData.imageWidth}}px !important;" src="{{singleImg}}" /> <image class="notice-icon" mode="widthFix" style="width:{{datas.componentData.imageWidth}}px !important;" src="{{singleImg}}" />
......
...@@ -31,8 +31,12 @@ VantComponent({ ...@@ -31,8 +31,12 @@ VantComponent({
sticky: Boolean, sticky: Boolean,
border: Boolean, border: Boolean,
swipeable: Boolean, swipeable: Boolean,
titleActiveColor: String, titleActiveColor: {
titleInactiveColor: String, type: [String, null]
},
titleInactiveColor: {
type: [String, null]
},
color: String, color: String,
datas: Object, datas: Object,
animated: { animated: {
...@@ -49,7 +53,6 @@ VantComponent({ ...@@ -49,7 +53,6 @@ VantComponent({
// observer: "resize" // observer: "resize"
}, },
lineLengthType: { lineLengthType: {
type: [String, Number],
value: 1 // 1默认自适应 2短自适应 3 固定宽度取值lineWidth value: 1 // 1默认自适应 2短自适应 3 固定宽度取值lineWidth
}, },
linePosition: { linePosition: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment