12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <view class=" column">
- <view class="u-flex-y-center">
- <view class="list-item" @click="goLive(item)" v-for="(item,index) in list" :key="index">
- {{index}}
- </view>
- </view>
- <!-- <view class="list-item">
- </view>
- <view class="list-item">
- </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,
- }
- },
- onLoad(option) {
- this.getList()
- },
- methods: {
- goLive(item) {
- var liveId=item.liveId
- uni.setStorageSync('liveId', liveId);
-
- console.log("要传的liveId",liveId)
- uni.navigateTo({
- url:'/pages/home/living'
- // 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>
- .list-item {
- width: 100rpx;
- height: 100rpx;
- background-color: #0082f4;
- margin-right: 10rpx;
- color: #111;
- image {
- width: 100%;
- height: 100%;
- }
- }
- </style>
|