This commit is contained in:
dean 2025-08-31 23:04:06 +08:00
parent 80783f4486
commit 5271a56f48
9 changed files with 229 additions and 157 deletions

View File

@ -14,14 +14,15 @@
:columns="2"
:height="'80vh'"
@image-click="handlerClick"
@load-more-action = "queryList"
>
<template #empty>
<!-- <template #empty>
<view class="custom-empty">
<image src="/static/images/no-videos.png" />
<text>没有找到视频内容</text>
</view>
</template>
</template> -->
</image-grid-simple>
</view>
</template>
@ -32,54 +33,13 @@
return {
current:0,
tabs:[],
list:[
{
"id":1,
"title":"1",
"src":"../../static/images/default.png"
},
{
"id":2,
"title":2,
"src":"../../static/images/default.png"
},
{
"id":3,
"title":3,
"src":"../../static/images/default.png"
},
{
"id":9,
"title":9,
"src":"../../static/images/default.png"
},
{
"id":4,
"title":4,
"src":"../../static/images/default.png"
},
{
"id":5,
"title":5,
"src":"../../static/images/default.png"
},
{
"id":6,
"title":6,
"src":"../../static/images/default.png"
},
{
"id":7,
"title":7,
"src":"../../static/images/default.png"
},
{
"id":8,
"title":8,
"src":"../../static/images/default.png"
}
]
list:[],
pageInfo:{
index:1,
size:10,
isEnd:false,
sub_category_id:0
}
}
},
onLoad() {
@ -88,21 +48,69 @@
methods: {
getCategory() {
//
this.tabs = [
{label:"拉布布",value:"labubu"},
{label:"科幻",value:"kh"},
{label:"酷炫汽车1",value:"car1"},
{label:"酷炫汽车2",value:"car2"},
{label:"酷炫汽车3",value:"car3"},
{label:"酷炫汽车4",value:"car4"},
{label:"酷炫汽车5",value:"car5"},
{label:"雏田",value:"ct"}
]
let param = {
index:1,
size:1000,
target:'sub'
}
try {
this.$http.get('/category/list',param).then((resp)=>{
this.tabs = [];
resp.data?.list.forEach((item,idx)=>{
this.tabs.push({
id:item?.id,
label:item?.name,
});
});
this.pageInfo.sub_category_id = this.tabs[this.current].id
this.queryList()
})
} catch(err){
console.log("query category error",err)
}
},
handleTabChange(idx) {
this.current = idx;
console.log(this.tabs[idx])
this.pageInfo.sub_category_id = this.tabs[this.current].id
},
queryList() {
if (this.pageInfo.isEnd) {
uni.showToast({
title: '没有更多数据了哦!^v^',
icon: 'none',
complete: () => {
console.log("no more data")
}
});
return
}
let param = {
...this.pageInfo
}
try {
uni.$http.get('/resource/list',param).then((resp) => {
console.log("resp data",resp.data);
resp.data?.list.forEach((item,idx)=>{
this.list.push({
id:item?.id,
name:item?.name,
src:item?.thumb_src,
android_src:item?.android_src,
});
});
console.log("length:",this.list.length,resp.data.page.rows,resp.data.page)
if (this.list.length >= resp.data.page.rows) {
this.pageInfo.isEnd = true
} else {
this.pageInfo.isEnd = false
this.pageInfo.index++
}
})
}catch(err) {
console.log("catch query list err:",err)
}
}
}
}
</script>

View File

