Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
c091e14b31
7 changed files with 0 additions and 280 deletions
  1. 165
      components/notice-bar/index.js
  2. 3
      components/notice-bar/index.json
  3. 22
      components/notice-bar/index.wxml
  4. 52
      components/notice-bar/index.wxss
  5. 2
      pages/article/hot-index/index.js
  6. 1
      pages/article/hot-index/index.json
  7. 35
      pages/article/hot-index/index.wxml

165
components/notice-bar/index.js

@ -1,165 +0,0 @@
import baseComponent from '../helpers/baseComponent'
import classNames from '../helpers/classNames'
baseComponent({
properties: {
prefixCls: {
type: String,
value: 'wux-notice-bar',
},
icon: {
type: String,
value: null,
},
content: {
type: String,
value: '',
},
mode: {
type: String,
value: '',
},
action: {
type: String,
value: null,
},
loop: {
type: Boolean,
value: false,
},
leading: {
type: Number,
value: 500,
},
trailing: {
type: Number,
value: 1000,
},
speed: {
type: Number,
value: 25,
},
},
data: {
animatedWidth: 0,
overflowWidth: 0,
visible: true,
},
computed: {
classes: ['prefixCls', function(prefixCls) {
const wrap = classNames(prefixCls)
const hd = `${prefixCls}__hd`
const icon = `${prefixCls}__icon`
const bd = `${prefixCls}__bd`
const container = `${prefixCls}__marquee-container`
const marquee = `${prefixCls}__marquee`
const ft = `${prefixCls}__ft`
const action = `${prefixCls}__action`
return {
wrap,
hd,
icon,
bd,
container,
marquee,
ft,
action,
}
}],
},
observers: {
content() {
this.resetAnimation()
},
},
methods: {
clearMarqueeTimer() {
if (this.marqueeTimer) {
clearTimeout(this.marqueeTimer)
this.marqueeTimer = null
}
},
startAnimation() {
this.clearMarqueeTimer()
const { loop, leading, trailing, speed } = this.data
const isLeading = this.data.animatedWidth === 0
const timeout = isLeading ? leading : speed
const animate = () => {
let animatedWidth = this.data.animatedWidth + 1
const isRoundOver = animatedWidth > this.data.overflowWidth
// 判断是否完成一次滚动
if (isRoundOver) {
if (!loop) return
// 重置初始位置
animatedWidth = 0
}
// 判断是否等待一段时间后进行下一次滚动
if (isRoundOver && trailing) {
this.triggerEvent('loop')
setTimeout(() => {
this.setData({ animatedWidth })
this.marqueeTimer = setTimeout(animate, speed)
}, trailing)
} else {
this.setData({ animatedWidth })
this.marqueeTimer = setTimeout(animate, speed)
}
}
if (this.data.overflowWidth !== 0) {
this.marqueeTimer = setTimeout(animate, timeout)
}
},
initAnimation(isForce) {
const { prefixCls } = this.data
const query = wx.createSelectorQuery().in(this)
query.select(`.${prefixCls}__marquee-container`).boundingClientRect()
query.select(`.${prefixCls}__marquee`).boundingClientRect()
query.exec((rects) => {
if (rects.filter((n) => !n).length) return
const [container, text] = rects
const overflowWidth = text.width - container.width
if (this.data.overflowWidth !== overflowWidth || isForce) {
this.setData({ overflowWidth, animatedWidth: 0 }, () => {
// 当文本内容存在且长度可滚动时,才触发动画
if (text.width > 0 && overflowWidth > 0) {
this.startAnimation()
} else {
this.startLoop()
}
})
}
})
},
startLoop: function () {
this.clearMarqueeTimer()
this.marqueeTimer = setTimeout(() => {
this.triggerEvent('loop')
}, 3000)
},
resetAnimation() {
this.initAnimation(true)
},
stopAnimation() {
this.clearMarqueeTimer()
},
onAction() {
if (this.data.mode === 'closable') {
this.clearMarqueeTimer()
this.setData({ visible: false })
}
this.triggerEvent('click')
},
onClick() {
this.triggerEvent('click')
},
},
ready() {
this.initAnimation()
},
detached() {
this.clearMarqueeTimer()
},
})

3
components/notice-bar/index.json

@ -1,3 +0,0 @@
{
"component": true
}

22
components/notice-bar/index.wxml

@ -1,22 +0,0 @@
<view class="wux-class {{ classes.wrap }}" wx:if="{{ visible }}" bindtap="onClick">
<view class="{{ classes.hd }}">
<image class="{{ classes.icon }}" src="{{ icon }}" wx:if="{{ icon }}" />
<block wx:else>
<slot name="header"></slot>
</block>
</view>
<view class="{{ classes.bd }}">
<view class="{{ classes.container }}">
<view class="{{ classes.marquee }}" style="transform: translate3d({{ -animatedWidth + 'px' }}, 0px, 0px)">
<block wx:if="{{ content }}">{{ content }}</block>
<slot></slot>
</view>
</view>
</view>
<view class="{{ classes.ft }}" catchtap="onAction" wx:if="{{ mode === 'closable' || mode === 'link' }}">
<image class="{{ classes.action }}" src="{{ action }}" wx:if="{{ action }}" />
<block wx:else>
<slot name="footer"></slot>
</block>
</view>
</view>

