123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <template>
- <view class="container">
- <image class="headImg" mode="aspectFill" :src="$fileUrl() + '/homeHead.jpeg'"></image>
- <view class="headBarrage">
- <l-barrage :data="barrageData" :defer="1" :loopCount="6">
- <!-- 自定义每条弹幕样式 content 为你传入的数据-->
- <template #default="{content}">
- <view class="bullet">{{content.text}}</view>
- </template>
- </l-barrage>
- </view>
- <view class="tabs">
- <view class="tab">
- <image :src="$fileUrl() + '/Frame3.png'" alt="">
- <span>全部</span>
- </view>
- <view class="tab" @click="$navigateTo('/pages/excellentValue/excellentValue')">
- <image :src="$fileUrl() + '/Frame4.png'" alt="">
- <span>超值挑战</span>
- </view>
- <view class="tab">
- <image :src="$fileUrl() + '/Frame2.png'" alt="">
- <span>拍卖专区</span>
- </view>
- <view class="tab">
- <image :src="$fileUrl() + '/Frame1.png'" alt="">
- <span>VIP福利</span>
- </view>
- </view>
- <view class="buttons">
- <view class="left">
- <image :src="$fileUrl() + '/button3.png'" @click="toInvite"></image>
- </view>
- <view class="right">
- <image :src="$fileUrl() + '/button1.png'"></image>
- <image :src="$fileUrl() + '/button2.png'"
- @click="$navigateTo('/pages/raffle/raffle')"></image>
- </view>
- </view>
- <view class="list-title">
- - 热门推荐 -
- </view>
- <view class="list">
- <view class="ka" v-for="(item, index) in kaList">
- <view class="top">
- <image mode="aspectFit" :src="$fileUrl() + '/ka.jpeg'"></image>
- </view>
- <view class="ka-info">
- <view class="ka-name">
- 宝可梦简中原盒拆拆乐
- </view>
- <view class="row">
- <uni-tag text="创意热销" inverted type="default"></uni-tag>
- <view class="money">
- ¥9.9
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- messageListApi
- } from "@/api/common.js"
- export default {
- data() {
- return {
- kaList: 6,
- messageList: [],
- barrageData: [],
- barrageIndex: 0,
- timeOut: null,
- interval: null,
- params: {
- limit: 20,
- page: 1,
- },
- total: null,
- }
- },
- onLoad(query) {
- if (query.inviteId) {
- getApp().globalData.inviteId = query.inviteId;
- } else {
- const scene = decodeURIComponent(query.scene)
- let inviteId = scene.split("=")[1]
- console.log(inviteId, 'inviteId')
- getApp().globalData.inviteId = inviteId;
- }
- },
- onShow() {
- this.getMessage()
- this.interval = setInterval(() => {
- console.log('重复获取消息')
- this.barrageIndex = 0
- this.getMessage()
- // let num = this.params.page * this.params.limit
- // if (this.total == null || this.total > num) {
- // console.log('获取消息接口')
- // // this.params.page += 1
- // this.barrageIndex = 0
- // this.getMessage()
- // }
- }, 60000)
- },
- onHide() {
- clearInterval(this.interval)
- },
- methods: {
- getMessage() {
- messageListApi(this.params).then(res => {
- this.messageList = res.data.list
- this.total = res.data.total
- this.initBarrage()
- })
- },
- // 初始化弹幕
- initBarrage() {
- let _this = this
- // console.log(_this.barrageIndex, '_this.barrageIndex')
- if (_this.messageList.length > 0) {
- _this.timeOut = setTimeout(() => {
- _this.barrageData.push({
- text: _this.messageList[_this.barrageIndex].content
- })
- // console.log(_this.barrageData, '_this.barrageData')
- _this.barrageIndex += 1
- clearTimeout(_this.timeOut)
- if (_this.barrageIndex > _this.messageList.length - 1) {
- _this.barrageIndex = 0
- } else {
- _this.initBarrage()
- }
- }, 1000)
- }
- },
- // 发送弹幕
- sendingBarrage() {
- let messageList = this.messageList
-
- },
- toInvite() {
- wx.navigateTo({
- url: '/pages/invite/invite'
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .container {
- /* padding: 20px; */
- font-size: 14px;
- line-height: 24px;
- }
- .headImg {
- height: 180px;
- width: 100%;
- }
- .headBarrage {
- height: 180px;
- width: 100%;
- position: absolute;
- top: 0;
- }
- .tabs {
- display: flex;
- justify-content: space-around;
- margin-top: 10px;
- >.tab {
- width: 20%;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- >image {
- width: 40px;
- height: 40px;
- }
- }
- }
- .buttons {
- margin-top: 5px;
- padding: 10px;
- display: flex;
- justify-content: space-between;
- >.left {
- width: calc(50vw - 15px);
- height: 40vw;
- image {
- width: 100%;
- height: 100%;
- }
- }
- >.right {
- width: calc(50vw - 15px);
- height: 40vw;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- align-items: center;
- image {
- width: 100%;
- height: calc(50% - 5px);
- }
- }
- }
- .list-title {
- font-size: 16px;
- font-weight: 600;
- text-align: center;
- padding: 10px;
- }
- .list {
- display: grid;
- grid-template-columns: 1fr 1fr;
- grid-gap: 10px;
- padding: 10px;
- .ka {
- width: calc(50vw - 15px);
- box-shadow: 0px 2px 8px 2px rgba(0, 0, 0, 0.1);
- border-radius: 10px;
- // height: 60vw;
- .top {
- // height: 60vw;
- background: linear-gradient(180deg, #FAF1A7 0%, #FFE456 100%);
- text-align: center;
- display: flex;
- justify-content: center;
- image {
- width: 35vw;
- height: 50vw;
- }
- }
- .ka-info {
- padding: 10px;
- .ka-name {
- font-size: 15px;
- font-weight: 600;
- }
- .row {
- margin-top: 5px;
- display: flex;
- justify-content: space-between;
- .money {
- font-size: 16px;
- font-weight: 600;
- color: #FF2C43;
- }
- }
- }
- }
- }
- .bullet {
- height: 30px;
- line-height: 30px;
- padding: 0 10px;
- border-radius: 15px;
- background-color: rgba(0, 0, 0, 0.3);
- color: #fff;
- }
- </style>
|