Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
4c482523
提交
4c482523
authored
4月 23, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 删除 linkedlist 示例
上级
ef8f4bfd
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
0 行增加
和
881 行删除
+0
-881
data.js
src/pages/example/linkedlist-nvue/data.js
+0
-56
index.nvue
src/pages/example/linkedlist-nvue/index.nvue
+0
-455
swiper-page.nvue
src/pages/example/linkedlist-nvue/swiper-page.nvue
+0
-147
data.ts
src/pages/example/linkedlist/data.ts
+0
-54
index.vue
src/pages/example/linkedlist/index.vue
+0
-169
没有找到文件。
src/pages/example/linkedlist-nvue/data.js
deleted
100644 → 0
浏览文件 @
ef8f4bfd
import
{
faker
}
from
'@faker-js/faker/locale/zh_CN'
import
{
pinyin
}
from
'pinyin-pro'
export
function
getData
()
{
const
data
=
Array
(
1000
)
.
fill
(
0
)
.
map
((
item
)
=>
{
const
name
=
faker
.
name
.
fullName
()
return
{
id
:
item
,
name
,
phone
:
faker
.
phone
.
number
(
'1###########'
),
avatar
:
faker
.
image
.
avatar
(),
unit
:
faker
.
company
.
name
(),
checked
:
false
,
}
})
const
result
=
data
.
map
((
item
)
=>
{
const
props
=
{}
if
(
item
.
name
)
{
item
.
letter
=
pinyin
(
item
.
name
.
charAt
(),
{
pattern
:
'first'
})[
0
].
toUpperCase
()
}
else
{
item
.
letter
=
'★'
}
return
{
...
item
,
...
props
,
// TODO: 存在性能问题,需要优化后再使用
// src: item.avatar || '/static/images/me/user_default.jpg',
text
:
item
.
name
,
subText
:
item
.
unit
,
}
})
.
reduce
((
prev
,
cur
)
=>
{
const
letter
=
cur
.
letter
const
index
=
prev
.
findIndex
((
item
)
=>
item
.
letter
===
letter
)
if
(
index
===
-
1
)
{
prev
.
push
({
letter
,
items
:
[
cur
],
})
}
else
{
prev
[
index
].
items
.
push
(
cur
)
}
return
prev
},
[])
.
sort
((
a
,
b
)
=>
{
return
a
.
letter
.
charCodeAt
(
0
)
-
b
.
letter
.
charCodeAt
(
0
)
})
return
result
}
src/pages/example/linkedlist-nvue/index.nvue
deleted
100644 → 0
浏览文件 @
ef8f4bfd
<template>
<list :id="pageId" class="page" :bounce="false" fixFreezing="true">
<cell>
<view id="head" class="header">
<text class="header-title">header</text>
</view>
</cell>
<cell>
<view class="tabs" :style="'height:' + pageHeight + 'px'">
<scroll-view
ref="tabbar1"
id="tab-bar"
class="tab-bar"
:scroll="false"
:scroll-x="true"
:show-scrollbar="false"
:scroll-into-view="scrollInto"
>
<view style="flex-direction: column">
<view style="flex-direction: row">
<view
class="uni-tab-item"
v-for="(tab, index) in tabList"
:key="tab.id"
:id="tab.id"
:ref="'tabitem' + index"
:data-id="index"
:data-current="index"
@click="ontabtap"
>
<text
class="uni-tab-item-title"
:class="tabIndex == index ? 'uni-tab-item-title-active' : ''"
>{{ tab.name }}</text
>
</view>
</view>
<view class="scroll-view-indicator">
<view
ref="underline"
class="scroll-view-underline"
:class="isTap ? 'scroll-view-animation' : ''"
:style="{ left: indicatorLineLeft + 'px', width: indicatorLineWidth + 'px' }"
></view>
</view>
</view>
</scroll-view>
<view class="tab-bar-line"></view>
<swiper
class="tab-view"
ref="swiper1"
id="tab-bar-view"
:current="tabIndex"
:duration="300"
@change="onswiperchange"
@transition="onswiperscroll"
@animationfinish="animationfinish"
@onAnimationEnd="animationfinish"
>
<swiper-item class="swiper-item" v-for="(page, index) in tabList" :key="index">
<swiper-page class="swiper-page" :pid="page.pageid" :parentId="pageId" ref="page"></swiper-page>
</swiper-item>
</swiper>
</view>
</cell>
</list>
</template>
<script>
// #ifdef APP-PLUS
const dom = weex.requireModule('dom')
// #endif
// 缓存每页最多
const MAX_CACHE_DATA = 100
// 缓存页签数量
const MAX_CACHE_PAGE = 3
const TAB_PRELOAD_OFFSET = 1
import swiperPage from './swiper-page.nvue'
export default {
components: {
swiperPage,
},
data() {
return {
tabList: [],
tabIndex: 0,
cacheTab: [],
scrollInto: '',
indicatorLineLeft: 0,
indicatorLineWidth: 0,
isTap: false,
showTitleView: true,
pageHeight: 300,
pageId: 'page',
}
},
onLoad() {
for (var i = 0; i < 1; i++) {
this.tabList.push({
id: 'tab' + i,
name: 'Tab ' + (i + 1),
pageid: i + 1,
})
}
},
onReady() {
this.pageHeight = uni.getSystemInfoSync().windowHeight
this._lastTabIndex = 0
this.swiperWidth = 0
this.tabbarWidth = 0
this.tabListSize = {}
this._touchTabIndex = 0
this._headHeight = 100
this.pageList = this.$refs.page
this.selectorQuery()
},
methods: {
ontabtap(e) {
let index = e.target.dataset.current || e.currentTarget.dataset.current
//let offsetIndex = this._touchTabIndex = Math.abs(index - this._lastTabIndex) > 1;
// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
this.isTap = true
var currentSize = this.tabListSize[index]
this.updateIndicator(currentSize.left, currentSize.width)
this._touchTabIndex = index
// #endif
this.switchTab(index)
},
onswiperchange(e) {
// 注意:百度小程序会触发2次
// #ifndef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
let index = e.target.current || e.detail.current
this.switchTab(index)
// #endif
},
onswiperscroll(e) {
if (this.isTap) {
return
}
var offsetX = e.detail.dx
var preloadIndex = this._lastTabIndex
if (offsetX > TAB_PRELOAD_OFFSET) {
preloadIndex++
} else if (offsetX < -TAB_PRELOAD_OFFSET) {
preloadIndex--
}
if (
preloadIndex === this._lastTabIndex ||
preloadIndex < 0 ||
preloadIndex > this.pageList.length - 1
) {
return
}
if (this.pageList[preloadIndex].dataList.length === 0) {
this.loadTabData(preloadIndex)
}
// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
var percentage = Math.abs(this.swiperWidth / offsetX)
var currentSize = this.tabListSize[this._lastTabIndex]
var preloadSize = this.tabListSize[preloadIndex]
var lineL = currentSize.left + (preloadSize.left - currentSize.left) / percentage
var lineW = currentSize.width + (preloadSize.width - currentSize.width) / percentage
this.updateIndicator(lineL, lineW)
// #endif
},
animationfinish(e) {
// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-QQ
let index = e.detail.current
if (this._touchTabIndex === index) {
this.isTap = false
}
this._lastTabIndex = index
this.switchTab(index)
this.updateIndicator(this.tabListSize[index].left, this.tabListSize[index].width)
// #endif
},
selectorQuery() {
// #ifdef APP-NVUE
uni.createSelectorQuery()
.in(this)
.select('#head')
.boundingClientRect()
.exec((rect) => {
this._headHeight = rect[0].height
})
// 查询 tabbar 宽度
uni.createSelectorQuery()
.in(this)
.select('#tab-bar')
.boundingClientRect()
.exec((rect) => {
this.tabbarWidth = rect[0].width
})
// 查询 tabview 宽度
uni.createSelectorQuery()
.in(this)
.select('#tab-bar-view')
.boundingClientRect()
.exec((rect) => {
this.swiperWidth = rect[0].width
})
// 因 nvue 暂不支持 class 查询
var queryTabSize = uni.createSelectorQuery().in(this)
for (var i = 0; i < this.tabList.length; i++) {
queryTabSize.select('#' + this.tabList[i].id).boundingClientRect()
}
queryTabSize.exec((rects) => {
rects.forEach((rect) => {
this.tabListSize[rect.dataset.id] = rect
})
this.updateIndicator(this.tabListSize[this.tabIndex].left, this.tabListSize[this.tabIndex].width)
this.switchTab(this.tabIndex)
})
// #endif
// #ifdef MP-WEIXIN || H5 || MP-QQ
uni.createSelectorQuery()
.in(this)
.select('.tab-view')
.fields(
{
dataset: true,
size: true,
},
(res) => {
this.swiperWidth = res.width
},
)
.exec()
uni.createSelectorQuery()
.in(this)
.selectAll('.uni-tab-item')
.boundingClientRect((rects) => {
rects.forEach((rect) => {
this.tabListSize[rect.dataset.id] = rect
})
this.updateIndicator(
this.tabListSize[this.tabIndex].left,
this.tabListSize[this.tabIndex].width,
)
})
.exec()
// #endif
},
updateIndicator(left, width) {
this.indicatorLineLeft = left
this.indicatorLineWidth = width
},
switchTab(index) {
if (this.pageList[index].dataList.length === 0) {
this.loadTabData(index)
}
this.pageList[index].setScrollRef(this._headHeight)
if (this.tabIndex === index) {
return
}
// 缓存 tabId
if (this.pageList[this.tabIndex].dataList.length > MAX_CACHE_DATA) {
let isExist = this.cacheTab.indexOf(this.tabIndex)
if (isExist < 0) {
this.cacheTab.push(this.tabIndex)
}
}
this.tabIndex = index
// #ifdef APP-NVUE
this.scrollTabTo(index)
// #endif
// #ifndef APP-NVUE
this.scrollInto = this.tabList[index].id
// #endif
// 释放 tabId
if (this.cacheTab.length > MAX_CACHE_PAGE) {
let cacheIndex = this.cacheTab[0]
this.clearTabData(cacheIndex)
this.cacheTab.splice(0, 1)
}
},
scrollTabTo(index) {
const el = this.$refs['tabitem' + index][0]
let offset = 0
// TODO fix ios offset
if (index > 0) {
offset = this.tabbarWidth / 2 - this.tabListSize[index].width / 2
if (this.tabListSize[index].right < this.tabbarWidth / 2) {
offset = this.tabListSize[0].width
}
}
dom.scrollToElement(el, {
offset: -offset,
})
},
loadTabData(index) {
this.pageList[index].loadData()
},
clearTabData(index) {
this.pageList[index].clear()
},
},
}
</script>
<style>
/* #ifndef APP-PLUS */
page {
width: 100%;
min-height: 100%;
display: flex;
}
/* #endif */
.page {
flex: 1;
}
.header {
height: 160px;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: #f4f4f4;
}
.header-title {
font-size: 30px;
font-weight: bold;
color: #444;
}
.flexible-view {
background-color: #f823ff;
}
.page-head {
height: 200px;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: red;
}
.tabs {
flex-direction: column;
overflow: hidden;
background-color: #ffffff;
/* #ifdef MP-ALIPAY || MP-BAIDU */
height: 100vh;
/* #endif */
}
.tab-bar {
width: 750rpx;
height: 84rpx;
flex-direction: row;
/* #ifndef APP-PLUS */
white-space: nowrap;
/* #endif */
}
/* #ifndef APP-NVUE */
.tab-bar ::-webkit-scrollbar {
display: none;
width: 0 !important;
height: 0 !important;
-webkit-appearance: none;
background: transparent;
}
/* #endif */
.scroll-view-indicator {
position: relative;
height: 2px;
background-color: transparent;
}
.scroll-view-underline {
position: absolute;
top: 0;
bottom: 0;
width: 0;
background-color: #007aff;
}
.scroll-view-animation {
transition-duration: 0.2s;
transition-property: left;
}
.tab-bar-line {
height: 1rpx;
background-color: #cccccc;
}
.tab-view {
flex: 1;
}
.uni-tab-item {
/* #ifndef APP-PLUS */
display: inline-block;
/* #endif */
flex-wrap: nowrap;
padding-left: 25px;
padding-right: 25px;
}
.uni-tab-item-title {
color: #555;
font-size: 30rpx;
height: 80rpx;
line-height: 80rpx;
flex-wrap: nowrap;
/* #ifndef APP-PLUS */
white-space: nowrap;
/* #endif */
}
.uni-tab-item-title-active {
color: #007aff;
}
.swiper-item {
flex: 1;
flex-direction: column;
}
.swiper-page {
flex: 1;
flex-direction: row;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
</style>
src/pages/example/linkedlist-nvue/swiper-page.nvue
deleted
100644 → 0
浏览文件 @
ef8f4bfd
<template>
<view class="uni-swiper-page">
<list ref="list" class="list" :offset-accuracy="5" :bounce="false" fixFreezing="true">
<cell v-for="(item, index) in dataList" :key="item.id" :ref="'item' + index">
<view class="list-item">
<text>{{ item.name }}</text>
</view>
</cell>
<cell class="loading"></cell>
</list>
</view>
</template>
<script>
import { faker } from '@faker-js/faker/locale/zh_CN'
import { pinyin } from 'pinyin-pro'
import fuiIndexList from '../../../components/FirstUI/fui-index-list/fui-index-list.vue'
export default {
components: {
fuiIndexList,
},
props: {
pid: {
type: [Number, String],
default: '',
},
parentId: {
type: String,
default: '',
},
},
data() {
return {
scrollable: true,
dataList: [],
}
},
created() {
for (var i = 0; i < 5000; i++) {
this.dataList.push({
id: i,
// name: faker.name.lastName() + faker.name.firstName(),
name: i,
})
}
},
methods: {
getData() {
const data = Array(1000)
.fill(0)
.map((item) => {
return {
id: item,
name: faker.name.lastName() + faker.name.firstName(),
phone: faker.phone.number('1###########'),
avatar: faker.image.avatar(),
unit: faker.company.name(),
checked: false,
}
})
const result = data
.map((item) => {
const props = {}
if (item.name) {
item.letter = pinyin(item.name.charAt(), { pattern: 'first' })[0].toUpperCase()
} else {
item.letter = '★'
}
return {
...item,
...props,
// TODO: 存在性能问题,需要优化后再使用
src: item.avatar || '/static/images/me/user_default.jpg',
text: item.name,
subText: item.unit,
}
})
.reduce((prev, cur) => {
const letter = cur.letter
const index = prev.findIndex((item) => item.letter === letter)
if (index === -1) {
prev.push({
letter,
items: [cur],
})
} else {
prev[index].items.push(cur)
}
return prev
}, [])
.sort((a, b) => {
return a.letter.charCodeAt(0) - b.letter.charCodeAt(0)
})
return result
},
setScrollRef(height) {
if (this.$refs['list'].setSpecialEffects) {
this.$refs['list'].setSpecialEffects({
id: this.parentId,
headerHeight: height,
})
}
},
loadData() {
// 首次激活时被调用
},
clear() {
// 释放数据时被调用,参考 swiper-list 缓存配置
this.dataList.length = 0
},
},
}
</script>
<style scoped>
.uni-swiper-page {
flex: 1;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.list {
flex: 1;
background-color: #ebebeb;
}
.list-item {
margin-left: 12px;
margin-right: 12px;
margin-top: 12px;
padding: 20px;
background-color: #fff;
border-radius: 5px;
}
.loading {
height: 20px;
}
</style>
src/pages/example/linkedlist/data.ts
deleted
100644 → 0
浏览文件 @
ef8f4bfd
import
{
faker
}
from
'@faker-js/faker/locale/zh_CN'
import
{
pinyin
}
from
'pinyin-pro'
export
function
getData
()
{
const
data
=
Array
(
1000
)
.
fill
(
0
)
.
map
((
item
)
=>
{
return
{
id
:
item
,
name
:
faker
.
name
.
lastName
()
+
faker
.
name
.
firstName
(),
phone
:
faker
.
phone
.
number
(
'1###########'
),
avatar
:
faker
.
image
.
avatar
(),
unit
:
faker
.
company
.
name
(),
checked
:
false
,
}
})
const
result
=
data
.
map
((
item
:
any
)
=>
{
const
props
=
{}
if
(
item
.
name
)
{
item
.
letter
=
pinyin
(
item
.
name
.
charAt
(),
{
toneType
:
'none'
,
pattern
:
'first'
})[
0
].
toUpperCase
()
}
else
{
item
.
letter
=
'#'
}
return
{
...
item
,
...
props
,
// TODO: 存在性能问题,需要优化后再使用
// src: item.avatar || '/static/images/me/user_default.jpg',
text
:
item
.
name
,
subText
:
item
.
unit
,
}
})
.
reduce
((
prev
:
any
,
cur
:
any
)
=>
{
const
letter
=
cur
.
letter
const
index
=
prev
.
findIndex
((
item
:
any
)
=>
item
.
letter
===
letter
)
if
(
index
===
-
1
)
{
prev
.
push
({
letter
,
items
:
[
cur
],
})
}
else
{
prev
[
index
].
items
.
push
(
cur
)
}
return
prev
},
[])
.
sort
((
a
:
any
,
b
:
any
)
=>
{
return
a
.
letter
.
charCodeAt
(
0
)
-
b
.
letter
.
charCodeAt
(
0
)
})
return
result
}
src/pages/example/linkedlist/index.vue
deleted
100644 → 0
浏览文件 @
ef8f4bfd
<
script
setup
lang=
"ts"
>
import
{
getData
}
from
'./data'
interface
Params
{
title
?:
string
multiple
?:
boolean
}
const
model
=
reactive
({
params
:
{}
as
Params
,
search
:
''
,
data
:
[]
as
Recordable
[],
show
:
false
,
buttons
:
[],
})
const
data
=
computed
(()
=>
{
const
list
=
model
.
data
.
filter
((
item
:
any
)
=>
{
item
.
data
=
model
.
search
?
item
.
items
.
filter
(
(
subItem
:
any
)
=>
subItem
.
name
?.
includes
(
model
.
search
)
||
subItem
.
unit
?.
includes
(
model
.
search
)
||
subItem
.
phone
?.
includes
(
model
.
search
),
)
:
item
.
items
return
item
.
data
.
length
>
0
})
return
{
list
,
total
:
list
.
reduce
((
prev
:
any
,
cur
:
any
)
=>
prev
+
cur
.
data
.
length
,
0
),
}
})
onLoad
(({
multiple
,
title
})
=>
{
model
.
params
.
title
=
title
model
.
params
.
multiple
=
multiple
===
'true'
// 自定义设置标题
if
(
title
)
{
uni
.
setNavigationBarTitle
({
title
})
}
// 获取人员列表
Message
.
loading
(
'加载中...'
)
model
.
data
=
getData
()
Message
.
hideLoading
()
// 操作项
model
.
buttons
=
[]
if
(
model
.
params
.
multiple
)
{
model
.
buttons
.
push
({
name
:
'确定'
,
value
:
'SUBMIT'
,
type
:
'primary'
,
onClick
:
()
=>
{
const
result
=
toRaw
(
model
.
data
)
.
reduce
((
all
,
item
)
=>
all
.
concat
(
item
.
data
),
[])
.
filter
((
item
:
any
)
=>
item
.
checked
)
console
.
log
(
'Multiple Result'
,
result
)
callback
(
result
)
},
})
}
})
function
search
(
e
:
any
)
{
model
.
search
=
e
.
detail
.
value
||
''
}
function
choose
(
value
:
any
)
{
if
(
model
.
params
?.
multiple
)
{
data
.
value
.
list
[
value
.
index
].
data
[
value
.
subIndex
].
checked
=
!
value
.
checked
}
else
{
console
.
log
(
'Single Result'
,
value
)
callback
(
value
)
}
}
function
callback
(
result
:
any
)
{
uni
.
$emit
(
'chooseShootOrderReceiverUser'
,
result
)
uni
.
navigateBack
()
}
const
buttonWidth
=
computed
(()
=>
{
const
len
=
model
.
buttons
.
length
return
(
750
-
60
)
/
len
-
(
len
-
1
)
*
(
30
/
len
)
})
</
script
>
<
template
>
<view
class=
"wrap"
>
<!-- -->
<fui-virtual-index-list
isSrc
:listData=
"data.list"
:isSelect=
"model.params?.multiple"
:subRight=
"false"
@
init=
"model.show = true"
@
click=
"choose"
:class=
"model.params?.multiple ? 'multiple' : ''"
:debug=
"true"
>
<fui-search-bar
@
input=
"search"
@
clear=
"model.search = ''"
/>
<template
#
footer
>
<fui-loadmore
v-if=
"!model.show"
/>
<fui-divider
:text=
"`$
{data.total || 0}联系人`" v-if="model.show" />
<!-- 安全区 -->
<fui-safe-area
/>
</
template
>
</fui-virtual-index-list>
<!-- 多选确认按钮 -->
<!-- 操作 -->
<view
class=
"opts"
v-if=
"model.params.multiple"
>
<!-- 操作按钮 -->
<view
class=
"opts-wrap"
>
<fui-button
v-for=
"opt in model.buttons"
:key=
"opt.value"
@
tap=
"opt.onClick"
:text=
"opt.name"
:type=
"opt.type"
radius=
"96rpx"
:width=
"`${buttonWidth}rpx`"
height=
"96rpx"
/>
</view>
<!-- 安全区 -->
<fui-safe-area
/>
</view>
</view>
</template>
<
style
lang=
"less"
scoped
>
//
.multiple
{
padding-bottom
:
140
rpx
;
}
.opts
{
position
:
fixed
;
bottom
:
0
;
left
:
0
;
right
:
0
;
z-index
:
100
;
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
space-between
;
padding
:
20
rpx
30
rpx
;
background-color
:
#fff
;
box-shadow
:
0
-2
rpx
10
rpx
0
rgb
(
0
0
0
/
10%
);
.opts-wrap
{
width
:
100%
;
display
:
flex
;
flex-direction
:
row
;
align-items
:
center
;
justify-content
:
space-between
;
}
}
</
style
>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论