52
components/notice-bar/index.wxss

@ -1,52 +0,0 @@
.wux-notice-bar {
background-color: #fefcec;
height: 72rpx;
overflow: hidden;
font-size: 28rpx;
line-height: 72rpx;
color: #f76a24;
display: -ms-flexbox;
display: flex;
padding: 0 20rpx
}
.wux-notice-bar__icon {
width: 30rpx;
height: 30rpx;
margin-right: 20rpx
}
.wux-notice-bar__action {
width: 30rpx;
height: 30rpx;
margin-left: 20rpx
}
.wux-notice-bar__hd {
display: -ms-flexbox;
display: flex;
margin-right: 8rpx;
-ms-flex-align: center;
align-items: center
}
.wux-notice-bar__bd {
-ms-flex: 1;
flex: 1;
width: 100%;
width: auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
.wux-notice-bar__marquee-container {
overflow: hidden
}
.wux-notice-bar__marquee {
position: relative;
transform: translate3d(0,0,0);
white-space: nowrap;
display: inline-block
}
.wux-notice-bar__ft {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center
}

2
pages/article/hot-index/index.js

@ -155,8 +155,6 @@ Component({
this.fetchNoticeList()
}
this.setData({ content: this.data.noticeList[this.data.noticeIndex].title })
this.notice = this.notice || this.selectComponent('#wux-notice-bar')
this.notice.resetAnimation()
},
onClick: function(){
wx.navigateTo({ url: '/pages/html/notice/index?id=' + this.data.noticeList[this.data.noticeIndex].id })

1
pages/article/hot-index/index.json

@ -8,7 +8,6 @@
"wux-col": "/components/col/index",
"wux-grids": "/components/grids/index",
"wux-grid": "/components/grid/index",
"wux-notice-bar": "/components/notice-bar/index",
"wux-divider": "/components/divider/index",
"wux-image": "/components/image/index",
"refresh-view": "/components/refresher/index",

35
pages/article/hot-index/index.wxml

@ -1,40 +1,5 @@
<!-- <scroll-view scroll-y style="height: {{height}}rpx;" lower-threshold="200" bindscrolltolower="fetchMomentList"> -->
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchMomentList">
<!-- <wux-notice-bar id="wux-notice-bar" wux-class="notice-bar" loop speed="100" mode="link" icon="" action=""
bind:click="onClick" bind:loop="onLoop" wx:if="{{content}}">
<text slot="header" class="cuIcon-notification text-gray" style="font-size:36rpx"></text>
<text slot="footer" class="cuIcon-right text-gray" style="font-size:36rpx"></text>
<text>{{content}}</text>
</wux-notice-bar> -->
<!-- <wux-skeleton active wx:if="{{!factoryList.length}}">
<view class="bg-white flex flex-justify" style="padding:24rpx 0rpx 12rpx 30rpx">
<wux-skeleton-paragraph rounded rows="1" wux-class="case-class" />
<wux-skeleton-paragraph rounded rows="1" wux-class="case2-class" />
</view>
<view class="bg-white flex" style="padding: 12rpx 30rpx 24rpx 30rpx">
<view wx:for="{{5}}" wx:key="index" class="item-host" style="padding-left:{{index == 0? 0 : 8}}rpx;">
<wux-skeleton-avatar shape="rounded" size="large" />
<wux-skeleton-paragraph rounded rows="1" wux-class="host-class" />
</view>
</view>
</wux-skeleton> -->
<!-- <view wx:else>
<view class="bg-white flex flex-justify" style="padding:20rpx 30rpx;">
<view class="text-bold text-df" style="color:#333333">纸厂动态</view>
<view class="text-gray text-df" bindtap="toFactoryList">更多<text class="cuIcon-right text-gray" style="font-size:14px"></text></view>
</view>
<scroll-view class="bg-white" scroll-x scroll-with-animation="{{true}}">
<view class="flex" style="padding: 4rpx 30rpx 20rpx 30rpx">
<view wx:for="{{factoryList}}" wx:key="index" class="item-host" style="padding-left:{{index==0?0:30}}rpx;flex:1" data-index="{{index}}" bindtap="toFactory">
<wux-image width="{{50}}" height="{{50}}" shape="rounded" src="{{item.logoImg}}" mode="aspectFill">
<image class="image-load" style="border-radius: 8rpx" slot="loading" src="/assets/image/def_image.png"></image>
<image class="image-load" style="border-radius: 8rpx" slot="error" src="/assets/image/def_image.png"></image>
</wux-image>
<view class="text-sm text-cut" style="text-align: center;width:96rpx;margin-top:4rpx">{{item.shortName}}</view>
</view>
</view>
</scroll-view>
</view> -->
<!----------------------------------------------------帖子列表---------------------------------------------------------------->
<wux-skeleton active wx:if="{{!momentList.length}}">
<view class="cu-card dynamic no-card" wx:for="{{5}}" wx:key="index">

Loading…
Cancel
Save