Commit 10dcb8f7 by 侯体倬

公告修改

parent 96280bca
...@@ -122,9 +122,10 @@ export default { ...@@ -122,9 +122,10 @@ export default {
}, },
// 获取用户信息 // 获取用户信息
getUserInfo() { getUserInfo() {
if (this.$store.state.userInfo.nickName) { this.nickName = this.$store.state.userInfo.nickName } if (this.$store.state.userInfo) {
if (this.$store.state.userInfo.avatarUrl) { this.avatar = this.$store.state.userInfo.avatarUrl } this.nickName = this.$store.state.userInfo.nickName
else { this.avatar = this.$store.state.userInfo.avatarUrl
} else {
this.avatar = "http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/jpg/02c0c235-daae-412d-bced-5fb315ad570e.jpg" this.avatar = "http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/jpg/02c0c235-daae-412d-bced-5fb315ad570e.jpg"
} }
}, },
......
// static/nativeComponents/Notice/index.js // static/nativeComponents/Notice/index.js
let app = getApp() const app = getApp();
const { DFSImg, $themeToLink } = app;
Component({ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
...@@ -14,61 +15,68 @@ Component({ ...@@ -14,61 +15,68 @@ Component({
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
timer:null, singleImg: '',
newLeft : 0 CommonHeight: 0,
NoticeMargin: 0,
NoticePadding: 0
}, },
ready(){ ready() {
let marqueeWidth = 0; let { noticeList, singleImage } = this.data.datas.componentData
let screenWidth = 0; singleImage = DFSImg(singleImage)
let _this = this for (let i = 0; i < noticeList.length; i++) {
this.createSelectorQuery().select('.marquee').boundingClientRect(function(res){ let imageUrl = DFSImg(noticeList[i].imageUrl)
if (res) { noticeList[i].imageUrl = imageUrl
marqueeWidth = res.width }
_this.createSelectorQuery().select('.notice').boundingClientRect(function (res1) { this.setData({
if (res1) { singleImg: singleImage,
screenWidth = res1.width "data.datas.componentData.noticeList": noticeList
})
console.log(marqueeWidth, screenWidth, 'screenWidth') this.getNoticeHeight()
this.getNoticeMargin()
if (marqueeWidth > screenWidth) { this.getNoticePadding()
_this.marqueeMove(marqueeWidth,screenWidth);
}else{
clearInterval(_this.data.timer);
_this.setData({
newLeft : 0
})
}
}
}).exec()
}
}).exec()
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
marqueeMove(marqueeWidth,screenWidth){ onclickHandle(e) {
clearInterval(this.data.timer); app.$themeToLink(this.data.datas.componentData.noticeList[e.currentTarget.dataset.index].link)
},
this.data.timer = setInterval(() => { getNoticeMargin() {
this.setData({ this.setData({
newLeft : this.data.newLeft - 1 NoticeMargin: this.data.datas.componentData.verticalMargin+'px '+this.data.datas.componentData.horizontalMargin+'px'
}) })
if(Math.abs(this.data.newLeft) >= marqueeWidth + 200){ },
getNoticePadding() {
this.setData({
NoticePadding: this.data.datas.componentData.verticalPadding+'px '+this.data.datas.componentData.horizontalPadding+'px'
})
},
getNoticeHeight() {
if (this.data.datas.componentData.isChange) {
if (this.data.datas.componentData.imageWidth > this.data.datas.componentData.noticeWidth) {
this.setData({ this.setData({
newLeft: screenWidth CommonHeight: this.data.datas.componentData.imageWidth < 53 ? '53px' : this.data.datas.componentData.imageWidth + 'px'
}) })
return
} else if (this.data.datas.componentData.noticeWidth >= this.data.datas.componentData.imageWidth) {
this.setData({
CommonHeight: this.data.datas.componentData.noticeWidth < 53 ? '53px' : this.data.datas.componentData.noticeWidth + 'px'
})
return
} }
},10) this.setData({
CommonHeight: this.data.datas.componentData.noticeWidth > this.data.datas.componentData.imageWidth ? this.data.datas.componentData.noticeWidth + 'px' : this.data.datas.componentData.imageWidth + 'px'
}, })
onclickHandle(){ return
app.$themeToLink(this.data.datas.componentData.link) } else {
this.setData({
CommonHeight: this.data.datas.componentData.noticeWidth < 53 ? '53px' : this.data.datas.componentData.noticeWidth + 'px'
})
return
}
} }
} }
}) })
{ {
"component": true, "component": true,
"usingComponents": {} "usingComponents": {
} "van-icon": "/static/vant/icon/index"
\ No newline at end of file }
}
<!--static/nativeComponents/Notice/index.wxml--> <!--static/nativeComponents/Notice/index.wxml-->
<view class="notice-wrap" style="background-color:{{datas.componentData.backgroundColor}}"> <view class="notice" style="border-radius:{{datas.componentData.borderRadius}}px;background-color:{{datas.componentData.backgroundColor}};margin:{{NoticeMargin}};padding:{{NoticePadding}};height:{{(CommonHeight)}}">
<view class="notice" style="text-align:left;color:{{datas.componentData.fontColor}}; "> <swiper autoplay interval="3000" vertical style="height:{{CommonHeight}}" circular>
<view class="marquee" style="left:{{newLeft * 2}}rpx" bindtap="onclickHandle">{{datas.componentData.content}}</view> <swiper-item wx:for="{{datas.componentData.noticeList}}" wx:key="{{index}}">
<view class="container" bindtap="onclickHandle" data-index="{{index}}" style="width: 100%;height:{{CommonHeight}}">
<block wx:if="{{item.imageUrl||datas.componentData.singleImage}}">
<view wx:if="{{datas.componentData.styleType===1}}">
<image class="notice-icon" style="width:{{datas.componentData.imageWidth}}px !important;height:{{datas.componentData.imageWidth}}px;" src="{{item.imageUrl}}" />
</view>
<view wx:else>
<image class="notice-icon" style="width:{{datas.componentData.imageWidth}}px !important;height:{{datas.componentData.imageWidth}}px;" src="{{singleImg}}" />
</view>
</block>
<view class="notice-content" style="font-size:{{datas.componentData.fontSize}}px;color:{{datas.componentData.fontColor}}">
<text class="content">{{item.title}}</text>
</view>
<van-icon class="notice-arrowhead" name="arrow" color="#000" wx:if="{{!datas.componentData.showArrow}}"></van-icon>
</view>
</swiper-item>
</swiper>
</view> </view>
</view>
/* static/nativeComponents/Notice/index.wxss */ /* static/nativeComponents/Notice/index.wxss */
.notice{ .notice {
font-size: 32rpx;
position: relative; position: relative;
}
.notice .container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
.container .notice-icon {
margin-left: 15px;
width: 100%;
border-radius: 6px;
}
.container .notice-content {
flex: auto;
margin-left: 15px;
}
.notice-content .content {
flex: auto;
word-wrap: break-word;
word-break: break-all;
overflow: hidden; overflow: hidden;
height: 80rpx; text-overflow: ellipsis;
width: calc(100vw - 40rpx); display: -webkit-box;
margin-left: 20rpx; -webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.container .notice-arrowhead {
margin: 0 15px;
width: 17px;
height: 17px;
} }
.marquee {
position: absolute;
height: 80rpx;
line-height: 80rpx;
/* width: 100%; */
margin: 0 auto;
white-space: nowrap;
box-sizing: border-box;
}
\ No newline at end of file
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