Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
vk-uni
vk-uview-ui
提交
3ed863e6
vk-uview-ui
项目概览
vk-uni
/
vk-uview-ui
9 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
vk-uview-ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3ed863e6
编写于
5月 18, 2023
作者:
VK1688
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增u-swiper-plus组件,支持视频轮播
上级
cebaf6eb
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
784 addition
and
42 deletion
+784
-42
pages/example/components.vue
pages/example/components.vue
+18
-41
uni_modules/vk-uview-ui/components/u-swiper-plus/components/u-swiper-indicator.vue
...omponents/u-swiper-plus/components/u-swiper-indicator.vue
+135
-0
uni_modules/vk-uview-ui/components/u-swiper-plus/u-swiper-plus.vue
...es/vk-uview-ui/components/u-swiper-plus/u-swiper-plus.vue
+529
-0
uni_modules/vk-uview-ui/index.js
uni_modules/vk-uview-ui/index.js
+3
-0
uni_modules/vk-uview-ui/libs/function/addStyle.js
uni_modules/vk-uview-ui/libs/function/addStyle.js
+42
-0
uni_modules/vk-uview-ui/libs/function/test.js
uni_modules/vk-uview-ui/libs/function/test.js
+57
-1
未找到文件。
pages/example/components.vue
浏览文件 @
3ed863e6
<
template
>
<view
class=
"wrap"
>
<page-nav></page-nav>
<view
class=
"list-wrap"
>
<u-cell-group
title-bg-color=
"rgb(243, 244, 246)"
:title=
"item.groupName"
v-for=
"(item, index) in components"
:key=
"index"
>
<u-cell-item
:titleStyle=
"
{ fontWeight: 500 }" @click="openPage(item1.path)" :title="item1.title" v-for="(item1, index1) in item.list" :key="index1">
<template
v-slot:icon
>
<image
class=
"u-cell-icon"
:src=
"getIcon(item1.icon)"
mode=
"widthFix"
></image>
</
template
>
</u-cell-item>
</u-cell-group>
</view>
<view
class=
"other"
>
<u-alert-tips
type=
"primary"
title=
"其他组件的使用方法与之前一样!"
></u-alert-tips>
</view>
<u-gap
height=
"70"
></u-gap>
<u-swiper-plus
:list=
"list"
:height=
"750"
:indicator=
"true"
indicatorMode=
"dot"
:videoAutoplay=
"true"
:videoMuted=
"false"
:radius=
"0"
></u-swiper-plus>
</view>
</
template
>
<
script
>
import
components
from
"
./components.config.js
"
;
export
default
{
data
()
{
return
{
components
:
components
list
:
[
{
url
:
'
https://mp-682ae78c-682a-45cd-a7d4-1289bec9cd4f.cdn.bspapp.com/cloudstorage/77c09154-caa4-4547-b300-b5e1d4ede958.mp4
'
,
// poster: 'https://mp-682ae78c-682a-45cd-a7d4-1289bec9cd4f.cdn.bspapp.com/cloudstorage/9c2a399f-c4ae-4743-bbb4-dae4caf55e5a.png'
},
'
https://mp-682ae78c-682a-45cd-a7d4-1289bec9cd4f.cdn.bspapp.com/cloudstorage/77c09154-caa4-4547-b300-b5e1d4ede958.mp4
'
,
{
url
:
'
https://mp-682ae78c-682a-45cd-a7d4-1289bec9cd4f.cdn.bspapp.com/cloudstorage/9c2a399f-c4ae-4743-bbb4-dae4caf55e5a.png
'
,
title
:
'
身无彩凤双飞翼,心有灵犀一点通
'
},
{
url
:
'
https://mp-682ae78c-682a-45cd-a7d4-1289bec9cd4f.cdn.bspapp.com/cloudstorage/9c2a399f-c4ae-4743-bbb4-dae4caf55e5a.png
'
,
title
:
'
谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳
'
}
]
};
},
methods
:
{
openPage
(
path
)
{
this
.
$u
.
route
({
url
:
path
});
}
},
computed
:
{
getIcon
()
{
return
path
=>
{
return
"
https://cdn.uviewui.com/uview/example/
"
+
path
+
"
.png
"
;
};
}
}
};
</
script
>
<
style
>
/* page {
background-color: rgb(240, 242, 244);
} */
</
style
>
<
style
lang=
"scss"
scoped
>
.u-cell-icon
{
width
:
36rpx
;
height
:
36rpx
;
margin-right
:
8rpx
;
}
.other
{
padding
:
30rpx
;
}
</
style
>
</
style
>
\ No newline at end of file
uni_modules/vk-uview-ui/components/u-swiper-plus/components/u-swiper-indicator.vue
0 → 100644
浏览文件 @
3ed863e6
<
template
>
<view
class=
"u-swiper-indicator"
>
<view
class=
"u-swiper-indicator__wrapper"
v-if=
"indicatorMode === 'line'"
:class=
"[`u-swiper-indicator__wrapper--$
{indicatorMode}`]"
:style="{
width: $u.addUnit(lineWidth * length),
backgroundColor: indicatorInactiveColor
}"
>
<view
class=
"u-swiper-indicator__wrapper--line__bar"
:style=
"[lineStyle]"
></view>
</view>
<view
class=
"u-swiper-indicator__wrapper"
v-if=
"indicatorMode === 'dot'"
>
<view
class=
"u-swiper-indicator__wrapper__dot"
v-for=
"(item, index) in length"
:key=
"index"
:class=
"[index === current && 'u-swiper-indicator__wrapper__dot--active']"
:style=
"[dotStyle(index)]"
>
</view>
</view>
</view>
</
template
>
<
script
>
/**
* SwiperIndicator 轮播图指示器
* @description 该组件一般用于导航轮播,广告展示等场景,可开箱即用,
* @tutorial https://www.uviewui.com/components/swiper.html
* @property {String | Number} length 轮播的长度(默认 0 )
* @property {String | Number} current 当前处于活动状态的轮播的索引(默认 0 )
* @property {String} indicatorActiveColor 指示器非激活颜色
* @property {String} indicatorInactiveColor 指示器的激活颜色
* @property {String} indicatorMode 指示器模式(默认 'line' )
* @example <u-swiper :list="list4" indicator keyName="url" :autoplay="false"></u-swiper>
*/
export
default
{
name
:
'
u-swiper-indicator
'
,
props
:{
// 轮播的长度
length
:
{
type
:
[
String
,
Number
],
default
:
0
},
// 当前处于活动状态的轮播的索引
current
:
{
type
:
[
String
,
Number
],
default
:
0
},
// 指示器非激活颜色
indicatorActiveColor
:
{
type
:
String
,
default
:
''
},
// 指示器的激活颜色
indicatorInactiveColor
:
{
type
:
String
,
default
:
''
},
// 指示器模式,line-线型,dot-点型
indicatorMode
:
{
type
:
String
,
default
:
'
line
'
}
},
data
()
{
return
{
lineWidth
:
22
}
},
computed
:
{
// 指示器为线型的样式
lineStyle
()
{
let
style
=
{}
style
.
width
=
uni
.
$u
.
addUnit
(
this
.
lineWidth
)
style
.
transform
=
`translateX(
${
uni
.
$u
.
addUnit
(
this
.
current
*
this
.
lineWidth
)
}
)`
style
.
backgroundColor
=
this
.
indicatorActiveColor
return
style
},
// 指示器为点型的样式
dotStyle
()
{
return
index
=>
{
let
style
=
{}
style
.
backgroundColor
=
index
===
this
.
current
?
this
.
indicatorActiveColor
:
this
.
indicatorInactiveColor
return
style
}
}
},
}
</
script
>
<
style
lang=
"scss"
scoped
>
@import
"../../../libs/css/style.components.scss"
;
.u-swiper-indicator
{
&
__wrapper
{
@include
vue-flex
;
&
--line
{
border-radius
:
100px
;
height
:
4px
;
&
__bar
{
width
:
22px
;
height
:
4px
;
border-radius
:
100px
;
background-color
:
#FFFFFF
;
transition
:
transform
0
.3s
;
}
}
&
__dot
{
width
:
5px
;
height
:
5px
;
border-radius
:
100px
;
margin
:
0
4px
;
&
--active
{
width
:
12px
;
}
}
}
}
</
style
>
uni_modules/vk-uview-ui/components/u-swiper-plus/u-swiper-plus.vue
0 → 100644
浏览文件 @
3ed863e6
此差异已折叠。
点击以展开。
uni_modules/vk-uview-ui/index.js
浏览文件 @
3ed863e6
...
...
@@ -68,6 +68,8 @@ import {sys, os} from './libs/function/sys.js'
import
debounce
from
'
./libs/function/debounce.js
'
// 节流方法
import
throttle
from
'
./libs/function/throttle.js
'
// 对象转字符串,或者字符串转对象
import
addStyle
from
'
./libs/function/addStyle.js
'
// 配置信息
...
...
@@ -111,6 +113,7 @@ const $u = {
zIndex
,
debounce
,
throttle
,
addStyle
}
// $u挂载到uni对象上
...
...
uni_modules/vk-uview-ui/libs/function/addStyle.js
0 → 100644
浏览文件 @
3ed863e6
import
test
from
'
./test.js
'
/**
* @description 样式转换
* 对象转字符串,或者字符串转对象
* @param {object | string} customStyle 需要转换的目标
* @param {String} target 转换的目的,object-转为对象,string-转为字符串
* @returns {object|string}
*/
function
addStyle
(
customStyle
,
target
=
'
object
'
)
{
// 字符串转字符串,对象转对象情形,直接返回
if
(
test
.
empty
(
customStyle
)
||
typeof
(
customStyle
)
===
'
object
'
&&
target
===
'
object
'
||
target
===
'
string
'
&&
typeof
(
customStyle
)
===
'
string
'
)
{
return
customStyle
}
// 字符串转对象
if
(
target
===
'
object
'
)
{
// 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 20px 0如果去掉了就错了),空格是无用的
customStyle
=
trim
(
customStyle
)
// 根据";"将字符串转为数组形式
const
styleArray
=
customStyle
.
split
(
'
;
'
)
const
style
=
{}
// 历遍数组,拼接成对象
for
(
let
i
=
0
;
i
<
styleArray
.
length
;
i
++
)
{
// 'font-size:20px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤
if
(
styleArray
[
i
])
{
const
item
=
styleArray
[
i
].
split
(
'
:
'
)
style
[
trim
(
item
[
0
])]
=
trim
(
item
[
1
])
}
}
return
style
}
// 这里为对象转字符串形式
let
string
=
''
for
(
const
i
in
customStyle
)
{
// 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
const
key
=
i
.
replace
(
/
([
A-Z
])
/g
,
'
-$1
'
).
toLowerCase
()
string
+=
`
${
key
}
:
${
customStyle
[
i
]}
;`
}
// 去除两端空格
return
trim
(
string
)
}
export
default
addStyle
uni_modules/vk-uview-ui/libs/function/test.js
浏览文件 @
3ed863e6
...
...
@@ -205,6 +205,56 @@ function code(value, len = 6) {
}
/**
* 是否函数方法
* @param {Object} value
*/
function
func
(
value
)
{
return
typeof
value
===
'
function
'
}
/**
* 是否promise对象
* @param {Object} value
*/
function
promise
(
value
)
{
return
object
(
value
)
&&
func
(
value
.
then
)
&&
func
(
value
.
catch
)
}
/** 是否图片格式
* @param {Object} value
*/
function
image
(
value
)
{
const
newValue
=
value
.
split
(
'
?
'
)[
0
]
const
IMAGE_REGEXP
=
/
\.(
jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg
)
/i
return
IMAGE_REGEXP
.
test
(
newValue
)
}
/**
* 是否视频格式
* @param {Object} value
*/
function
video
(
value
)
{
const
VIDEO_REGEXP
=
/
\.(
mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8
)
/i
return
VIDEO_REGEXP
.
test
(
value
)
}
/**
* 是否为正则对象
* @param {Object}
* @return {Boolean}
*/
function
regExp
(
o
)
{
return
o
&&
Object
.
prototype
.
toString
.
call
(
o
)
===
'
[object RegExp]
'
}
/**
* 验证字符串
*/
function
string
(
value
)
{
return
typeof
value
===
'
string
'
}
export
default
{
email
,
mobile
,
...
...
@@ -228,5 +278,11 @@ export default {
landline
,
object
,
array
,
code
code
,
func
,
promise
,
video
,
image
,
regExp
,
string
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录