This commit is contained in:
dean 2025-09-01 22:36:04 +08:00
parent 5271a56f48
commit e93bb3017f
9 changed files with 4052 additions and 470 deletions

View File

@ -1,12 +1,14 @@
<template>
<smart-tabs
<!-- <smart-tabs
:tabs="tabs"
:initial-index="current"
:scrollEnable="true"
:activeColor="'#19c324'"
@change="handleTabChange"
>
</smart-tabs>
</smart-tabs> -->
<uni-data-select v-model="categoryParam.id" :localdata="categoryList" @change="categoryChanged"></uni-data-select>
<uni-data-select v-model="subCategoryParam.id" :localdata="subCategoryList" @change="subCategoryChanged"></uni-data-select>
<!-- 视频列表 -->
<view class="video-container">
<image-grid-simple
@ -31,19 +33,36 @@
export default {
data() {
return {
current:0,
tabs:[],
categoryParam:{
target:'all',
id:0
},
categoryList:[
{
text:'全部',
value:0
}
],
subCategoryParam:{
id:0
},
subCategoryList:[
{
text:'全部',
value:0
}
],
list:[],
pageInfo:{
index:1,
size:10,
isEnd:false,
sub_category_id:0
}
}
},
onLoad() {
this.getCategory()
this.getCategory();
this.queryList();
},
methods: {
getCategory() {
@ -51,27 +70,65 @@
let param = {
index:1,
size:1000,
target:'sub'
target:'parent'
}
try {
this.$http.get('/category/list',param).then((resp)=>{
this.tabs = [];
this.categoryList = [
{
text:'全部',
value:0
}
];
resp.data?.list.forEach((item,idx)=>{
this.tabs.push({
id:item?.id,
label:item?.name,
this.categoryList.push({
value:item?.id,
text: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;
this.pageInfo.sub_category_id = this.tabs[this.current].id
getSubCategory() {
//
let param = {
index:1,
size:1000,
}
if (this.categoryParam.id === 0) {
param.target = 'sub'
} else {
param.parent_id = this.categoryParam.id
}
try {
this.$http.get('/category/list',param).then((resp)=>{
this.subCategoryList = [
{
text:'全部',
value:0
}
];
resp.data?.list.forEach((item,idx)=>{
this.subCategoryList.push({
value:item?.id,
text:item?.name,
});
});
})
} catch(err){
console.log("query category error",err)
}
},
categoryChanged(e) {
//
this.getSubCategory();
this.queryList();
},
subCategoryChanged(e) {
//
this.queryList();
},
queryList() {
if (this.pageInfo.isEnd) {
@ -87,6 +144,17 @@
let param = {
...this.pageInfo
}
if (this.categoryParam.id === 0) {
param.target = 'all'
} else {
param.category_id = this.categoryParam.id
}
if (this.subCategoryParam.id !== 0) {
param.sub_category_id = this.subCategoryParam.id
}
try {
uni.$http.get('/resource/list',param).then((resp) => {
console.log("resp data",resp.data);

File diff suppressed because it is too large Load Diff

View File

@ -3,47 +3,100 @@ const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
data() {
return {
current: 0,
tabs: [],
categoryParam: {
target: "all",
id: 0
},
categoryList: [
{
text: "全部",
value: 0
}
],
subCategoryParam: {
id: 0
},
subCategoryList: [
{
text: "全部",
value: 0
}
],
list: [],
pageInfo: {
index: 1,
size: 10,
isEnd: false,
sub_category_id: 0
isEnd: false
}
};
},
onLoad() {
this.getCategory();
this.queryList();
},
methods: {
getCategory() {
let param = {
index: 1,
size: 1e3,
target: "sub"
target: "parent"
};
try {
this.$http.get("/category/list", param).then((resp) => {
var _a;
this.tabs = [];
this.categoryList = [
{
text: "全部",
value: 0
}
];
(_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.categoryList.push({
value: item == null ? void 0 : item.id,
text: 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;
this.pageInfo.sub_category_id = this.tabs[this.current].id;
getSubCategory() {
let param = {
index: 1,
size: 1e3
};
if (this.categoryParam.id === 0) {
param.target = "sub";
} else {
param.parent_id = this.categoryParam.id;
}
try {
this.$http.get("/category/list", param).then((resp) => {
var _a;
this.subCategoryList = [
{
text: "全部",
value: 0
}
];
(_a = resp.data) == null ? void 0 : _a.list.forEach((item, idx) => {
this.subCategoryList.push({
value: item == null ? void 0 : item.id,
text: item == null ? void 0 : item.name
});
});
});
} catch (err) {
console.log("query category error", err);
}
},
categoryChanged(e) {
this.getSubCategory();
this.queryList();
},
subCategoryChanged(e) {
this.queryList();
},
queryList() {
if (this.pageInfo.isEnd) {
@ -59,6 +112,14 @@ const _sfc_main = {
let param = {
...this.pageInfo
};
if (this.categoryParam.id === 0) {
param.target = "all";
} else {
param.category_id = this.categoryParam.id;
}
if (this.subCategoryParam.id !== 0) {
param.sub_category_id = this.subCategoryParam.id;
}
try {
common_vendor.index.$http.get("/resource/list", param).then((resp) => {
var _a;
@ -86,27 +147,32 @@ const _sfc_main = {
}
};
if (!Array) {
const _easycom_smart_tabs2 = common_vendor.resolveComponent("smart-tabs");
const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
const _easycom_image_grid_simple2 = common_vendor.resolveComponent("image-grid-simple");
(_easycom_smart_tabs2 + _easycom_image_grid_simple2)();
(_easycom_uni_data_select2 + _easycom_image_grid_simple2)();
}
const _easycom_smart_tabs = () => "../../components/smart-tabs/smart-tabs.js";
const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
const _easycom_image_grid_simple = () => "../../components/image-grid-simple/image-grid-simple.js";
if (!Math) {
(_easycom_smart_tabs + _easycom_image_grid_simple)();
(_easycom_uni_data_select + _easycom_image_grid_simple)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.o($options.handleTabChange),
b: common_vendor.p({
tabs: $data.tabs,
["initial-index"]: $data.current,
scrollEnable: true,
activeColor: "#19c324"
a: common_vendor.o($options.categoryChanged),
b: common_vendor.o(($event) => $data.categoryParam.id = $event),
c: common_vendor.p({
localdata: $data.categoryList,
modelValue: $data.categoryParam.id
}),
c: common_vendor.o(_ctx.handlerClick),
d: common_vendor.o($options.queryList),
e: common_vendor.p({
d: common_vendor.o($options.subCategoryChanged),
e: common_vendor.o(($event) => $data.subCategoryParam.id = $event),
f: common_vendor.p({
localdata: $data.subCategoryList,
modelValue: $data.subCategoryParam.id
}),
g: common_vendor.o(_ctx.handlerClick),
h: common_vendor.o($options.queryList),
i: common_vendor.p({
imageList: $data.list,
columns: 2,
height: "80vh"

View File

@ -1,7 +1,7 @@
{
"navigationBarTitleText": "分类",
"usingComponents": {
"smart-tabs": "../../components/smart-tabs/smart-tabs",
"uni-data-select": "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select",
"image-grid-simple": "../../components/image-grid-simple/image-grid-simple"
}
}

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}}" bindimageClick="{{c}}" bindloadMoreAction="{{d}}" u-i="684df9a6-1" bind:__l="__l" u-p="{{e}}"></image-grid-simple></view>
<uni-data-select wx:if="{{c}}" bindchange="{{a}}" u-i="684df9a6-0" bind:__l="__l" bindupdateModelValue="{{b}}" u-p="{{c}}"></uni-data-select><uni-data-select wx:if="{{f}}" bindchange="{{d}}" u-i="684df9a6-1" bind:__l="__l" bindupdateModelValue="{{e}}" u-p="{{f}}"></uni-data-select><view class="video-container"><image-grid-simple wx:if="{{i}}" bindimageClick="{{g}}" bindloadMoreAction="{{h}}" u-i="684df9a6-2" bind:__l="__l" u-p="{{i}}"></image-grid-simple></view>

View File

@ -0,0 +1,316 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "uni-data-select",
mixins: [common_vendor.tr.mixinDatacom || {}],
props: {
localdata: {
type: Array,
default() {
return [];
}
},
value: {
type: [String, Number],
default: ""
},
modelValue: {
type: [String, Number],
default: ""
},
label: {
type: String,
default: ""
},
placeholder: {
type: String,
default: "请选择"
},
emptyTips: {
type: String,
default: "无选项"
},
clear: {
type: Boolean,
default: true
},
defItem: {
type: Number,
default: 0
},
disabled: {
type: Boolean,
default: false
},
// 格式化输出 用法 field="_id as value, version as text, uni_platform as label" format="{label} - {text}"
format: {
type: String,
default: ""
},
placement: {
type: String,
default: "bottom"
}
},
data() {
return {
showSelector: false,
current: "",
mixinDatacomResData: [],
apps: [],
channels: [],
cacheKey: "uni-data-select-lastSelectedValue"
};
},
created() {
this.debounceGet = this.debounce(() => {
this.query();
}, 300);
if (this.collection && !this.localdata.length) {
this.debounceGet();
}
},
computed: {
typePlaceholder() {
const text = {
"opendb-stat-app-versions": "版本",
"opendb-app-channels": "渠道",
"opendb-app-list": "应用"
};
const common = this.placeholder;
const placeholder = text[this.collection];
return placeholder ? common + placeholder : common;
},
valueCom() {
return this.modelValue;
},
textShow() {
let text = this.current;
return text;
},
getOffsetByPlacement() {
switch (this.placement) {
case "top":
return "bottom:calc(100% + 12px);";
case "bottom":
return "top:calc(100% + 12px);";
}
}
},
watch: {
localdata: {
immediate: true,
handler(val, old) {
if (Array.isArray(val) && old !== val) {
this.mixinDatacomResData = val;
}
}
},
valueCom(val, old) {
this.initDefVal();
},
mixinDatacomResData: {
immediate: true,
handler(val) {
if (val.length) {
this.initDefVal();
}
}
}
},
methods: {
debounce(fn, time = 100) {
let timer = null;
return function(...args) {
if (timer)
clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, args);
}, time);
};
},
// 执行数据库查询
query() {
this.mixinDatacomEasyGet();
},
// 监听查询条件变更事件
onMixinDatacomPropsChange() {
if (this.collection) {
this.debounceGet();
}
},
initDefVal() {
let defValue = "";
if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
defValue = this.valueCom;
} else {
let strogeValue;
if (this.collection) {
strogeValue = this.getCache();
}
if (strogeValue || strogeValue === 0) {
defValue = strogeValue;
} else {
let defItem = "";
if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value;
}
defValue = defItem;
}
if (defValue || defValue === 0) {
this.emit(defValue);
}
}
const def = this.mixinDatacomResData.find((item) => item.value === defValue);
this.current = def ? this.formatItemName(def) : "";
},
/**
* @param {[String, Number]} value
* 判断用户给的 value 是否同时为禁用状态
*/
isDisabled(value) {
let isDisabled = false;
this.mixinDatacomResData.forEach((item) => {
if (item.value === value) {
isDisabled = item.disable;
}
});
return isDisabled;
},
clearVal() {
this.emit("");
this.current = "";
if (this.collection) {
this.removeCache();
}
},
change(item) {
if (!item.disable) {
this.showSelector = false;
this.current = this.formatItemName(item);
this.emit(item.value);
}
},
emit(val) {
this.$emit("input", val);
this.$emit("update:modelValue", val);
this.$emit("change", val);
if (this.collection) {
this.setCache(val);
}
},
toggleSelector() {
if (this.disabled) {
return;
}
this.showSelector = !this.showSelector;
},
formatItemName(item) {
let {
text,
value,
channel_code
} = item;
channel_code = channel_code ? `(${channel_code})` : "";
if (this.format) {
let str = "";
str = this.format;
for (let key in item) {
str = str.replace(new RegExp(`{${key}}`, "g"), item[key]);
}
return str;
} else {
return this.collection.indexOf("app-list") > 0 ? `${text}(${value})` : text ? text : `未命名${channel_code}`;
}
},
// 获取当前加载的数据
getLoadData() {
return this.mixinDatacomResData;
},
// 获取当前缓存key
getCurrentCacheKey() {
return this.collection;
},
// 获取缓存
getCache(name = this.getCurrentCacheKey()) {
let cacheData = common_vendor.index.getStorageSync(this.cacheKey) || {};
return cacheData[name];
},
// 设置缓存
setCache(value, name = this.getCurrentCacheKey()) {
let cacheData = common_vendor.index.getStorageSync(this.cacheKey) || {};
cacheData[name] = value;
common_vendor.index.setStorageSync(this.cacheKey, cacheData);
},
// 删除缓存
removeCache(name = this.getCurrentCacheKey()) {
let cacheData = common_vendor.index.getStorageSync(this.cacheKey) || {};
delete cacheData[name];
common_vendor.index.setStorageSync(this.cacheKey, cacheData);
}
}
};
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
_easycom_uni_icons2();
}
const _easycom_uni_icons = () => "../../../uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
_easycom_uni_icons();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $props.label
}, $props.label ? {
b: common_vendor.t($props.label + "")
} : {}, {
c: $data.current
}, $data.current ? {
d: common_vendor.t($options.textShow)
} : {
e: common_vendor.t($options.typePlaceholder)
}, {
f: $data.current && $props.clear && !$props.disabled
}, $data.current && $props.clear && !$props.disabled ? {
g: common_vendor.p({
type: "clear",
color: "#c0c4cc",
size: "24"
}),
h: common_vendor.o((...args) => $options.clearVal && $options.clearVal(...args))
} : {
i: common_vendor.p({
type: $data.showSelector ? "top" : "bottom",
size: "14",
color: "#999"
})
}, {
j: common_vendor.o((...args) => $options.toggleSelector && $options.toggleSelector(...args)),
k: $data.showSelector
}, $data.showSelector ? {
l: common_vendor.o((...args) => $options.toggleSelector && $options.toggleSelector(...args))
} : {}, {
m: $data.showSelector
}, $data.showSelector ? common_vendor.e({
n: common_vendor.n($props.placement == "bottom" ? "uni-popper__arrow_bottom" : "uni-popper__arrow_top"),
o: $data.mixinDatacomResData.length === 0
}, $data.mixinDatacomResData.length === 0 ? {
p: common_vendor.t($props.emptyTips)
} : {
q: common_vendor.f($data.mixinDatacomResData, (item, index, i0) => {
return {
a: common_vendor.t($options.formatItemName(item)),
b: item.disable ? 1 : "",
c: index,
d: common_vendor.o(($event) => $options.change(item), index)
};
})
}, {
r: common_vendor.s($options.getOffsetByPlacement)
}) : {}, {
s: $props.disabled ? 1 : "",
t: $data.current ? 1 : ""
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"uni-icons": "../../../uni-icons/components/uni-icons/uni-icons"
}
}

View File

@ -0,0 +1 @@
<view class="uni-stat__select"><label wx:if="{{a}}" class="uni-label-text hide-on-phone">{{b}}</label><view class="{{['uni-stat-box', t && 'uni-stat__actived']}}"><view class="{{['uni-select', s && 'uni-select--disabled']}}"><view class="uni-select__input-box" bindtap="{{j}}"><view wx:if="{{c}}" class="uni-select__input-text">{{d}}</view><view wx:else class="uni-select__input-text uni-select__input-placeholder">{{e}}</view><view wx:if="{{f}}" key="clear-button" catchtap="{{h}}"><uni-icons wx:if="{{g}}" u-i="263ffa72-0" bind:__l="__l" u-p="{{g}}"/></view><view wx:else key="arrow-button"><uni-icons wx:if="{{i}}" u-i="263ffa72-1" bind:__l="__l" u-p="{{i}}"/></view></view><view wx:if="{{k}}" class="uni-select--mask" bindtap="{{l}}"/><view wx:if="{{m}}" class="uni-select__selector" style="{{r}}"><view class="{{n}}"></view><scroll-view scroll-y="true" class="uni-select__selector-scroll"><view wx:if="{{o}}" class="uni-select__selector-empty"><text>{{p}}</text></view><block wx:else><view wx:for="{{q}}" wx:for-item="item" wx:key="c" class="uni-select__selector-item" bindtap="{{item.d}}"><text class="{{[item.b && 'uni-select__selector__disabled']}}">{{item.a}}</text></view></block></scroll-view></view></view></view></view>

View File

@ -0,0 +1,201 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
@media screen and (max-width: 500px) {
.hide-on-phone {
display: none;
}
}
.uni-stat__select {
display: flex;
align-items: center;
width: 100%;
flex: 1;
box-sizing: border-box;
}
.uni-stat-box {
background-color: #fff;
width: 100%;
flex: 1;
}
.uni-stat__actived {
width: 100%;
flex: 1;
}
.uni-label-text {
font-size: 14px;
font-weight: bold;
color: #6a6a6a;
margin: auto 0;
margin-right: 5px;
}
.uni-select {
font-size: 14px;
border: 1px solid #e5e5e5;
box-sizing: border-box;
border-radius: 4px;
padding: 0 5px;
padding-left: 10px;
position: relative;
display: flex;
-webkit-user-select: none;
user-select: none;
flex-direction: row;
align-items: center;
border-bottom: solid 1px #e5e5e5;
width: 100%;
flex: 1;
height: 35px;
}
.uni-select--disabled {
background-color: #f5f7fa;
cursor: not-allowed;
}
.uni-select__label {
font-size: 16px;
height: 35px;
padding-right: 10px;
color: #909399;
}
.uni-select__input-box {
height: 35px;
width: 0px;
position: relative;
display: flex;
flex: 1;
flex-direction: row;
align-items: center;
}
.uni-select__input {
flex: 1;
font-size: 14px;
height: 22px;
line-height: 22px;
}
.uni-select__input-plac {
font-size: 14px;
color: #909399;
}
.uni-select__selector {
box-sizing: border-box;
position: absolute;
left: 0;
width: 100%;
background-color: #FFFFFF;
border: 1px solid #EBEEF5;
border-radius: 6px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 3;
padding: 4px 0;
}
.uni-select__selector-scroll {
max-height: 200px;
box-sizing: border-box;
}
.uni-select__selector-empty,
.uni-select__selector-item {
display: flex;
cursor: pointer;
line-height: 35px;
font-size: 14px;
text-align: center;
/* border-bottom: solid 1px $uni-border-3; */
padding: 0px 10px;
}
.uni-select__selector-item:hover {
background-color: #f9f9f9;
}
.uni-select__selector-empty:last-child,
.uni-select__selector-item:last-child {
border-bottom: none;
}
.uni-select__selector__disabled {
opacity: 0.4;
cursor: default;
}
/* picker 弹出层通用的指示小三角 */
.uni-popper__arrow_bottom,
.uni-popper__arrow_bottom::after,
.uni-popper__arrow_top,
.uni-popper__arrow_top::after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 6px;
}
.uni-popper__arrow_bottom {
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
top: -6px;
left: 10%;
margin-right: 3px;
border-top-width: 0;
border-bottom-color: #EBEEF5;
}
.uni-popper__arrow_bottom::after {
content: " ";
top: 1px;
margin-left: -6px;
border-top-width: 0;
border-bottom-color: #fff;
}
.uni-popper__arrow_top {
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
bottom: -6px;
left: 10%;
margin-right: 3px;
border-bottom-width: 0;
border-top-color: #EBEEF5;
}
.uni-popper__arrow_top::after {
content: " ";
bottom: 1px;
margin-left: -6px;
border-bottom-width: 0;
border-top-color: #fff;
}
.uni-select__input-text {
width: 100%;
color: #333;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
overflow: hidden;
}
.uni-select__input-placeholder {
color: #6a6a6a;
font-size: 12px;
}
.uni-select--mask {
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 2;
}