74 changed files with 1958 additions and 2559 deletions
@ -1,8 +0,0 @@ |
|||||
# Default ignored files |
|
||||
/shelf/ |
|
||||
/workspace.xml |
|
||||
# Datasource local storage ignored files |
|
||||
/../../../../:\workspace\bnyer-cloud-hub\.idea/dataSources/ |
|
||||
/dataSources.local.xml |
|
||||
# Editor-based HTTP Client requests |
|
||||
/httpRequests/ |
|
||||
@ -1,204 +1,158 @@ |
|||||
<template> |
<template> |
||||
<view class="container"> |
<view class="container"> |
||||
<!-- <view v-if="!showChoiceness"> |
|
||||
<view class="top"> |
<view class="top"> |
||||
<image class="back-img" src="../../static/img/start.gif" mode=""></image> |
<uni-notice-bar show-get-more show-icon more-text="查看更多" text="年末大礼:uni-app1.4 新增百度、支付宝小程序。插件市场重磅上线!" |
||||
<view class="top-bottom"> |
@getmore="getMore" /> |
||||
</view> |
<uni-notice-bar show-icon scrollable |
||||
<uni-search-bar class="uni-mt-10" placeholder="请输入喜欢的艺术家代号吧~" clearButton="auto" cancelButton="none" |
text="uni-app 版正式发布,开发一次,同时发布iOS、Android、H5、微信小程序、支付宝小程序、百度小程序、头条小程序等7大平台。" /> |
||||
@confirm="search" /> |
|
||||
<text>热门艺术家</text> |
|
||||
<view class="user-list"> |
|
||||
<view class="user-list-box" v-for="(item,index) in hotCreatorList" :key='item.id' |
|
||||
@click="goCreatorDetail(item.scanCode)"> |
|
||||
<image :src="item.img" mode=""></image> |
|
||||
<text>{{item.scanCode}}</text> |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
</view> |
||||
<view class="middle"> |
<view class="middle"> |
||||
<text>近期精选</text> |
<uni-section title="我的資金" type="line" padding> |
||||
<image src="../../static/img/slide-top.svg" mode=""></image> |
<text>錢包餘額</text> |
||||
|
</uni-section> |
||||
|
</view> |
||||
|
<view class="foot"> |
||||
|
<uni-section title="更多服務" type="line" padding> |
||||
|
<uni-grid :column="4" :highlight="true" @change="change"> |
||||
|
<uni-grid-item v-for="(item, index) in list" :index="index" :key="index"> |
||||
|
<view class="grid-item-box" style="background-color: #fff;" > |
||||
|
<uni-icons type="image" :size="30" color="#777" /> |
||||
|
<text class="text">{{item}}</text> |
||||
</view> |
</view> |
||||
|
</uni-grid-item> |
||||
|
</uni-grid> |
||||
|
</uni-section> |
||||
</view> |
</view> |
||||
<Choiceness v-else></Choiceness> --> |
|
||||
</view> |
</view> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import { |
|
||||
loginWx |
|
||||
} from '@/api/index.js' |
|
||||
export default { |
export default { |
||||
data() { |
data() { |
||||
return { |
return { |
||||
hotCreatorList: [], |
list:['美團外賣','支付助手','廣告助手','上傳圖片','消息通知','我的信息','我的短信','我的頭像'] |
||||
isTarget: true, |
|
||||
showChoiceness:false |
|
||||
} |
|
||||
}, |
|
||||
// 下拉刷新 |
|
||||
onPullDownRefresh() { |
|
||||
this.showChoiceness = false |
|
||||
uni.stopPullDownRefresh() |
|
||||
}, |
|
||||
created() { |
|
||||
const userInfo = uni.getStorageSync('userInfo') |
|
||||
if (!userInfo) { |
|
||||
console.log('havent userInfo') |
|
||||
this.getUserInfo() |
|
||||
} else { |
|
||||
console.log('have userInfo') |
|
||||
} |
|
||||
}, |
|
||||
onPageScroll(e) { |
|
||||
// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件 |
|
||||
|
|
||||
if (e.scrollTop > 160) { |
|
||||
this.showChoiceness = true |
|
||||
// uni.redirectTo({ |
|
||||
// url: '../index/choiceness' |
|
||||
// }) |
|
||||
} |
} |
||||
}, |
}, |
||||
methods: { |
methods: { |
||||
// 搜索 |
change(e) { |
||||
search(res) { |
// this.index = e.detail.index |
||||
if (res.value) { |
let { |
||||
console.log('search', res.value) |
index |
||||
this.goCreatorDetail(res.value) |
} = e.detail |
||||
} else { |
this.list[index].badge && this.list[index].badge++ |
||||
uni.showToast({ |
|
||||
title: '请输入艺术家代号', |
|
||||
icon: 'none' |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
}, |
|
||||
// 获取用户信息 |
|
||||
getUserInfo() { |
|
||||
wx.login({ |
|
||||
force: true, |
|
||||
success: res => { |
|
||||
wx.getUserInfo({ |
|
||||
withCredentials: true, |
|
||||
success: userInfo => { |
|
||||
const params = { |
|
||||
code: res.code, |
|
||||
encryptedData: userInfo.encryptedData, |
|
||||
iv: userInfo.iv |
|
||||
} |
|
||||
// 用户授权登录 |
|
||||
console.log('params',params); |
|
||||
loginWx(params).then(res => { |
|
||||
if (res.data.code === 200) { |
|
||||
uni.setStorage({ |
|
||||
key: 'userInfo', |
|
||||
data: res.data.data.userInfo, |
|
||||
}) |
|
||||
} else { |
|
||||
uni.showToast({ |
uni.showToast({ |
||||
title: res.data.msg, |
title: `点击第${index+1}个宫格`, |
||||
icon: 'none' |
icon: 'none' |
||||
}) |
}) |
||||
} |
|
||||
}).catch(res => {}) |
|
||||
console.log(`getUserInfo 调用成功`, userInfo); |
|
||||
}, |
|
||||
fail(userInfo) { |
|
||||
console.log(`getUserInfo 调用失败`); |
|
||||
}, |
|
||||
}); |
|
||||
}, |
|
||||
fail(res) { |
|
||||
console.log(`login 调用失败`); |
|
||||
}, |
|
||||
}); |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
|
|
||||
// 滚动监听 |
|
||||
handleScroll() { |
|
||||
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop |
|
||||
console.log(scrollTop) |
|
||||
}, |
}, |
||||
}, |
}, |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<style lang="less"> |
<style lang="scss"> |
||||
.container { |
.middle { |
||||
.top { |
margin-top: 80px; |
||||
width: 100vw; |
} |
||||
|
|
||||
image { |
.foot { |
||||
width: 100vw; |
margin-top: 80px; |
||||
height: 400rpx; |
} |
||||
} |
|
||||
|
// .container { |
||||
.uni-searchbar { |
// .top { |
||||
border: 1px solid #11A8FD; |
// width: 100vw; |
||||
margin: 0 40rpx; |
|
||||
border-radius: 16rpx; |
// image { |
||||
padding: 0; |
// width: 100vw; |
||||
|
// height: 400rpx; |
||||
.uni-searchbar__box { |
// } |
||||
padding: 0; |
|
||||
border-radius: 16rpx !important; |
// .uni-searchbar { |
||||
} |
// border: 1px solid #11A8FD; |
||||
} |
// margin: 0 40rpx; |
||||
|
// border-radius: 16rpx; |
||||
>text { |
// padding: 0; |
||||
font-weight: bold; |
|
||||
font-size: 14px; |
// .uni-searchbar__box { |
||||
display: block; |
// padding: 0; |
||||
text-align: center; |
// border-radius: 16rpx !important; |
||||
padding-top: 40rpx; |
// } |
||||
padding-bottom: 20rpx; |
// } |
||||
} |
|
||||
|
// >text { |
||||
.user-list { |
// font-weight: bold; |
||||
|
// font-size: 14px; |
||||
|
// display: block; |
||||
|
// text-align: center; |
||||
|
// padding-top: 40rpx; |
||||
|
// padding-bottom: 20rpx; |
||||
|
// } |
||||
|
|
||||
|
// .user-list { |
||||
|
// display: flex; |
||||
|
// justify-content: flex-start; |
||||
|
// align-items: center; |
||||
|
// overflow-x: auto; |
||||
|
|
||||
|
// .user-list-box { |
||||
|
// width: 140rpx; |
||||
|
// padding: 20rpx; |
||||
|
// text-align: center; |
||||
|
|
||||
|
// image { |
||||
|
// width: 100rpx; |
||||
|
// height: 100rpx; |
||||
|
// border-radius: 100rpx; |
||||
|
// } |
||||
|
|
||||
|
// text { |
||||
|
// font-size: 24rpx; |
||||
|
// color: #1E1E1E; |
||||
|
// text-align: center; |
||||
|
// } |
||||
|
// } |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
// .middle { |
||||
|
// text-align: center; |
||||
|
// height: calc(100vh - 248rpx); |
||||
|
// padding-top: 40rpx; |
||||
|
|
||||
|
// text { |
||||
|
// font-weight: bold; |
||||
|
// font-size: 14px; |
||||
|
// display: block; |
||||
|
// } |
||||
|
|
||||
|
// image { |
||||
|
// width: 40rpx; |
||||
|
// height: 40rpx; |
||||
|
// } |
||||
|
// } |
||||
|
// } |
||||
|
.grid-item-box { |
||||
|
flex: 1; |
||||
|
// position: relative; |
||||
|
/* #ifndef APP-NVUE */ |
||||
display: flex; |
display: flex; |
||||
justify-content: flex-start; |
/* #endif */ |
||||
|
flex-direction: column; |
||||
align-items: center; |
align-items: center; |
||||
overflow-x: auto; |
justify-content: center; |
||||
|
padding: 15px 0; |
||||
.user-list-box { |
|
||||
width: 140rpx; |
|
||||
padding: 20rpx; |
|
||||
text-align: center; |
|
||||
|
|
||||
image { |
|
||||
width: 100rpx; |
|
||||
height: 100rpx; |
|
||||
border-radius: 100rpx; |
|
||||
} |
} |
||||
|
|
||||
text { |
.grid-item-box-row { |
||||
font-size: 24rpx; |
flex: 1; |
||||
color: #1E1E1E; |
// position: relative; |
||||
text-align: center; |
/* #ifndef APP-NVUE */ |
||||
} |
display: flex; |
||||
} |
/* #endif */ |
||||
} |
flex-direction: row; |
||||
} |
align-items: center; |
||||
|
justify-content: center; |
||||
.middle { |
padding: 15px 0; |
||||
text-align: center; |
|
||||
height: calc(100vh - 248rpx); |
|
||||
padding-top: 40rpx; |
|
||||
|
|
||||
text { |
|
||||
font-weight: bold; |
|
||||
font-size: 14px; |
|
||||
display: block; |
|
||||
} |
|
||||
|
|
||||
image { |
|
||||
width: 40rpx; |
|
||||
height: 40rpx; |
|
||||
} |
|
||||
} |
|
||||
} |
} |
||||
</style> |
</style> |
||||
|
|||||
@ -1,6 +0,0 @@ |
|||||
## 0.1.2(2022-06-08) |
|
||||
- 修复 微信小程序 separator 不显示问题 |
|
||||
## 0.1.1(2022-06-02) |
|
||||
- 新增 支持 uni.scss 修改颜色 |
|
||||
## 0.1.0(2022-04-21) |
|
||||
- 初始化 |
|
||||
@ -1,121 +0,0 @@ |
|||||
<template> |
|
||||
<view class="uni-breadcrumb-item"> |
|
||||
<view :class="{ |
|
||||
'uni-breadcrumb-item--slot': true, |
|
||||
'uni-breadcrumb-item--slot-link': to && currentPage !== to |
|
||||
}" @click="navTo"> |
|
||||
<slot /> |
|
||||
</view> |
|
||||
<i v-if="separatorClass" class="uni-breadcrumb-item--separator" :class="separatorClass" /> |
|
||||
<text v-else class="uni-breadcrumb-item--separator">{{ separator }}</text> |
|
||||
</view> |
|
||||
</template> |
|
||||
<script> |
|
||||
/** |
|
||||
* BreadcrumbItem 面包屑导航子组件 |
|
||||
* @property {String/Object} to 路由跳转页面路径/对象 |
|
||||
* @property {Boolean} replace 在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持) |
|
||||
*/ |
|
||||
export default { |
|
||||
data() { |
|
||||
return { |
|
||||
currentPage: "" |
|
||||
} |
|
||||
}, |
|
||||
options: { |
|
||||
virtualHost: true |
|
||||
}, |
|
||||
props: { |
|
||||
to: { |
|
||||
type: String, |
|
||||
default: '' |
|
||||
}, |
|
||||
replace:{ |
|
||||
type: Boolean, |
|
||||
default: false |
|
||||
} |
|
||||
}, |
|
||||
inject: { |
|
||||
uniBreadcrumb: { |
|
||||
from: "uniBreadcrumb", |
|
||||
default: null |
|
||||
} |
|
||||
}, |
|
||||
created(){ |
|
||||
const pages = getCurrentPages() |
|
||||
const page = pages[pages.length-1] |
|
||||
|
|
||||
if(page){ |
|
||||
this.currentPage = `/${page.route}` |
|
||||
} |
|
||||
}, |
|
||||
computed: { |
|
||||
separator() { |
|
||||
return this.uniBreadcrumb.separator |
|
||||
}, |
|
||||
separatorClass() { |
|
||||
return this.uniBreadcrumb.separatorClass |
|
||||
} |
|
||||
}, |
|
||||
methods: { |
|
||||
navTo() { |
|
||||
const { to } = this |
|
||||
|
|
||||
if (!to || this.currentPage === to){ |
|
||||
return |
|
||||
} |
|
||||
|
|
||||
if(this.replace){ |
|
||||
uni.redirectTo({ |
|
||||
url:to |
|
||||
}) |
|
||||
}else{ |
|
||||
uni.navigateTo({ |
|
||||
url:to |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
<style lang="scss"> |
|
||||
$uni-primary: #2979ff !default; |
|
||||
$uni-base-color: #6a6a6a !default; |
|
||||
$uni-main-color: #3a3a3a !default; |
|
||||
.uni-breadcrumb-item { |
|
||||
display: flex; |
|
||||
align-items: center; |
|
||||
white-space: nowrap; |
|
||||
font-size: 14px; |
|
||||
|
|
||||
&--slot { |
|
||||
color: $uni-base-color; |
|
||||
padding: 0 10px; |
|
||||
|
|
||||
&-link { |
|
||||
color: $uni-main-color; |
|
||||
font-weight: bold; |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
cursor: pointer; |
|
||||
/* #endif */ |
|
||||
|
|
||||
&:hover { |
|
||||
color: $uni-primary; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
&--separator { |
|
||||
font-size: 12px; |
|
||||
color: $uni-base-color; |
|
||||
} |
|
||||
|
|
||||
&:first-child &--slot { |
|
||||
padding-left: 0; |
|
||||
} |
|
||||
|
|
||||
&:last-child &--separator { |
|
||||
display: none; |
|
||||
} |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,41 +0,0 @@ |
|||||
<template> |
|
||||
<view class="uni-breadcrumb"> |
|
||||
<slot /> |
|
||||
</view> |
|
||||
</template> |
|
||||
<script> |
|
||||
/** |
|
||||
* Breadcrumb 面包屑导航父组件 |
|
||||
* @description 显示当前页面的路径,快速返回之前的任意页面 |
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=xxx |
|
||||
* @property {String} separator 分隔符,默认为斜杠'/' |
|
||||
* @property {String} separatorClass 图标分隔符 class |
|
||||
*/ |
|
||||
export default { |
|
||||
options: { |
|
||||
virtualHost: true |
|
||||
}, |
|
||||
props: { |
|
||||
separator: { |
|
||||
type: String, |
|
||||
default: '/' |
|
||||
}, |
|
||||
separatorClass: { |
|
||||
type: String, |
|
||||
default: '' |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
provide() { |
|
||||
return { |
|
||||
uniBreadcrumb: this |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
</script> |
|
||||
<style lang="scss"> |
|
||||
.uni-breadcrumb { |
|
||||
display: flex; |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,88 +0,0 @@ |
|||||
{ |
|
||||
"id": "uni-breadcrumb", |
|
||||
"displayName": "uni-breadcrumb 面包屑", |
|
||||
"version": "0.1.2", |
|
||||
"description": "Breadcrumb 面包屑", |
|
||||
"keywords": [ |
|
||||
"uni-breadcrumb", |
|
||||
"breadcrumb", |
|
||||
"uni-ui", |
|
||||
"面包屑导航", |
|
||||
"面包屑" |
|
||||
], |
|
||||
"repository": "", |
|
||||
"engines": { |
|
||||
"HBuilderX": "^3.1.0" |
|
||||
}, |
|
||||
"directories": { |
|
||||
"example": "../../temps/example_temps" |
|
||||
}, |
|
||||
"dcloudext": { |
|
||||
"category": [ |
|
||||
"前端组件", |
|
||||
"通用组件" |
|
||||
], |
|
||||
"sale": { |
|
||||
"regular": { |
|
||||
"price": "0.00" |
|
||||
}, |
|
||||
"sourcecode": { |
|
||||
"price": "0.00" |
|
||||
} |
|
||||
}, |
|
||||
"contact": { |
|
||||
"qq": "" |
|
||||
}, |
|
||||
"declaration": { |
|
||||
"ads": "无", |
|
||||
"data": "无", |
|
||||
"permissions": "无" |
|
||||
}, |
|
||||
"npmurl": "" |
|
||||
}, |
|
||||
"uni_modules": { |
|
||||
"dependencies": [], |
|
||||
"encrypt": [], |
|
||||
"platforms": { |
|
||||
"cloud": { |
|
||||
"tcb": "y", |
|
||||
"aliyun": "y" |
|
||||
}, |
|
||||
"client": { |
|
||||
"Vue": { |
|
||||
"vue2": "y", |
|
||||
"vue3": "y" |
|
||||
}, |
|
||||
"App": { |
|
||||
"app-vue": "y", |
|
||||
"app-nvue": "n" |
|
||||
}, |
|
||||
"H5-mobile": { |
|
||||
"Safari": "y", |
|
||||
"Android Browser": "y", |
|
||||
"微信浏览器(Android)": "y", |
|
||||
"QQ浏览器(Android)": "y" |
|
||||
}, |
|
||||
"H5-pc": { |
|
||||
"Chrome": "y", |
|
||||
"IE": "y", |
|
||||
"Edge": "y", |
|
||||
"Firefox": "y", |
|
||||
"Safari": "y" |
|
||||
}, |
|
||||
"小程序": { |
|
||||
"微信": "y", |
|
||||
"阿里": "u", |
|
||||
"百度": "u", |
|
||||
"字节跳动": "u", |
|
||||
"QQ": "u", |
|
||||
"京东": "u" |
|
||||
}, |
|
||||
"快应用": { |
|
||||
"华为": "u", |
|
||||
"联盟": "u" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,66 +0,0 @@ |
|||||
|
|
||||
## breadcrumb 面包屑导航 |
|
||||
> **组件名:uni-breadcrumb** |
|
||||
> 代码块: `ubreadcrumb` |
|
||||
|
|
||||
显示当前页面的路径,快速返回之前的任意页面。 |
|
||||
|
|
||||
### 安装方式 |
|
||||
|
|
||||
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。 |
|
||||
|
|
||||
如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55) |
|
||||
|
|
||||
### 基本用法 |
|
||||
|
|
||||
在 ``template`` 中使用组件 |
|
||||
|
|
||||
```html |
|
||||
<uni-breadcrumb separator="/"> |
|
||||
<uni-breadcrumb-item v-for="(route,index) in routes" :key="index" :to="route.to">{{route.name}}</uni-breadcrumb-item> |
|
||||
</uni-breadcrumb> |
|
||||
``` |
|
||||
|
|
||||
```js |
|
||||
export default { |
|
||||
name: "uni-stat-breadcrumb", |
|
||||
data() { |
|
||||
return { |
|
||||
routes: [{ |
|
||||
to: '/A', |
|
||||
name: 'A页面' |
|
||||
}, { |
|
||||
to: '/B', |
|
||||
name: 'B页面' |
|
||||
}, { |
|
||||
to: '/C', |
|
||||
name: 'C页面' |
|
||||
}] |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
``` |
|
||||
|
|
||||
|
|
||||
## API |
|
||||
|
|
||||
### Breadcrumb Props |
|
||||
|
|
||||
|属性名 |类型 |默认值 |说明 | |
|
||||
|:-: |:-: |:-: |:-: | |
|
||||
|separator |String |斜杠'/' |分隔符 | |
|
||||
|separatorClass |String | |图标分隔符 class | |
|
||||
|
|
||||
### Breadcrumb Item Props |
|
||||
|
|
||||
|属性名 |类型 |默认值 |说明 | |
|
||||
|:-: |:-: |:-: |:-: | |
|
||||
|to |String | |路由跳转页面路径 | |
|
||||
|replace|Boolean | |在使用 to 进行路由跳转时,启用 replace 将不会向 history 添加新记录(仅 h5 支持) | |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
## 组件示例 |
|
||||
|
|
||||
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb](https://hellouniapp.dcloud.net.cn/pages/extUI/breadcrumb/breadcrumb) |
|
||||
@ -1,10 +0,0 @@ |
|||||
## 0.1.3(2022-06-02) |
|
||||
- 修复 localdata 赋值不生效的 bug |
|
||||
- 新增 支持 uni.scss 修改颜色 |
|
||||
- 新增 支持选项禁用(数据选项设置 disabled: true 即禁用) |
|
||||
## 0.1.2(2022-05-08) |
|
||||
- 修复 当 value 为 0 时选择不生效的 bug |
|
||||
## 0.1.1(2022-05-07) |
|
||||
- 新增 记住上次的选项(仅 collection 存在时有效) |
|
||||
## 0.1.0(2022-04-22) |
|
||||
- 初始化 |
|
||||
@ -1,402 +0,0 @@ |
|||||
<template> |
|
||||
<view class="uni-stat__select"> |
|
||||
<span v-if="label" class="uni-label-text hide-on-phone">{{label + ':'}}</span> |
|
||||
<view :class="{'uni-stat__actived': current}"> |
|
||||
<view class="uni-select"> |
|
||||
<view class="uni-select__input-box" @click="toggleSelector"> |
|
||||
<view v-if="current" class="uni-select__input-text">{{current}}</view> |
|
||||
<view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view> |
|
||||
<uni-icons v-if="current && clear" type="clear" color="#e1e1e1" size="18" @click="clearVal" /> |
|
||||
<uni-icons v-else :type="showSelector? 'top' : 'bottom'" size="14" color="#999" /> |
|
||||
</view> |
|
||||
<view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" /> |
|
||||
<view class="uni-select__selector" v-if="showSelector"> |
|
||||
<view class="uni-popper__arrow"></view> |
|
||||
<scroll-view scroll-y="true" class="uni-select__selector-scroll"> |
|
||||
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0"> |
|
||||
<text>{{emptyTips}}</text> |
|
||||
</view> |
|
||||
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" |
|
||||
:key="index" @click="change(item)"> |
|
||||
<text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text> |
|
||||
</view> |
|
||||
</scroll-view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
/** |
|
||||
* DataChecklist 数据选择器 |
|
||||
* @description 通过数据渲染的下拉框组件 |
|
||||
* @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select |
|
||||
* @property {String} value 默认值 |
|
||||
* @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}] |
|
||||
* @property {Boolean} clear 是否可以清空已选项 |
|
||||
* @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效 |
|
||||
* @property {String} label 左侧标题 |
|
||||
* @property {String} placeholder 输入框的提示文字 |
|
||||
* @event {Function} change 选中发生变化触发 |
|
||||
*/ |
|
||||
|
|
||||
export default { |
|
||||
name: "uni-stat-select", |
|
||||
mixins: [uniCloud.mixinDatacom || {}], |
|
||||
data() { |
|
||||
return { |
|
||||
showSelector: false, |
|
||||
current: '', |
|
||||
mixinDatacomResData: [], |
|
||||
apps: [], |
|
||||
channels: [] |
|
||||
}; |
|
||||
}, |
|
||||
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 |
|
||||
} |
|
||||
}, |
|
||||
created() { |
|
||||
this.last = `${this.collection}_last_selected_option_value` |
|
||||
if (this.collection && !this.localdata.length) { |
|
||||
this.mixinDatacomEasyGet() |
|
||||
} |
|
||||
}, |
|
||||
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 |
|
||||
} |
|
||||
}, |
|
||||
watch: { |
|
||||
localdata: { |
|
||||
immediate: true, |
|
||||
handler(val, old) { |
|
||||
if (Array.isArray(val) && old!==val) { |
|
||||
this.mixinDatacomResData = val |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
// #ifndef VUE3 |
|
||||
value() { |
|
||||
this.initDefVal() |
|
||||
}, |
|
||||
// #endif |
|
||||
// #ifdef VUE3 |
|
||||
modelValue() { |
|
||||
this.initDefVal() |
|
||||
}, |
|
||||
// #endif |
|
||||
mixinDatacomResData: { |
|
||||
immediate: true, |
|
||||
handler(val) { |
|
||||
if (val.length) { |
|
||||
this.initDefVal() |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
methods: { |
|
||||
initDefVal() { |
|
||||
let defValue = '' |
|
||||
if ((this.value || this.value === 0) && !this.isDisabled(this.value)) { |
|
||||
defValue = this.value |
|
||||
} else if ((this.modelValue || this.modelValue === 0) && !this.isDisabled(this.modelValue)) { |
|
||||
defValue = this.modelValue |
|
||||
} else { |
|
||||
let strogeValue |
|
||||
if (this.collection) { |
|
||||
strogeValue = uni.getStorageSync(this.last) |
|
||||
} |
|
||||
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 |
|
||||
} |
|
||||
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('') |
|
||||
if (this.collection) { |
|
||||
uni.removeStorageSync(this.last) |
|
||||
} |
|
||||
}, |
|
||||
change(item) { |
|
||||
if (!item.disable) { |
|
||||
this.showSelector = false |
|
||||
this.current = this.formatItemName(item) |
|
||||
this.emit(item.value) |
|
||||
} |
|
||||
}, |
|
||||
emit(val) { |
|
||||
this.$emit('change', val) |
|
||||
this.$emit('input', val) |
|
||||
this.$emit('update:modelValue', val) |
|
||||
if (this.collection) { |
|
||||
uni.setStorageSync(this.last, val) |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
toggleSelector() { |
|
||||
this.showSelector = !this.showSelector |
|
||||
}, |
|
||||
formatItemName(item) { |
|
||||
let { |
|
||||
text, |
|
||||
value, |
|
||||
channel_code |
|
||||
} = item |
|
||||
channel_code = channel_code ? `(${channel_code})` : '' |
|
||||
return this.collection.indexOf('app-list') > 0 ? |
|
||||
`${text}(${value})` : |
|
||||
( |
|
||||
text ? |
|
||||
text : |
|
||||
`未命名${channel_code}` |
|
||||
) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<style> |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
@media screen and (max-width: 500px) { |
|
||||
.hide-on-phone { |
|
||||
display: none; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/* #endif */ |
|
||||
.uni-stat__select { |
|
||||
display: flex; |
|
||||
align-items: center; |
|
||||
padding: 15px; |
|
||||
cursor: pointer; |
|
||||
} |
|
||||
|
|
||||
.uni-stat__actived { |
|
||||
outline: 1px solid #2979ff; |
|
||||
} |
|
||||
|
|
||||
.uni-label-text { |
|
||||
font-size: 14px; |
|
||||
font-weight: bold; |
|
||||
color: #555; |
|
||||
margin: auto 0; |
|
||||
margin-right: 5px; |
|
||||
} |
|
||||
|
|
||||
.uni-select { |
|
||||
font-size: 14px; |
|
||||
border: 1px solid #DCDFE6; |
|
||||
box-sizing: border-box; |
|
||||
border-radius: 4px; |
|
||||
padding: 0 5px; |
|
||||
position: relative; |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
display: flex; |
|
||||
user-select: none; |
|
||||
/* #endif */ |
|
||||
flex-direction: row; |
|
||||
align-items: center; |
|
||||
border-bottom: solid 1px #DDDDDD; |
|
||||
} |
|
||||
|
|
||||
.uni-select__label { |
|
||||
font-size: 16px; |
|
||||
line-height: 22px; |
|
||||
padding-right: 10px; |
|
||||
color: #999999; |
|
||||
} |
|
||||
|
|
||||
.uni-select__input-box { |
|
||||
min-height: 36px; |
|
||||
position: relative; |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
display: flex; |
|
||||
/* #endif */ |
|
||||
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: #999; |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector { |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
box-sizing: border-box; |
|
||||
/* #endif */ |
|
||||
position: absolute; |
|
||||
top: calc(100% + 12px); |
|
||||
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: 2; |
|
||||
padding: 4px 0; |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector-scroll { |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
max-height: 200px; |
|
||||
box-sizing: border-box; |
|
||||
/* #endif */ |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector-empty, |
|
||||
.uni-select__selector-item { |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
display: flex; |
|
||||
cursor: pointer; |
|
||||
/* #endif */ |
|
||||
line-height: 36px; |
|
||||
font-size: 14px; |
|
||||
text-align: center; |
|
||||
/* border-bottom: solid 1px #DDDDDD; */ |
|
||||
padding: 0px 10px; |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector-item:hover { |
|
||||
background-color: #f9f9f9; |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector-empty:last-child, |
|
||||
.uni-select__selector-item:last-child { |
|
||||
/* #ifndef APP-NVUE */ |
|
||||
border-bottom: none; |
|
||||
/* #endif */ |
|
||||
} |
|
||||
|
|
||||
.uni-select__selector__disabled { |
|
||||
opacity: 0.4; |
|
||||
cursor: default; |
|
||||
} |
|
||||
|
|
||||
/* picker 弹出层通用的指示小三角 */ |
|
||||
.uni-popper__arrow, |
|
||||
.uni-popper__arrow::after { |
|
||||
position: absolute; |
|
||||
display: block; |
|
||||
width: 0; |
|
||||
height: 0; |
|
||||
border-color: transparent; |
|
||||
border-style: solid; |
|
||||
border-width: 6px; |
|
||||
} |
|
||||
|
|
||||
.uni-popper__arrow { |
|
||||
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::after { |
|
||||
content: " "; |
|
||||
top: 1px; |
|
||||
margin-left: -6px; |
|
||||
border-top-width: 0; |
|
||||
border-bottom-color: #fff; |
|
||||
} |
|
||||
|
|
||||
.uni-select__input-text { |
|
||||
width: 280px; |
|
||||
color: #333; |
|
||||
white-space: nowrap; |
|
||||
text-overflow: ellipsis; |
|
||||
-o-text-overflow: ellipsis; |
|
||||
overflow: hidden; |
|
||||
} |
|
||||
|
|
||||
.uni-select__input-placeholder { |
|
||||
color: #666; |
|
||||
} |
|
||||
|
|
||||
.uni-select--mask { |
|
||||
position: fixed; |
|
||||
top: 0; |
|
||||
bottom: 0; |
|
||||
right: 0; |
|
||||
left: 0; |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,88 +0,0 @@ |
|||||
{ |
|
||||
"id": "uni-data-select", |
|
||||
"displayName": "uni-data-select 下拉框选择器", |
|
||||
"version": "0.1.3", |
|
||||
"description": "通过数据驱动的下拉框选择器", |
|
||||
"keywords": [ |
|
||||
"uni-ui", |
|
||||
"select", |
|
||||
"uni-data-select", |
|
||||
"下拉框", |
|
||||
"下拉选" |
|
||||
], |
|
||||
"repository": "https://github.com/dcloudio/uni-ui", |
|
||||
"engines": { |
|
||||
"HBuilderX": "^3.1.1" |
|
||||
}, |
|
||||
"directories": { |
|
||||
"example": "../../temps/example_temps" |
|
||||
}, |
|
||||
"dcloudext": { |
|
||||
"category": [ |
|
||||
"前端组件", |
|
||||
"通用组件" |
|
||||
], |
|
||||
"sale": { |
|
||||
"regular": { |
|
||||
"price": "0.00" |
|
||||
}, |
|
||||
"sourcecode": { |
|
||||
"price": "0.00" |
|
||||
} |
|
||||
}, |
|
||||
"contact": { |
|
||||
"qq": "" |
|
||||
}, |
|
||||
"declaration": { |
|
||||
"ads": "无", |
|
||||
"data": "无", |
|
||||
"permissions": "无" |
|
||||
}, |
|
||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
|
||||
}, |
|
||||
"uni_modules": { |
|
||||
"dependencies": ["uni-load-more"], |
|
||||
"encrypt": [], |
|
||||
"platforms": { |
|
||||
"cloud": { |
|
||||
"tcb": "y", |
|
||||
"aliyun": "y" |
|
||||
}, |
|
||||
"client": { |
|
||||
"App": { |
|
||||
"app-vue": "u", |
|
||||
"app-nvue": "n" |
|
||||
}, |
|
||||
"H5-mobile": { |
|
||||
"Safari": "y", |
|
||||
"Android Browser": "y", |
|
||||
"微信浏览器(Android)": "y", |
|
||||
"QQ浏览器(Android)": "y" |
|
||||
}, |
|
||||
"H5-pc": { |
|
||||
"Chrome": "y", |
|
||||
"IE": "y", |
|
||||
"Edge": "y", |
|
||||
"Firefox": "y", |
|
||||
"Safari": "y" |
|
||||
}, |
|
||||
"小程序": { |
|
||||
"微信": "y", |
|
||||
"阿里": "u", |
|
||||
"百度": "u", |
|
||||
"字节跳动": "u", |
|
||||
"QQ": "u", |
|
||||
"京东": "u" |
|
||||
}, |
|
||||
"快应用": { |
|
||||
"华为": "u", |
|
||||
"联盟": "u" |
|
||||
}, |
|
||||
"Vue": { |
|
||||
"vue2": "y", |
|
||||
"vue3": "y" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,8 +0,0 @@ |
|||||
## DataSelect 下拉框选择器 |
|
||||
> **组件名:uni-data-select** |
|
||||
> 代码块: `uDataSelect` |
|
||||
|
|
||||
当选项过多时,使用下拉菜单展示并选择内容 |
|
||||
|
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select) |
|
||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 |
|
||||
@ -0,0 +1,293 @@ |
|||||
|
/** |
||||
|
* 简单处理对象拷贝 |
||||
|
* @param {Obejct} 被拷贝对象 |
||||
|
* @@return {Object} 拷贝对象 |
||||
|
*/ |
||||
|
export const deepCopy = (val) => { |
||||
|
return JSON.parse(JSON.stringify(val)) |
||||
|
} |
||||
|
/** |
||||
|
* 过滤数字类型 |
||||
|
* @param {String} format 数字类型 |
||||
|
* @@return {Boolean} 返回是否为数字类型 |
||||
|
*/ |
||||
|
export const typeFilter = (format) => { |
||||
|
return format === 'int' || format === 'double' || format === 'number' || format === 'timestamp'; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 把 value 转换成指定的类型,用于处理初始值,原因是初始值需要入库不能为 undefined |
||||
|
* @param {String} key 字段名 |
||||
|
* @param {any} value 字段值 |
||||
|
* @param {Object} rules 表单校验规则 |
||||
|
*/ |
||||
|
export const getValue = (key, value, rules) => { |
||||
|
const isRuleNumType = rules.find(val => val.format && typeFilter(val.format)); |
||||
|
const isRuleBoolType = rules.find(val => (val.format && val.format === 'boolean') || val.format === 'bool'); |
||||
|
// 输入类型为 number
|
||||
|
if (!!isRuleNumType) { |
||||
|
if (!value && value !== 0) { |
||||
|
value = null |
||||
|
} else { |
||||
|
value = isNumber(Number(value)) ? Number(value) : value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 输入类型为 boolean
|
||||
|
if (!!isRuleBoolType) { |
||||
|
value = isBoolean(value) ? value : false |
||||
|
} |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取表单数据 |
||||
|
* @param {String|Array} name 真实名称,需要使用 realName 获取 |
||||
|
* @param {Object} data 原始数据 |
||||
|
* @param {any} value 需要设置的值 |
||||
|
*/ |
||||
|
export const setDataValue = (field, formdata, value) => { |
||||
|
formdata[field] = value |
||||
|
return value || '' |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取表单数据 |
||||
|
* @param {String|Array} field 真实名称,需要使用 realName 获取 |
||||
|
* @param {Object} data 原始数据 |
||||
|
*/ |
||||
|
export const getDataValue = (field, data) => { |
||||
|
return objGet(data, field) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取表单类型 |
||||
|
* @param {String|Array} field 真实名称,需要使用 realName 获取 |
||||
|
*/ |
||||
|
export const getDataValueType = (field, data) => { |
||||
|
const value = getDataValue(field, data) |
||||
|
return { |
||||
|
type: type(value), |
||||
|
value |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取表单可用的真实name |
||||
|
* @param {String|Array} name 表单name |
||||
|
* @@return {String} 表单可用的真实name |
||||
|
*/ |
||||
|
export const realName = (name, data = {}) => { |
||||
|
const base_name = _basePath(name) |
||||
|
if (typeof base_name === 'object' && Array.isArray(base_name) && base_name.length > 1) { |
||||
|
const realname = base_name.reduce((a, b) => a += `#${b}`, '_formdata_') |
||||
|
return realname |
||||
|
} |
||||
|
return base_name[0] || name |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 判断是否表单可用的真实name |
||||
|
* @param {String|Array} name 表单name |
||||
|
* @@return {String} 表单可用的真实name |
||||
|
*/ |
||||
|
export const isRealName = (name) => { |
||||
|
const reg = /^_formdata_#*/ |
||||
|
return reg.test(name) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取表单数据的原始格式 |
||||
|
* @@return {Object|Array} object 需要解析的数据 |
||||
|
*/ |
||||
|
export const rawData = (object = {}, name) => { |
||||
|
let newData = JSON.parse(JSON.stringify(object)) |
||||
|
let formData = {} |
||||
|
for(let i in newData){ |
||||
|
let path = name2arr(i) |
||||
|
objSet(formData,path,newData[i]) |
||||
|
} |
||||
|
return formData |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 真实name还原为 array |
||||
|
* @param {*} name |
||||
|
*/ |
||||
|
export const name2arr = (name) => { |
||||
|
let field = name.replace('_formdata_#', '') |
||||
|
field = field.split('#').map(v => (isNumber(v) ? Number(v) : v)) |
||||
|
return field |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 对象中设置值 |
||||
|
* @param {Object|Array} object 源数据 |
||||
|
* @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] |
||||
|
* @param {String} value 需要设置的值 |
||||
|
*/ |
||||
|
export const objSet = (object, path, value) => { |
||||
|
if (typeof object !== 'object') return object; |
||||
|
_basePath(path).reduce((o, k, i, _) => { |
||||
|
if (i === _.length - 1) { |
||||
|
// 若遍历结束直接赋值
|
||||
|
o[k] = value |
||||
|
return null |
||||
|
} else if (k in o) { |
||||
|
// 若存在对应路径,则返回找到的对象,进行下一次遍历
|
||||
|
return o[k] |
||||
|
} else { |
||||
|
// 若不存在对应路径,则创建对应对象,若下一路径是数字,新对象赋值为空数组,否则赋值为空对象
|
||||
|
o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {} |
||||
|
return o[k] |
||||
|
} |
||||
|
}, object) |
||||
|
// 返回object
|
||||
|
return object; |
||||
|
} |
||||
|
|
||||
|
// 处理 path, path有三种形式:'a[0].b.c'、'a.0.b.c' 和 ['a','0','b','c'],需要统一处理成数组,便于后续使用
|
||||
|
function _basePath(path) { |
||||
|
// 若是数组,则直接返回
|
||||
|
if (Array.isArray(path)) return path |
||||
|
// 若有 '[',']',则替换成将 '[' 替换成 '.',去掉 ']'
|
||||
|
return path.replace(/\[/g, '.').replace(/\]/g, '').split('.') |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 从对象中获取值 |
||||
|
* @param {Object|Array} object 源数据 |
||||
|
* @param {String| Array} path 'a.b.c' 或 ['a',0,'b','c'] |
||||
|
* @param {String} defaultVal 如果无法从调用链中获取值的默认值 |
||||
|
*/ |
||||
|
export const objGet = (object, path, defaultVal = 'undefined') => { |
||||
|
// 先将path处理成统一格式
|
||||
|
let newPath = _basePath(path) |
||||
|
// 递归处理,返回最后结果
|
||||
|
let val = newPath.reduce((o, k) => { |
||||
|
return (o || {})[k] |
||||
|
}, object); |
||||
|
return !val || val !== undefined ? val : defaultVal |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 是否为 number 类型 |
||||
|
* @param {any} num 需要判断的值 |
||||
|
* @return {Boolean} 是否为 number |
||||
|
*/ |
||||
|
export const isNumber = (num) => { |
||||
|
return !isNaN(Number(num)) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 是否为 boolean 类型 |
||||
|
* @param {any} bool 需要判断的值 |
||||
|
* @return {Boolean} 是否为 boolean |
||||
|
*/ |
||||
|
export const isBoolean = (bool) => { |
||||
|
return (typeof bool === 'boolean') |
||||
|
} |
||||
|
/** |
||||
|
* 是否有必填字段 |
||||
|
* @param {Object} rules 规则 |
||||
|
* @return {Boolean} 是否有必填字段 |
||||
|
*/ |
||||
|
export const isRequiredField = (rules) => { |
||||
|
let isNoField = false; |
||||
|
for (let i = 0; i < rules.length; i++) { |
||||
|
const ruleData = rules[i]; |
||||
|
if (ruleData.required) { |
||||
|
isNoField = true; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
return isNoField; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取数据类型 |
||||
|
* @param {Any} obj 需要获取数据类型的值 |
||||
|
*/ |
||||
|
export const type = (obj) => { |
||||
|
var class2type = {}; |
||||
|
|
||||
|
// 生成class2type映射
|
||||
|
"Boolean Number String Function Array Date RegExp Object Error".split(" ").map(function(item, index) { |
||||
|
class2type["[object " + item + "]"] = item.toLowerCase(); |
||||
|
}) |
||||
|
if (obj == null) { |
||||
|
return obj + ""; |
||||
|
} |
||||
|
return typeof obj === "object" || typeof obj === "function" ? |
||||
|
class2type[Object.prototype.toString.call(obj)] || "object" : |
||||
|
typeof obj; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 判断两个值是否相等 |
||||
|
* @param {any} a 值 |
||||
|
* @param {any} b 值 |
||||
|
* @return {Boolean} 是否相等 |
||||
|
*/ |
||||
|
export const isEqual = (a, b) => { |
||||
|
//如果a和b本来就全等
|
||||
|
if (a === b) { |
||||
|
//判断是否为0和-0
|
||||
|
return a !== 0 || 1 / a === 1 / b; |
||||
|
} |
||||
|
//判断是否为null和undefined
|
||||
|
if (a == null || b == null) { |
||||
|
return a === b; |
||||
|
} |
||||
|
//接下来判断a和b的数据类型
|
||||
|
var classNameA = toString.call(a), |
||||
|
classNameB = toString.call(b); |
||||
|
//如果数据类型不相等,则返回false
|
||||
|
if (classNameA !== classNameB) { |
||||
|
return false; |
||||
|
} |
||||
|
//如果数据类型相等,再根据不同数据类型分别判断
|
||||
|
switch (classNameA) { |
||||
|
case '[object RegExp]': |
||||
|
case '[object String]': |
||||
|
//进行字符串转换比较
|
||||
|
return '' + a === '' + b; |
||||
|
case '[object Number]': |
||||
|
//进行数字转换比较,判断是否为NaN
|
||||
|
if (+a !== +a) { |
||||
|
return +b !== +b; |
||||
|
} |
||||
|
//判断是否为0或-0
|
||||
|
return +a === 0 ? 1 / +a === 1 / b : +a === +b; |
||||
|
case '[object Date]': |
||||
|
case '[object Boolean]': |
||||
|
return +a === +b; |
||||
|
} |
||||
|
//如果是对象类型
|
||||
|
if (classNameA == '[object Object]') { |
||||
|
//获取a和b的属性长度
|
||||
|
var propsA = Object.getOwnPropertyNames(a), |
||||
|
propsB = Object.getOwnPropertyNames(b); |
||||
|
if (propsA.length != propsB.length) { |
||||
|
return false; |
||||
|
} |
||||
|
for (var i = 0; i < propsA.length; i++) { |
||||
|
var propName = propsA[i]; |
||||
|
//如果对应属性对应值不相等,则返回false
|
||||
|
if (a[propName] !== b[propName]) { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
//如果是数组类型
|
||||
|
if (classNameA == '[object Array]') { |
||||
|
if (a.toString() == b.toString()) { |
||||
|
return true; |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
@ -1,4 +1,5 @@ |
|||||
{ |
{ |
||||
"uni-pagination.prevText": "prev", |
"uni-pagination.prevText": "prev", |
||||
"uni-pagination.nextText": "next" |
"uni-pagination.nextText": "next", |
||||
|
"uni-pagination.piecePerPage": "piece/page" |
||||
} |
} |
||||
|
|||||
@ -1,4 +1,5 @@ |
|||||
{ |
{ |
||||
"uni-pagination.prevText": "anterior", |
"uni-pagination.prevText": "anterior", |
||||
"uni-pagination.nextText": "próxima" |
"uni-pagination.nextText": "prxima", |
||||
|
"uni-pagination.piecePerPage": "Art¨ªculo/P¨¢gina" |
||||
} |
} |
||||
|
|||||
@ -1,4 +1,5 @@ |
|||||
{ |
{ |
||||
"uni-pagination.prevText": "précédente", |
"uni-pagination.prevText": "précédente", |
||||
"uni-pagination.nextText": "suivante" |
"uni-pagination.nextText": "suivante", |
||||
|
"uni-pagination.piecePerPage": "Articles/Pages" |
||||
} |
} |
||||
|
|||||
@ -1,4 +1,5 @@ |
|||||
{ |
{ |
||||
"uni-pagination.prevText": "上一页", |
"uni-pagination.prevText": "上一页", |
||||
"uni-pagination.nextText": "下一页" |
"uni-pagination.nextText": "下一页", |
||||
|
"uni-pagination.piecePerPage": "条/页" |
||||
} |
} |
||||
|
|||||
@ -1,4 +1,5 @@ |
|||||
{ |
{ |
||||
"uni-pagination.prevText": "上一頁", |
"uni-pagination.prevText": "上一頁", |
||||
"uni-pagination.nextText": "下一頁" |
"uni-pagination.nextText": "下一頁", |
||||
|
"uni-pagination.piecePerPage": "條/頁" |
||||
} |
} |
||||
|
|||||
@ -1,39 +0,0 @@ |
|||||
## 2.0.13(2021-11-18) |
|
||||
邱 |
|
||||
## 2.0.12(2021-11-18) |
|
||||
123123 |
|
||||
## 2.0.11(2021-11-18) |
|
||||
0000 |
|
||||
## 2.0.10(2021-11-18) |
|
||||
111234 |
|
||||
## 2.0.9(2021-11-18) |
|
||||
3333 |
|
||||
## 2.0.8(2021-11-18) |
|
||||
=== |
|
||||
## 2.0.7(2021-11-18) |
|
||||
111 |
|
||||
## 2.0.6(2021-05-26) |
|
||||
- test |
|
||||
## 0.0.37(2021-03-23) |
|
||||
- uni-forms 更新 校验器 |
|
||||
- uni-forms 修复 表单规则设置类型为 number 的情况下,值为0校验失败的Bug |
|
||||
|
|
||||
|
|
||||
## 0.0.36(2021-03-23) |
|
||||
- uni-forms 更新 校验器 |
|
||||
- uni-forms 修复 表单规则设置类型为 number 的情况下,值为0校验失败的Bug |
|
||||
|
|
||||
|
|
||||
## 0.0.35(2021-03-23) |
|
||||
- uni-forms 更新 校验器 |
|
||||
- uni-forms 修复 表单规则设置类型为 number 的情况下,值为0校验失败的Bug |
|
||||
|
|
||||
|
|
||||
## 0.0.34(2021-03-23) |
|
||||
- 测试新同步插件 |
|
||||
## 0.0.33(2021-03-09) |
|
||||
- test |
|
||||
## 0.0.32(2021-02-24) |
|
||||
- 更新 read 2 |
|
||||
## 0.0.31(2021-02-24) |
|
||||
- 同步 readme.md |
|
||||
@ -1,26 +0,0 @@ |
|||||
<template> |
|
||||
<view> |
|
||||
测试插件 |
|
||||
</view> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
export default { |
|
||||
data() { |
|
||||
return { |
|
||||
|
|
||||
}; |
|
||||
}, |
|
||||
onLoad() { |
|
||||
let fonts = [] |
|
||||
let obj = {} |
|
||||
fonts.forEach(v=>{ |
|
||||
obj[v.name] = '\\u'+v.unicode |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<style> |
|
||||
|
|
||||
</style> |
|
||||
@ -1,83 +0,0 @@ |
|||||
{ |
|
||||
"id": "uni-test", |
|
||||
"displayName": "Test 测试插件", |
|
||||
"version": "2.0.13", |
|
||||
"description": "测试插件 ", |
|
||||
"keywords": [ |
|
||||
"test" |
|
||||
], |
|
||||
"repository": "https://github.com/dcloudio/uni-ui", |
|
||||
"engines": { |
|
||||
"HBuilderX": "^3.1.3" |
|
||||
}, |
|
||||
"directories": { |
|
||||
"example": "../../temps/example_temps" |
|
||||
}, |
|
||||
"dcloudext": { |
|
||||
"category": [ |
|
||||
"前端组件", |
|
||||
"通用组件" |
|
||||
], |
|
||||
"sale": { |
|
||||
"regular": { |
|
||||
"price": "0.00" |
|
||||
}, |
|
||||
"sourcecode": { |
|
||||
"price": "0.00" |
|
||||
} |
|
||||
}, |
|
||||
"contact": { |
|
||||
"qq": "" |
|
||||
}, |
|
||||
"declaration": { |
|
||||
"ads": "无", |
|
||||
"data": "无", |
|
||||
"permissions": "无" |
|
||||
}, |
|
||||
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" |
|
||||
}, |
|
||||
"uni_modules": { |
|
||||
"dependencies": ["uni-scss"], |
|
||||
"encrypt": [], |
|
||||
"platforms": { |
|
||||
"cloud": { |
|
||||
"tcb": "y", |
|
||||
"aliyun": "y" |
|
||||
}, |
|
||||
"client": { |
|
||||
"App": { |
|
||||
"app-vue": "y", |
|
||||
"app-nvue": "y" |
|
||||
}, |
|
||||
"H5-mobile": { |
|
||||
"Safari": "y", |
|
||||
"Android Browser": "y", |
|
||||
"微信浏览器(Android)": "y", |
|
||||
"QQ浏览器(Android)": "y" |
|
||||
}, |
|
||||
"H5-pc": { |
|
||||
"Chrome": "y", |
|
||||
"IE": "y", |
|
||||
"Edge": "y", |
|
||||
"Firefox": "y", |
|
||||
"Safari": "y" |
|
||||
}, |
|
||||
"小程序": { |
|
||||
"微信": "y", |
|
||||
"阿里": "y", |
|
||||
"百度": "y", |
|
||||
"字节跳动": "y", |
|
||||
"QQ": "y" |
|
||||
}, |
|
||||
"快应用": { |
|
||||
"华为": "y", |
|
||||
"联盟": "y" |
|
||||
}, |
|
||||
"Vue": { |
|
||||
"vue2": "y", |
|
||||
"vue3": "y" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
|
|
||||
|
|
||||
## DataCheckbox 数据驱动的单选复选框 |
|
||||
> **组件名:uni-data-checkbox** |
|
||||
> 代码块: `uDataCheckbox` |
|
||||
|
|
||||
|
|
||||
本组件是基于uni-app基础组件checkbox的封装。本组件要解决问题包括: |
|
||||
|
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-card) |
|
||||
@ -1,10 +0,0 @@ |
|||||
## 0.2.1(2022-05-09) |
|
||||
- 修复 content 为空时仍然弹出的bug |
|
||||
## 0.2.0(2022-05-07) |
|
||||
**注意:破坏性更新** |
|
||||
- 更新 text 属性变更为 content |
|
||||
- 更新 移除 width 属性 |
|
||||
## 0.1.1(2022-04-27) |
|
||||
- 修复 组件根 text 嵌套组件 warning |
|
||||
## 0.1.0(2022-04-21) |
|
||||
- 初始化 |
|
||||
@ -1,68 +0,0 @@ |
|||||
<template> |
|
||||
<view class="uni-tooltip"> |
|
||||
<slot></slot> |
|
||||
<view v-if="content || $slots.content" class="uni-tooltip-popup"> |
|
||||
<slot name="content"> |
|
||||
{{content}} |
|
||||
</slot> |
|
||||
</view> |
|
||||
</view> |
|
||||
</template> |
|
||||
|
|
||||
|
|
||||
<script> |
|
||||
/** |
|
||||
* Tooltip 提示文字 |
|
||||
* @description 常用于展示鼠标 hover 时的提示信息。 |
|
||||
* @tutorial https://uniapp.dcloud.io/component/uniui/uni-tooltip |
|
||||
* @property {String} content 弹出层显示的内容 |
|
||||
* @property {String} placement出现位置, 目前只支持 left |
|
||||
*/ |
|
||||
|
|
||||
|
|
||||
export default { |
|
||||
name: "uni-tooltip", |
|
||||
data() { |
|
||||
return { |
|
||||
|
|
||||
}; |
|
||||
}, |
|
||||
props: { |
|
||||
content: { |
|
||||
type: String, |
|
||||
default: '' |
|
||||
}, |
|
||||
|
|
||||
placement: { |
|
||||
type: String, |
|
||||
default: 'bottom' |
|
||||
}, |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<style> |
|
||||
.uni-tooltip { |
|
||||
position: relative; |
|
||||
cursor: pointer; |
|
||||
} |
|
||||
|
|
||||
.uni-tooltip-popup { |
|
||||
z-index: 1; |
|
||||
display: none; |
|
||||
position: absolute; |
|
||||
left: 0; |
|
||||
background-color: #333; |
|
||||
border-radius: 8px; |
|
||||
color: #fff; |
|
||||
font-size: 12px; |
|
||||
text-align: left; |
|
||||
line-height: 16px; |
|
||||
padding: 12px; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
.uni-tooltip:hover .uni-tooltip-popup { |
|
||||
display: block; |
|
||||
} |
|
||||
</style> |
|
||||
@ -1,88 +0,0 @@ |
|||||
{ |
|
||||
"id": "uni-tooltip", |
|
||||
"displayName": "uni-tooltip 提示文字", |
|
||||
"version": "0.2.1", |
|
||||
"description": "Tooltip 提示文字", |
|
||||
"keywords": [ |
|
||||
"uni-tooltip", |
|
||||
"uni-ui", |
|
||||
"tooltip", |
|
||||
"tip", |
|
||||
"文字提示" |
|
||||
], |
|
||||
"repository": "https://github.com/dcloudio/uni-ui", |
|
||||
"engines": { |
|
||||
"HBuilderX": "" |
|
||||
}, |
|
||||
"directories": { |
|
||||
"example": "../../temps/example_temps" |
|
||||
}, |
|
||||
"dcloudext": { |
|
||||
"category": [ |
|
||||
"前端组件", |
|
||||
"通用组件" |
|
||||
], |
|
||||
"sale": { |
|
||||
"regular": { |
|
||||
"price": "0.00" |
|
||||
}, |
|
||||
"sourcecode": { |
|
||||
"price": "0.00" |
|
||||
} |
|
||||
}, |
|
||||
"contact": { |
|
||||
"qq": "" |
|
||||
}, |
|
||||
"declaration": { |
|
||||
"ads": "无 ", |
|
||||
"data": "无", |
|
||||
"permissions": "无" |
|
||||
}, |
|
||||
"npmurl": "" |
|
||||
}, |
|
||||
"uni_modules": { |
|
||||
"dependencies": [], |
|
||||
"encrypt": [], |
|
||||
"platforms": { |
|
||||
"cloud": { |
|
||||
"tcb": "y", |
|
||||
"aliyun": "y" |
|
||||
}, |
|
||||
"client": { |
|
||||
"Vue": { |
|
||||
"vue2": "y", |
|
||||
"vue3": "y" |
|
||||
}, |
|
||||
"App": { |
|
||||
"app-vue": "y", |
|
||||
"app-nvue": "u" |
|
||||
}, |
|
||||
"H5-mobile": { |
|
||||
"Safari": "y", |
|
||||
"Android Browser": "y", |
|
||||
"微信浏览器(Android)": "y", |
|
||||
"QQ浏览器(Android)": "y" |
|
||||
}, |
|
||||
"H5-pc": { |
|
||||
"Chrome": "y", |
|
||||
"IE": "y", |
|
||||
"Edge": "y", |
|
||||
"Firefox": "y", |
|
||||
"Safari": "y" |
|
||||
}, |
|
||||
"小程序": { |
|
||||
"微信": "y", |
|
||||
"阿里": "u", |
|
||||
"百度": "u", |
|
||||
"字节跳动": "u", |
|
||||
"QQ": "u", |
|
||||
"京东": "u" |
|
||||
}, |
|
||||
"快应用": { |
|
||||
"华为": "u", |
|
||||
"联盟": "u" |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,8 +0,0 @@ |
|||||
## Badge 数字角标 |
|
||||
> **组件名:uni-tooltip** |
|
||||
> 代码块: `uTooltip` |
|
||||
|
|
||||
数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景, |
|
||||
|
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-tooltip) |
|
||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 |
|
||||
Loading…
Reference in new issue