@ -61,8 +61,11 @@
if (options.id) {
this.id = options.id;
// id
this.$http.get('/resource/'+this.id).then((resp)=>{
this.url = resp.url
this.$http.get('/resource/detail/'+this.id).then((resp)=>{
console.log("detail:",resp.data)
this.url = resp.data?.item.android_src
console.log("detail-url:",this.url)
}).catch((err)=>{
console.log('请求异常')
})

View File

@ -33,8 +33,9 @@
{ label: '最新', name: 'new', badge: 0 },
],
page:1,
size:4,
size:6,
tag:'hot',
isEnd:false,
videoConfig:{
"columns":2
},
@ -55,6 +56,10 @@
handleTabChange(idx) {
this.current = idx;
this.tag = this.tabs[idx]?.name
this.isEnd = false
this.list = []
this.page = 1
this.queryList()
},
handlerClick(item) {
console.log("video click",item)
@ -68,8 +73,18 @@
handleLoginSuccess(event) {
console.log('检测到登录成功,刷新首页数据');
this.queryList()
},
},
queryList() {
if (this.isEnd) {
uni.showToast({
title: '没有更多数据了哦!^v^',
icon: 'none',
complete: () => {
console.log("no more data")
}
});
return
}
let param = {
index:this.page,
size:this.size,
@ -84,8 +99,14 @@
name:item?.name,
src:item?.thumb_src,
android_src:item?.android_src,
})
})
});
});
console.log("length:",this.list.length,resp.data.page.rows,resp.data.page)
if (this.list.length >= resp.data.page.rows) {
this.isEnd = true
} else {
this.isEnd = false
}
this.page++
})
}catch(err) {

View File

@ -1,58 +1,17 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
current: 0,
tabs: [],
list: [
{
"id": 1,
"title": "1",
"src": "../../static/images/default.png"
},
{
"id": 2,
"title": 2,
"src": "../../static/images/default.png"
},
{
"id": 3,
"title": 3,
"src": "../../static/images/default.png"
},
{
"id": 9,
"title": 9,
"src": "../../static/images/default.png"
},
{
"id": 4,
"title": 4,
"src": "../../static/images/default.png"
},
{
"id": 5,
"title": 5,
"src": "../../static/images/default.png"
},
{
"id": 6,
"title": 6,
"src": "../../static/images/default.png"
},
{
"id": 7,
"title": 7,
"src": "../../static/images/default.png"
},
{
"id": 8,
"title": 8,
"src": "../../static/images/default.png"
}
]
list: [],
pageInfo: {
index: 1,
size: 10,
isEnd: false,
sub_category_id: 0
}
};
},
onLoad() {
@ -60,20 +19,69 @@ const _sfc_main = {
},
methods: {
getCategory() {
this.tabs = [
{ label: "拉布布", value: "labubu" },
{ label: "科幻", value: "kh" },
{ label: "酷炫汽车1", value: "car1" },
{ label: "酷炫汽车2", value: "car2" },
{ label: "酷炫汽车3", value: "car3" },
{ label: "酷炫汽车4", value: "car4" },
{ label: "酷炫汽车5", value: "car5" },
{ label: "雏田", value: "ct" }
];
let param = {
index: 1,
size: 1e3,
target: "sub"
};
try {
this.$http.get("/category/list", param).then((resp) => {
var _a;
this.tabs = [];
(_a = resp.data) == null ? void 0 : _a.list.forEach((item, idx) => {
this.tabs.push({
id: item == null ? void 0 : item.id,
label: item == null ? void 0 : item.name
});
});
this.pageInfo.sub_category_id = this.tabs[this.current].id;
this.queryList();
});
} catch (err) {
console.log("query category error", err);
}
},
handleTabChange(idx) {
this.current = idx;
console.log(this.tabs[idx]);
this.pageInfo.sub_category_id = this.tabs[this.current].id;
},
queryList() {
if (this.pageInfo.isEnd) {
common_vendor.index.showToast({
title: "没有更多数据了哦!^v^",
icon: "none",
complete: () => {
console.log("no more data");
}
});
return;
}
let param = {
...this.pageInfo
};
try {
common_vendor.index.$http.get("/resource/list", param).then((resp) => {
var _a;
console.log("resp data", resp.data);
(_a = resp.data) == null ? void 0 : _a.list.forEach((item, idx) => {
this.list.push({
id: item == null ? void 0 : item.id,
name: item == null ? void 0 : item.name,
src: item == null ? void 0 : item.thumb_src,
android_src: item == null ? void 0 : item.android_src
});
});
console.log("length:", this.list.length, resp.data.page.rows, resp.data.page);
if (this.list.length >= resp.data.page.rows) {
this.pageInfo.isEnd = true;
} else {
this.pageInfo.isEnd = false;
this.pageInfo.index++;
}
});
} catch (err) {
console.log("catch query list err:", err);
}
}
}
};
@ -96,8 +104,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
scrollEnable: true,
activeColor: "#19c324"
}),
c: common_assets._imports_0,
d: common_vendor.o(_ctx.handlerClick),
c: common_vendor.o(_ctx.handlerClick),
d: common_vendor.o($options.queryList),
e: common_vendor.p({
imageList: $data.list,
columns: 2,

View File

@ -1 +1 @@
<smart-tabs wx:if="{{b}}" bindchange="{{a}}" u-i="684df9a6-0" bind:__l="__l" u-p="{{b}}"></smart-tabs><view class="video-container"><image-grid-simple wx:if="{{e}}" u-s="{{['empty']}}" bindimageClick="{{d}}" u-i="684df9a6-1" bind:__l="__l" u-p="{{e}}"><view class="custom-empty" slot="empty"><image src="{{c}}"/><text>没有找到视频内容</text></view></image-grid-simple></view>
<smart-tabs wx:if="{{b}}" bindchange="{{a}}" u-i="684df9a6-0" bind:__l="__l" u-p="{{b}}"></smart-tabs><view class="video-container"><image-grid-simple wx:if="{{e}}" bindimageClick="{{c}}" bindloadMoreAction="{{d}}" u-i="684df9a6-1" bind:__l="__l" u-p="{{e}}"></image-grid-simple></view>

View File

@ -33,8 +33,11 @@ const _sfc_main = {
onLoad(options) {
if (options.id) {
this.id = options.id;
this.$http.get("/resource/" + this.id).then((resp) => {
this.url = resp.url;
this.$http.get("/resource/detail/" + this.id).then((resp) => {
var _a;
console.log("detail:", resp.data);
this.url = (_a = resp.data) == null ? void 0 : _a.item.android_src;
console.log("detail-url:", this.url);
}).catch((err) => {
console.log("请求异常");
});

View File

@ -10,8 +10,9 @@ const _sfc_main = {
{ label: "最新", name: "new", badge: 0 }
],
page: 1,
size: 4,
size: 6,
tag: "hot",
isEnd: false,
videoConfig: {
"columns": 2
},
@ -32,6 +33,10 @@ const _sfc_main = {
var _a;
this.current = idx;
this.tag = (_a = this.tabs[idx]) == null ? void 0 : _a.name;
this.isEnd = false;
this.list = [];
this.page = 1;
this.queryList();
},
handlerClick(item) {
console.log("video click", item);
@ -47,6 +52,16 @@ const _sfc_main = {
this.queryList();
},
queryList() {
if (this.isEnd) {
common_vendor.index.showToast({
title: "没有更多数据了哦!^v^",
icon: "none",
complete: () => {
console.log("no more data");
}
});
return;
}
let param = {
index: this.page,
size: this.size,
@ -64,6 +79,12 @@ const _sfc_main = {
android_src: item == null ? void 0 : item.android_src
});
});
console.log("length:", this.list.length, resp.data.page.rows, resp.data.page);
if (this.list.length >= resp.data.page.rows) {
this.isEnd = true;
} else {
this.isEnd = false;
}
this.page++;
});
} catch (err) {

View File

@ -13,16 +13,16 @@ const silentLogin = async () => {
return token;
}
console.log("静默登录", token);
let newToken;
let data;
if (utils_config.PLATFORM === "mp-weixin") {
newToken = await wxSilentLogin();
console.log("newToken~~~~~~~~~");
data = await wxSilentLogin();
}
if (newToken) {
console.log("静默登录-----", newToken);
saveLocalToken(newToken);
common_vendor.index.$emit("LOGIN_SUCCESS", { token: newToken });
return newToken;
if (data) {
console.log("静默登录-----", data.token);
saveLocalToken(data.token);
saveUserInfo(data.user);
common_vendor.index.$emit("LOGIN_SUCCESS", { token: data.token });
return data.token;
}
throw new Error("静默登录失败");
} catch (error) {
@ -60,8 +60,8 @@ const wxSilentLogin = async () => {
fail: reject
});
});
if (response.code === 200 && response.data.token) {
return response.data.token;
if (response.code === 200) {
return response.data;
}
throw new Error(response.msg || "微信登录失败");
} catch (error) {
@ -103,8 +103,8 @@ const ksSilentLogin = async () => {
fail: reject
});
});
if (res.code === 0 && res.data.token) {
return res.data.token;
if (res.code === 0) {
return res.data;
}
throw new Error(res.msg || "快手登录失败");
} catch (error) {
@ -120,6 +120,9 @@ const saveLocalToken = (token) => {
const tokenKey = "wx_token";
common_vendor.index.setStorageSync(tokenKey, token);
};
const saveUserInfo = (user) => {
common_vendor.index.setStorageSync("user-info", user);
};
const checkLoginStatus = async () => {
try {
const token = getLocalToken();

View File

@ -17,23 +17,23 @@ export const silentLogin = async () => {
console.log("静默登录",token)
// 2. 执行平台静默登录
let newToken;
let data;
if (PLATFORM === 'mp-weixin') {
newToken = await wxSilentLogin();
console.log("newToken~~~~~~~~~")
data = await wxSilentLogin();
} else if (PLATFORM === 'mp-kuaishou') {
newToken = await ksSilentLogin();
data = await ksSilentLogin();
} else {
// 待处理
throw new Error("当前平台不支持")
}
// 3. 保存token
if (newToken) {
console.log("静默登录-----",newToken)
saveLocalToken(newToken);
uni.$emit('LOGIN_SUCCESS', { token: newToken });
return newToken;
if (data) {
console.log("静默登录-----",data.token)
saveLocalToken(data.token);
saveUserInfo(data.user)
uni.$emit('LOGIN_SUCCESS', { token: data.token });
return data.token;
}
throw new Error('静默登录失败');
@ -81,8 +81,8 @@ const wxSilentLogin = async () => {
});
// 4. 处理登录响应
if (response.code === 200 && response.data.token) {
return response.data.token;
if (response.code === 200) {
return response.data;
}
throw new Error(response.msg || '微信登录失败');
@ -135,8 +135,8 @@ const ksSilentLogin = async () => {
});
// 3. 返回token
if (res.code === 0 && res.data.token) {
return res.data.token;
if (res.code === 0) {
return res.data;
}
throw new Error(res.msg || '快手登录失败');
@ -158,6 +158,11 @@ const saveLocalToken = (token) => {
uni.setStorageSync(tokenKey, token);
};
// 保存用户信息
const saveUserInfo = (user) => {
uni.setStorageSync('user-info', user);
};
// 获取用户信息(需要授权)
export const getUserInfo = async () => {
try {