123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <view class=" content ">
- <view class="list">
- <view class="list-item" @click="goLive(item)" v-for="(item,index) in list" :key="index">
- <image :src="item.liveImgUrl"></image>
- <view class="info">
- <text>{{item.liveName}}</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- liveList
- } from '@/api/list'
- // import { LiveWS } from '@/utils/liveWS'
- // import { login,loginByWeChat,getUserInfo,loginByApple } from '@/api/user'
- export default {
- data() {
- return {
- list: null,
- liveId:null
- }
- },
- onLoad(option) {
- this.getList()
- },
- methods: {
- goLive(item) {
- this.liveId = item.liveId
- console.log("要传的liveId", this.liveId)
- uni.navigateTo({
- url: '/pages/home/living?liveId='+this.liveId
- // url: `/pages/home/living?liveId=${encodeURIComponent(JSON.stringify(liveId))}`
- });
- },
- getList() {
- const data = {
- page: 1,
- page_size: 10,
- };
- uni.showLoading({
- title: "处理中..."
- });
- liveList(data)
- .then(res => {
- if (res.code == 200) {
- this.list = res.rows; // 直接赋值给 this.list
- console.log("list>>", this.list); // ✅ 打印已定义的 this.list
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- })
- .catch(rej => {
- console.log("请求失败:", JSON.stringify(rej));
- })
- .finally(() => {
- uni.hideLoading();
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- background-color: #111;
- min-height: 100vh;
- padding: 24rpx;
- .list {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list-item {
- border-radius: 16rpx;
- width: 340rpx;
- height: 600rpx;
- background-color: #0082f4;
- margin-right: 10rpx;
- margin-bottom: 24rpx;
- overflow: hidden;
- position: relative;
- .info {
- position: absolute;
- left: 20rpx;
- bottom: 14rpx;
- color: #ffffff;
- }
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- </style>
|