123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- <template>
- <view class="marquee_box" @touchstart='touchstartFn' @touchend='touchendFn'>
- <view class="" v-if="direction=='right'||direction=='left'">
- <view v-if="broadcastType=='text'" class="marquee_container" :style="'background:'+broadcastStylees.back_color+';'">
- <view v-if="broadcastIconIsDisplay" class="broadIcon" :style="'background:'+broadcastStylees.back_color+';font-size:28rpx;'">
- <text class="iconfont icon-guangbozheng-"></text>
- <text style="margin-left:12rpx;">{{broadcast_tit}}:</text>
- </view>
- <view class="boradcast_text_left_rig" :class='[direction=="left"?"marquee_text_left":direction=="right"?"marquee_text_right":"",animation_paused?"animation_pausedcss":""]'
- :style="'--marqueeWidth--:'+(-broadcastStylees.width_mal)+'px;--speed--:'+broadcastStylees.time+'s;width:'+broadcastStylees.width_mal+'px;'">
- <view v-for="(item,index) in broadcastDataes" @click.stop="click_event(index)" :key="index" :style="'color:'+broadcastStylees.text_color+';margin-left:'+(index!=0?item.starspos:0)+'px;font-size:'+broadcastStylees.font_size+'rpx;'">
- {{item.text}}
- </view>
- </view>
- </view>
- <view v-if="broadcastType=='mould'" class="mould">
- <view class="" style="width: 100%;position: relative;overflow: hidden;" :style="'height:'+viewHeight+'rpx;'">
- <view id="widthBox" class="broadcastTopBtm dsf" :class="[direction=='left'?'broadcastDataTopBtmDatacss_let':direction=='right'?'broadcastDataTopBtmDatacss_rig':'',animation_paused?'animation_pausedcss':'']"
- :style="styleWidth">
- <view class="bml01" style="display: flex;justify-content: space-between;">
- <view v-for="(item, index) in groupBookingList" :key="index" class="floor-item">
- <image class="list-image" :src="item.image"></image>
- <view class="tpl-box">
- <image mode="scaleToFill" src="https://shicai.liuniu946.com/img/img063.png"></image>
- <view class="price-list flex">
- <view class="out-price">¥{{ item.ot_price }}</view>
- <view class="xianprice">
- <text>¥{{ item.price }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="bml02" style="display: flex;justify-content: space-between;">
- <view v-for="(item, index) in groupBookingList" :key="index" class="floor-item">
- <image class="list-image" :src="item.image"></image>
- <view class="tpl-box">
- <image mode="scaleToFill" src="https://shicai.liuniu946.com/img/img063.png"></image>
- <view class="price-list flex">
- <view class="out-price">¥{{ item.ot_price }}</view>
- <view class="xianprice">
- <text>¥{{ item.price }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view v-if="direction=='top'||direction=='bottom'" class="broadcastTopBtm" :style="'font-size:'+broadcastStyle.font_size+'rpx;color:'+broadcastStyle.text_color+';background:'+broadcastStyle.back_color+';height:'+viewHeight+'rpx;--scrollHeight--:'+(-broadcastTopBtmHeight/2)+'px;--scrollSpeed--:'+(broadcastTopBtmHeight/2)/broadcastStyle.speed+'s;'">
- <view v-if="broadcastType=='text'" :class="[direction=='top'?'broadcastDataTopBtmDatacss_top':direction=='bottom'?'broadcastDataTopBtmDatacss_bottom':'',animation_paused?'animation_pausedcss':'']">
- <view v-for="(item,index) in broadcastDataTopBtmDataes"
- :key="index"
- @click.stop="click_event(index)"
- class="bdbd_item">
- <!-- {{item}} -->
- </view>
- </view>
- <view v-if="broadcastType=='mould'" :class="[direction=='top'?'broadcastDataTopBtmDatacss_top':direction=='bottom'?'broadcastDataTopBtmDatacss_bottom':'',animation_paused?'animation_pausedcss':'']">
- <view class="">
- <slot />
- </view>
- <view class="">
- <slot />
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- /**
- * author:G.bro
- * date:20200513
- * * **/
- export default {
- data() {
- return {
- broadcastDataes: [],
- broadcastDataTopBtmDataes: [],
- broadcastStylees: {},
- broadcastTopBtmHeight: 0,
- scrlloWidth: 0,
- animation_paused: false,
- qualifications:true,
- styleWidth:''
- }
- },
- props: {
- groupBookingList:{
- default:function () {
- return []
- }
- },
- broadcastType: {
- type: String,
- default: 'text' //mould
- },
- // broadcastDataTopBtmData: {
- // type: Array
- // },
- broadcastData: {
- type: Array
- },
- broadcastStyle: {
- type: Object,
- default () {
- return {
- speed: 90, //滚动速度,每秒3个字
- font_size: "28", //字体大小(rpx)
- text_color: "#fff", //字体颜色
- back_color: "#815CD4", //背景色
- }
- }
- },
- broadcastIconIsDisplay: { //图标是否显示
- type: Boolean,
- default: false
- },
- // broadcast_icon: {
- // type: String,
- // default: ''
- // },
- broadcast_tit: {
- type: String,
- default: '今日热点'
- },
- direction: {
- type: String,
- default: 'left'
- },
- viewHeight: {
- type: Number,
- default: 200
- },
- touchEvent: {
- type: true,
- default: false
- }
- },
- comments: {
- },
- created() {
- if (this.broadcastType == "text") {
- if (this.direction == "right" || this.direction == "left") {
- this.initial_let_rig();
- } else {
- let arr = [...this.broadcastData];
- arr = arr.concat(arr);
- this.broadcastDataTopBtmDataes = arr;
- }
- }
- },
- mounted() {},
- methods: {
- getBoxWidth(){
- let that = this;
- if (this.direction == "top" || this.direction == "bottom") {
- const query2 = uni.createSelectorQuery().in(this)
- query2.select('.broadcastDataTopBtmDatacss_' + this.direction).boundingClientRect(rect => {
- that.broadcastTopBtmHeight = rect.height;
- if(that.viewHeight-rect.height>10){
- that.qualifications=false;
- that.animation_paused = true;
- that.broadcastDataTopBtmDataes.splice(that.broadcastDataTopBtmDataes.length/2,that.broadcastDataTopBtmDataes.length-1);
- }
- console.log(that.broadcastDataTopBtmDataes.length/2, 'that.surplusHeight')
- }).exec()
- }
- if (this.direction == "left" || this.direction == "right") {
- if (this.broadcastType == 'mould') {
- const query = uni.createSelectorQuery().in(this)
- query.select('.bml01').boundingClientRect(rect => {
- console.log(rect);
- that.scrlloWidth = +rect.width;
- let styleWidth='--scrollWidth--:-'+that.scrlloWidth+'px;--scrollSpeed2--:'+that.scrlloWidth/that.broadcastStyle.speed+'s;width:'+that.scrlloWidth*2+'px;'
- that.$set(that,'styleWidth',styleWidth);
- }).exec()
- query.select('.bml01').boundingClientRect(rect => {
- console.log(rect);
- that.scrlloWidth = +rect.width;
- let styleWidth='--scrollWidth--:-'+that.scrlloWidth+'px;--scrollSpeed2--:'+that.scrlloWidth/that.broadcastStyle.speed+'s;width:'+that.scrlloWidth*2+'px;'
- that.$set(that,'styleWidth',styleWidth);
- }).exec()
- }
- // if(this.broadcastType=='text'){有偏差
- // let assist = { ...this.broadcastStyle};
- // const querys = uni.createSelectorQuery().in(this)
- // querys.select('.boradcast_text_left_rig').boundingClientRect(rect => {
- // assist.width_mal = rect.width;
- // assist.time = rect.width/assist.speed;
- // that.broadcastStylees=assist;
- // }).exec()
- // }
- }
- },
- touchendFn(e) {
- if (this.touchEvent&&this.qualifications) {
- this.animation_paused = false;
- }
- },
- touchstartFn(e) {
- if (this.touchEvent&&this.qualifications) {
- this.animation_paused = true;
- }
- },
- initial_let_rig() {
- let broadcastData = [...this.broadcastData];
- console.log(this.direction, 'this.direction')
- if (this.direction == "right") {
- broadcastData.reverse();
- }
- let ititdata = broadcastData.map((item) => {
- return {
- "text": item,
- "starspos": uni.getSystemInfoSync().windowWidth - 103
- }
- }),
- assist = { ...this.broadcastStyle
- },
- this_width = 0,
- spacing = 0,
- speed = (assist.speed * assist.font_size); //m每秒行走的距离
- for (let i in ititdata) {
- this_width += ititdata[i].text.length * assist.font_size;
- if (i != ititdata.length - 1) {
- spacing += ititdata[i].starspos
- }
- }
- let total_length = (this_width / 2) + spacing; //总长
- assist.time = total_length / speed; /**滚动时间*/
- assist.width_mal = total_length;
- this.broadcastDataes = ititdata;
- this.broadcastStylees = assist;
- },
- click_event(index){
- let nub = this.broadcastDataTopBtmDataes.length/2;
- let dataNub=0;
- if(index>nub-1){
- dataNub = index -nub
- }else{
- dataNub = index;
- }
-
- this.$emit("changeEvent",{dataNub,msg:`你点击了${index+1}条`});
- }
- }
- }
- </script>
- <style lang="scss">
- .tpl-box {
- position: relative;
- image {
- width: 149rpx;
- height: 33rpx;
- }
- }
- .floor-item {
- margin: 0rpx 25rpx;
- .list-image {
- width: 140rpx;
- height: 140rpx;
- border-radius: 15rpx;
- }
- .price-list {
- font-size: 20rpx;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- padding: 5rpx 10rpx;
- line-height: 1;
- height: 33rpx;
- align-items: flex-end;
- .out-price {
- color: #b25e15;
- text-decoration: line-through;
- font-size: 17rpx;
- }
- .xianprice {
- color: #ffffff;
- font-size: 24rpx !important;
- // padding-bottom: 5rpx;
- }
- .moneyIcon {
- font-size: 17rpx;
- }
- }
- }
- /* page {
- overflow: hidden;
- width: 100%;
- } */
- .marquee_box {
- width: 100%;
- overflow: hidden;
- position: inherit;
- height: auto;
- }
- .mould {
- width: 750rpx;
- overflow: hidden;
- position: inherit;
- }
- .dsf {
- display: flex;
- justify-content: space-between;
- }
- .broadIcon {
- /* width: 60rpx; */
- padding: 0 22rpx;
- height: 60rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- position: absolute;
- left: 0;
- top: 0;
- color: #fff;
- z-index: 999;
- line-height: 60rpx;
- }
- .marquee_container {
- position: relative;
- width: 100%;
- height: 60rpx;
- }
- .marquee_text_left {
- display: flex;
- white-space: nowrap;
- animation-name: around_left;
- animation-duration: var(--speed--);
- animation-iteration-count: infinite;
- animation-timing-function: linear;
- line-height: 60rpx;
- position: absolute;
- }
- @keyframes around_left {
- from {
- left: 100%;
- }
- to {
- left: var(--marqueeWidth--);
- }
- }
- .marquee_text_right {
- display: flex;
- white-space: nowrap;
- animation-name: around_right;
- animation-duration: var(--speed--);
- animation-iteration-count: infinite;
- animation-timing-function: linear;
- line-height: 60rpx;
- position: absolute;
- }
- @keyframes around_right {
- from {
- right: 100%;
- }
- to {
- right: var(--marqueeWidth--);
- }
- }
- .marquee_tit {
- height: 60rpx;
- line-height: 60rpx;
- }
- .broadcastTopBtm {
- padding: 12rx;
- overflow: hidden;
- position: relative;
- }
- .broadcastDataTopBtmDatacss_top {
- width: 100%;
- animation-name: around_top;
- animation-duration: var(--scrollSpeed--);
- animation-iteration-count: infinite;
- animation-timing-function: linear;
- position: absolute;
- left: 0;
- }
- @keyframes around_top {
- from {
- top: 0%;
- }
- to {
- top: var(--scrollHeight--);
- }
- }
- .broadcastDataTopBtmDatacss_bottom {
- width: 100%;
- animation-name: around_Bottom;
- animation-duration: var(--scrollSpeed--);
- animation-iteration-count: infinite;
- animation-timing-function: linear;
- position: absolute;
- left: 0;
- }
- @keyframes around_Bottom {
- from {
- bottom: 0%;
- }
- to {
- bottom: var(--scrollHeight--);
- }
- }
- .broadcastDataTopBtmDatacss_let {
- width: 100%;
- animation-name: around_let;
- animation-duration: var(--scrollSpeed2--);
- animation-iteration-count: infinite;
- animation-timing-function: linear;
- position: absolute;
- left: 0;
- top: 0;
- }
- .animation_pausedcss {
- animation-play-state: paused;
- }
- @keyframes around_let {
- from {
- left: 0%;
- }
- to {
- left: var(--scrollWidth--);
- }
- }
- .bdbd_item {
- padding: 0 12rpx;
- line-height: 60rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- @font-face {
- font-family: "iconfont";
- src: url('//at.alicdn.com/t/font_1686137_9el2ov99ag.eot?t=1589197045289');
- /* IE9 */
- src: url('//at.alicdn.com/t/font_1686137_9el2ov99ag.eot?t=1589197045289#iefix') format('embedded-opentype'),
- /* IE6-IE8 */
- url('data:application/x-font-woff2;charset=utf-8;base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BGiWwuSZo8KX3YOgfkRnbpgEA') format('woff2'),
- url('//at.alicdn.com/t/font_1686137_9el2ov99ag.woff?t=1589197045289') format('woff'),
- url('//at.alicdn.com/t/font_1686137_9el2ov99ag.ttf?t=1589197045289') format('truetype'),
- /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
- url('//at.alicdn.com/t/font_1686137_9el2ov99ag.svg?t=1589197045289#iconfont') format('svg');
- /* iOS 4.1- */
- }
- .iconfont {
- font-family: "iconfont" !important;
- font-size: 16px;
- font-style: normal;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- }
- .icon-guangbozheng-:before {
- content: "\e640";
- }
- </style>
|