Compare commits

..

10 Commits

Author SHA1 Message Date
RuoYi
c7b4db67bf 完成输入和单位换算一体组件 2025-02-07 07:07:08 +08:00
RuoYi
295c0f2ced 支持Modal弹框自定义标题 2023-07-12 13:14:47 +08:00
RuoYi
c27a8aa129 升级uni-ui到最新版本1.4.27 2023-07-12 09:42:10 +08:00
RuoYi
296b15acbe 新增是否开启用户注册功能 2023-07-11 17:09:59 +08:00
若依
47a18b8422
!5 【轻量级PR】:修复从本地缓存中同步获取和移除指定key时因未重新获取本地缓存导致的BUG
Merge pull request !5 from 耿嘉祺/master
2023-07-10 06:14:54 +00:00
耿嘉祺
6533168310 修复从本地缓存中同步获取和移除指定key时因未重新获取本地缓存导致的BUG 2023-05-11 12:17:49 +08:00
RuoYi
3b7b1f21e3 修复ColorUI缺少Icon的问题(I6BZE6) 2023-04-06 15:17:04 +08:00
RuoYi
ee5b341812 RuoYi-App 1.1.0 2022-12-28 13:59:09 +08:00
RuoYi
1c5aefbf4f 优化登录页面验证码显示效果 2022-12-28 13:32:49 +08:00
RuoYi
55fb5c5f61 升级uni-ui到最新版本1.4.23 2022-12-28 10:03:07 +08:00
110 changed files with 7148 additions and 4351 deletions

View File

@ -1,11 +1,11 @@
<p align="center"> <p align="center">
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-43e3941654fa3054c9684bf53d1b1d356a1.png"> <img alt="logo" src="https://oscimg.oschina.net/oscnet/up-43e3941654fa3054c9684bf53d1b1d356a1.png">
</p> </p>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v1.0.0</h1> <h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v1.1.0</h1>
<h4 align="center">基于UniApp开发的轻量级移动端框架</h4> <h4 align="center">基于UniApp开发的轻量级移动端框架</h4>
<p align="center"> <p align="center">
<a href="https://gitee.com/y_project/RuoYi-App/stargazers"><img src="https://gitee.com/y_project/RuoYi-App/badge/star.svg?theme=dark"></a> <a href="https://gitee.com/y_project/RuoYi-App/stargazers"><img src="https://gitee.com/y_project/RuoYi-App/badge/star.svg?theme=dark"></a>
<a href="https://gitee.com/y_project/RuoYi-App"><img src="https://img.shields.io/badge/RuoYi-v1.0.0-brightgreen.svg"></a> <a href="https://gitee.com/y_project/RuoYi-App"><img src="https://img.shields.io/badge/RuoYi-v1.1.0-brightgreen.svg"></a>
<a href="https://gitee.com/y_project/RuoYi-App/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a> <a href="https://gitee.com/y_project/RuoYi-App/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
</p> </p>
@ -25,7 +25,7 @@ RuoYi App 移动解决方案采用uniapp框架一份代码多终端适配
- 官网网站:[http://ruoyi.vip](http://ruoyi.vip) - 官网网站:[http://ruoyi.vip](http://ruoyi.vip)
- 文档地址:[http://doc.ruoyi.vip](http://doc.ruoyi.vip) - 文档地址:[http://doc.ruoyi.vip](http://doc.ruoyi.vip)
- H5页体验[http://h5.ruoyi.vip](http://h5.ruoyi.vip) - H5页体验[http://h5.ruoyi.vip](http://h5.ruoyi.vip)
- QQ交流群 ①133713780 - QQ交流群 ①133713780(满)、②146013835
- 小程序体验 - 小程序体验
<img src="https://oscimg.oschina.net/oscnet/up-26c76dc90b92acdbd9ac8cd5252f07c8ad9.jpg" alt="小程序演示"/> <img src="https://oscimg.oschina.net/oscnet/up-26c76dc90b92acdbd9ac8cd5252f07c8ad9.jpg" alt="小程序演示"/>

View File

@ -18,6 +18,18 @@ export function login(username, password, code, uuid) {
}) })
} }
// 注册方法
export function register(data) {
return request({
url: '/register',
headers: {
isToken: false
},
method: 'post',
data: data
})
}
// 获取用户详细信息 // 获取用户详细信息
export function getInfo() { export function getInfo() {
return request({ return request({

47
api/system/conversion.js Normal file
View File

@ -0,0 +1,47 @@
import upload from '@/utils/upload'
import request from '@/utils/request'
// 查询单位换算列表
export function listConversion(query) {
return request({
url: '/system/conversion/list',
method: 'get',
params: query
})
}
// 查询单位换算详细
export function getConversion(id) {
return request({
url: '/system/conversion/' + id,
method: 'get'
})
}
// 新增单位换算
export function addConversion(data) {
return request({
url: '/system/conversion',
method: 'post',
data: data
})
}
// 修改单位换算
export function updateConversion(data) {
return request({
url: '/system/conversion',
method: 'put',
data: data
})
}
// 删除单位换算
export function delConversion(id) {
return request({
url: '/system/conversion/' + id,
method: 'delete'
})
}

View File

@ -1,12 +1,13 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
baseUrl: 'http://localhost:8080', // baseUrl: 'https://vue.ruoyi.vip/prod-api',
baseUrl: 'http://192.168.3.19:9090',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称
name: "ruoyi-app", name: "ruoyi-app",
// 应用版本 // 应用版本
version: "1.0.0", version: "1.1.0",
// 应用logo // 应用logo
logo: "/static/logo.png", logo: "/static/logo.png",
// 官方网站 // 官方网站

View File

@ -1,8 +1,8 @@
{ {
"name": "若依移动端", "name": "若依移动端",
"appid" : "__UNI__25A9D80", "appid": "__UNI__1347B29",
"description": "", "description": "",
"versionName" : "1.0.0", "versionName": "1.1.0",
"versionCode": "100", "versionCode": "100",
"transformPx": false, "transformPx": false,
"app-plus": { "app-plus": {

5
package.json Normal file
View File

@ -0,0 +1,5 @@
{
"dependencies": {
"bignumber.js": "^9.1.2"
}
}

View File

@ -0,0 +1,76 @@
/* ===pages-tool===
pages-tool使
pages-toolpages.josn便
使
,pages.json
pages.jsonpaes-config.jsonpages.josn,
pages.json
*/
{
//,globalStyle使pages.json
//"globalStyle" : "pages-config/globalStyle.json"
//pages.jsonglobalStyle
"globalStyle" : "",
//,easycom使pages.json
//"easycom" : "pages-config/easycom.json"
//pages.jsoneasycom
"easycom" : "",
//,tabBar使pages.json
//"tabBar" : "pages-config/tabBar.json"
//pages.jsontabBar
"tabBar" : "",
//,pages使pages.json
//"pages" : ["pages-config/pages-moduleA.json", "pages-config/pages-moduleB.json", "pages-config/pages-moduleC.json", ...]
//pages.jsonpages
"pages" : [],
//,condition使pages.json
//"condition" : "pages-config/condition.json"
//pages.jsoncondition
"condition" : "",
//,pages使pages.json
//"subPackages" : [pages-config/subPackages-moduleNameA.json, pages-config/subPackages-moduleNameB.json, ...],
//pages.jsonsubPackages
//pages
"subPackages" : [],
//,preloadRule使pages.json
//"preloadRule" : "pages-config/preloadRule.json"
//pages.jsonpreloadRule
"preloadRule" : "",
//"workers" : "pages-config/workers.json"
//pages.json
"workers" : "",
//,leftWindow使pages.json
//"leftWindow" : "pages-config/leftWindow.json"
//pages.jsonleftWindow
"leftWindow" : "",
//,topWindow使pages.json
//"topWindow" : "pages-config/topWindow.json"
//pages.jsontopWindow
"topWindow" : "",
//,rightWindow使pages.json
//"rightWindow" : "pages-config/rightWindow.json"
//pages.jsonrightWindow
"rightWindow" : "",
//,uniIdRouter使pages.json
//"uniIdRouter" : "pages-config/uniIdRouter.json"
//pages.jsonuniIdRouter
"uniIdRouter" : "",
//page.json
//"entryPagePath" : "/...." "entryPagePath" : "pages-config/entryPagePath.json"
"entryPagePath": ""
}

40
pages-config.json Normal file
View File

@ -0,0 +1,40 @@
/* ===pages-tool===
pages-tool
pages-toolpages.josn便
使
,pages.json
pages.jsonpaes-config.jsonpages.josn,
pages.json
*/
{
"globalStyle" : "pages-config/globalStyle.json",
"easycom" : "",
"tabBar" : "pages-config/tabBar.json",
"pages" : ["pages-config/pages-all.json"],
"condition" : "",
"leftWindow" : "",
"topWindow" : "",
"rightWindow" : "",
"uniIdRouter" : "",
///
"subPackages" : [],
"preloadRule" : "",
"workers" : "",
"entryPagePath": ""
}

View File

@ -0,0 +1,8 @@
/* /// Pages-Tool: pages-toolpages-config.json,pages.json*/
{
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "RuoYi",
"navigationBarBackgroundColor": "#FFFFFF"
}
}

View File

@ -0,0 +1,75 @@
/* /// Pages-Tool: pages-toolpages-config.json,pages.json*/
{
"pages": [{
"path": "pages/login",
"style": {
"navigationBarTitleText": "登录"
}
}, {
"path": "pages/register",
"style": {
"navigationBarTitleText": "注册"
}
}, {
"path": "pages/index",
"style": {
"navigationBarTitleText": "若依移动端框架",
"navigationStyle": "custom"
}
}, {
"path": "pages/work/index",
"style": {
"navigationBarTitleText": "工作台"
}
}, {
"path": "pages/mine/index",
"style": {
"navigationBarTitleText": "我的"
}
}, {
"path": "pages/mine/avatar/index",
"style": {
"navigationBarTitleText": "修改头像"
}
}, {
"path": "pages/mine/info/index",
"style": {
"navigationBarTitleText": "个人信息"
}
}, {
"path": "pages/mine/info/edit",
"style": {
"navigationBarTitleText": "编辑资料"
}
}, {
"path": "pages/mine/pwd/index",
"style": {
"navigationBarTitleText": "修改密码"
}
}, {
"path": "pages/mine/setting/index",
"style": {
"navigationBarTitleText": "应用设置"
}
}, {
"path": "pages/mine/help/index",
"style": {
"navigationBarTitleText": "常见问题"
}
}, {
"path": "pages/mine/about/index",
"style": {
"navigationBarTitleText": "关于我们"
}
}, {
"path": "pages/common/webview/index",
"style": {
"navigationBarTitleText": "浏览网页"
}
}, {
"path": "pages/common/textview/index",
"style": {
"navigationBarTitleText": "浏览文本"
}
}]
}

25
pages-config/tabBar.json Normal file
View File

@ -0,0 +1,25 @@
/* /// Pages-Tool: pages-toolpages-config.json,pages.json*/
{
"tabBar": {
"color": "#000000",
"selectedColor": "#000000",
"borderStyle": "white",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index",
"iconPath": "static/images/tabbar/home.png",
"selectedIconPath": "static/images/tabbar/home_.png",
"text": "首页"
}, {
"pagePath": "pages/work/index",
"iconPath": "static/images/tabbar/work.png",
"selectedIconPath": "static/images/tabbar/work_.png",
"text": "计算工具"
}, {
"pagePath": "pages/mine/index",
"iconPath": "static/images/tabbar/mine.png",
"selectedIconPath": "static/images/tabbar/mine_.png",
"text": "我的"
}]
}
}

View File

@ -4,6 +4,11 @@
"style": { "style": {
"navigationBarTitleText": "登录" "navigationBarTitleText": "登录"
} }
}, {
"path": "pages/register",
"style": {
"navigationBarTitleText": "注册"
}
}, { }, {
"path": "pages/index", "path": "pages/index",
"style": { "style": {
@ -80,14 +85,13 @@
"pagePath": "pages/work/index", "pagePath": "pages/work/index",
"iconPath": "static/images/tabbar/work.png", "iconPath": "static/images/tabbar/work.png",
"selectedIconPath": "static/images/tabbar/work_.png", "selectedIconPath": "static/images/tabbar/work_.png",
"text": "工作台" "text": "计算工具"
}, { }, {
"pagePath": "pages/mine/index", "pagePath": "pages/mine/index",
"iconPath": "static/images/tabbar/mine.png", "iconPath": "static/images/tabbar/mine.png",
"selectedIconPath": "static/images/tabbar/mine_.png", "selectedIconPath": "static/images/tabbar/mine_.png",
"text": "我的" "text": "我的"
} }]
]
}, },
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",

View File

@ -1,8 +1,7 @@
<template> <template>
<view class="normal-login-container"> <view class="normal-login-container">
<view class="logo-content align-center justify-center flex"> <view class="logo-content align-center justify-center flex">
<image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix"> <image style="width: 100rpx; height: 100rpx" :src="globalConfig.appInfo.logo" mode="widthFix"></image>
</image>
<text class="title">若依移动端登录</text> <text class="title">若依移动端登录</text>
</view> </view>
<view class="login-form-content"> <view class="login-form-content">
@ -14,98 +13,118 @@
<view class="iconfont icon-password icon"></view> <view class="iconfont icon-password icon"></view>
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" /> <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
</view> </view>
<view class="input-item flex align-center" v-if="captchaEnabled"> <view class="input-item flex align-center" style="width: 60%; margin: 0px" v-if="captchaEnabled">
<view class="iconfont icon-code icon"></view> <view class="iconfont icon-code icon"></view>
<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" /> <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<view class="login-code">
<image :src="codeUrl" @click="getCode" class="login-code-img"></image> <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
</view> </view>
</view>
<view class="action-btn"> <view class="action-btn">
<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button> <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
</view> </view>
<view class="reg text-center" v-if="register">
<text class="text-grey1">没有账号</text>
<text @click="handleUserRegister" class="text-blue">立即注册</text>
</view> </view>
<view class="xieyi text-center"> <view class="xieyi text-center">
<text class="text-grey1">登录即代表同意</text> <text class="text-grey1">登录即代表同意</text>
<text @click="handleUserAgrement" class="text-blue">用户协议</text> <text @click="handleUserAgrement" class="text-blue">用户协议</text>
<text @click="handlePrivacy" class="text-blue">隐私协议</text> <text @click="handlePrivacy" class="text-blue">隐私协议</text>
</view> </view>
</view> </view>
</view>
</template> </template>
<script> <script>
import { getCodeImg } from '@/api/login' import { getCodeImg } from '@/api/login';
export default { export default {
data() { data() {
return { return {
codeUrl: "", codeUrl: '',
captchaEnabled: true, captchaEnabled: true,
//
register: false,
globalConfig: getApp().globalData.config, globalConfig: getApp().globalData.config,
loginForm: { loginForm: {
username: "admin", username: 'admin',
password: "admin123", password: 'admin123',
code: "", code: '',
uuid: '' uuid: ''
} }
} };
}, },
created() { created() {
this.getCode() this.getCode();
}, },
methods: { methods: {
handleConversion(result) {
// console.log(':', result.initialValue);
// console.log(':', result.newValue);
// console.log(':', result.oldUnit);
// console.log(':', result.newUnit);
},
//
handleUserRegister() {
this.$tab.redirectTo(`/pages/register`);
},
// //
handlePrivacy() { handlePrivacy() {
let site = this.globalConfig.appInfo.agreements[0] let site = this.globalConfig.appInfo.agreements[0];
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`) this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`);
}, },
// //
handleUserAgrement() { handleUserAgrement() {
let site = this.globalConfig.appInfo.agreements[1] let site = this.globalConfig.appInfo.agreements[1];
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`) this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`);
}, },
// //
getCode() { getCode() {
getCodeImg().then(res => { getCodeImg().then((res) => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled;
if (this.captchaEnabled) { if (this.captchaEnabled) {
this.codeUrl = 'data:image/gif;base64,' + res.img this.codeUrl = 'data:image/gif;base64,' + res.img;
this.loginForm.uuid = res.uuid this.loginForm.uuid = res.uuid;
} }
}) });
}, },
// //
async handleLogin() { async handleLogin() {
if (this.loginForm.username === "") { if (this.loginForm.username === '') {
this.$modal.msgError("请输入您的账号") this.$modal.msgError('请输入您的账号');
} else if (this.loginForm.password === "") { } else if (this.loginForm.password === '') {
this.$modal.msgError("请输入您的密码") this.$modal.msgError('请输入您的密码');
} else if (this.loginForm.code === "" && this.captchaEnabled) { } else if (this.loginForm.code === '' && this.captchaEnabled) {
this.$modal.msgError("请输入验证码") this.$modal.msgError('请输入验证码');
} else { } else {
this.$modal.loading("登录中,请耐心等待...") this.$modal.loading('登录中,请耐心等待...');
this.pwdLogin() this.pwdLogin();
} }
}, },
// //
async pwdLogin() { async pwdLogin() {
this.$store.dispatch('Login', this.loginForm).then(() => { this.$store
this.$modal.closeLoading() .dispatch('Login', this.loginForm)
this.loginSuccess() .then(() => {
}).catch(() => { this.$modal.closeLoading();
if (this.captchaEnabled) { this.loginSuccess();
this.getCode()
}
}) })
.catch(() => {
if (this.captchaEnabled) {
this.getCode();
}
});
}, },
// //
loginSuccess(result) { loginSuccess(result) {
// //
this.$store.dispatch('GetInfo').then(res => { this.$store.dispatch('GetInfo').then((res) => {
this.$tab.reLaunch('/pages/index') this.$tab.reLaunch('/pages/index');
}) });
}
} }
} }
};
</script> </script>
<style lang="scss"> <style lang="scss">
@ -156,7 +175,6 @@
text-align: left; text-align: left;
padding-left: 15px; padding-left: 15px;
} }
} }
.login-btn { .login-btn {
@ -164,18 +182,26 @@
height: 45px; height: 45px;
} }
.reg {
margin-top: 15px;
}
.xieyi { .xieyi {
color: #333; color: #333;
margin-top: 20px; margin-top: 20px;
} }
}
.easyinput { .login-code {
width: 100%; height: 38px;
} float: right;
}
.login-code-img { .login-code-img {
height: 45px; height: 38px;
position: absolute;
margin-left: 10px;
width: 200rpx;
}
}
}
} }
</style> </style>

View File

@ -1,5 +1,13 @@
<template> <template>
<view class="mine-container" :style="{ height: `${windowHeight}px` }"> <view class="mine-container" :style="{ height: `${windowHeight}px` }">
<yjly-number_unit
:unitType="'length'"
:unitName.sync="selectedUnitName"
:value.sync="inputValue"
:showEnglishOnly="true"
:decimalPlaces="5"
@conversion="handleConversion"
></yjly-number_unit>
<!--顶部个人信息栏--> <!--顶部个人信息栏-->
<view class="header-section"> <view class="header-section">
<view class="flex padding justify-between"> <view class="flex padding justify-between">
@ -7,15 +15,10 @@
<view v-if="!avatar" class="cu-avatar xl round bg-white"> <view v-if="!avatar" class="cu-avatar xl round bg-white">
<view class="iconfont icon-people text-gray icon"></view> <view class="iconfont icon-people text-gray icon"></view>
</view> </view>
<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"> <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"></image>
</image> <view v-if="!name" @click="handleToLogin" class="login-tip">点击登录</view>
<view v-if="!name" @click="handleToLogin" class="login-tip">
点击登录
</view>
<view v-if="name" @click="handleToInfo" class="user-info"> <view v-if="name" @click="handleToInfo" class="user-info">
<view class="u_title"> <view class="u_title">用户名{{ name }}</view>
用户名{{ name }}
</view>
</view> </view>
</view> </view>
<view @click="handleToInfo" class="flex align-center"> <view @click="handleToInfo" class="flex align-center">
@ -71,66 +74,75 @@
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import storage from '@/utils/storage' import storage from '@/utils/storage';
export default { export default {
data() { data() {
return { return {
selectedUnitName: 'm(米)',
inputValue: 12,
name: this.$store.state.user.name, name: this.$store.state.user.name,
version: getApp().globalData.config.appInfo.version version: getApp().globalData.config.appInfo.version
} };
}, },
computed: { computed: {
avatar() { avatar() {
return this.$store.state.user.avatar return this.$store.state.user.avatar;
}, },
windowHeight() { windowHeight() {
return uni.getSystemInfoSync().windowHeight - 50 return uni.getSystemInfoSync().windowHeight - 50;
} }
}, },
methods: { methods: {
handleConversion(result) {
// console.log(':', result.initialValue);
// console.log(':', result.newValue);
// console.log(':', result.oldUnit);
// console.log(':', result.newUnit);
},
handleToInfo() { handleToInfo() {
this.$tab.navigateTo('/pages/mine/info/index') this.$tab.navigateTo('/pages/mine/info/index');
}, },
handleToEditInfo() { handleToEditInfo() {
this.$tab.navigateTo('/pages/mine/info/edit') this.$tab.navigateTo('/pages/mine/info/edit');
}, },
handleToSetting() { handleToSetting() {
this.$tab.navigateTo('/pages/mine/setting/index') this.$tab.navigateTo('/pages/mine/setting/index');
}, },
handleToLogin() { handleToLogin() {
this.$tab.reLaunch('/pages/login') this.$tab.reLaunch('/pages/login');
}, },
handleToAvatar() { handleToAvatar() {
this.$tab.navigateTo('/pages/mine/avatar/index') this.$tab.navigateTo('/pages/mine/avatar/index');
}, },
handleLogout() { handleLogout() {
this.$modal.confirm('确定注销并退出系统吗?').then(() => { this.$modal.confirm('确定注销并退出系统吗?').then(() => {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
this.$tab.reLaunch('/pages/index') this.$tab.reLaunch('/pages/index');
}) });
}) });
}, },
handleHelp() { handleHelp() {
this.$tab.navigateTo('/pages/mine/help/index') this.$tab.navigateTo('/pages/mine/help/index');
}, },
handleAbout() { handleAbout() {
this.$tab.navigateTo('/pages/mine/about/index') this.$tab.navigateTo('/pages/mine/about/index');
}, },
handleJiaoLiuQun() { handleJiaoLiuQun() {
this.$modal.showToast('QQ群133713780') this.$modal.showToast('QQ群133713780、②146013835');
}, },
handleBuilding() { handleBuilding() {
this.$modal.showToast('模块建设中~') this.$modal.showToast('模块建设中~');
}
} }
} }
};
</script> </script>
<style lang="scss"> <style lang="scss">
@ -142,7 +154,6 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
.header-section { .header-section {
padding: 15px 15px 45px 15px; padding: 15px 15px 45px 15px;
background-color: #3c96f3; background-color: #3c96f3;

196
pages/register.vue Normal file
View File

@ -0,0 +1,196 @@
<template>
<view class="normal-login-container">
<view class="logo-content align-center justify-center flex">
<image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
</image>
<text class="title">若依移动端注册</text>
</view>
<view class="login-form-content">
<view class="input-item flex align-center">
<view class="iconfont icon-user icon"></view>
<input v-model="registerForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
</view>
<view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view>
<input v-model="registerForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
</view>
<view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view>
<input v-model="registerForm.confirmPassword" type="password" class="input" placeholder="请输入重复密码" maxlength="20" />
</view>
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
<view class="iconfont icon-code icon"></view>
<input v-model="registerForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<view class="login-code">
<image :src="codeUrl" @click="getCode" class="login-code-img"></image>
</view>
</view>
<view class="action-btn">
<button @click="handleRegister()" class="register-btn cu-btn block bg-blue lg round">注册</button>
</view>
</view>
<view class="xieyi text-center">
<text @click="handleUserLogin" class="text-blue">使用已有账号登录</text>
</view>
</view>
</template>
<script>
import { getCodeImg, register } from '@/api/login'
export default {
data() {
return {
codeUrl: "",
captchaEnabled: true,
globalConfig: getApp().globalData.config,
registerForm: {
username: "",
password: "",
confirmPassword: "",
code: "",
uuid: ''
}
}
},
created() {
this.getCode()
},
methods: {
//
handleUserLogin() {
this.$tab.navigateTo(`/pages/login`)
},
//
getCode() {
getCodeImg().then(res => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
if (this.captchaEnabled) {
this.codeUrl = 'data:image/gif;base64,' + res.img
this.registerForm.uuid = res.uuid
}
})
},
//
async handleRegister() {
if (this.registerForm.username === "") {
this.$modal.msgError("请输入您的账号")
} else if (this.registerForm.password === "") {
this.$modal.msgError("请输入您的密码")
} else if (this.registerForm.confirmPassword === "") {
this.$modal.msgError("请再次输入您的密码")
} else if (this.registerForm.password !== this.registerForm.confirmPassword) {
this.$modal.msgError("两次输入的密码不一致")
} else if (this.registerForm.code === "" && this.captchaEnabled) {
this.$modal.msgError("请输入验证码")
} else {
this.$modal.loading("注册中,请耐心等待...")
this.register()
}
},
//
async register() {
register(this.registerForm).then(res => {
this.$modal.closeLoading()
uni.showModal({
title: "系统提示",
content: "恭喜你,您的账号 " + this.registerForm.username + " 注册成功!",
success: function (res) {
if (res.confirm) {
uni.redirectTo({ url: `/pages/login` });
}
}
})
}).catch(() => {
if (this.captchaEnabled) {
this.getCode()
}
})
},
//
registerSuccess(result) {
//
this.$store.dispatch('GetInfo').then(res => {
this.$tab.reLaunch('/pages/index')
})
}
}
}
</script>
<style lang="scss">
page {
background-color: #ffffff;
}
.normal-login-container {
width: 100%;
.logo-content {
width: 100%;
font-size: 21px;
text-align: center;
padding-top: 15%;
image {
border-radius: 4px;
}
.title {
margin-left: 10px;
}
}
.login-form-content {
text-align: center;
margin: 20px auto;
margin-top: 15%;
width: 80%;
.input-item {
margin: 20px auto;
background-color: #f5f6f7;
height: 45px;
border-radius: 20px;
.icon {
font-size: 38rpx;
margin-left: 10px;
color: #999;
}
.input {
width: 100%;
font-size: 14px;
line-height: 20px;
text-align: left;
padding-left: 15px;
}
}
.register-btn {
margin-top: 40px;
height: 45px;
}
.xieyi {
color: #333;
margin-top: 20px;
}
.login-code {
height: 38px;
float: right;
.login-code-img {
height: 38px;
position: absolute;
margin-left: 10px;
width: 200rpx;
}
}
}
}
</style>

View File

@ -5,7 +5,7 @@ const loginPage = "/pages/login"
// 页面白名单 // 页面白名单
const whiteList = [ const whiteList = [
'/pages/login', '/pages/common/webview/index' '/pages/login', '/pages/register', '/pages/common/webview/index'
] ]
// 检查地址白名单 // 检查地址白名单

View File

@ -25,18 +25,18 @@ export default {
uni.hideToast() uni.hideToast()
}, },
// 弹出提示 // 弹出提示
alert(content) { alert(content, title) {
uni.showModal({ uni.showModal({
title: '提示', title: title || '系统提示',
content: content, content: content,
showCancel: false showCancel: false
}) })
}, },
// 确认窗体 // 确认窗体
confirm(content) { confirm(content, title) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.showModal({ uni.showModal({
title: '系统提示', title: title || '系统提示',
content: content, content: content,
cancelText: '取消', cancelText: '取消',
confirmText: '确定', confirmText: '确定',

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,7 @@
## 1.2.22023-01-28
- 修复 运行/打包 控制台警告问题
## 1.2.12022-09-05
- 修复 当 text 超过 max-num 时badge 的宽度计算是根据 text 的长度计算,更改为 css 计算实际展示宽度,详见:[https://ask.dcloud.net.cn/question/150473](https://ask.dcloud.net.cn/question/150473)
## 1.2.02021-11-19 ## 1.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-badge](https://uniapp.dcloud.io/component/uniui/uni-badge)

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="uni-badge--x"> <view class="uni-badge--x">
<slot /> <slot />
<text v-if="text" :class="classNames" :style="[badgeWidth, positionStyle, customStyle, dotStyle]" <text v-if="text" :class="classNames" :style="[positionStyle, customStyle, dotStyle]"
class="uni-badge" @click="onClick()">{{displayValue}}</text> class="uni-badge" @click="onClick()">{{displayValue}}</text>
</view> </view>
</template> </template>
@ -130,16 +130,13 @@
const match = whiteList[this.absolute] const match = whiteList[this.absolute]
return match ? match : whiteList['rightTop'] return match ? match : whiteList['rightTop']
}, },
badgeWidth() {
return {
width: `${this.width}px`
}
},
dotStyle() { dotStyle() {
if (!this.isDot) return {} if (!this.isDot) return {}
return { return {
width: '10px', width: '10px',
minWidth: '0',
height: '10px', height: '10px',
padding: '0',
borderRadius: '10px' borderRadius: '10px'
} }
}, },
@ -195,10 +192,13 @@
display: flex; display: flex;
overflow: hidden; overflow: hidden;
box-sizing: border-box; box-sizing: border-box;
font-feature-settings: "tnum";
min-width: 20px;
/* #endif */ /* #endif */
justify-content: center; justify-content: center;
flex-direction: row; flex-direction: row;
height: 20px; height: 20px;
padding: 0 4px;
line-height: 18px; line-height: 18px;
color: #fff; color: #fff;
border-radius: 100px; border-radius: 100px;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-badge", "id": "uni-badge",
"displayName": "uni-badge 数字角标", "displayName": "uni-badge 数字角标",
"version": "1.2.0", "version": "1.2.2",
"description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。", "description": "数字角标(徽章)组件,在元素周围展示消息提醒,一般用于列表、九宫格、按钮等地方。",
"keywords": [ "keywords": [
"", "",
@ -19,10 +19,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -39,7 +35,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss"], "dependencies": ["uni-scss"],

View File

@ -1,5 +1,5 @@
## 0.1.22022-06-08 ## 0.1.22022-06-08
- 修复 微信小程序 separator 不显示问题 - 修复 微信小程序 separator 不显示的Bug
## 0.1.12022-06-02 ## 0.1.12022-06-02
- 新增 支持 uni.scss 修改颜色 - 新增 支持 uni.scss 修改颜色
## 0.1.02022-04-21 ## 0.1.02022-04-21

View File

@ -1,13 +1,23 @@
## 1.4.102023-04-10
- 修复 某些情况 monthSwitch 未触发的Bug
## 1.4.92023-02-02
- 修复 某些情况切换月份错误的Bug
## 1.4.82023-01-30
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/161964)
## 1.4.72022-09-16
- 优化 支持使用 uni-scss 控制主题色
## 1.4.62022-09-08
- 修复 表头年月切换导致改变当前日期为选择月1号且未触发change事件的Bug
## 1.4.52022-02-25 ## 1.4.52022-02-25
- 修复 条件编译 nvue 不支持的 css 样式 - 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.42022-02-25 ## 1.4.42022-02-25
- 修复 条件编译 nvue 不支持的 css 样式 - 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.32021-09-22 ## 1.4.32021-09-22
- 修复 startDate、 endDate 属性失效的 bug - 修复 startDate、 endDate 属性失效的Bug
## 1.4.22021-08-24 ## 1.4.22021-08-24
- 新增 支持国际化 - 新增 支持国际化
## 1.4.12021-08-05 ## 1.4.12021-08-05
- 修复 弹出层被 tabbar 遮盖 bug - 修复 弹出层被 tabbar 遮盖的Bug
## 1.4.02021-07-30 ## 1.4.02021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) - 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.3.162021-05-12 ## 1.3.162021-05-12

View File

@ -51,11 +51,10 @@
</template> </template>
<script> <script>
import { import { initVueI18n } from '@dcloudio/uni-i18n'
initVueI18n import i18nMessages from './i18n/index.js'
} from '@dcloudio/uni-i18n' const { t } = initVueI18n(i18nMessages)
import messages from './i18n/index.js'
const { t } = initVueI18n(messages)
export default { export default {
emits:['change'], emits:['change'],
props: { props: {
@ -102,7 +101,7 @@
$uni-color-error: #e43d33; $uni-color-error: #e43d33;
$uni-opacity-disabled: 0.3; $uni-opacity-disabled: 0.3;
$uni-text-color-disable:#c0c0c0; $uni-text-color-disable:#c0c0c0;
$uni-color-primary: #2979ff; $uni-primary: #2979ff !default;
.uni-calendar-item__weeks-box { .uni-calendar-item__weeks-box {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -152,11 +151,11 @@
} }
.uni-calendar-item--isDay-text { .uni-calendar-item--isDay-text {
color: $uni-color-primary; color: $uni-primary;
} }
.uni-calendar-item--isDay { .uni-calendar-item--isDay {
background-color: $uni-color-primary; background-color: $uni-primary;
opacity: 0.8; opacity: 0.8;
color: #fff; color: #fff;
} }
@ -167,13 +166,13 @@
} }
.uni-calendar-item--checked { .uni-calendar-item--checked {
background-color: $uni-color-primary; background-color: $uni-primary;
color: #fff; color: #fff;
opacity: 0.8; opacity: 0.8;
} }
.uni-calendar-item--multiple { .uni-calendar-item--multiple {
background-color: $uni-color-primary; background-color: $uni-primary;
color: #fff; color: #fff;
opacity: 0.8; opacity: 0.8;
} }

View File

@ -20,7 +20,7 @@
<view class="uni-calendar__header-btn-box" @click.stop="next"> <view class="uni-calendar__header-btn-box" @click.stop="next">
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<text class="uni-calendar__backtoday" @click="backtoday">{{todayText}}</text> <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text>
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
@ -62,12 +62,12 @@
<script> <script>
import Calendar from './util.js'; import Calendar from './util.js';
import calendarItem from './uni-calendar-item.vue' import CalendarItem from './uni-calendar-item.vue'
import {
initVueI18n import { initVueI18n } from '@dcloudio/uni-i18n'
} from '@dcloudio/uni-i18n' import i18nMessages from './i18n/index.js'
import messages from './i18n/index.js' const { t } = initVueI18n(i18nMessages)
const { t } = initVueI18n(messages)
/** /**
* Calendar 日历 * Calendar 日历
* @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等 * @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等
@ -90,7 +90,7 @@
*/ */
export default { export default {
components: { components: {
calendarItem CalendarItem
}, },
emits:['close','confirm','change','monthSwitch'], emits:['close','confirm','change','monthSwitch'],
props: { props: {
@ -199,26 +199,26 @@
} }
}, },
created() { created() {
//
this.cale = new Calendar({ this.cale = new Calendar({
// date: new Date(),
selected: this.selected, selected: this.selected,
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
range: this.range, range: this.range,
}) })
//
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
// this.setDay
}, },
methods: { methods: {
// 穿 // 穿
clean() {}, clean() {},
bindDateChange(e) { bindDateChange(e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
console.log(this.cale.getDate(value)); this.setDate(value)
this.init(value)
const { year,month } = this.cale.getDate(value)
this.$emit('monthSwitch', {
year,
month
})
}, },
/** /**
* 初始化日期显示 * 初始化日期显示
@ -323,11 +323,16 @@
/** /**
* 回到今天 * 回到今天
*/ */
backtoday() { backToday() {
console.log(this.cale.getDate(new Date()).fullDate); const nowYearMonth = `${this.nowDate.year}-${this.nowDate.month}`
let date = this.cale.getDate(new Date()).fullDate const date = this.cale.getDate(new Date())
// this.cale.setDate(date) const todayYearMonth = `${date.year}-${date.month}`
this.init(date)
if(nowYearMonth !== todayYearMonth) {
this.monthSwitch()
}
this.init(date.fullDate)
this.change() this.change()
}, },
/** /**
@ -446,7 +451,6 @@
.uni-calendar--fixed-width { .uni-calendar--fixed-width {
width: 50px; width: 50px;
// padding: 0 15px;
} }
.uni-calendar__backtoday { .uni-calendar__backtoday {

View File

@ -76,10 +76,20 @@ class Calendar {
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期 dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
break break
case 'month': case 'month':
if (dd.getDate() === 31) { if (dd.getDate() === 31 && AddDayCount>0) {
dd.setDate(dd.getDate() + AddDayCount) dd.setDate(dd.getDate() + AddDayCount)
} else { } else {
dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期 const preMonth = dd.getMonth()
dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
const nextMonth = dd.getMonth()
// 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
}
// 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
}
} }
break break
case 'year': case 'year':

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-calendar", "id": "uni-calendar",
"displayName": "uni-calendar 日历", "displayName": "uni-calendar 日历",
"version": "1.4.5", "version": "1.4.10",
"description": "日历组件", "description": "日历组件",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -19,10 +19,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -39,7 +35,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [], "dependencies": [],

View File

@ -77,7 +77,7 @@ export default {
### Calendar Props ### Calendar Props
| 属性名 | 类型 | 默认值| 说明 | | 属性名 | 类型 | 默认值| 说明 |
| | | | - | - | - | - |
| date | String |- | 自定义当前时间,默认为今天 | | date | String |- | 自定义当前时间,默认为今天 |
| lunar | Boolean | false | 显示农历 | | lunar | Boolean | false | 显示农历 |
| startDate | String |- | 日期选择范围-开始日期 | | startDate | String |- | 日期选择范围-开始日期 |
@ -91,7 +91,7 @@ export default {
### Calendar Events ### Calendar Events
| 事件名 | 说明 |返回值| | 事件名 | 说明 |返回值|
| | | | | - | - | - |
| open | 弹出日历组件,`insert :false` 时生效|- | | open | 弹出日历组件,`insert :false` 时生效|- |

View File

@ -21,7 +21,9 @@
</view> </view>
</view> </view>
<view class="uni-card__header-extra" @click="onClick('extra')"> <view class="uni-card__header-extra" @click="onClick('extra')">
<slot name="extra">
<text class="uni-card__header-extra-text">{{ extra }}</text> <text class="uni-card__header-extra-text">{{ extra }}</text>
</slot>
</view> </view>
</view> </view>
</slot> </slot>

View File

@ -5,23 +5,23 @@
</view> </view>
<view class="uni-combox__input-box"> <view class="uni-combox__input-box">
<input class="uni-combox__input" type="text" :placeholder="placeholder" <input class="uni-combox__input" type="text" :placeholder="placeholder"
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
@blur="onBlur" />
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector"> <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
</uni-icons> </uni-icons>
</view> </view>
<view class="uni-combox__selector" v-if="showSelector"> <view class="uni-combox__selector" v-if="showSelector">
<view class="uni-popper__arrow"></view> <view class="uni-popper__arrow"></view>
<scroll-view scroll-y="true" class="uni-combox__selector-scroll"> <scroll-view scroll-y="true" class="uni-combox__selector-scroll" @scroll="onScroll">
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0"> <view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
<text>{{emptyTips}}</text> <text>{{emptyTips}}</text>
</view> </view>
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" <view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index" @click="onSelectorClick(index)">
@click="onSelectorClick(index)">
<text>{{item}}</text> <text>{{item}}</text>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 新增蒙层点击蒙层时关闭选项显示 -->
<view class="uni-combox__mask" v-show="showSelector" @click="showSelector = false"></view>
</view> </view>
</template> </template>
@ -83,7 +83,8 @@
data() { data() {
return { return {
showSelector: false, showSelector: false,
inputVal: '' inputVal: '',
blurTimer:null,
} }
}, },
computed: { computed: {
@ -94,6 +95,9 @@
return `width: ${this.labelWidth}` return `width: ${this.labelWidth}`
}, },
filterCandidates() { filterCandidates() {
if (this.inputVal !== 0 && !this.inputVal) {
return this.candidates
}
return this.candidates.filter((item) => { return this.candidates.filter((item) => {
return item.toString().indexOf(this.inputVal) > -1 return item.toString().indexOf(this.inputVal) > -1
}) })
@ -128,10 +132,16 @@
this.showSelector = true this.showSelector = true
}, },
onBlur() { onBlur() {
setTimeout(() => { this.blurTimer = setTimeout(() => {
this.showSelector = false this.showSelector = false
}, 153) }, 153)
}, },
onScroll(){ // blur
if(this.blurTimer) {
clearTimeout(this.blurTimer)
this.blurTimer = null
}
},
onSelectorClick(index) { onSelectorClick(index) {
this.inputVal = this.filterCandidates[index] this.inputVal = this.filterCandidates[index]
this.showSelector = false this.showSelector = false
@ -205,7 +215,7 @@
border: 1px solid #EBEEF5; border: 1px solid #EBEEF5;
border-radius: 6px; border-radius: 6px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 2; z-index: 3;
padding: 4px 0; padding: 4px 0;
} }
@ -272,4 +282,13 @@
.uni-combox__no-border { .uni-combox__no-border {
border: none; border: none;
} }
.uni-combox__mask {
width:100%;
height:100%;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
</style> </style>

View File

@ -86,6 +86,10 @@
timestamp: { timestamp: {
type: Number, type: Number,
default: 0 default: 0
},
zeroPad: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@ -199,18 +203,10 @@
} else { } else {
this.timeUp() this.timeUp()
} }
if (day < 10) { day = (day < 10 && this.zeroPad) ? `0${day}` : day
day = '0' + day hour = (hour < 10 && this.zeroPad) ? `0${hour}` : hour
} minute = (minute < 10 && this.zeroPad) ? `0${minute}` : minute
if (hour < 10) { second = (second < 10 && this.zeroPad) ? `0${second}` : second
hour = '0' + hour
}
if (minute < 10) {
minute = '0' + minute
}
if (second < 10) {
second = '0' + second
}
this.d = day this.d = day
this.h = hour this.h = hour
this.i = minute this.i = minute

View File

@ -1,3 +1,5 @@
## 1.0.32022-09-16
- 可以使用 uni-scss 控制主题色
## 1.0.22022-06-30 ## 1.0.22022-06-30
- 优化 在 uni-forms 中的依赖注入方式 - 优化 在 uni-forms 中的依赖注入方式
## 1.0.12022-02-07 ## 1.0.12022-02-07

View File

@ -384,12 +384,14 @@
setStyleBackgroud(item) { setStyleBackgroud(item) {
let styles = {} let styles = {}
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
if (this.selectedColor) {
if (this.mode !== 'list') { if (this.mode !== 'list') {
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
} }
if (this.mode === 'tag') { if (this.mode === 'tag') {
styles['background-color'] = item.selected? selectedColor:'#f5f5f5' styles['background-color'] = item.selected? selectedColor:'#f5f5f5'
} }
}
let classles = '' let classles = ''
for (let i in styles) { for (let i in styles) {
classles += `${i}:${styles[i]};` classles += `${i}:${styles[i]};`
@ -399,6 +401,7 @@
setStyleIcon(item) { setStyleIcon(item) {
let styles = {} let styles = {}
let classles = '' let classles = ''
if (this.selectedColor) {
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
styles['background-color'] = item.selected?selectedColor:'#fff' styles['background-color'] = item.selected?selectedColor:'#fff'
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
@ -407,7 +410,7 @@
styles['background-color'] = '#F2F6FC' styles['background-color'] = '#F2F6FC'
styles['border-color'] = item.selected?selectedColor:'#DCDFE6' styles['border-color'] = item.selected?selectedColor:'#DCDFE6'
} }
}
for (let i in styles) { for (let i in styles) {
classles += `${i}:${styles[i]};` classles += `${i}:${styles[i]};`
} }
@ -416,6 +419,7 @@
setStyleIconText(item) { setStyleIconText(item) {
let styles = {} let styles = {}
let classles = '' let classles = ''
if (this.selectedColor) {
let selectedColor = this.selectedColor?this.selectedColor:'#2979ff' let selectedColor = this.selectedColor?this.selectedColor:'#2979ff'
if (this.mode === 'tag') { if (this.mode === 'tag') {
styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666' styles.color = item.selected?(this.selectedTextColor?this.selectedTextColor:'#fff'):'#666'
@ -425,7 +429,7 @@
if(!item.selected && item.disabled){ if(!item.selected && item.disabled){
styles.color = '#999' styles.color = '#999'
} }
}
for (let i in styles) { for (let i in styles) {
classles += `${i}:${styles[i]};` classles += `${i}:${styles[i]};`
} }
@ -448,7 +452,7 @@
</script> </script>
<style lang="scss"> <style lang="scss">
$checked-color: #2979ff; $uni-primary: #2979ff !default;
$border-color: #DCDFE6; $border-color: #DCDFE6;
$disable:0.4; $disable:0.4;
@ -614,8 +618,8 @@
// //
&.is-checked { &.is-checked {
.checkbox__inner { .checkbox__inner {
border-color: $checked-color; border-color: $uni-primary;
background-color: $checked-color; background-color: $uni-primary;
.checkbox__inner-icon { .checkbox__inner-icon {
opacity: 1; opacity: 1;
@ -623,14 +627,14 @@
} }
} }
.radio__inner { .radio__inner {
border-color: $checked-color; border-color: $uni-primary;
.radio__inner-icon { .radio__inner-icon {
opacity: 1; opacity: 1;
background-color: $checked-color; background-color: $uni-primary;
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
// //
&.is-disable { &.is-disable {
@ -683,10 +687,10 @@
} }
&.is-checked { &.is-checked {
border-color: $checked-color; border-color: $uni-primary;
.checkbox__inner { .checkbox__inner {
border-color: $checked-color; border-color: $uni-primary;
background-color: $checked-color; background-color: $uni-primary;
.checkbox__inner-icon { .checkbox__inner-icon {
opacity: 1; opacity: 1;
transform: rotate(45deg); transform: rotate(45deg);
@ -694,16 +698,16 @@
} }
.radio__inner { .radio__inner {
border-color: $checked-color; border-color: $uni-primary;
.radio__inner-icon { .radio__inner-icon {
opacity: 1; opacity: 1;
background-color: $checked-color; background-color: $uni-primary;
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
// //
@ -735,8 +739,8 @@
} }
&.is-checked { &.is-checked {
background-color: $checked-color; background-color: $uni-primary;
border-color: $checked-color; border-color: $uni-primary;
.checklist-text { .checklist-text {
color: #fff; color: #fff;
@ -775,8 +779,8 @@
&.is-checked { &.is-checked {
.checkbox__inner { .checkbox__inner {
border-color: $checked-color; border-color: $uni-primary;
background-color: $checked-color; background-color: $uni-primary;
.checkbox__inner-icon { .checkbox__inner-icon {
opacity: 1; opacity: 1;
@ -789,13 +793,13 @@
} }
} }
.checklist-text { .checklist-text {
color: $checked-color; color: $uni-primary;
} }
.checklist-content { .checklist-content {
.checkobx__list { .checkobx__list {
opacity: 1; opacity: 1;
border-color: $checked-color; border-color: $uni-primary;
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-checkbox", "id": "uni-data-checkbox",
"displayName": "uni-data-checkbox 数据选择器", "displayName": "uni-data-checkbox 数据选择器",
"version": "1.0.2", "version": "1.0.3",
"description": "通过数据驱动的单选框和复选框", "description": "通过数据驱动的单选框和复选框",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-load-more","uni-scss"], "dependencies": ["uni-load-more","uni-scss"],

View File

@ -1,3 +1,14 @@
## 1.1.22023-04-11
- 修复 更改 modelValue 报错的 bug
- 修复 v-for 未使用 key 值控制台 warning
## 1.1.12023-02-21
- 修复代码合并时引发 value 属性为空时不渲染数据的问题
## 1.1.02023-02-15
- 修复 localdata 不支持动态更新的bug
## 1.0.92023-02-15
- 修复 localdata 不支持动态更新的bug
## 1.0.82022-09-16
- 可以使用 uni-scss 控制主题色
## 1.0.72022-07-06 ## 1.0.72022-07-06
- 优化 pc端图标位置不正确的问题 - 优化 pc端图标位置不正确的问题
## 1.0.62022-07-05 ## 1.0.62022-07-05

View File

@ -16,8 +16,7 @@
</view> </view>
</scroll-view> </scroll-view>
<text v-else class="selected-area placeholder">{{placeholder}}</text> <text v-else class="selected-area placeholder">{{placeholder}}</text>
<view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" <view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" @click.stop="clear">
@click.stop="clear">
<uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons> <uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
</view> </view>
<view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly "> <view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly ">
@ -40,8 +39,8 @@
</view> </view>
<data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata" <data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata"
:preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where" :preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where"
:step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true" :step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true" :map="map"
:map="map" :ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick"> :ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick">
</data-picker-view> </data-picker-view>
</view> </view>
</view> </view>
@ -76,7 +75,7 @@
*/ */
export default { export default {
name: 'UniDataPicker', name: 'UniDataPicker',
emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue'], emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue','inputclick'],
mixins: [dataPicker], mixins: [dataPicker],
components: { components: {
DataPickerView DataPickerView
@ -128,58 +127,49 @@
} }
}, },
created() { created() {
this.form = this.getForm('uniForms')
this.formItem = this.getForm('uniFormsItem')
if (this.formItem) {
if (this.formItem.name) {
this.rename = this.formItem.name
this.form.inputChildrens.push(this)
}
}
this.$nextTick(() => { this.$nextTick(() => {
this.load() this.load();
}) })
}, },
watch: {
localdata: {
handler() {
this.load()
},
deep: true
},
},
methods: { methods: {
clear() { clear() {
this.inputSelected.splice(0) this._dispatchEvent([]);
this._dispatchEvent([])
}, },
onPropsChange() { onPropsChange() {
this._treeData = [] this._treeData = [];
this.selectedIndex = 0 this.selectedIndex = 0;
this.load()
this.load();
}, },
load() { load() {
if (this.readonly) { if (this.readonly) {
this._processReadonly(this.localdata, this.dataValue) this._processReadonly(this.localdata, this.dataValue);
return return;
} }
if (this.isLocaldata) { //
this.loadData() if (this.isLocalData) {
this.inputSelected = this.selected.slice(0) this.loadData();
} else if (!this.parentField && !this.selfField && this.hasValue) { this.inputSelected = this.selected.slice(0);
this.getNodeData(() => { } else if (this.isCloudDataList || this.isCloudDataTree) { // Cloud
this.inputSelected = this.selected.slice(0) this.loading = true;
}) this.getCloudDataValue().then((res) => {
} else if (this.hasValue) { this.loading = false;
this.getTreePath(() => { this.inputSelected = res;
this.inputSelected = this.selected.slice(0) }).catch((err) => {
this.loading = false;
this.errorMessage = err;
}) })
} }
}, },
getForm(name = 'uniForms') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
return parent;
},
show() { show() {
this.isOpened = true this.isOpened = true
setTimeout(() => { setTimeout(() => {
@ -197,6 +187,7 @@
}, },
handleInput() { handleInput() {
if (this.readonly) { if (this.readonly) {
this.$emit('inputclick')
return return
} }
this.show() this.show()
@ -413,7 +404,12 @@
.uni-data-tree-dialog { .uni-data-tree-dialog {
position: fixed; position: fixed;
left: 0; left: 0;
/* #ifndef APP-NVUE */
top: 20%; top: 20%;
/* #endif */
/* #ifdef APP-NVUE */
top: 200px;
/* #endif */
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: #FFFFFF; background-color: #FFFFFF;
@ -550,5 +546,6 @@
border-top-width: 0; border-top-width: 0;
border-bottom-color: #fff; border-bottom-color: #fff;
} }
/* #endif */ /* #endif */
</style> </style>

View File

@ -42,7 +42,7 @@ export default {
}, },
pageSize: { pageSize: {
type: Number, type: Number,
default: 20 default: 500
}, },
getcount: { getcount: {
type: [Boolean, String], type: [Boolean, String],
@ -122,19 +122,22 @@ export default {
} }
}, },
computed: { computed: {
isLocaldata() { isLocalData() {
return !this.collection.length return !this.collection.length;
}, },
postField() { isCloudData() {
let fields = [this.field]; return this.collection.length > 0;
if (this.parentField) { },
fields.push(`${this.parentField} as parent_value`); isCloudDataList() {
} return (this.isCloudData && (!this.parentField && !this.selfField));
return fields.join(','); },
isCloudDataTree() {
return (this.isCloudData && this.parentField && this.selfField);
}, },
dataValue() { dataValue() {
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined) let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
return isModelValue ? this.modelValue : this.value this.modelValue !== undefined);
return isModelValue ? this.modelValue : this.value;
}, },
hasValue() { hasValue() {
if (typeof this.dataValue === 'number') { if (typeof this.dataValue === 'number') {
@ -183,8 +186,169 @@ export default {
}, },
methods: { methods: {
onPropsChange() { onPropsChange() {
this._treeData = [] this._treeData = [];
}, },
// 填充 pickview 数据
async loadData() {
if (this.isLocalData) {
this.loadLocalData();
} else if (this.isCloudDataList) {
this.loadCloudDataList();
} else if (this.isCloudDataTree) {
this.loadCloudDataTree();
}
},
// 加载本地数据
async loadLocalData() {
this._treeData = [];
this._extractTree(this.localdata, this._treeData);
let inputValue = this.dataValue;
if (inputValue === undefined) {
return;
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1];
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value];
}
}
this.selected = this._findNodePath(inputValue, this.localdata);
},
// 加载 Cloud 数据 (单列)
async loadCloudDataList() {
if (this.loading) {
return;
}
this.loading = true;
try {
let response = await this.getCommand();
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (树形)
async loadCloudDataTree() {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataTreeWhere()
};
if (this.gettree) {
commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
}
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
this._treeData = responseData;
this._updateBindData();
this._updateSelected();
this.onDataChange();
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 加载 Cloud 数据 (节点)
async loadCloudDataNode(callback) {
if (this.loading) {
return;
}
this.loading = true;
try {
let commandOptions = {
field: this._cloudDataPostField(),
where: this._cloudDataNodeWhere()
};
let response = await this.getCommand(commandOptions);
let responseData = response.result.data;
callback(responseData);
} catch (e) {
this.errorMessage = e;
} finally {
this.loading = false;
}
},
// 回显 Cloud 数据
getCloudDataValue() {
if (this.isCloudDataList) {
return this.getCloudDataListValue();
}
if (this.isCloudDataTree) {
return this.getCloudDataTreeValue();
}
},
// 回显 Cloud 数据 (单列)
getCloudDataListValue() {
// 根据 field's as value标识匹配 where 条件
let where = [];
let whereField = this._getForeignKeyByField();
if (whereField) {
where.push(`${whereField} == '${this.dataValue}'`)
}
where = where.join(' || ');
if (this.where) {
where = `(${this.where}) && (${where})`
}
return this.getCommand({
field: this._cloudDataPostField(),
where
}).then((res) => {
this.selected = res.result.data;
return res.result.data;
});
},
// 回显 Cloud 数据 (树形)
getCloudDataTreeValue() {
return this.getCommand({
field: this._cloudDataPostField(),
getTreePath: {
startWith: `${this.selfField}=='${this.dataValue}'`
}
}).then((res) => {
let treePath = [];
this._extractTreePath(res.result.data, treePath);
this.selected = treePath;
return treePath;
});
},
getCommand(options = {}) { getCommand(options = {}) {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
let db = uniCloud.database(this.spaceInfo) let db = uniCloud.database(this.spaceInfo)
@ -229,125 +393,16 @@ export default {
return db return db
}, },
getNodeData(callback) {
if (this.loading) { _cloudDataPostField() {
return let fields = [this.field];
if (this.parentField) {
fields.push(`${this.parentField} as parent_value`);
} }
this.loading = true return fields.join(',');
this.getCommand({
field: this.postField,
where: this._pathWhere()
}).then((res) => {
this.loading = false
this.selected = res.result.data
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
}, },
getTreePath(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({ _cloudDataTreeWhere() {
field: this.postField,
getTreePath: {
startWith: `${this.selfField}=='${this.dataValue}'`
}
}).then((res) => {
this.loading = false
let treePath = []
this._extractTreePath(res.result.data, treePath)
this.selected = treePath
callback && callback()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
loadData() {
if (this.isLocaldata) {
this._processLocalData()
return
}
if (this.dataValue != null) {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
this._updateSelected()
})
return
}
if (this.stepSearh) {
this._loadNodeData((data) => {
this._treeData = data
this._updateBindData()
})
} else {
this._loadAllData((data) => {
this._treeData = []
this._extractTree(data, this._treeData, null)
this._updateBindData()
})
}
},
_loadAllData(callback) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
gettree: true,
startwith: `${this.selfField}=='${this.dataValue}'`
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_loadNodeData(callback, pw) {
if (this.loading) {
return
}
this.loading = true
this.getCommand({
field: this.postField,
where: pw || this._postWhere(),
pageSize: 500
}).then((res) => {
this.loading = false
callback(res.result.data)
this.onDataChange()
}).catch((err) => {
this.loading = false
this.errorMessage = err
})
},
_pathWhere() {
let result = []
let where_field = this._getParentNameByField();
if (where_field) {
result.push(`${where_field} == '${this.dataValue}'`)
}
if (this.where) {
return `(${this.where}) && (${result.join(' || ')})`
}
return result.join(' || ')
},
_postWhere() {
let result = [] let result = []
let selected = this.selected let selected = this.selected
let parentField = this.parentField let parentField = this.parentField
@ -364,17 +419,35 @@ export default {
if (this.where) { if (this.where) {
where.push(`(${this.where})`) where.push(`(${this.where})`)
} }
if (result.length) { if (result.length) {
where.push(`(${result.join(' || ')})`) where.push(`(${result.join(' || ')})`)
} }
return where.join(' && ') return where.join(' && ')
}, },
_nodeWhere() {
let result = [] _cloudDataNodeWhere() {
let selected = this.selected let where = []
let selected = this.selected;
if (selected.length) { if (selected.length) {
result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`) where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
}
where = where.join(' || ');
if (this.where) {
return `(${this.where}) && (${where})`
}
return where
},
_getWhereByForeignKey() {
let result = []
let whereField = this._getForeignKeyByField();
if (whereField) {
result.push(`${whereField} == '${this.dataValue}'`)
} }
if (this.where) { if (this.where) {
@ -383,41 +456,23 @@ export default {
return result.join(' || ') return result.join(' || ')
}, },
_getParentNameByField() {
const fields = this.field.split(','); _getForeignKeyByField() {
let where_field = null; let fields = this.field.split(',');
let whereField = null;
for (let i = 0; i < fields.length; i++) { for (let i = 0; i < fields.length; i++) {
const items = fields[i].split('as'); const items = fields[i].split('as');
if (items.length < 2) { if (items.length < 2) {
continue; continue;
} }
if (items[1].trim() === 'value') { if (items[1].trim() === 'value') {
where_field = items[0].trim(); whereField = items[0].trim();
break; break;
} }
} }
return where_field return whereField;
},
_isTreeView() {
return (this.parentField && this.selfField)
},
_updateSelected() {
var dl = this.dataList
var sl = this.selected
let textField = this.map.text
let valueField = this.map.value
for (var i = 0; i < sl.length; i++) {
var value = sl[i].value
var dl2 = dl[i]
for (var j = 0; j < dl2.length; j++) {
var item2 = dl2[j]
if (item2[valueField] === value) {
sl[i].text = item2[textField]
break
}
}
}
}, },
_updateBindData(node) { _updateBindData(node) {
const { const {
dataList, dataList,
@ -445,6 +500,25 @@ export default {
hasNodes hasNodes
} }
}, },
_updateSelected() {
let dl = this.dataList
let sl = this.selected
let textField = this.map.text
let valueField = this.map.value
for (let i = 0; i < sl.length; i++) {
let value = sl[i].value
let dl2 = dl[i]
for (let j = 0; j < dl2.length; j++) {
let item2 = dl2[j]
if (item2[valueField] === value) {
sl[i].text = item2[textField]
break
}
}
}
},
_filterData(data, paths) { _filterData(data, paths) {
let dataList = [] let dataList = []
let hasNodes = true let hasNodes = true
@ -453,8 +527,8 @@ export default {
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '') return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
})) }))
for (let i = 0; i < paths.length; i++) { for (let i = 0; i < paths.length; i++) {
var value = paths[i].value let value = paths[i].value
var nodes = data.filter((item) => { let nodes = data.filter((item) => {
return item.parent_value === value return item.parent_value === value
}) })
@ -470,6 +544,7 @@ export default {
hasNodes hasNodes
} }
}, },
_extractTree(nodes, result, parent_value) { _extractTree(nodes, result, parent_value) {
let list = result || [] let list = result || []
let valueField = this.map.value let valueField = this.map.value
@ -493,6 +568,7 @@ export default {
} }
} }
}, },
_extractTreePath(nodes, result) { _extractTreePath(nodes, result) {
let list = result || [] let list = result || []
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
@ -512,6 +588,7 @@ export default {
} }
} }
}, },
_findNodePath(key, nodes, path = []) { _findNodePath(key, nodes, path = []) {
let textField = this.map.text let textField = this.map.text
let valueField = this.map.value let valueField = this.map.value
@ -540,24 +617,6 @@ export default {
path.pop() path.pop()
} }
return [] return []
},
_processLocalData() {
this._treeData = []
this._extractTree(this.localdata, this._treeData)
var inputValue = this.dataValue
if (inputValue === undefined) {
return
}
if (Array.isArray(inputValue)) {
inputValue = inputValue[inputValue.length - 1]
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
inputValue = inputValue[this.map.value]
}
}
this.selected = this._findNodePath(inputValue, this.localdata)
} }
} }
} }

View File

@ -1,26 +1,28 @@
<template> <template>
<view class="uni-data-pickerview"> <view class="uni-data-pickerview">
<scroll-view class="selected-area" scroll-x="true" scroll-y="false" :show-scrollbar="false"> <scroll-view v-if="!isCloudDataList" class="selected-area" scroll-x="true">
<view class="selected-list"> <view class="selected-list">
<template v-for="(item,index) in selected"> <view
<view class="selected-item" class="selected-item"
:class="{'selected-item-active':index==selectedIndex, 'selected-item-text-overflow': ellipsis}" v-for="(item,index) in selected"
v-if="item.text" @click="handleSelect(index)"> :key="index"
<text class="">{{item.text}}</text> :class="{
'selected-item-active':index == selectedIndex
}"
@click="handleSelect(index)"
>
<text>{{item.text || ''}}</text>
</view> </view>
</template>
</view> </view>
</scroll-view> </scroll-view>
<view class="tab-c"> <view class="tab-c">
<template v-for="(child, i) in dataList" > <scroll-view class="list" :scroll-y="true">
<scroll-view class="list" :key="i" v-if="i==selectedIndex" :scroll-y="true"> <view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in dataList[selectedIndex]" :key="j"
<view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child" @click="handleNodeClick(item, selectedIndex, j)">
@click="handleNodeClick(item, i, j)"> <text class="item-text">{{item[map.text]}}</text>
<text class="item-text item-text-overflow">{{item[map.text]}}</text> <view class="check" v-if="selected.length > selectedIndex && item[map.value] == selected[selectedIndex].value"></view>
<view class="check" v-if="selected.length > i && item[map.value] == selected[i].value"></view>
</view> </view>
</scroll-view> </scroll-view>
</template>
<view class="loading-cover" v-if="loading"> <view class="loading-cover" v-if="loading">
<uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more> <uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
@ -64,43 +66,33 @@
default: true default: true
} }
}, },
data() {
return {}
},
created() { created() {
if (this.managedMode) { if (!this.managedMode) {
return
}
this.$nextTick(() => { this.$nextTick(() => {
this.load() this.loadData();
}) })
}
}, },
methods: { methods: {
onPropsChange() { onPropsChange() {
this._treeData = [] this._treeData = [];
this.selectedIndex = 0 this.selectedIndex = 0;
this.load() this.$nextTick(() => {
}, this.loadData();
load() {
if (this.isLocaldata) {
this.loadData()
} else if (this.dataValue.length) {
this.getTreePath((res) => {
this.loadData()
}) })
}
}, },
handleSelect(index) { handleSelect(index) {
this.selectedIndex = index this.selectedIndex = index;
}, },
handleNodeClick(item, i, j) { handleNodeClick(item, i, j) {
if (item.disable) { if (item.disable) {
return return;
} }
const node = this.dataList[i][j]
const text = node[this.map.text] const node = this.dataList[i][j];
const value = node[this.map.value] const text = node[this.map.text];
const value = node[this.map.value];
if (i < this.selected.length - 1) { if (i < this.selected.length - 1) {
this.selected.splice(i, this.selected.length - i) this.selected.splice(i, this.selected.length - i)
this.selected.push({ this.selected.push({
@ -124,18 +116,16 @@
hasNodes hasNodes
} = this._updateBindData() } = this._updateBindData()
if (!this._isTreeView() && !hasNodes) { //
if (this.isLocalData) {
this.onSelectedChange(node, (!hasNodes || isleaf))
} else if (this.isCloudDataList) { // Cloud ()
this.onSelectedChange(node, true) this.onSelectedChange(node, true)
return } else if (this.isCloudDataTree) { // Cloud ()
} if (isleaf) {
this.onSelectedChange(node, node.isleaf)
if (this.isLocaldata && (!hasNodes || isleaf)) { } else if (!hasNodes) { //
this.onSelectedChange(node, true) this.loadCloudDataNode((data) => {
return
}
if (!isleaf && !hasNodes) {
this._loadNodeData((data) => {
if (!data.length) { if (!data.length) {
node.isleaf = true node.isleaf = true
} else { } else {
@ -143,11 +133,9 @@
this._updateBindData(node) this._updateBindData(node)
} }
this.onSelectedChange(node, node.isleaf) this.onSelectedChange(node, node.isleaf)
}, this._nodeWhere()) })
return }
} }
this.onSelectedChange(node, false)
}, },
updateData(data) { updateData(data) {
this._treeData = data.treeData this._treeData = data.treeData
@ -160,7 +148,7 @@
} }
}, },
onDataChange() { onDataChange() {
this.$emit('datachange') this.$emit('datachange');
}, },
onSelectedChange(node, isleaf) { onSelectedChange(node, isleaf) {
if (isleaf) { if (isleaf) {
@ -177,7 +165,10 @@
} }
} }
</script> </script>
<style >
<style lang="scss">
$uni-primary: #007aff !default;
.uni-data-pickerview { .uni-data-pickerview {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -229,15 +220,14 @@
.selected-area { .selected-area {
width: 750rpx; width: 750rpx;
} }
/* #endif */ /* #endif */
.selected-list { .selected-list {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
flex-wrap: nowrap;
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
flex-wrap: nowrap;
padding: 0 5px; padding: 0 5px;
border-bottom: 1px solid #f8f8f8; border-bottom: 1px solid #f8f8f8;
} }
@ -265,11 +255,11 @@
} }
.selected-item-active { .selected-item-active {
border-bottom: 2px solid #007aff; border-bottom: 2px solid $uni-primary;
} }
.selected-item-text { .selected-item-text {
color: #007aff; color: $uni-primary;
} }
.tab-c { .tab-c {
@ -319,7 +309,7 @@
.check { .check {
margin-right: 5px; margin-right: 5px;
border: 2px solid #007aff; border: 2px solid $uni-primary;
border-left: 0; border-left: 0;
border-top: 0; border-top: 0;
height: 12px; height: 12px;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-picker", "id": "uni-data-picker",
"displayName": "uni-data-picker 数据驱动的picker选择器", "displayName": "uni-data-picker 数据驱动的picker选择器",
"version": "1.0.7", "version": "1.1.2",
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景", "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -19,10 +19,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -39,7 +35,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [
@ -56,7 +53,7 @@
"client": { "client": {
"App": { "App": {
"app-vue": "y", "app-vue": "y",
"app-nvue": "y" "app-nvue": "u"
}, },
"H5-mobile": { "H5-mobile": {
"Safari": "y", "Safari": "y",

View File

@ -1,3 +1,22 @@
## 1.0.62023-04-12
- 修复 微信小程序点击时会改变背景颜色的 bug
## 1.0.52023-02-03
- 修复 禁用时会显示清空按钮
## 1.0.42023-02-02
- 优化 查询条件短期内多次变更只查询最后一次变更后的结果
- 调整 内部缓存键名调整为 uni-data-select-lastSelectedValue
## 1.0.32023-01-16
- 修复 不关联服务空间报错的问题
## 1.0.22023-01-14
- 新增 属性 `format` 可用于格式化显示选项内容
## 1.0.12022-12-06
- 修复 当where变化时数据不会自动更新的问题
## 0.1.92022-09-05
- 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
## 0.1.82022-08-29
- 修复 点击的位置不准确
## 0.1.72022-08-12
- 新增 支持 disabled 属性
## 0.1.62022-07-06 ## 0.1.62022-07-06
- 修复 pc端宽度异常的bug - 修复 pc端宽度异常的bug
## 0.1.5 ## 0.1.5

View File

@ -2,12 +2,16 @@
<view class="uni-stat__select"> <view class="uni-stat__select">
<span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span> <span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span>
<view class="uni-stat-box" :class="{'uni-stat__actived': current}"> <view class="uni-stat-box" :class="{'uni-stat__actived': current}">
<view class="uni-select"> <view class="uni-select" :class="{'uni-select--disabled':disabled}">
<view class="uni-select__input-box" @click="toggleSelector"> <view class="uni-select__input-box" @click="toggleSelector">
<view v-if="current" class="uni-select__input-text">{{current}}</view> <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> <view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view>
<uni-icons v-if="current && clear" type="clear" color="#c0c4cc" size="24" @click="clearVal" /> <view v-if="current && clear && !disabled" @click.stop="clearVal" >
<uni-icons v-else :type="showSelector? 'top' : 'bottom'" size="14" color="#999" /> <uni-icons type="clear" color="#c0c4cc" size="24"/>
</view>
<view v-else>
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" />
</view>
</view> </view>
<view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" /> <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" />
<view class="uni-select__selector" v-if="showSelector"> <view class="uni-select__selector" v-if="showSelector">
@ -16,10 +20,9 @@
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0"> <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
<text>{{emptyTips}}</text> <text>{{emptyTips}}</text>
</view> </view>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" <view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
:key="index" @click="change(item)"> @click="change(item)">
<text <text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
:class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -39,21 +42,13 @@
* @property {Boolean} emptyText 没有数据时显示的文字 本地数据无效 * @property {Boolean} emptyText 没有数据时显示的文字 本地数据无效
* @property {String} label 左侧标题 * @property {String} label 左侧标题
* @property {String} placeholder 输入框的提示文字 * @property {String} placeholder 输入框的提示文字
* @property {Boolean} disabled 是否禁用
* @event {Function} change 选中发生变化触发 * @event {Function} change 选中发生变化触发
*/ */
export default { export default {
name: "uni-stat-select", name: "uni-data-select",
mixins: [uniCloud.mixinDatacom || {}], mixins: [uniCloud.mixinDatacom || {}],
data() {
return {
showSelector: false,
current: '',
mixinDatacomResData: [],
apps: [],
channels: []
};
},
props: { props: {
localdata: { localdata: {
type: Array, type: Array,
@ -88,12 +83,33 @@
defItem: { defItem: {
type: Number, type: Number,
default: 0 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: ''
},
},
data() {
return {
showSelector: false,
current: '',
mixinDatacomResData: [],
apps: [],
channels: [],
cacheKey: "uni-data-select-lastSelectedValue",
};
}, },
created() { created() {
this.last = `${this.collection}_last_selected_option_value` this.debounceGet = this.debounce(() => {
this.query();
}, 300);
if (this.collection && !this.localdata.length) { if (this.collection && !this.localdata.length) {
this.mixinDatacomEasyGet() this.debounceGet();
} }
}, },
computed: { computed: {
@ -108,6 +124,14 @@
return placeholder ? return placeholder ?
common + placeholder : common + placeholder :
common common
},
valueCom(){
// #ifdef VUE3
return this.modelValue;
// #endif
// #ifndef VUE3
return this.value;
// #endif
} }
}, },
watch: { watch: {
@ -119,16 +143,9 @@
} }
} }
}, },
// #ifndef VUE3 valueCom(val, old) {
value() {
this.initDefVal() this.initDefVal()
}, },
// #endif
// #ifdef VUE3
modelValue() {
this.initDefVal()
},
// #endif
mixinDatacomResData: { mixinDatacomResData: {
immediate: true, immediate: true,
handler(val) { handler(val) {
@ -139,27 +156,46 @@
} }
}, },
methods: { 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() { initDefVal() {
let defValue = '' let defValue = ''
if ((this.value || this.value === 0) && !this.isDisabled(this.value)) { if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
defValue = this.value defValue = this.valueCom
} else if ((this.modelValue || this.modelValue === 0) && !this.isDisabled(this.modelValue)) {
defValue = this.modelValue
} else { } else {
let strogeValue let strogeValue
if (this.collection) { if (this.collection) {
strogeValue = uni.getStorageSync(this.last) strogeValue = this.getCache()
} }
if (strogeValue || strogeValue === 0) { if (strogeValue || strogeValue === 0) {
defValue = strogeValue defValue = strogeValue
} else { } else {
let defItem = '' let defItem = ''
if (this.defItem > 0 && this.defItem < this.mixinDatacomResData.length) { if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value defItem = this.mixinDatacomResData[this.defItem - 1].value
} }
defValue = defItem defValue = defItem
} }
if (defValue || defValue === 0) {
this.emit(defValue) this.emit(defValue)
}
} }
const def = this.mixinDatacomResData.find(item => item.value === defValue) const def = this.mixinDatacomResData.find(item => item.value === defValue)
this.current = def ? this.formatItemName(def) : '' this.current = def ? this.formatItemName(def) : ''
@ -184,7 +220,7 @@
clearVal() { clearVal() {
this.emit('') this.emit('')
if (this.collection) { if (this.collection) {
uni.removeStorageSync(this.last) this.removeCache()
} }
}, },
change(item) { change(item) {
@ -195,15 +231,18 @@
} }
}, },
emit(val) { emit(val) {
this.$emit('change', val)
this.$emit('input', val) this.$emit('input', val)
this.$emit('update:modelValue', val) this.$emit('update:modelValue', val)
this.$emit('change', val)
if (this.collection) { if (this.collection) {
uni.setStorageSync(this.last, val) this.setCache(val);
} }
}, },
toggleSelector() { toggleSelector() {
if (this.disabled) {
return
}
this.showSelector = !this.showSelector this.showSelector = !this.showSelector
}, },
formatItemName(item) { formatItemName(item) {
@ -213,6 +252,16 @@
channel_code channel_code
} = item } = item
channel_code = channel_code ? `(${channel_code})` : '' 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 ? return this.collection.indexOf('app-list') > 0 ?
`${text}(${value})` : `${text}(${value})` :
( (
@ -221,6 +270,32 @@
`未命名${channel_code}` `未命名${channel_code}`
) )
} }
},
//
getLoadData(){
return this.mixinDatacomResData;
},
// key
getCurrentCacheKey(){
return this.collection;
},
//
getCache(name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
return cacheData[name];
},
//
setCache(value, name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
cacheData[name] = value;
uni.setStorageSync(this.cacheKey, cacheData);
},
//
removeCache(name=this.getCurrentCacheKey()){
let cacheData = uni.getStorageSync(this.cacheKey) || {};
delete cacheData[name];
uni.setStorageSync(this.cacheKey, cacheData);
},
} }
} }
</script> </script>
@ -244,7 +319,9 @@
display: flex; display: flex;
align-items: center; align-items: center;
// padding: 15px; // padding: 15px;
/* #ifdef H5 */
cursor: pointer; cursor: pointer;
/* #endif */
width: 100%; width: 100%;
flex: 1; flex: 1;
box-sizing: border-box; box-sizing: border-box;
@ -287,6 +364,11 @@
width: 100%; width: 100%;
flex: 1; flex: 1;
height: 35px; height: 35px;
&--disabled {
background-color: #f5f7fa;
cursor: not-allowed;
}
} }
.uni-select__label { .uni-select__label {
@ -298,7 +380,7 @@
} }
.uni-select__input-box { .uni-select__input-box {
// height: 35px; height: 35px;
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -332,7 +414,7 @@
border: 1px solid #EBEEF5; border: 1px solid #EBEEF5;
border-radius: 6px; border-radius: 6px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 2; z-index: 3;
padding: 4px 0; padding: 4px 0;
} }
@ -343,6 +425,14 @@
/* #endif */ /* #endif */
} }
/* #ifdef H5 */
@media (min-width: 768px) {
.uni-select__selector-scroll {
max-height: 600px;
}
}
/* #endif */
.uni-select__selector-empty, .uni-select__selector-empty,
.uni-select__selector-item { .uni-select__selector-item {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -422,5 +512,6 @@
bottom: 0; bottom: 0;
right: 0; right: 0;
left: 0; left: 0;
z-index: 2;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-data-select", "id": "uni-data-select",
"displayName": "uni-data-select 下拉框选择器", "displayName": "uni-data-select 下拉框选择器",
"version": "0.1.6", "version": "1.0.6",
"description": "通过数据驱动的下拉框选择器", "description": "通过数据驱动的下拉框选择器",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-load-more"], "dependencies": ["uni-load-more"],

View File

@ -1,31 +1,71 @@
## 2.2.222023-03-30
- 修复 日历 picker 修改年月后自动选中当月1日 [详情](https://ask.dcloud.net.cn/question/165937)
- 修复 小程序端 低版本 ios NaN [详情](https://ask.dcloud.net.cn/question/162979)
## 2.2.212023-02-20
- 修复 firefox 浏览器显示区域点击无法拉起日历弹框的Bug [详情](https://ask.dcloud.net.cn/question/163362)
## 2.2.202023-02-17
- 优化 值为空依然选中当天问题
- 优化 提供 default-value 属性支持配置选择器打开时默认显示的时间
- 优化 非范围选择未选择日期时间,点击确认按钮选中当前日期时间
- 优化 字节小程序日期时间范围选择,底部日期换行问题
## 2.2.192023-02-09
- 修复 2.2.18 引起范围选择配置 end 选择无效的Bug [详情](https://github.com/dcloudio/uni-ui/issues/686)
## 2.2.182023-02-08
- 修复 移动端范围选择change事件触发异常的Bug [详情](https://github.com/dcloudio/uni-ui/issues/684)
- 优化 PC端输入日期格式错误时返回当前日期时间
- 优化 PC端输入日期时间超出 start、end 限制的Bug
- 优化 移动端日期时间范围用法时间展示不完整问题
## 2.2.172023-02-04
- 修复 小程序端绑定 Date 类型报错的Bug [详情](https://github.com/dcloudio/uni-ui/issues/679)
- 修复 vue3 time-picker 无法显示绑定时分秒的Bug
## 2.2.162023-02-02
- 修复 字节小程序报错的Bug
## 2.2.152023-02-02
- 修复 某些情况切换月份错误的Bug
## 2.2.142023-01-30
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/162033)
## 2.2.132023-01-10
- 修复 多次加载组件造成内存占用的Bug
## 2.2.122022-12-01
- 修复 vue3 下 i18n 国际化初始值不正确的Bug
## 2.2.112022-09-19
- 修复 支付宝小程序样式错乱的Bug [详情](https://github.com/dcloudio/uni-app/issues/3861)
## 2.2.102022-09-19
- 修复 反向选择日期范围日期显示异常的Bug [详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
## 2.2.92022-09-16
- 可以使用 uni-scss 控制主题色
## 2.2.82022-09-08
- 修复 close事件无效的Bug
## 2.2.72022-09-05
- 修复 移动端 maskClick 无效的Bug [详情](https://ask.dcloud.net.cn/question/140824)
## 2.2.62022-06-30 ## 2.2.62022-06-30
- 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致 - 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致
## 2.2.52022-06-24 ## 2.2.52022-06-24
- 修复 日历顶部年月及底部确认未国际化 bug - 修复 日历顶部年月及底部确认未国际化的Bug
## 2.2.42022-03-31 ## 2.2.42022-03-31
- 修复 Vue3 下动态赋值,单选类型未响应的 bug - 修复 Vue3 下动态赋值,单选类型未响应的Bug
## 2.2.32022-03-28 ## 2.2.32022-03-28
- 修复 Vue3 下动态赋值未响应的 bug - 修复 Vue3 下动态赋值未响应的Bug
## 2.2.22021-12-10 ## 2.2.22021-12-10
- 修复 clear-icon 属性在小程序平台不生效的 bug - 修复 clear-icon 属性在小程序平台不生效的Bug
## 2.2.12021-12-10 ## 2.2.12021-12-10
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的 bug - 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的Bug
## 2.2.02021-11-19 ## 2.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 优化 组件UI并提供设计资源 [详情](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker) - 文档迁移 [https://uniapp.dcloud.io/component/uniui/uni-datetime-picker](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
## 2.1.52021-11-09 ## 2.1.52021-11-09
- 新增 提供组件设计资源,组件样式调整 - 新增 提供组件设计资源,组件样式调整
## 2.1.42021-09-10 ## 2.1.42021-09-10
- 修复 hide-second 在移动端的 bug - 修复 hide-second 在移动端的Bug
- 修复 单选赋默认值时,赋值日期未高亮的 bug - 修复 单选赋默认值时,赋值日期未高亮的Bug
- 修复 赋默认值时,移动端未正确显示时间的 bug - 修复 赋默认值时,移动端未正确显示时间的Bug
## 2.1.32021-09-09 ## 2.1.32021-09-09
- 新增 hide-second 属性,支持只使用时分,隐藏秒 - 新增 hide-second 属性,支持只使用时分,隐藏秒
## 2.1.22021-09-03 ## 2.1.22021-09-03
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次 - 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法 - 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
- 优化 调整字号大小,美化日历界面 - 优化 调整字号大小,美化日历界面
- 修复 因国际化导致的 placeholder 失效的 bug - 修复 因国际化导致的 placeholder 失效的Bug
## 2.1.12021-08-24 ## 2.1.12021-08-24
- 新增 支持国际化 - 新增 支持国际化
- 优化 范围选择器在 pc 端过宽的问题 - 优化 范围选择器在 pc 端过宽的问题
@ -33,50 +73,50 @@
- 新增 适配 vue3 - 新增 适配 vue3
## 2.0.192021-08-09 ## 2.0.192021-08-09
- 新增 支持作为 uni-forms 子组件相关功能 - 新增 支持作为 uni-forms 子组件相关功能
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的 bug - 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的Bug
## 2.0.182021-08-05 ## 2.0.182021-08-05
- 修复 type 属性动态赋值无效的 bug - 修复 type 属性动态赋值无效的Bug
- 修复 ‘确认’按钮被 tabbar 遮盖 bug - 修复 ‘确认’按钮被 tabbar 遮盖 bug
- 修复 组件未赋值时范围选左、右日历相同的 bug - 修复 组件未赋值时范围选左、右日历相同的Bug
## 2.0.172021-08-04 ## 2.0.172021-08-04
- 修复 范围选未正确显示当前值的 bug - 修复 范围选未正确显示当前值的Bug
- 修复 h5 平台(移动端)报错 'cale' of undefined 的 bug - 修复 h5 平台(移动端)报错 'cale' of undefined 的Bug
## 2.0.162021-07-21 ## 2.0.162021-07-21
- 新增 return-type 属性支持返回 date 日期对象 - 新增 return-type 属性支持返回 date 日期对象
## 2.0.152021-07-14 ## 2.0.152021-07-14
- 修复 单选日期类型,初始赋值后不在当前日历的 bug - 修复 单选日期类型,初始赋值后不在当前日历的Bug
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效) - 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
- 优化 移动端移除显示框的清空按钮,无实际用途 - 优化 移动端移除显示框的清空按钮,无实际用途
## 2.0.142021-07-14 ## 2.0.142021-07-14
- 修复 组件赋值为空,界面未更新的 bug - 修复 组件赋值为空,界面未更新的Bug
- 修复 start 和 end 不能动态赋值的 bug - 修复 start 和 end 不能动态赋值的Bug
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的 bug - 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的Bug
## 2.0.132021-07-08 ## 2.0.132021-07-08
- 修复 范围选择不能动态赋值的 bug - 修复 范围选择不能动态赋值的Bug
## 2.0.122021-07-08 ## 2.0.122021-07-08
- 修复 范围选择的初始时间在一个月内时造成无法选择的bug - 修复 范围选择的初始时间在一个月内时造成无法选择的bug
## 2.0.112021-07-08 ## 2.0.112021-07-08
- 优化 弹出层在超出视窗边缘定位不准确的问题 - 优化 弹出层在超出视窗边缘定位不准确的问题
## 2.0.102021-07-08 ## 2.0.102021-07-08
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的 bug - 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的Bug
- 优化 弹出层在超出视窗边缘被遮盖的问题 - 优化 弹出层在超出视窗边缘被遮盖的问题
## 2.0.92021-07-07 ## 2.0.92021-07-07
- 新增 maskClick 事件 - 新增 maskClick 事件
- 修复 特殊情况日历 rpx 布局错误的 bugrpx -> px - 修复 特殊情况日历 rpx 布局错误的Bugrpx -> px
- 修复 范围选择时清空返回值不合理的bug['', ''] -> [] - 修复 范围选择时清空返回值不合理的bug['', ''] -> []
## 2.0.82021-07-07 ## 2.0.82021-07-07
- 新增 日期时间显示框支持插槽 - 新增 日期时间显示框支持插槽
## 2.0.72021-07-01 ## 2.0.72021-07-01
- 优化 添加 uni-icons 依赖 - 优化 添加 uni-icons 依赖
## 2.0.62021-05-22 ## 2.0.62021-05-22
- 修复 图标在小程序上不显示的 bug - 修复 图标在小程序上不显示的Bug
- 优化 重命名引用组件,避免潜在组件命名冲突 - 优化 重命名引用组件,避免潜在组件命名冲突
## 2.0.52021-05-20 ## 2.0.52021-05-20
- 优化 代码目录扁平化 - 优化 代码目录扁平化
## 2.0.42021-05-12 ## 2.0.42021-05-12
- 新增 组件示例地址 - 新增 组件示例地址
## 2.0.32021-05-10 ## 2.0.32021-05-10
- 修复 ios 下不识别 '-' 日期格式的 bug - 修复 ios 下不识别 '-' 日期格式的Bug
- 优化 pc 下弹出层添加边框和阴影 - 优化 pc 下弹出层添加边框和阴影
## 2.0.22021-05-08 ## 2.0.22021-05-08
- 修复 在 admin 中获取弹出层定位错误的bug - 修复 在 admin 中获取弹出层定位错误的bug
@ -87,7 +127,7 @@
> 注意此版本不向后兼容不再支持单独时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker > 注意此版本不向后兼容不再支持单独时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker
## 1.0.62021-03-18 ## 1.0.62021-03-18
- 新增 hide-second 属性,时间支持仅选择时、分 - 新增 hide-second 属性,时间支持仅选择时、分
- 修复 选择跟显示的日期不一样的 bug - 修复 选择跟显示的日期不一样的Bug
- 修复 chang事件触发2次的 bug - 修复 chang事件触发2次的Bug
- 修复 分、秒 end 范围错误的 bug - 修复 分、秒 end 范围错误的Bug
- 优化 更好的 nvue 适配 - 优化 更好的 nvue 适配

View File

@ -16,7 +16,7 @@
<text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text> <text v-if="selected && weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
<text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text> <text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
</view> </view>
<view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view> <view :class="{'uni-calendar-item--today': weeks.isToday}"></view>
</view> </view>
</template> </template>
@ -41,10 +41,6 @@
return [] return []
} }
}, },
lunar: {
type: Boolean,
default: false
},
checkHover: { checkHover: {
type: Boolean, type: Boolean,
default: false default: false
@ -62,6 +58,8 @@
</script> </script>
<style lang="scss" > <style lang="scss" >
$uni-primary: #007aff !default;
.uni-calendar-item__weeks-box { .uni-calendar-item__weeks-box {
flex: 1; flex: 1;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -78,12 +76,7 @@
font-size: 14px; font-size: 14px;
// font-family: Lato-Bold, Lato; // font-family: Lato-Bold, Lato;
font-weight: bold; font-weight: bold;
color: #455997; color: darken($color: $uni-primary, $amount: 40%);
}
.uni-calendar-item__weeks-lunar-text {
font-size: 12px;
color: #333;
} }
.uni-calendar-item__weeks-box-item { .uni-calendar-item__weeks-box-item {
@ -114,7 +107,6 @@
} }
.uni-calendar-item__weeks-box .uni-calendar-item--disable { .uni-calendar-item__weeks-box .uni-calendar-item--disable {
// background-color: rgba(249, 249, 249, $uni-opacity-disabled);
cursor: default; cursor: default;
} }
@ -122,7 +114,7 @@
color: #D1D1D1; color: #D1D1D1;
} }
.uni-calendar-item--isDay { .uni-calendar-item--today {
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 17%; right: 17%;
@ -138,7 +130,7 @@
} }
.uni-calendar-item__weeks-box .uni-calendar-item--checked { .uni-calendar-item__weeks-box .uni-calendar-item--checked {
background-color: #007aff; background-color: $uni-primary;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
border: 3px solid #fff; border: 3px solid #fff;
@ -159,7 +151,7 @@
.uni-calendar-item--multiple .uni-calendar-item--before-checked, .uni-calendar-item--multiple .uni-calendar-item--before-checked,
.uni-calendar-item--multiple .uni-calendar-item--after-checked { .uni-calendar-item--multiple .uni-calendar-item--after-checked {
background-color: #409eff; background-color: $uni-primary;
border-radius: 50%; border-radius: 50%;
box-sizing: border-box; box-sizing: border-box;
border: 3px solid #F6F7FC; border: 3px solid #F6F7FC;

View File

@ -1,31 +1,37 @@
<template> <template>
<view class="uni-calendar" @mouseleave="leaveCale"> <view class="uni-calendar" @mouseleave="leaveCale">
<view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}" <view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
@click="clean"></view> @click="maskClick"></view>
<view v-if="insert || show" class="uni-calendar__content" <view v-if="insert || show" class="uni-calendar__content"
:class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}"> :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
<view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}"> <view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
<view v-if="left" class="uni-calendar__header-btn-box" @click.stop="pre">
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
<view class="uni-calendar__header-btn uni-calendar--left"></view> <view class="uni-calendar__header-btn uni-calendar--left"></view>
</view> </view>
<picker mode="date" :value="date" fields="month" @change="bindDateChange"> <picker mode="date" :value="date" fields="month" @change="bindDateChange">
<text <text
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text> class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
</picker> </picker>
<view v-if="right" class="uni-calendar__header-btn-box" @click.stop="next">
<view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<view v-if="!insert" class="dialog-close" @click="clean">
<view v-if="!insert" class="dialog-close" @click="close">
<view class="dialog-close-plus" data-id="close"></view> <view class="dialog-close-plus" data-id="close"></view>
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view> <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
</view> </view>
<!-- <text class="uni-calendar__backtoday" @click="backtoday">回到今天</text> -->
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
<view v-if="showMonth" class="uni-calendar__box-bg"> <view v-if="showMonth" class="uni-calendar__box-bg">
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text> <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view> </view>
<view class="uni-calendar__weeks" style="padding-bottom: 7px;"> <view class="uni-calendar__weeks" style="padding-bottom: 7px;">
<view class="uni-calendar__weeks-day"> <view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text> <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
@ -49,43 +55,45 @@
<text class="uni-calendar__weeks-day-text">{{SATText}}</text> <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view> </view>
</view> </view>
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex"> <view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex"> <view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar" <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate" :selected="selected" :checkHover="range" @change="choiceDate"
@handleMouse="handleMouse"> @handleMouse="handleMouse">
</calendar-item> </calendar-item>
</view> </view>
</view> </view>
</view> </view>
<view v-if="!insert && !range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"
<view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
style="padding: 0 80px;"> style="padding: 0 80px;">
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view> <view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
<time-picker type="time" :start="reactStartTime" :end="reactEndTime" v-model="time" <time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style"> :disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
<view v-if="!insert && range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"> <view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
<view class="uni-date-changed--time-start"> <view class="uni-date-changed--time-start">
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}} <view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
</view> </view>
<time-picker type="time" :start="reactStartTime" v-model="timeRange.startTime" :border="false" <time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style"> :hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
<uni-icons type="arrowthinright" color="#999" style="line-height: 50px;"></uni-icons> <view style="line-height: 50px;">
<uni-icons type="arrowthinright" color="#999"></uni-icons>
</view>
<view class="uni-date-changed--time-end"> <view class="uni-date-changed--time-end">
<view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view> <view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
<time-picker type="time" :end="reactEndTime" v-model="timeRange.endTime" :border="false" <time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style"> :hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
</time-picker> </time-picker>
</view> </view>
</view> </view>
<view v-if="!insert" class="uni-date-changed uni-date-btn--ok"> <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
<!-- <view class="uni-calendar__header-btn-box">
<text class="uni-calendar__button-text uni-calendar--fixed-width">{{okText}}</text>
</view> -->
<view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view> <view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
</view> </view>
</view> </view>
@ -93,22 +101,19 @@
</template> </template>
<script> <script>
import Calendar from './util.js'; import { Calendar, getDate, getTime } from './util.js';
import calendarItem from './calendar-item.vue' import calendarItem from './calendar-item.vue'
import timePicker from './time-picker.vue' import timePicker from './time-picker.vue'
import {
initVueI18n import { initVueI18n } from '@dcloudio/uni-i18n'
} from '@dcloudio/uni-i18n' import i18nMessages from './i18n/index.js'
import messages from './i18n/index.js' const { t } = initVueI18n(i18nMessages)
const {
t
} = initVueI18n(messages)
/** /**
* Calendar 日历 * Calendar 日历
* @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等 * @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56 * @tutorial https://ext.dcloud.net.cn/plugin?id=56
* @property {String} date 自定义当前时间默认为今天 * @property {String} date 自定义当前时间默认为今天
* @property {Boolean} lunar 显示农历
* @property {String} startDate 日期选择范围-开始日期 * @property {String} startDate 日期选择范围-开始日期
* @property {String} endDate 日期选择范围-结束日期 * @property {String} endDate 日期选择范围-结束日期
* @property {Boolean} range 范围选择 * @property {Boolean} range 范围选择
@ -118,10 +123,11 @@
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容 * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
* @property {Array} selected 打点期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] * @property {Array} selected 打点期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
* @property {Boolean} showMonth 是否选择月份为背景 * @property {Boolean} showMonth 是否选择月份为背景
* @property {[String} defaultValue 选择器打开时默认显示的时间
* @event {Function} change 日期改变`insert :ture` 时生效 * @event {Function} change 日期改变`insert :ture` 时生效
* @event {Function} confirm 确认选择`insert :false` 时生效 * @event {Function} confirm 确认选择`insert :false` 时生效
* @event {Function} monthSwitch 切换月份时触发 * @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" /> * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/ */
export default { export default {
components: { components: {
@ -149,10 +155,6 @@
return [] return []
} }
}, },
lunar: {
type: Boolean,
default: false
},
startDate: { startDate: {
type: String, type: String,
default: '' default: ''
@ -161,11 +163,19 @@
type: String, type: String,
default: '' default: ''
}, },
startPlaceholder: {
type: String,
default: ''
},
endPlaceholder: {
type: String,
default: ''
},
range: { range: {
type: Boolean, type: Boolean,
default: false default: false
}, },
typeHasTime: { hasTime: {
type: Boolean, type: Boolean,
default: false default: false
}, },
@ -181,14 +191,6 @@
type: Boolean, type: Boolean,
default: true default: true
}, },
left: {
type: Boolean,
default: true
},
right: {
type: Boolean,
default: true
},
checkHover: { checkHover: {
type: Boolean, type: Boolean,
default: true default: true
@ -207,6 +209,10 @@
fulldate: '' fulldate: ''
} }
} }
},
defaultValue: {
type: [String, Object, Array],
default: ''
} }
}, },
data() { data() {
@ -214,7 +220,7 @@
show: false, show: false,
weeks: [], weeks: [],
calendar: {}, calendar: {},
nowDate: '', nowDate: {},
aniMaskShow: false, aniMaskShow: false,
firstEnter: true, firstEnter: true,
time: '', time: '',
@ -232,7 +238,7 @@
watch: { watch: {
date: { date: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
if (!this.range) { if (!this.range) {
this.tempSingleDate = newVal this.tempSingleDate = newVal
setTimeout(() => { setTimeout(() => {
@ -243,33 +249,44 @@
}, },
defTime: { defTime: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
if (!this.range) { if (!this.range) {
this.time = newVal this.time = newVal
} else { } else {
// console.log('-----', newVal);
this.timeRange.startTime = newVal.start this.timeRange.startTime = newVal.start
this.timeRange.endTime = newVal.end this.timeRange.endTime = newVal.end
} }
} }
}, },
startDate(val) { startDate(val) {
this.cale.resetSatrtDate(val) // watch created
if(!this.cale){
return
}
this.cale.setStartDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
endDate(val) { endDate(val) {
this.cale.resetEndDate(val) // watch created
if(!this.cale){
return
}
this.cale.setEndDate(val)
this.cale.setDate(this.nowDate.fullDate) this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
selected(newVal) { selected(newVal) {
// watch created
if(!this.cale){
return
}
this.cale.setSelectInfo(this.nowDate.fullDate, newVal) this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
}, },
pleStatus: { pleStatus: {
immediate: true, immediate: true,
handler(newVal, oldVal) { handler(newVal) {
const { const {
before, before,
after, after,
@ -292,11 +309,16 @@
this.cale.lastHover = false this.cale.lastHover = false
} }
} else { } else {
// watch created
if(!this.cale){
return
}
this.cale.setDefaultMultiple(before, after) this.cale.setDefaultMultiple(before, after)
if (which === 'left') { if (which === 'left' && before) {
this.setDate(before) this.setDate(before)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
} else { } else if(after) {
this.setDate(after) this.setDate(after)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
} }
@ -307,15 +329,13 @@
} }
}, },
computed: { computed: {
reactStartTime() { timepickerStartTime() {
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
const res = activeDate === this.startDate ? this.selectableTimes.start : '' return activeDate === this.startDate ? this.selectableTimes.start : ''
return res
}, },
reactEndTime() { timepickerEndTime() {
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
const res = activeDate === this.endDate ? this.selectableTimes.end : '' return activeDate === this.endDate ? this.selectableTimes.end : ''
return res
}, },
/** /**
* for i18n * for i18n
@ -366,17 +386,13 @@
created() { created() {
// //
this.cale = new Calendar({ this.cale = new Calendar({
// date: new Date(),
selected: this.selected, selected: this.selected,
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
range: this.range, range: this.range,
// multipleStatus: this.pleStatus
}) })
// //
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
// this.setDay
}, },
methods: { methods: {
leaveCale() { leaveCale() {
@ -405,10 +421,10 @@
const [yearB, monthB] = B.split('-') const [yearB, monthB] = B.split('-')
return yearA === yearB && monthA === monthB return yearA === yearB && monthA === monthB
}, },
//
// 穿 maskClick() {
clean() {
this.close() this.close()
this.$emit('maskClose')
}, },
clearCalender() { clearCalender() {
@ -426,33 +442,49 @@
this.tempSingleDate = '' this.tempSingleDate = ''
} }
this.calendar.fullDate = '' this.calendar.fullDate = ''
this.setDate() this.setDate(new Date())
}, },
bindDateChange(e) { bindDateChange(e) {
const value = e.detail.value + '-1' const value = e.detail.value + '-1'
this.init(value) this.setDate(value)
}, },
/** /**
* 初始化日期显示 * 初始化日期显示
* @param {Object} date * @param {Object} date
*/ */
init(date) { init(date) {
this.cale.setDate(date) // watch created
if(!this.cale){
return
}
this.cale.setDate(date || new Date())
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date) this.nowDate = this.cale.getInfo(date)
this.calendar = {...this.nowDate}
if(!date){
// date
this.calendar.fullDate = ''
if(this.defaultValue && !this.range){
//
const defaultDate = new Date(this.defaultValue)
const fullDate = getDate(defaultDate)
const year = defaultDate.getFullYear()
const month = defaultDate.getMonth()+1
const date = defaultDate.getDate()
const day = defaultDate.getDay()
this.calendar = {
fullDate,
year,
month,
date,
day
},
this.tempSingleDate = fullDate
this.time = getTime(defaultDate, this.hideSecond)
}
}
}, },
// choiceDate(weeks) {
// if (weeks.disable) return
// this.calendar = weeks
// //
// this.cale.setMultiple(this.calendar.fullDate, true)
// this.weeks = this.cale.weeks
// this.tempSingleDate = this.calendar.fullDate
// this.tempRange.before = this.cale.multipleStatus.before
// this.tempRange.after = this.cale.multipleStatus.after
// this.change()
// },
/** /**
* 打开日历弹窗 * 打开日历弹窗
*/ */
@ -460,7 +492,6 @@
// //
if (this.clearDate && !this.insert) { if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus() this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date)
this.init(this.date) this.init(this.date)
} }
this.show = true this.show = true
@ -514,12 +545,20 @@
* @param {Object} name * @param {Object} name
*/ */
setEmit(name) { setEmit(name) {
if(!this.range){
if(!this.calendar.fullDate){
this.calendar = this.cale.getInfo(new Date())
this.tempSingleDate = this.calendar.fullDate
}
if(this.hasTime && !this.time) {
this.time = getTime(new Date(), this.hideSecond)
}
}
let { let {
year, year,
month, month,
date, date,
fullDate, fullDate,
lunar,
extraInfo extraInfo
} = this.calendar } = this.calendar
this.$emit(name, { this.$emit(name, {
@ -530,7 +569,6 @@
time: this.time, time: this.time,
timeRange: this.timeRange, timeRange: this.timeRange,
fulldate: fullDate, fulldate: fullDate,
lunar,
extraInfo: extraInfo || {} extraInfo: extraInfo || {}
}) })
}, },
@ -546,48 +584,26 @@
this.cale.setMultiple(this.calendar.fullDate, true) this.cale.setMultiple(this.calendar.fullDate, true)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
this.tempSingleDate = this.calendar.fullDate this.tempSingleDate = this.calendar.fullDate
const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
if (beforeDate > afterDate && afterDate) {
this.tempRange.before = this.cale.multipleStatus.after
this.tempRange.after = this.cale.multipleStatus.before
} else {
this.tempRange.before = this.cale.multipleStatus.before this.tempRange.before = this.cale.multipleStatus.before
this.tempRange.after = this.cale.multipleStatus.after this.tempRange.after = this.cale.multipleStatus.after
this.change()
},
/**
* 回到今天
*/
backtoday() {
let date = this.cale.getDate(new Date()).fullDate
// this.cale.setDate(date)
this.init(date)
this.change()
},
/**
* 比较时间大小
*/
dateCompare(startDate, endDate) {
//
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
//
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
} }
this.change()
}, },
/** changeMonth(type) {
* 上个月 let newDate
*/ if(type === 'pre') {
pre() { newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate } else if(type === 'next') {
this.setDate(preDate) newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
this.monthSwitch() }
}, this.setDate(newDate)
/**
* 下个月
*/
next() {
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate)
this.monthSwitch() this.monthSwitch()
}, },
/** /**
@ -604,6 +620,8 @@
</script> </script>
<style lang="scss" > <style lang="scss" >
$uni-primary: #007aff !default;
.uni-calendar { .uni-calendar {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -714,7 +732,7 @@
text-align: center; text-align: center;
width: 100px; width: 100px;
font-size: 14px; font-size: 14px;
color: #007aff; color: $uni-primary;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
letter-spacing: 3px; letter-spacing: 3px;
/* #endif */ /* #endif */
@ -845,6 +863,9 @@
.uni-date-changed--time-date { .uni-date-changed--time-date {
color: #999; color: #999;
line-height: 50px; line-height: 50px;
/* #ifdef MP-TOUTIAO */
font-size: 16px;
/* #endif */
margin-right: 5px; margin-right: 5px;
// opacity: 0.6; // opacity: 0.6;
} }
@ -893,7 +914,7 @@
border-radius: 100px; border-radius: 100px;
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
background-color: #007aff; background-color: $uni-primary;
color: #fff; color: #fff;
font-size: 16px; font-size: 16px;
letter-spacing: 2px; letter-spacing: 2px;

View File

@ -1,7 +1,7 @@
{ {
"uni-datetime-picker.selectDate": "select date", "uni-datetime-picker.selectDate": "select date",
"uni-datetime-picker.selectTime": "select time", "uni-datetime-picker.selectTime": "select time",
"uni-datetime-picker.selectDateTime": "select datetime", "uni-datetime-picker.selectDateTime": "select date and time",
"uni-datetime-picker.startDate": "start date", "uni-datetime-picker.startDate": "start date",
"uni-datetime-picker.endDate": "end date", "uni-datetime-picker.endDate": "end date",
"uni-datetime-picker.startTime": "start time", "uni-datetime-picker.startTime": "start time",

View File

@ -1,45 +0,0 @@
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
// #endif

View File

@ -77,21 +77,14 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef H5 -->
<!-- <keypress v-if="visible" @esc="tiggerTimePicker" @enter="setTime" /> -->
<!-- #endif -->
</view> </view>
</template> </template>
<script> <script>
// #ifdef H5 import { initVueI18n } from '@dcloudio/uni-i18n'
import keypress from './keypress' import i18nMessages from './i18n/index.js'
// #endif const { t } = initVueI18n(i18nMessages)
import { import { fixIosDateFormat } from './util'
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from './i18n/index.js'
const { t } = initVueI18n(messages)
/** /**
* DatetimePicker 时间选择器 * DatetimePicker 时间选择器
@ -108,11 +101,6 @@
export default { export default {
name: 'UniDatetimePicker', name: 'UniDatetimePicker',
components: {
// #ifdef H5
keypress
// #endif
},
data() { data() {
return { return {
indicatorStyle: `height: 50px;`, indicatorStyle: `height: 50px;`,
@ -185,10 +173,11 @@
} }
}, },
watch: { watch: {
// #ifndef VUE3
value: { value: {
handler(newVal, oldVal) { handler(newVal) {
if (newVal) { if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari this.parseValue(fixIosDateFormat(newVal))
this.initTime(false) this.initTime(false)
} else { } else {
this.time = '' this.time = ''
@ -197,6 +186,21 @@
}, },
immediate: true immediate: true
}, },
// #endif
// #ifdef VUE3
modelValue: {
handler(newVal) {
if (newVal) {
this.parseValue(fixIosDateFormat(newVal))
this.initTime(false)
} else {
this.time = ''
this.parseValue(Date.now())
}
},
immediate: true
},
// #endif
type: { type: {
handler(newValue) { handler(newValue) {
if (newValue === 'date') { if (newValue === 'date') {
@ -217,13 +221,13 @@
}, },
start: { start: {
handler(newVal) { handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'start') // iOSsafari this.parseDatetimeRange(fixIosDateFormat(newVal), 'start')
}, },
immediate: true immediate: true
}, },
end: { end: {
handler(newVal) { handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') // iOSsafari this.parseDatetimeRange(fixIosDateFormat(newVal), 'end')
}, },
immediate: true immediate: true
}, },
@ -527,7 +531,7 @@
const day = now.getDate() const day = now.getDate()
dateBase = year + '/' + month + '/' + day + ' ' dateBase = year + '/' + month + '/' + day + ' '
} }
if (Number(value) && typeof value !== NaN) { if (Number(value)) {
value = parseInt(value) value = parseInt(value)
dateBase = 0 dateBase = 0
} }
@ -598,7 +602,7 @@
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60 pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
return return
} }
if (Number(point) && Number(point) !== NaN) { if (Number(point)) {
point = parseInt(point) point = parseInt(point)
} }
// datetime end , // datetime end ,
@ -736,7 +740,7 @@
*/ */
initTimePicker() { initTimePicker() {
if (this.disabled) return if (this.disabled) return
const value = this.fixIosDateFormat(this.value) const value = fixIosDateFormat(this.time)
this.initPickerValue(value) this.initPickerValue(value)
this.visible = !this.visible this.visible = !this.visible
}, },
@ -770,7 +774,9 @@
} }
</script> </script>
<style> <style lang="scss">
$uni-primary: #007aff !default;
.uni-datetime-picker { .uni-datetime-picker {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
/* width: 100%; */ /* width: 100%; */
@ -804,7 +810,7 @@
.uni-datetime-picker-btn-text { .uni-datetime-picker-btn-text {
font-size: 14px; font-size: 14px;
color: #007AFF; color: $uni-primary;
} }
.uni-datetime-picker-btn-group { .uni-datetime-picker-btn-group {
@ -889,6 +895,7 @@
.uni-datetime-picker-text { .uni-datetime-picker-text {
font-size: 14px; font-size: 14px;
line-height: 50px
} }
.uni-datetime-picker-sign { .uni-datetime-picker-sign {

View File

@ -1,27 +1,24 @@
class Calendar { class Calendar {
constructor({ constructor({
date,
selected, selected,
startDate, startDate,
endDate, endDate,
range, range,
// multipleStatus
} = {}) { } = {}) {
// 当前日期 // 当前日期
this.date = this.getDate(new Date()) // 当前初入日期 this.date = this.getDateObj(new Date()) // 当前初入日期
// 打点信息 // 打点信息
this.selected = selected || []; this.selected = selected || [];
// 范围开始 // 起始时间
this.startDate = startDate this.startDate = startDate
// 范围结束 // 终止时间
this.endDate = endDate this.endDate = endDate
// 是否范围选择
this.range = range this.range = range
// 多选状态 // 多选状态
this.cleanMultipleStatus() this.cleanMultipleStatus()
// 每周日期 // 每周日期
this.weeks = {} this.weeks = {}
// this._getWeek(this.date.fullDate)
// this.multipleStatus = multipleStatus
this.lastHover = false this.lastHover = false
} }
/** /**
@ -29,8 +26,8 @@ class Calendar {
* @param {Object} date * @param {Object} date
*/ */
setDate(date) { setDate(date) {
this.selectDate = this.getDate(date) const selectDate = this.getDateObj(date)
this._getWeek(this.selectDate.fullDate) this.getWeeks(selectDate.fullDate)
} }
/** /**
@ -44,93 +41,82 @@ class Calendar {
} }
} }
/** setStartDate(startDate) {
* 重置开始日期
*/
resetSatrtDate(startDate) {
// 范围开始
this.startDate = startDate this.startDate = startDate
} }
/** setEndDate(endDate) {
* 重置结束日期
*/
resetEndDate(endDate) {
// 范围结束
this.endDate = endDate this.endDate = endDate
} }
getPreMonthObj(date){
date = fixIosDateFormat(date)
date = new Date(date)
const oldMonth = date.getMonth()
date.setMonth(oldMonth - 1)
const newMonth = date.getMonth()
if(oldMonth !== 0 && newMonth - oldMonth === 0){
date.setMonth(newMonth - 1)
}
return this.getDateObj(date)
}
getNextMonthObj(date){
date = fixIosDateFormat(date)
date = new Date(date)
const oldMonth = date.getMonth()
date.setMonth(oldMonth + 1)
const newMonth = date.getMonth()
if(newMonth - oldMonth > 1){
date.setMonth(newMonth - 1)
}
return this.getDateObj(date)
}
/** /**
* 获取任意时间 * 获取指定格式Date对象
*/ */
getDate(date, AddDayCount = 0, str = 'day') { getDateObj(date) {
if (!date) { date = fixIosDateFormat(date)
date = new Date() date = new Date(date)
}
if (typeof date !== 'object') {
date = date.replace(/-/g, '/')
}
const dd = new Date(date)
switch (str) {
case 'day':
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
break
case 'month':
if (dd.getDate() === 31) {
dd.setDate(dd.getDate() + AddDayCount)
} else {
dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期
}
break
case 'year':
dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
break
}
const y = dd.getFullYear()
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期不足10补0
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号不足10补0
return { return {
fullDate: y + '-' + m + '-' + d, fullDate: getDate(date),
year: y, year: date.getFullYear(),
month: m, month: addZero(date.getMonth() + 1),
date: d, date: addZero(date.getDate()),
day: dd.getDay() day: date.getDay()
} }
} }
/** /**
* 获取上月剩余天数 * 获取上一个月日期集合
*/ */
_getLastMonthDays(firstDay, full) { getPreMonthDays(amount, dateObj) {
let dateArr = [] const result = []
for (let i = firstDay; i > 0; i--) { for (let i = amount - 1; i >= 0; i--) {
const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate() const month = dateObj.month - 1
dateArr.push({ result.push({
date: beforeDate, date: new Date(dateObj.year, month, -i).getDate(),
month: full.month - 1, month,
disable: true disable: true
}) })
} }
return dateArr return result
} }
/** /**
* 获取本月天数 * 获取本月日期集合
*/ */
_currentMonthDys(dateData, full) { getCurrentMonthDays(amount, dateObj) {
let dateArr = [] const result = []
let fullDate = this.date.fullDate const fullDate = this.date.fullDate
for (let i = 1; i <= dateData; i++) { for (let i = 1; i <= amount; i++) {
let isinfo = false const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
let nowDate = full.year + '-' + (full.month < 10 ? const isToday = fullDate === currentDate
full.month : full.month) + '-' + (i < 10 ?
'0' + i : i)
// 是否今天
let isDay = fullDate === nowDate
// 获取打点信息 // 获取打点信息
let info = this.selected && this.selected.find((item) => { const info = this.selected && this.selected.find((item) => {
if (this.dateEqual(nowDate, item.date)) { if (this.dateEqual(currentDate, item.date)) {
return item return item
} }
}) })
@ -139,62 +125,52 @@ class Calendar {
let disableBefore = true let disableBefore = true
let disableAfter = true let disableAfter = true
if (this.startDate) { if (this.startDate) {
// let dateCompBefore = this.dateCompare(this.startDate, fullDate) disableBefore = dateCompare(this.startDate, currentDate)
// disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
disableBefore = this.dateCompare(this.startDate, nowDate)
} }
if (this.endDate) { if (this.endDate) {
// let dateCompAfter = this.dateCompare(fullDate, this.endDate) disableAfter = dateCompare(currentDate, this.endDate)
// disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
disableAfter = this.dateCompare(nowDate, this.endDate)
}
let multiples = this.multipleStatus.data
let checked = false
let multiplesStatus = -1
if (this.range) {
if (multiples) {
multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, nowDate)
})
}
if (multiplesStatus !== -1) {
checked = true
}
}
let data = {
fullDate: nowDate,
year: full.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after),
afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after),
month: full.month,
disable: !(disableBefore && disableAfter),
isDay,
userChecked: false
}
if (info) {
data.extraInfo = info
} }
dateArr.push(data) let multiples = this.multipleStatus.data
let multiplesStatus = -1
if (this.range && multiples) {
multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, currentDate)
})
} }
return dateArr const checked = multiplesStatus !== -1
result.push({
fullDate: currentDate,
year: dateObj.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after),
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after),
month: dateObj.month,
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)),
isToday,
userChecked: false,
extraInfo: info
})
}
return result
} }
/** /**
* 获取下月天数 * 获取下一个月日期集合
*/ */
_getNextMonthDays(surplus, full) { _getNextMonthDays(amount, dateObj) {
let dateArr = [] const result = []
for (let i = 1; i < surplus + 1; i++) { const month = dateObj.month + 1
dateArr.push({ for (let i = 1; i <= amount; i++) {
result.push({
date: i, date: i,
month: Number(full.month) + 1, month,
disable: true disable: true
}) })
} }
return dateArr return result
} }
/** /**
@ -205,58 +181,37 @@ class Calendar {
if (!date) { if (!date) {
date = new Date() date = new Date()
} }
const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
return dateInfo
}
/** return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
* 比较时间大小
*/
dateCompare(startDate, endDate) {
// 计算截止时间
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
// 计算详细项的截止时间
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
}
} }
/** /**
* 比较时间是否相等 * 比较时间是否相等
*/ */
dateEqual(before, after) { dateEqual(before, after) {
// 计算截止时间 before = new Date(fixIosDateFormat(before))
before = new Date(before.replace('-', '/').replace('-', '/')) after = new Date(fixIosDateFormat(after))
// 计算详细项的截止时间 return before.valueOf() === after.valueOf()
after = new Date(after.replace('-', '/').replace('-', '/'))
if (before.getTime() - after.getTime() === 0) {
return true
} else {
return false
}
} }
/** /**
* 比较真实起始日期 * 比较真实起始日期
*/ */
isLogicBefore(currentDay, before, after) { isLogicBefore(currentDate, before, after) {
let logicBefore = before let logicBefore = before
if (before && after) { if (before && after) {
logicBefore = this.dateCompare(before, after) ? before : after logicBefore = dateCompare(before, after) ? before : after
} }
return this.dateEqual(logicBefore, currentDay) return this.dateEqual(logicBefore, currentDate)
} }
isLogicAfter(currentDay, before, after) { isLogicAfter(currentDate, before, after) {
let logicAfter = after let logicAfter = after
if (before && after) { if (before && after) {
logicAfter = this.dateCompare(before, after) ? after : before logicAfter = dateCompare(before, after) ? after : before
} }
return this.dateEqual(logicAfter, currentDay) return this.dateEqual(logicAfter, currentDate)
} }
/** /**
@ -276,7 +231,7 @@ class Calendar {
var unixDe = de.getTime() - 24 * 60 * 60 * 1000 var unixDe = de.getTime() - 24 * 60 * 60 * 1000
for (var k = unixDb; k <= unixDe;) { for (var k = unixDb; k <= unixDe;) {
k = k + 24 * 60 * 60 * 1000 k = k + 24 * 60 * 60 * 1000
arr.push(this.getDate(new Date(parseInt(k))).fullDate) arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
} }
return arr return arr
} }
@ -285,11 +240,12 @@ class Calendar {
* 获取多选状态 * 获取多选状态
*/ */
setMultiple(fullDate) { setMultiple(fullDate) {
if (!this.range) return
let { let {
before, before,
after after
} = this.multipleStatus } = this.multipleStatus
if (!this.range) return
if (before && after) { if (before && after) {
if (!this.lastHover) { if (!this.lastHover) {
this.lastHover = true this.lastHover = true
@ -306,7 +262,7 @@ class Calendar {
this.lastHover = false this.lastHover = false
} else { } else {
this.multipleStatus.after = fullDate this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
.after); .after);
} else { } else {
@ -316,32 +272,28 @@ class Calendar {
this.lastHover = true this.lastHover = true
} }
} }
this._getWeek(fullDate) this.getWeeks(fullDate)
} }
/** /**
* 鼠标 hover 更新多选状态 * 鼠标 hover 更新多选状态
*/ */
setHoverMultiple(fullDate) { setHoverMultiple(fullDate) {
let { if (!this.range || this.lastHover) return
before,
after
} = this.multipleStatus
if (!this.range) return const { before } = this.multipleStatus
if (this.lastHover) return
if (!before) { if (!before) {
this.multipleStatus.before = fullDate this.multipleStatus.before = fullDate
} else { } else {
this.multipleStatus.after = fullDate this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
} else { } else {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
} }
} }
this._getWeek(fullDate) this.getWeeks(fullDate)
} }
/** /**
@ -351,12 +303,12 @@ class Calendar {
this.multipleStatus.before = before this.multipleStatus.before = before
this.multipleStatus.after = after this.multipleStatus.after = after
if (before && after) { if (before && after) {
if (this.dateCompare(before, after)) { if (dateCompare(before, after)) {
this.multipleStatus.data = this.geDateAll(before, after); this.multipleStatus.data = this.geDateAll(before, after);
this._getWeek(after) this.getWeeks(after)
} else { } else {
this.multipleStatus.data = this.geDateAll(after, before); this.multipleStatus.data = this.geDateAll(after, before);
this._getWeek(before) this.getWeeks(before)
} }
} }
} }
@ -365,46 +317,87 @@ class Calendar {
* 获取每周数据 * 获取每周数据
* @param {Object} dateData * @param {Object} dateData
*/ */
_getWeek(dateData) { getWeeks(dateData) {
const { const {
fullDate,
year, year,
month, month,
date, } = this.getDateObj(dateData)
day
} = this.getDate(dateData) const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
let firstDay = new Date(year, month - 1, 1).getDay() const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
let currentDay = new Date(year, month, 0).getDate()
let dates = { const currentMonthDayAmount = new Date(year, month, 0).getDate()
lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天 const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
nextMonthDays: [], // 下个月开始几天 const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
weeks: [] const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
const weeks = new Array(6)
for (let i = 0; i < calendarDays.length; i++) {
const index = Math.floor(i / 7)
if(!weeks[index]){
weeks[index] = new Array(7)
} }
let canlender = [] weeks[index][i % 7] = calendarDays[i]
const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
let weeks = {}
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for (let i = 0; i < canlender.length; i++) {
if (i % 7 === 0) {
weeks[parseInt(i / 7)] = new Array(7)
} }
weeks[parseInt(i / 7)][i % 7] = canlender[i]
} this.calendar = calendarDays
this.canlender = canlender
this.weeks = weeks this.weeks = weeks
} }
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
} }
function getDateTime(date, hideSecond){
return `${getDate(date)} ${getTime(date, hideSecond)}`
}
export default Calendar function getDate(date) {
date = fixIosDateFormat(date)
date = new Date(date)
const year = date.getFullYear()
const month = date.getMonth()+1
const day = date.getDate()
return `${year}-${addZero(month)}-${addZero(day)}`
}
function getTime(date, hideSecond){
date = fixIosDateFormat(date)
date = new Date(date)
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
}
function addZero(num) {
if(num < 10){
num = `0${num}`
}
return num
}
function getDefaultSecond(hideSecond) {
return hideSecond ? '00:00' : '00:00:00'
}
function dateCompare(startDate, endDate) {
startDate = new Date(fixIosDateFormat(startDate))
endDate = new Date(fixIosDateFormat(endDate))
return startDate <= endDate
}
function checkDate(date){
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
return date.match(dateReg)
}
const dateTimeReg = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( [0-5][0-9]:[0-5][0-9]:[0-5][0-9])?$/
function fixIosDateFormat(value) {
if (typeof value === 'string' && dateTimeReg.test(value)) {
value = value.replace(/-/g, '/')
}
return value
}
export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat}

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-datetime-picker", "id": "uni-datetime-picker",
"displayName": "uni-datetime-picker 日期选择器", "displayName": "uni-datetime-picker 日期选择器",
"version": "2.2.6", "version": "2.2.22",
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择", "description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
"keywords": [ "keywords": [
"uni-datetime-picker", "uni-datetime-picker",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,47 +1,97 @@
## 1.1.92023-04-11
- 修复 vue3 下 keyboardheightchange 事件报错的bug
## 1.1.82023-03-29
- 优化 trim 属性默认值
## 1.1.72023-03-29
- 新增 cursor-spacing 属性
## 1.1.62023-01-28
- 新增 keyboardheightchange 事件,可监听键盘高度变化
## 1.1.52022-11-29
- 优化 主题样式
## 1.1.42022-10-27
- 修复 props 中背景颜色无默认值的bug
## 1.1.02022-06-30 ## 1.1.02022-06-30
- 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容 - 新增 在 uni-forms 1.4.0 中使用可以在 blur 时校验内容
- 新增 clear 事件,点击右侧叉号图标触发 - 新增 clear 事件,点击右侧叉号图标触发
- 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发 - 新增 change 事件 ,仅在输入框失去焦点或用户按下回车时触发
- 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等 - 优化 组件样式,组件获取焦点时高亮显示,图标颜色调整等
-
## 1.0.52022-06-07 ## 1.0.52022-06-07
- 优化 clearable 显示策略 - 优化 clearable 显示策略
## 1.0.42022-06-07 ## 1.0.42022-06-07
- 优化 clearable 显示策略 - 优化 clearable 显示策略
## 1.0.32022-05-20 ## 1.0.32022-05-20
- 修复 关闭图标某些情况下无法取消的 bug - 修复 关闭图标某些情况下无法取消的 bug
## 1.0.22022-04-12 ## 1.0.22022-04-12
- 修复 默认值不生效的 bug - 修复 默认值不生效的 bug
## 1.0.12022-04-02 ## 1.0.12022-04-02
- 修复 value 不能为 0 的 bug - 修复 value 不能为 0 的 bug
## 1.0.02021-11-19 ## 1.0.02021-11-19
- 优化 组件 UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 优化 组件 UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-easyinput](https://uniapp.dcloud.io/component/uniui/uni-easyinput)
## 0.1.42021-08-20 ## 0.1.42021-08-20
- 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug - 修复 在 uni-forms 的动态表单中默认值校验不通过的 bug
## 0.1.32021-08-11 ## 0.1.32021-08-11
- 修复 在 uni-forms 中重置表单,错误信息无法清除的问题 - 修复 在 uni-forms 中重置表单,错误信息无法清除的问题
## 0.1.22021-07-30 ## 0.1.22021-07-30
- 优化 vue3 下事件警告的问题 - 优化 vue3 下事件警告的问题
## 0.1.1 ## 0.1.1
- 优化 errorMessage 属性支持 Boolean 类型 - 优化 errorMessage 属性支持 Boolean 类型
## 0.1.02021-07-13 ## 0.1.02021-07-13
- 组件兼容 vue3如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) - 组件兼容 vue3如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 0.0.162021-06-29 ## 0.0.162021-06-29
- 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug - 修复 confirmType 属性(仅 type="text" 生效)导致多行文本框无法换行的 bug
## 0.0.152021-06-21 ## 0.0.152021-06-21
- 修复 passwordIcon 属性拼写错误的 bug - 修复 passwordIcon 属性拼写错误的 bug
## 0.0.142021-06-18 ## 0.0.142021-06-18
- 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标 - 新增 passwordIcon 属性,当 type=password 时是否显示小眼睛图标
- 修复 confirmType 属性不生效的问题 - 修复 confirmType 属性不生效的问题
## 0.0.132021-06-04 ## 0.0.132021-06-04
- 修复 disabled 状态可清出内容的 bug - 修复 disabled 状态可清出内容的 bug
## 0.0.122021-05-12 ## 0.0.122021-05-12
- 新增 组件示例地址 - 新增 组件示例地址
## 0.0.112021-05-07 ## 0.0.112021-05-07
- 修复 input-border 属性不生效的问题 - 修复 input-border 属性不生效的问题
## 0.0.102021-04-30 ## 0.0.102021-04-30
- 修复 ios 遮挡文字、显示一半的问题 - 修复 ios 遮挡文字、显示一半的问题
## 0.0.92021-02-05 ## 0.0.92021-02-05
- 调整为 uni_modules 目录规范 - 调整为 uni_modules 目录规范
- 优化 兼容 nvue 页面 - 优化 兼容 nvue 页面

View File

@ -1,34 +1,74 @@
<template> <template>
<view class="uni-easyinput" :class="{ 'uni-easyinput-error': msg }" :style="boxStyle"> <view class="uni-easyinput" :class="{ 'uni-easyinput-error': msg }" :style="boxStyle">
<view class="uni-easyinput__content" :class="inputContentClass" :style="inputContentStyle"> <view class="uni-easyinput__content" :class="inputContentClass" :style="inputContentStyle">
<uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" <uni-icons v-if="prefixIcon" class="content-clear-icon" :type="prefixIcon" color="#c0c4cc" @click="onClickIcon('prefix')" size="22"></uni-icons>
@click="onClickIcon('prefix')" size="22"></uni-icons> <textarea
<textarea v-if="type === 'textarea'" class="uni-easyinput__content-textarea" v-if="type === 'textarea'"
:class="{'input-padding':inputBorder}" :name="name" :value="val" :placeholder="placeholder" class="uni-easyinput__content-textarea"
:placeholderStyle="placeholderStyle" :disabled="disabled" :class="{ 'input-padding': inputBorder }"
placeholder-class="uni-easyinput__placeholder-class" :maxlength="inputMaxlength" :focus="focused" :name="name"
:autoHeight="autoHeight" @input="onInput" @blur="_Blur" @focus="_Focus" @confirm="onConfirm"></textarea> :value="val"
<input v-else :type="type === 'password'?'text':type" class="uni-easyinput__content-input" :placeholder="placeholder"
:style="inputStyle" :name="name" :value="val" :password="!showPassword && type === 'password'" :placeholderStyle="placeholderStyle"
:placeholder="placeholder" :placeholderStyle="placeholderStyle" :disabled="disabled"
placeholder-class="uni-easyinput__placeholder-class" :disabled="disabled" :maxlength="inputMaxlength" placeholder-class="uni-easyinput__placeholder-class"
:focus="focused" :confirmType="confirmType" @focus="_Focus" @blur="_Blur" @input="onInput" :maxlength="inputMaxlength"
@confirm="onConfirm" /> :focus="focused"
:autoHeight="autoHeight"
:cursor-spacing="cursorSpacing"
@input="onInput"
@blur="_Blur"
@focus="_Focus"
@confirm="onConfirm"
@keyboardheightchange="onkeyboardheightchange"
></textarea>
<input
v-else
:type="type === 'password' ? 'text' : type"
class="uni-easyinput__content-input"
:style="inputStyle"
:name="name"
:value="val"
:password="!showPassword && type === 'password'"
:placeholder="placeholder"
:placeholderStyle="placeholderStyle"
placeholder-class="uni-easyinput__placeholder-class"
:disabled="disabled"
:maxlength="inputMaxlength"
:focus="focused"
:confirmType="confirmType"
:cursor-spacing="cursorSpacing"
@focus="_Focus"
@blur="_Blur"
@input="onInput"
@confirm="onConfirm"
@keyboardheightchange="onkeyboardheightchange"
/>
<template v-if="type === 'password' && passwordIcon"> <template v-if="type === 'password' && passwordIcon">
<!-- 开启密码时显示小眼睛 --> <!-- 开启密码时显示小眼睛 -->
<uni-icons v-if="isVal" class="content-clear-icon" :class="{'is-textarea-icon':type==='textarea'}" <uni-icons
:type="showPassword?'eye-slash-filled':'eye-filled'" :size="22" v-if="isVal"
:color="focusShow?'#2979ff':'#c0c4cc'" @click="onEyes"> class="content-clear-icon"
</uni-icons> :class="{ 'is-textarea-icon': type === 'textarea' }"
:type="showPassword ? 'eye-slash-filled' : 'eye-filled'"
:size="22"
:color="focusShow ? primaryColor : '#c0c4cc'"
@click="onEyes"
></uni-icons>
</template> </template>
<template v-else-if="suffixIcon"> <template v-else-if="suffixIcon">
<uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" <uni-icons v-if="suffixIcon" class="content-clear-icon" :type="suffixIcon" color="#c0c4cc" @click="onClickIcon('suffix')" size="22"></uni-icons>
@click="onClickIcon('suffix')" size="22"></uni-icons>
</template> </template>
<template v-else> <template v-else>
<uni-icons v-if="clearable && isVal && !disabled && type !== 'textarea'" class="content-clear-icon" <uni-icons
:class="{'is-textarea-icon':type==='textarea'}" type="clear" :size="clearSize" v-if="clearable && isVal && !disabled && type !== 'textarea'"
:color="msg?'#dd524d':(focusShow?'#2979ff':'#c0c4cc')" @click="onClear"></uni-icons> class="content-clear-icon"
:class="{ 'is-textarea-icon': type === 'textarea' }"
type="clear"
:size="clearSize"
:color="msg ? '#dd524d' : focusShow ? primaryColor : '#c0c4cc'"
@click="onClear"
></uni-icons>
</template> </template>
<slot name="right"></slot> <slot name="right"></slot>
</view> </view>
@ -59,7 +99,9 @@
* @property {Number } clearSize 清除图标的大小单位px默认15 * @property {Number } clearSize 清除图标的大小单位px默认15
* @property {String} prefixIcon 输入框头部图标 * @property {String} prefixIcon 输入框头部图标
* @property {String} suffixIcon 输入框尾部图标 * @property {String} suffixIcon 输入框尾部图标
* @property {String} primaryColor 设置主题色默认#2979ff
* @property {Boolean} trim 是否自动去除两端的空格 * @property {Boolean} trim 是否自动去除两端的空格
* @property {Boolean} cursorSpacing 指定光标与键盘的距离单位 px
* @value both 去除两端空格 * @value both 去除两端空格
* @value left 去除左侧空格 * @value left 去除左侧空格
* @value right 去除右侧空格 * @value right 去除右侧空格
@ -78,27 +120,27 @@
* @example <uni-easyinput v-model="mobile"></uni-easyinput> * @example <uni-easyinput v-model="mobile"></uni-easyinput>
*/ */
function obj2strClass(obj) { function obj2strClass(obj) {
let classess = '' let classess = '';
for (let key in obj) { for (let key in obj) {
const val = obj[key] const val = obj[key];
if (val) { if (val) {
classess += `${key} ` classess += `${key} `;
} }
} }
return classess return classess;
} }
function obj2strStyle(obj) { function obj2strStyle(obj) {
let style = '' let style = '';
for (let key in obj) { for (let key in obj) {
const val = obj[key] const val = obj[key];
style += `${key}:${val};` style += `${key}:${val};`;
} }
return style return style;
} }
export default { export default {
name: 'uni-easyinput', name: 'uni-easyinput',
emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm', 'clear', 'eyes', 'change'], emits: ['click', 'iconClick', 'update:modelValue', 'input', 'focus', 'blur', 'confirm', 'clear', 'eyes', 'change', 'keyboardheightchange'],
model: { model: {
prop: 'modelValue', prop: 'modelValue',
event: 'update:modelValue' event: 'update:modelValue'
@ -114,7 +156,7 @@
formItem: { formItem: {
from: 'uniFormItem', from: 'uniFormItem',
default: null default: null
}, }
}, },
props: { props: {
name: String, name: String,
@ -171,20 +213,29 @@
}, },
trim: { trim: {
type: [Boolean, String], type: [Boolean, String],
default: true default: false
},
cursorSpacing: {
type: Number,
default: 0
}, },
passwordIcon: { passwordIcon: {
type: Boolean, type: Boolean,
default: true default: true
}, },
primaryColor: {
type: String,
default: '#2979ff'
},
styles: { styles: {
type: Object, type: Object,
default() { default() {
return { return {
color: '#333', color: '#333',
backgroundColor: '#fff',
disableColor: '#F7F6F6', disableColor: '#F7F6F6',
borderColor: '#e5e5e5' borderColor: '#e5e5e5'
} };
} }
}, },
errorMessage: { errorMessage: {
@ -202,18 +253,19 @@
showClearIcon: false, showClearIcon: false,
showPassword: false, showPassword: false,
focusShow: false, focusShow: false,
localMsg: '' localMsg: '',
isEnter: false // 使
}; };
}, },
computed: { computed: {
// //
isVal() { isVal() {
const val = this.val const val = this.val;
// fixed by mehaotian 00 // fixed by mehaotian 00
if (val || val === 0) { if (val || val === 0) {
return true return true;
} }
return false return false;
}, },
msg() { msg() {
@ -222,7 +274,7 @@
// return this.errorMessage || this.formItem.errMsg; // return this.errorMessage || this.formItem.errMsg;
// } // }
// TODO formItem errMsg // TODO formItem errMsg
return this.localMsg || this.errorMessage return this.localMsg || this.errorMessage;
}, },
// uniappinputmaxlength // uniappinputmaxlength
inputMaxlength() { inputMaxlength() {
@ -231,7 +283,7 @@
// style // style
boxStyle() { boxStyle() {
return `color:${this.inputBorder && this.msg?'#e43d33':this.styles.color};` return `color:${this.inputBorder && this.msg ? '#e43d33' : this.styles.color};`;
}, },
// input // input
inputContentClass() { inputContentClass() {
@ -239,54 +291,55 @@
'is-input-border': this.inputBorder, 'is-input-border': this.inputBorder,
'is-input-error-border': this.inputBorder && this.msg, 'is-input-error-border': this.inputBorder && this.msg,
'is-textarea': this.type === 'textarea', 'is-textarea': this.type === 'textarea',
'is-disabled': this.disabled 'is-disabled': this.disabled,
}) 'is-focused': this.focusShow
});
}, },
inputContentStyle() { inputContentStyle() {
const focusColor = this.focusShow ? '#2979ff' : this.styles.borderColor const focusColor = this.focusShow ? this.primaryColor : this.styles.borderColor;
const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor const borderColor = this.inputBorder && this.msg ? '#dd524d' : focusColor;
return obj2strStyle({ return obj2strStyle({
'border-color': borderColor || '#e5e5e5', 'border-color': borderColor || '#e5e5e5',
'background-color': this.disabled ? this.styles.disableColor : '#fff' 'background-color': this.disabled ? this.styles.disableColor : this.styles.backgroundColor
}) });
}, },
// input // input
inputStyle() { inputStyle() {
const paddingRight = this.type === 'password' || this.clearable || this.prefixIcon ? '' : '10px' const paddingRight = this.type === 'password' || this.clearable || this.prefixIcon ? '' : '10px';
return obj2strStyle({ return obj2strStyle({
'padding-right': paddingRight, 'padding-right': paddingRight,
'padding-left': this.prefixIcon ? '' : '10px' 'padding-left': this.prefixIcon ? '' : '10px'
}) });
} }
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.val = newVal this.val = newVal;
}, },
modelValue(newVal) { modelValue(newVal) {
this.val = newVal this.val = newVal;
}, },
focus(newVal) { focus(newVal) {
this.$nextTick(() => { this.$nextTick(() => {
this.focused = this.focus this.focused = this.focus;
this.focusShow = this.focus this.focusShow = this.focus;
}) });
} }
}, },
created() { created() {
this.init() this.init();
// TODO vue3 computed inject formItem.errMsg // TODO vue3 computed inject formItem.errMsg
if (this.form && this.formItem) { if (this.form && this.formItem) {
this.$watch('formItem.errMsg', (newVal) => { this.$watch('formItem.errMsg', newVal => {
this.localMsg = newVal this.localMsg = newVal;
}) });
} }
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.focused = this.focus this.focused = this.focus;
this.focusShow = this.focus this.focusShow = this.focus;
}) });
}, },
methods: { methods: {
/** /**
@ -294,11 +347,11 @@
*/ */
init() { init() {
if (this.value || this.value === 0) { if (this.value || this.value === 0) {
this.val = this.value this.val = this.value;
} else if (this.modelValue || this.modelValue === 0) { } else if (this.modelValue || this.modelValue === 0 || this.modelValue === '') {
this.val = this.modelValue this.val = this.modelValue;
} else { } else {
this.val = null this.val = null;
} }
}, },
@ -307,15 +360,15 @@
* @param {Object} type * @param {Object} type
*/ */
onClickIcon(type) { onClickIcon(type) {
this.$emit('iconClick', type) this.$emit('iconClick', type);
}, },
/** /**
* 显示隐藏内容密码框时生效 * 显示隐藏内容密码框时生效
*/ */
onEyes() { onEyes() {
this.showPassword = !this.showPassword this.showPassword = !this.showPassword;
this.$emit('eyes', this.showPassword) this.$emit('eyes', this.showPassword);
}, },
/** /**
@ -326,19 +379,19 @@
let value = event.detail.value; let value = event.detail.value;
// //
if (this.trim) { if (this.trim) {
if (typeof(this.trim) === 'boolean' && this.trim) { if (typeof this.trim === 'boolean' && this.trim) {
value = this.trimStr(value) value = this.trimStr(value);
} }
if (typeof(this.trim) === 'string') { if (typeof this.trim === 'string') {
value = this.trimStr(value, this.trim) value = this.trimStr(value, this.trim);
} }
}; }
if (this.errMsg) this.errMsg = '' if (this.errMsg) this.errMsg = '';
this.val = value this.val = value;
// TODO vue2 // TODO vue2
this.$emit('input', value); this.$emit('input', value);
// TODO  vue3 // TODO  vue3
this.$emit('update:modelValue', value) this.$emit('update:modelValue', value);
}, },
/** /**
@ -348,13 +401,13 @@
*/ */
onFocus() { onFocus() {
this.$nextTick(() => { this.$nextTick(() => {
this.focused = true this.focused = true;
}) });
this.$emit('focus', null); this.$emit('focus', null);
}, },
_Focus(event) { _Focus(event) {
this.focusShow = true this.focusShow = true;
this.$emit('focus', event); this.$emit('focus', event);
}, },
@ -364,22 +417,22 @@
* @param {Object} event * @param {Object} event
*/ */
onBlur() { onBlur() {
this.focused = false this.focused = false;
this.$emit('focus', null); this.$emit('focus', null);
}, },
_Blur(event) { _Blur(event) {
let value = event.detail.value; let value = event.detail.value;
this.focusShow = false this.focusShow = false;
this.$emit('blur', event); this.$emit('blur', event);
// eventstring // eventstring
this.$emit('change', this.val) if (this.isEnter === false) {
this.$emit('change', this.val);
}
// //
if (this.form && this.formItem) { if (this.form && this.formItem) {
const { const { validateTrigger } = this.form;
validateTrigger
} = this.form
if (validateTrigger === 'blur') { if (validateTrigger === 'blur') {
this.formItem.onFieldChange() this.formItem.onFieldChange();
} }
} }
}, },
@ -390,7 +443,11 @@
*/ */
onConfirm(e) { onConfirm(e) {
this.$emit('confirm', this.val); this.$emit('confirm', this.val);
this.$emit('change', this.val) this.isEnter = true;
this.$emit('change', this.val);
this.$nextTick(() => {
this.isEnter = false;
});
}, },
/** /**
@ -403,9 +460,18 @@
this.$emit('input', ''); this.$emit('input', '');
// TODO vue2 // TODO vue2
// TODO  vue3 // TODO  vue3
this.$emit('update:modelValue', '') this.$emit('update:modelValue', '');
// //
this.$emit('clear') this.$emit('clear');
},
/**
* 键盘高度发生变化的时候触发此事件
* 兼容性微信小程序2.7.0+App 3.1.0+
* @param {Object} event
*/
onkeyboardheightchange(event) {
this.$emit("keyboardheightchange",event);
}, },
/** /**
@ -419,9 +485,9 @@
} else if (pos === 'right') { } else if (pos === 'right') {
return str.trimRight(); return str.trimRight();
} else if (pos === 'start') { } else if (pos === 'start') {
return str.trimStart() return str.trimStart();
} else if (pos === 'end') { } else if (pos === 'end') {
return str.trimEnd() return str.trimEnd();
} else if (pos === 'all') { } else if (pos === 'all') {
return str.replace(/\s+/g, ''); return str.replace(/\s+/g, '');
} else if (pos === 'none') { } else if (pos === 'none') {
@ -435,7 +501,7 @@
<style lang="scss"> <style lang="scss">
$uni-error: #e43d33; $uni-error: #e43d33;
$uni-border-1: #DCDFE6 !default; $uni-border-1: #dcdfe6 !default;
.uni-easyinput { .uni-easyinput {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -556,11 +622,9 @@
.uni-easyinput__placeholder-class { .uni-easyinput__placeholder-class {
color: mix(#fff, $uni-error, 50%); color: mix(#fff, $uni-error, 50%);
;
} }
} }
.uni-easyinput--border { .uni-easyinput--border {
margin-bottom: 0; margin-bottom: 0;
padding: 10px 15px; padding: 10px 15px;
@ -582,11 +646,11 @@
} }
.is-disabled { .is-disabled {
background-color: #F7F6F6; background-color: #f7f6f6;
color: #D5D5D5; color: #d5d5d5;
.uni-easyinput__placeholder-class { .uni-easyinput__placeholder-class {
color: #D5D5D5; color: #d5d5d5;
font-size: 12px; font-size: 12px;
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-easyinput", "id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框", "displayName": "uni-easyinput 增强输入框",
"version": "1.1.0", "version": "1.1.9",
"description": "Easyinput 组件是对原生input组件的增强", "description": "Easyinput 组件是对原生input组件的增强",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,9 @@
## 1.2.52023-03-29
- 新增 pattern.icon 属性,可自定义图标
## 1.2.42022-09-07
小程序端由于 style 使用了对象导致报错,[详情](https://ask.dcloud.net.cn/question/152790?item_id=211778&rf=false)
## 1.2.32022-09-05
- 修复 nvue 环境下,具有 tabBar 时fab 组件下部位置无法正常获取 --window-bottom 的bug详见[https://ask.dcloud.net.cn/question/110638?notification_id=826310](https://ask.dcloud.net.cn/question/110638?notification_id=826310)
## 1.2.22021-12-29 ## 1.2.22021-12-29
- 更新 组件依赖 - 更新 组件依赖
## 1.2.12021-11-19 ## 1.2.12021-11-19

View File

@ -5,7 +5,9 @@
'uni-fab--rightBottom': rightBottom, 'uni-fab--rightBottom': rightBottom,
'uni-fab--leftTop': leftTop, 'uni-fab--leftTop': leftTop,
'uni-fab--rightTop': rightTop 'uni-fab--rightTop': rightTop
}" class="uni-fab"> }" class="uni-fab"
:style="nvueBottom"
>
<view :class="{ <view :class="{
'uni-fab__content--left': horizontal === 'left', 'uni-fab__content--left': horizontal === 'left',
'uni-fab__content--right': horizontal === 'right', 'uni-fab__content--right': horizontal === 'right',
@ -32,8 +34,8 @@
'uni-fab__circle--leftTop': leftTop, 'uni-fab__circle--leftTop': leftTop,
'uni-fab__circle--rightTop': rightTop, 'uni-fab__circle--rightTop': rightTop,
'uni-fab__content--other-platform': !isAndroidNvue 'uni-fab__content--other-platform': !isAndroidNvue
}" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor }" @click="_onClick"> }" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor, 'bottom': nvueBottom }" @click="_onClick">
<uni-icons class="fab-circle-icon" type="plusempty" :color="styles.iconColor" size="32" <uni-icons class="fab-circle-icon" :type="styles.icon" :color="styles.iconColor" size="32"
:class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons> :class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons>
<!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> <!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view>
<view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> --> <view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> -->
@ -113,7 +115,8 @@
selectedColor: '#007AFF', selectedColor: '#007AFF',
backgroundColor: '#fff', backgroundColor: '#fff',
buttonColor: '#007AFF', buttonColor: '#007AFF',
iconColor: '#fff' iconColor: '#fff',
icon: 'plusempty'
} }
} }
}, },
@ -158,6 +161,16 @@
}, },
horizontalRight() { horizontalRight() {
return this.getPosition(2, 'horizontal', 'right') return this.getPosition(2, 'horizontal', 'right')
},
// nvue bottom
nvueBottom() {
const safeBottom = uni.getSystemInfoSync().windowBottom;
// #ifdef APP-NVUE
return 30 + safeBottom
// #endif
// #ifndef APP-NVUE
return 30
// #endif
} }
}, },
watch: { watch: {
@ -194,6 +207,9 @@
* 按钮点击事件 * 按钮点击事件
*/ */
_onItemClick(index, item) { _onItemClick(index, item) {
if (!this.isShow) {
return
}
this.$emit('trigger', { this.$emit('trigger', {
index, index,
item item

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-fab", "id": "uni-fab",
"displayName": "uni-fab 悬浮按钮", "displayName": "uni-fab 悬浮按钮",
"version": "1.2.2", "version": "1.2.5",
"description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。", "description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss","uni-icons"], "dependencies": ["uni-scss","uni-icons"],

View File

@ -1,3 +1,7 @@
## 1.0.42023-03-29
- 修复 手动上传删除一个文件后不能再上传的bug
## 1.0.32022-12-19
- 新增 sourceType 属性, 可以自定义图片和视频选择的来源
## 1.0.22022-07-04 ## 1.0.22022-07-04
- 修复 在uni-forms下样式不生效的bug - 修复 在uni-forms下样式不生效的bug
## 1.0.12021-11-23 ## 1.0.12021-11-23

View File

@ -7,7 +7,7 @@ function chooseImage(opts) {
const { const {
count, count,
sizeType = ['original', 'compressed'], sizeType = ['original', 'compressed'],
sourceType = ['album', 'camera'], sourceType,
extension extension
} = opts } = opts
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -33,7 +33,7 @@ function chooseVideo(opts) {
camera, camera,
compressed, compressed,
maxDuration, maxDuration,
sourceType = ['album', 'camera'], sourceType,
extension extension
} = opts; } = opts;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -185,6 +185,12 @@
default () { default () {
return ['original', 'compressed'] return ['original', 'compressed']
} }
},
sourceType: {
type: Array,
default () {
return ['album', 'camera']
}
} }
}, },
data() { data() {
@ -349,6 +355,7 @@
type: this.fileMediatype, type: this.fileMediatype,
compressed: false, compressed: false,
sizeType: this.sizeType, sizeType: this.sizeType,
sourceType: this.sourceType,
// TODO video // TODO video
extension: _extname.length > 0 ? _extname : undefined, extension: _extname.length > 0 ? _extname : undefined,
count: this.limitLength - this.files.length, //9 count: this.limitLength - this.files.length, //9
@ -576,7 +583,11 @@
path: v.path, path: v.path,
size: v.size, size: v.size,
fileID:v.fileID, fileID:v.fileID,
url: v.url url: v.url,
// bug, #694
uuid: v.uuid,
status: v.status,
cloudPath: v.cloudPath
}) })
}) })
return newFilesData return newFilesData

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-file-picker", "id": "uni-file-picker",
"displayName": "uni-file-picker 文件选择上传", "displayName": "uni-file-picker 文件选择上传",
"version": "1.0.2", "version": "1.0.4",
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间", "description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,10 +17,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -37,7 +33,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss"], "dependencies": ["uni-scss"],

View File

@ -1,3 +1,9 @@
## 1.4.92023-02-10
- 修复 required 参数无法动态绑定
## 1.4.82022-08-23
- 优化 根据 rules 自动添加 required 的问题
## 1.4.72022-08-22
- 修复 item 未设置 require 属性rules 设置 require 后,星号也显示的 bug详见[https://ask.dcloud.net.cn/question/151540](https://ask.dcloud.net.cn/question/151540)
## 1.4.62022-07-13 ## 1.4.62022-07-13
- 修复 model 需要校验的值没有声明对应字段时导致第一次不触发校验的bug - 修复 model 需要校验的值没有声明对应字段时导致第一次不触发校验的bug
## 1.4.52022-07-05 ## 1.4.52022-07-05

View File

@ -2,9 +2,9 @@
<view class="uni-forms-item" <view class="uni-forms-item"
:class="['is-direction-' + localLabelPos ,border?'uni-forms-item--border':'' ,border && isFirstBorder?'is-first-border':'']"> :class="['is-direction-' + localLabelPos ,border?'uni-forms-item--border':'' ,border && isFirstBorder?'is-first-border':'']">
<slot name="label"> <slot name="label">
<view class="uni-forms-item__label" :class="{'no-label':!label && !isRequired}" <view class="uni-forms-item__label" :class="{'no-label':!label && !required}"
:style="{width:localLabelWidth,justifyContent: localLabelAlign}"> :style="{width:localLabelWidth,justifyContent: localLabelAlign}">
<text v-if="isRequired" class="is-required">*</text> <text v-if="required" class="is-required">*</text>
<text>{{label}}</text> <text>{{label}}</text>
</view> </view>
</slot> </slot>
@ -126,7 +126,6 @@
data() { data() {
return { return {
errMsg: '', errMsg: '',
isRequired: false,
userRules: null, userRules: null,
localLabelAlign: 'left', localLabelAlign: 'left',
localLabelWidth: '65px', localLabelWidth: '65px',
@ -315,7 +314,6 @@
this.localLabelWidth = this._labelWidthUnit(labelWidth) this.localLabelWidth = this._labelWidthUnit(labelWidth)
// //
this.localLabelPos = this._labelPosition() this.localLabelPos = this._labelPosition()
this.isRequired = this.required
// form // form
this.form && type && childrens.push(this) this.form && type && childrens.push(this)
@ -351,8 +349,6 @@
this.validator = validator this.validator = validator
// //
this.itemSetValue(_getDataValue(this.name, localData)) this.itemSetValue(_getDataValue(this.name, localData))
this.isRequired = this._isRequired()
}, },
unInit() { unInit() {
if (this.form) { if (this.form) {
@ -387,9 +383,13 @@
// //
_isRequired() { _isRequired() {
if (this.form) { // TODO
return this.required || this.form._isRequiredField(this.itemRules.rules || []) // if (this.form) {
} // if (this.form._isRequiredField(this.itemRules.rules || []) && this.required) {
// return true
// }
// return false
// }
return this.required return this.required
}, },

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-forms", "id": "uni-forms",
"displayName": "uni-forms 表单", "displayName": "uni-forms 表单",
"version": "1.4.6", "version": "1.4.9",
"description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据", "description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,29 @@
## 1.2.142023-04-14
- 优化 uni-list-chat 具名插槽`header` 非app端套一层元素方便使用时通过外层元素定位实现样式修改
## 1.2.132023-03-03
- uni-list-chat 新增 支持具名插槽`header`
## 1.2.122023-02-01
- 新增 列表图标新增 customPrefix 属性 ,用法 [详见](https://uniapp.dcloud.net.cn/component/uniui/uni-icons.html#icons-props)
## 1.2.112023-01-31
- 修复 无反馈效果呈现的bug
## 1.2.92022-11-22
- 修复 uni-list-chat 在vue3下跳转报错的bug
## 1.2.82022-11-21
- 修复 uni-list-chat avatar属性 值为本地路径时错误的问题
## 1.2.72022-11-21
- 修复 uni-list-chat avatar属性 在腾讯云版uniCloud下错误的问题
## 1.2.62022-11-18
- 修复 uni-list-chat note属性 支持:“草稿”字样功能 文本少1位的问题
## 1.2.52022-11-15
- 修复 uni-list-item 的 customStyle 属性 padding值在 H5端 无效的bug
## 1.2.42022-11-15
- 修复 uni-list-item 的 customStyle 属性 padding值在nvuevue2下无效的bug
## 1.2.32022-11-14
- uni-list-chat 新增 avatar 支持 fileId
## 1.2.22022-11-11
- uni-list 新增属性 render-reverse 详情参考:[https://uniapp.dcloud.net.cn/component/list.html](https://uniapp.dcloud.net.cn/component/list.html)
- uni-list-chat note属性 支持:“草稿”字样 加红显示 详情参考uni-im[https://ext.dcloud.net.cn/plugin?name=uni-im](https://ext.dcloud.net.cn/plugin?name=uni-im)
- uni-list-item 新增属性 customStyle 支持设置padding、backgroundColor
## 1.2.12022-03-30 ## 1.2.12022-03-30
- 删除无用文件 - 删除无用文件
## 1.2.02021-11-23 ## 1.2.02021-11-23

View File

@ -7,7 +7,7 @@
<view class="uni-list-chat__container"> <view class="uni-list-chat__container">
<view class="uni-list-chat__header-warp"> <view class="uni-list-chat__header-warp">
<view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }"> <view v-if="avatarCircle || avatarList.length === 0" class="uni-list-chat__header" :class="{ 'header--circle': avatarCircle }">
<image class="uni-list-chat__header-image" :class="{ 'header--circle': avatarCircle }" :src="avatar" mode="aspectFill"></image> <image class="uni-list-chat__header-image" :class="{ 'header--circle': avatarCircle }" :src="avatarUrl" mode="aspectFill"></image>
</view> </view>
<!-- 头像组 --> <!-- 头像组 -->
<view v-else class="uni-list-chat__header"> <view v-else class="uni-list-chat__header">
@ -18,13 +18,23 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifndef APP -->
<view class="slot-header">
<!-- #endif -->
<slot name="header"></slot>
<!-- #ifndef APP -->
</view>
<!-- #endif -->
<view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]"> <view v-if="badgeText && badgePositon === 'left'" class="uni-list-chat__badge uni-list-chat__badge-pos" :class="[isSingle]">
<text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text> <text class="uni-list-chat__badge-text">{{ badgeText === 'dot' ? '' : badgeText }}</text>
</view> </view>
<view class="uni-list-chat__content"> <view class="uni-list-chat__content">
<view class="uni-list-chat__content-main"> <view class="uni-list-chat__content-main">
<text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text> <text class="uni-list-chat__content-title uni-ellipsis">{{ title }}</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{ note }}</text> <view style="flex-direction: row;">
<text class="draft" v-if="isDraft">[草稿]</text>
<text class="uni-list-chat__content-note uni-ellipsis">{{isDraft?note.slice(14):note}}</text>
</view>
</view> </view>
<view class="uni-list-chat__content-extra"> <view class="uni-list-chat__content-extra">
<slot> <slot>
@ -121,6 +131,9 @@
}, },
// inject: ['list'], // inject: ['list'],
computed: { computed: {
isDraft(){
return this.note.slice(0,14) == '[uni-im-draft]'
},
isSingle() { isSingle() {
if (this.badgeText === 'dot') { if (this.badgeText === 'dot') {
return 'uni-badge--dot'; return 'uni-badge--dot';
@ -146,12 +159,32 @@
} }
} }
}, },
watch: {
avatar:{
handler(avatar) {
if(avatar.substr(0,8) == 'cloud://'){
uniCloud.getTempFileURL({
fileList: [avatar]
}).then(res=>{
// console.log(res);
// uniCloud
let fileList = res.fileList || res.result.fileList
this.avatarUrl = fileList[0].tempFileURL
})
}else{
this.avatarUrl = avatar
}
},
immediate: true
}
},
data() { data() {
return { return {
isFirstChild: false, isFirstChild: false,
border: true, border: true,
// avatarList: 3, // avatarList: 3,
imageWidth: 50 imageWidth: 50,
avatarUrl:''
}; };
}, },
mounted() { mounted() {
@ -198,7 +231,7 @@
} }
}, },
pageApi(api) { pageApi(api) {
uni[api]({ let callback = {
url: this.to, url: this.to,
success: res => { success: res => {
this.$emit('click', { this.$emit('click', {
@ -209,9 +242,24 @@
this.$emit('click', { this.$emit('click', {
data: err data: err
}); });
console.error(err.errMsg);
} }
}); }
switch (api) {
case 'navigateTo':
uni.navigateTo(callback)
break
case 'redirectTo':
uni.redirectTo(callback)
break
case 'reLaunch':
uni.reLaunch(callback)
break
case 'switchTab':
uni.switchTab(callback)
break
default:
uni.navigateTo(callback)
}
} }
} }
}; };
@ -445,13 +493,20 @@
overflow: hidden; overflow: hidden;
} }
.uni-list-chat__content-note { .draft ,.uni-list-chat__content-note {
margin-top: 3px; margin-top: 3px;
color: $note-color; color: $note-color;
font-size: $note-size; font-size: $note-size;
font-weight: $title-weight; font-weight: $title-weight;
overflow: hidden; overflow: hidden;
} }
.draft{
color: #eb3a41;
/* #ifndef APP-NVUE */
flex-shrink: 0;
/* #endif */
padding-right: 3px;
}
.uni-list-chat__content-extra { .uni-list-chat__content-extra {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */

View File

@ -1,21 +1,21 @@
<template> <template>
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<cell> <cell :keep-scroll-position="keepScrollPosition">
<!-- #endif --> <!-- #endif -->
<view :class="{ 'uni-list-item--disabled': disabled }" :style="{'background-color':customStyle.backgroundColor}"
<view :class="{ 'uni-list-item--disabled': disabled }"
:hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'" :hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
class="uni-list-item" @click="onClick"> class="uni-list-item" @click="onClick">
<view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view> <view v-if="!isFirstChild" class="border--left" :class="{ 'uni-list--border': border }"></view>
<view class="uni-list-item__container" <view class="uni-list-item__container"
:class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column' }"> :class="{ 'container--right': showArrow || link, 'flex--direction': direction === 'column'}"
:style="{paddingTop:padding.top,paddingLeft:padding.left,paddingRight:padding.right,paddingBottom:padding.bottom}">
<slot name="header"> <slot name="header">
<view class="uni-list-item__header"> <view class="uni-list-item__header">
<view v-if="thumb" class="uni-list-item__icon"> <view v-if="thumb" class="uni-list-item__icon">
<image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" /> <image :src="thumb" class="uni-list-item__icon-img" :class="['uni-list--' + thumbSize]" />
</view> </view>
<view v-else-if="showExtraIcon" class="uni-list-item__icon"> <view v-else-if="showExtraIcon" class="uni-list-item__icon">
<uni-icons :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" /> <uni-icons :customPrefix="extraIcon.customPrefix" :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" />
</view> </view>
</view> </view>
</slot> </slot>
@ -167,19 +167,75 @@
return { return {
type: '', type: '',
color: '#000000', color: '#000000',
size: 20 size: 20,
customPrefix: ''
}; };
} }
}, },
border: { border: {
type: Boolean, type: Boolean,
default: true default: true
},
customStyle: {
type: Object,
default () {
return {
padding: '',
backgroundColor: '#FFFFFF'
}
}
},
keepScrollPosition: {
type: Boolean,
default: false
}
},
watch: {
'customStyle.padding': {
handler(padding) {
if(typeof padding == 'number'){
padding += ''
}
let paddingArr = padding.split(' ')
if (paddingArr.length === 1) {
const allPadding = paddingArr[0]
this.padding = {
"top": allPadding,
"right": allPadding,
"bottom": allPadding,
"left": allPadding
}
} else if (paddingArr.length === 2) {
const [verticalPadding, horizontalPadding] = paddingArr;
this.padding = {
"top": verticalPadding,
"right": horizontalPadding,
"bottom": verticalPadding,
"left": horizontalPadding
}
} else if (paddingArr.length === 4) {
const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
this.padding = {
"top": topPadding,
"right": rightPadding,
"bottom": bottomPadding,
"left": leftPadding
}
}
},
immediate: true
} }
}, },
// inject: ['list'], // inject: ['list'],
data() { data() {
return { return {
isFirstChild: false isFirstChild: false,
padding: {
top: "",
right: "",
bottom: "",
left: ""
}
}; };
}, },
mounted() { mounted() {
@ -275,6 +331,7 @@
$uni-bg-color-hover:#f1f1f1; $uni-bg-color-hover:#f1f1f1;
$uni-text-color-grey:#999; $uni-text-color-grey:#999;
$list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg; $list-item-pd: $uni-spacing-col-lg $uni-spacing-row-lg;
.uni-list-item { .uni-list-item {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -289,12 +346,15 @@
cursor: pointer; cursor: pointer;
/* #endif */ /* #endif */
} }
.uni-list-item--disabled { .uni-list-item--disabled {
opacity: 0.3; opacity: 0.3;
} }
.uni-list-item--hover { .uni-list-item--hover {
background-color: $uni-bg-color-hover; background-color: $uni-bg-color-hover !important;
} }
.uni-list-item__container { .uni-list-item__container {
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -307,9 +367,11 @@
overflow: hidden; overflow: hidden;
// align-items: center; // align-items: center;
} }
.container--right { .container--right {
padding-right: 0; padding-right: 0;
} }
// .border--left { // .border--left {
// margin-left: $uni-spacing-row-lg; // margin-left: $uni-spacing-row-lg;
// } // }
@ -324,6 +386,7 @@
border-top-width: 0.5px; border-top-width: 0.5px;
/* #endif */ /* #endif */
} }
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
.uni-list--border:after { .uni-list--border:after {
position: absolute; position: absolute;
@ -336,6 +399,7 @@
transform: scaleY(0.5); transform: scaleY(0.5);
background-color: $uni-border-color; background-color: $uni-border-color;
} }
/* #endif */ /* #endif */
.uni-list-item__content { .uni-list-item__content {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -349,20 +413,24 @@
justify-content: space-between; justify-content: space-between;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__content--center { .uni-list-item__content--center {
justify-content: center; justify-content: center;
} }
.uni-list-item__content-title { .uni-list-item__content-title {
font-size: $uni-font-size-base; font-size: $uni-font-size-base;
color: #3b4144; color: #3b4144;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__content-note { .uni-list-item__content-note {
margin-top: 6rpx; margin-top: 6rpx;
color: $uni-text-color-grey; color: $uni-text-color-grey;
font-size: $uni-font-size-sm; font-size: $uni-font-size-sm;
overflow: hidden; overflow: hidden;
} }
.uni-list-item__extra { .uni-list-item__extra {
// width: 25%; // width: 25%;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@ -372,6 +440,7 @@
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
} }
.uni-list-item__header { .uni-list-item__header {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -379,12 +448,14 @@
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
.uni-list-item__icon { .uni-list-item__icon {
margin-right: 18rpx; margin-right: 18rpx;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.uni-list-item__icon-img { .uni-list-item__icon-img {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: block; display: block;
@ -393,6 +464,7 @@
width: $uni-img-size-base; width: $uni-img-size-base;
margin-right: 10px; margin-right: 10px;
} }
.uni-icon-wrapper { .uni-icon-wrapper {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -400,33 +472,40 @@
align-items: center; align-items: center;
padding: 0 10px; padding: 0 10px;
} }
.flex--direction { .flex--direction {
flex-direction: column; flex-direction: column;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
align-items: initial; align-items: initial;
/* #endif */ /* #endif */
} }
.flex--justify { .flex--justify {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
justify-content: initial; justify-content: initial;
/* #endif */ /* #endif */
} }
.uni-list--lg { .uni-list--lg {
height: $uni-img-size-lg; height: $uni-img-size-lg;
width: $uni-img-size-lg; width: $uni-img-size-lg;
} }
.uni-list--base { .uni-list--base {
height: $uni-img-size-base; height: $uni-img-size-base;
width: $uni-img-size-base; width: $uni-img-size-base;
} }
.uni-list--sm { .uni-list--sm {
height: $uni-img-size-sm; height: $uni-img-size-sm;
width: $uni-img-size-sm; width: $uni-img-size-sm;
} }
.uni-list-item__extra-text { .uni-list-item__extra-text {
color: $uni-text-color-grey; color: $uni-text-color-grey;
font-size: $uni-font-size-sm; font-size: $uni-font-size-sm;
} }
.uni-ellipsis-1 { .uni-ellipsis-1 {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
overflow: hidden; overflow: hidden;
@ -438,6 +517,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
/* #endif */ /* #endif */
} }
.uni-ellipsis-2 { .uni-ellipsis-2 {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
overflow: hidden; overflow: hidden;

View File

@ -7,7 +7,10 @@
</view> </view>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list> <list :bounce="false" :scrollable="true" show-scrollbar :render-reverse="renderReverse" @scroll="scroll" class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop"
loadmoreoffset="15">
<slot />
</list>
<!-- #endif --> <!-- #endif -->
</template> </template>
@ -26,6 +29,10 @@ export default {
} }
}, },
props: { props: {
stackFromEnd:{
type: Boolean,
default:false
},
enableBackToTop: { enableBackToTop: {
type: [Boolean, String], type: [Boolean, String],
default: false default: false
@ -37,6 +44,10 @@ export default {
border: { border: {
type: Boolean, type: Boolean,
default: true default: true
},
renderReverse:{
type: Boolean,
default: false
} }
}, },
// provide() { // provide() {
@ -50,6 +61,9 @@ export default {
methods: { methods: {
loadMore(e) { loadMore(e) {
this.$emit('scrolltolower'); this.$emit('scrolltolower');
},
scroll(e) {
this.$emit('scroll', e);
} }
} }
}; };
@ -57,6 +71,7 @@ export default {
<style lang="scss"> <style lang="scss">
$uni-bg-color:#ffffff; $uni-bg-color:#ffffff;
$uni-border-color:#e5e5e5; $uni-border-color:#e5e5e5;
.uni-list { .uni-list {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-list", "id": "uni-list",
"displayName": "uni-list 列表", "displayName": "uni-list 列表",
"version": "1.2.1", "version": "1.2.14",
"description": "List 组件 ,帮助使用者快速构建列表。", "description": "List 组件 ,帮助使用者快速构建列表。",
"keywords": [ "keywords": [
"", "",
@ -19,10 +19,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -39,7 +35,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,13 @@
## 1.3.112023-03-29
- 修复 自定义状态栏高度闪动BUG
## 1.3.102023-03-29
- 修复 暗黑模式下边线颜色错误的bug
## 1.3.92022-10-13
- 修复 条件编译错误的bug
## 1.3.82022-10-12
- 修复 nvue 环境 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.72022-08-11
- 修复 nvue 环境下 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.62022-06-30 ## 1.3.62022-06-30
- 修复 组件示例中插槽用法无法显示内容的bug - 修复 组件示例中插槽用法无法显示内容的bug
## 1.3.52022-05-24 ## 1.3.52022-05-24

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="uni-navbar" :class="{'uni-dark':dark}"> <view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}">
<view :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }" <view class="uni-navbar__content" :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }"
:style="{ 'background-color': themeBgColor }" class="uni-navbar__content"> :style="{ 'background-color': themeBgColor, 'border-bottom-color':themeColor }" >
<status-bar v-if="statusBar" /> <status-bar v-if="statusBar" />
<view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}" <view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight}"
class="uni-navbar__header"> class="uni-navbar__header">
@ -38,10 +38,12 @@
</view> </view>
</view> </view>
</view> </view>
<!-- #ifndef APP-NVUE -->
<view class="uni-navbar__placeholder" v-if="fixed"> <view class="uni-navbar__placeholder" v-if="fixed">
<status-bar v-if="statusBar" /> <status-bar v-if="statusBar" />
<view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" /> <view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" />
</view> </view>
<!-- #endif -->
</view> </view>
</template> </template>
@ -50,6 +52,8 @@
const getVal = (val) => typeof val === 'number' ? val + 'px' : val; const getVal = (val) => typeof val === 'number' ? val + 'px' : val;
/** /**
*
*
* NavBar 自定义导航栏 * NavBar 自定义导航栏
* @description 导航栏组件主要用于头部导航 * @description 导航栏组件主要用于头部导航
* @tutorial https://ext.dcloud.net.cn/plugin?id=52 * @tutorial https://ext.dcloud.net.cn/plugin?id=52
@ -196,6 +200,11 @@
<style lang="scss" scoped> <style lang="scss" scoped>
$nav-height: 44px; $nav-height: 44px;
.uni-nvue-fixed {
/* #ifdef APP-NVUE */
position: sticky;
/* #endif */
}
.uni-navbar { .uni-navbar {
// box-sizing: border-box; // box-sizing: border-box;
} }

View File

@ -9,11 +9,8 @@
name: 'UniStatusBar', name: 'UniStatusBar',
data() { data() {
return { return {
statusBarHeight: 20 statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px'
} }
},
mounted() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
} }
} }
</script> </script>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-nav-bar", "id": "uni-nav-bar",
"displayName": "uni-nav-bar 自定义导航栏", "displayName": "uni-nav-bar 自定义导航栏",
"version": "1.3.6", "version": "1.3.11",
"description": "自定义导航栏组件,主要用于头部导航。", "description": "自定义导航栏组件,主要用于头部导航。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,10 +17,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -37,7 +33,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,5 @@
## 1.2.12022-09-05
- 新增 属性 fontSize可修改文字大小。
## 1.2.02021-11-19 ## 1.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) - 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-notice-bar](https://uniapp.dcloud.io/component/uniui/uni-notice-bar) - 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-notice-bar](https://uniapp.dcloud.io/component/uniui/uni-notice-bar)

View File

@ -1,24 +1,47 @@
<template> <template>
<view v-if="show" class="uni-noticebar" :style="{ backgroundColor: backgroundColor }" @click="onClick"> <view v-if="show" class="uni-noticebar" :style="{ backgroundColor }" @click="onClick">
<uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound" <uni-icons v-if="showIcon === true || showIcon === 'true'" class="uni-noticebar-icon" type="sound"
:color="color" size="22" /> :color="color" :size="fontSize * 1.5" />
<view ref="textBox" class="uni-noticebar__content-wrapper" <view ref="textBox" class="uni-noticebar__content-wrapper"
:class="{'uni-noticebar__content-wrapper--scrollable':scrollable, 'uni-noticebar__content-wrapper--single':!scrollable && (single || moreText)}"> :class="{
'uni-noticebar__content-wrapper--scrollable': scrollable,
'uni-noticebar__content-wrapper--single': !scrollable && (single || moreText)
}"
:style="{ height: scrollable ? fontSize * 1.5 + 'px' : 'auto' }"
>
<view :id="elIdBox" class="uni-noticebar__content" <view :id="elIdBox" class="uni-noticebar__content"
:class="{'uni-noticebar__content--scrollable':scrollable, 'uni-noticebar__content--single':!scrollable && (single || moreText)}"> :class="{
'uni-noticebar__content--scrollable': scrollable,
'uni-noticebar__content--single': !scrollable && (single || moreText)
}"
>
<text :id="elId" ref="animationEle" class="uni-noticebar__content-text" <text :id="elId" ref="animationEle" class="uni-noticebar__content-text"
:class="{'uni-noticebar__content-text--scrollable':scrollable,'uni-noticebar__content-text--single':!scrollable && (single || showGetMore)}" :class="{
:style="{color:color, width:wrapWidth+'px', 'animationDuration': animationDuration, '-webkit-animationDuration': animationDuration ,animationPlayState: webviewHide?'paused':animationPlayState,'-webkit-animationPlayState':webviewHide?'paused':animationPlayState, animationDelay: animationDelay, '-webkit-animationDelay':animationDelay}">{{text}}</text> 'uni-noticebar__content-text--scrollable': scrollable,
'uni-noticebar__content-text--single': !scrollable && (single || showGetMore)
}"
:style="{
color: color,
fontSize: fontSize + 'px',
lineHeight: fontSize * 1.5 + 'px',
width: wrapWidth + 'px',
'animationDuration': animationDuration,
'-webkit-animationDuration': animationDuration,
animationPlayState: webviewHide ? 'paused' : animationPlayState,
'-webkit-animationPlayState': webviewHide ? 'paused' : animationPlayState,
animationDelay: animationDelay,
'-webkit-animationDelay': animationDelay
}"
>{{text}}</text>
</view> </view>
</view> </view>
<view v-if="showGetMore === true || showGetMore === 'true'" class="uni-noticebar__more uni-cursor-point" <view v-if="isShowGetMore" class="uni-noticebar__more uni-cursor-point"
@click="clickMore"> @click="clickMore">
<text v-if="moreText.length > 0" :style="{ color: moreColor }" class="uni-noticebar__more-text">{{ moreText }}</text> <text v-if="moreText.length > 0" :style="{ color: moreColor, fontSize: fontSize + 'px' }">{{ moreText }}</text>
<uni-icons v-else type="right" :color="moreColor" size="16" /> <uni-icons v-else type="right" :color="moreColor" :size="fontSize * 1.1" />
</view> </view>
<view class="uni-noticebar-close uni-cursor-point" v-if="(showClose === true || showClose === 'true') && (showGetMore === false || showGetMore === 'false')"> <view class="uni-noticebar-close uni-cursor-point" v-if="isShowClose">
<uni-icons <uni-icons type="closeempty" :color="color" :size="fontSize * 1.1" @click="close" />
type="closeempty" :color="color" size="16" @click="close" />
</view> </view>
</view> </view>
</template> </template>
@ -74,6 +97,10 @@
type: String, type: String,
default: '#FF9A43' default: '#FF9A43'
}, },
fontSize: {
type: Number,
default: 14
},
moreColor: { moreColor: {
type: String, type: String,
default: '#FF9A43' default: '#FF9A43'
@ -123,6 +150,15 @@
animationDelay: '0s' animationDelay: '0s'
} }
}, },
computed: {
isShowGetMore() {
return this.showGetMore === true || this.showGetMore === 'true'
},
isShowClose() {
return (this.showClose === true || this.showClose === 'true')
&& (this.showGetMore === false || this.showGetMore === 'false')
}
},
mounted() { mounted() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
var pages = getCurrentPages(); var pages = getCurrentPages();
@ -262,7 +298,7 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" scoped>
.uni-noticebar { .uni-noticebar {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -310,7 +346,6 @@
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
.uni-noticebar__content-wrapper--scrollable { .uni-noticebar__content-wrapper--scrollable {
position: relative; position: relative;
height: 18px;
} }
/* #endif */ /* #endif */
@ -383,10 +418,6 @@
padding-left: 5px; padding-left: 5px;
} }
.uni-noticebar__more-text {
font-size: 14px;
}
@keyframes notice { @keyframes notice {
100% { 100% {
transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0);

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-notice-bar", "id": "uni-notice-bar",
"displayName": "uni-notice-bar 通告栏", "displayName": "uni-notice-bar 通告栏",
"version": "1.2.0", "version": "1.2.1",
"description": "NoticeBar 通告栏组件,常用于展示公告信息,可设为滚动公告", "description": "NoticeBar 通告栏组件,常用于展示公告信息,可设为滚动公告",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -1,3 +1,10 @@
## 1.2.42022-09-19
- 修复,未对主题色设置默认色,导致未引入 uni-scss 变量文件报错。
- 修复,未对移动端当前页文字做主题色适配。
## 1.2.32022-09-15
- 修复未使用 uni-scss 主题色的 bug。
## 1.2.22022-07-06
- 修复 es 语言 i18n 错误
## 1.2.12021-11-22 ## 1.2.12021-11-22
- 修复 vue3中某些scss变量无法找到的问题 - 修复 vue3中某些scss变量无法找到的问题
## 1.2.02021-11-19 ## 1.2.02021-11-19

View File

@ -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"
} }

View File

@ -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"
} }

View File

@ -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"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "上一页", "uni-pagination.prevText": "上一页",
"uni-pagination.nextText": "下一页" "uni-pagination.nextText": "下一页",
"uni-pagination.piecePerPage": "条/页"
} }

View File

@ -1,4 +1,5 @@
{ {
"uni-pagination.prevText": "上一頁", "uni-pagination.prevText": "上一頁",
"uni-pagination.nextText": "下一頁" "uni-pagination.nextText": "下一頁",
"uni-pagination.piecePerPage": "條/頁"
} }

View File

@ -1,5 +1,15 @@
<template> <template>
<view class="uni-pagination"> <view class="uni-pagination">
<!-- #ifndef MP -->
<picker v-if="showPageSize === true || showPageSize === 'true'" class="select-picker" mode="selector"
:value="pageSizeIndex" :range="pageSizeRange" @change="pickerChange" @cancel="pickerClick"
@click.native="pickerClick">
<button type="default" size="mini" :plain="true">
<text>{{pageSizeRange[pageSizeIndex]}} {{piecePerPage}}</text>
<uni-icons class="select-picker-icon" type="arrowdown" size="12" color="#999"></uni-icons>
</button>
</picker>
<!-- #endif -->
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<view class="uni-pagination__total is-phone-hide"> {{ total }} </view> <view class="uni-pagination__total is-phone-hide"> {{ total }} </view>
<!-- #endif --> <!-- #endif -->
@ -16,8 +26,7 @@
</view> </view>
<view class="uni-pagination__num uni-pagination__num-flex-none"> <view class="uni-pagination__num uni-pagination__num-flex-none">
<view class="uni-pagination__num-current"> <view class="uni-pagination__num-current">
<text class="uni-pagination__num-current-text is-pc-hide" <text class="uni-pagination__num-current-text is-pc-hide current-index-text">{{ currentIndex }}</text>
style="color:#409EFF">{{ currentIndex }}</text>
<text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text> <text class="uni-pagination__num-current-text is-pc-hide">/{{ maxPage || 0 }}</text>
<!-- #ifndef APP-NVUE --> <!-- #ifndef APP-NVUE -->
<view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }" <view v-for="(item, index) in paper" :key="index" :class="{ 'page--active': item === currentIndex }"
@ -49,11 +58,15 @@
* @tutorial https://ext.dcloud.net.cn/plugin?id=32 * @tutorial https://ext.dcloud.net.cn/plugin?id=32
* @property {String} prevText 左侧按钮文字 * @property {String} prevText 左侧按钮文字
* @property {String} nextText 右侧按钮文字 * @property {String} nextText 右侧按钮文字
* @property {String} piecePerPageText /页文字
* @property {Number} current 当前页 * @property {Number} current 当前页
* @property {Number} total 数据总量 * @property {Number} total 数据总量
* @property {Number} pageSize 每页数据量 * @property {Number} pageSize 每页数据量
* @property {Number} showIcon = [true|false] 是否以 icon 形式展示按钮 * @property {Boolean} showIcon = [true|false] 是否以 icon 形式展示按钮
* @property {Boolean} showPageSize = [true|false] 是否展示每页条数
* @property {Array} pageSizeRange = [20, 50, 100, 500] 每页条数选框
* @event {Function} change 点击页码按钮时触发 ,e={type,current} current为当前页type值为next/prev表示点击的是上一页还是下一个 * @event {Function} change 点击页码按钮时触发 ,e={type,current} current为当前页type值为next/prev表示点击的是上一页还是下一个
* * @event {Function} pageSizeChange 当前每页条数改变时触发 ,e={pageSize} pageSize 为当前所选的每页条数
*/ */
import { import {
@ -65,7 +78,7 @@
} = initVueI18n(messages) } = initVueI18n(messages)
export default { export default {
name: 'UniPagination', name: 'UniPagination',
emits: ['update:modelValue', 'input', 'change'], emits: ['update:modelValue', 'input', 'change', 'pageSizeChange'],
props: { props: {
value: { value: {
type: [Number, String], type: [Number, String],
@ -81,6 +94,9 @@
nextText: { nextText: {
type: String, type: String,
}, },
piecePerPageText: {
type: String
},
current: { current: {
type: [Number, String], type: [Number, String],
default: 1 default: 1
@ -100,18 +116,32 @@
type: [Boolean, String], type: [Boolean, String],
default: false default: false
}, },
showPageSize: {
// icon
type: [Boolean, String],
default: false
},
pagerCount: { pagerCount: {
type: Number, type: Number,
default: 7 default: 7
},
pageSizeRange: {
type: Array,
default: () => [20, 50, 100, 500]
} }
}, },
data() { data() {
return { return {
pageSizeIndex: 0,
currentIndex: 1, currentIndex: 1,
paperData: [] paperData: [],
pickerShow: false
} }
}, },
computed: { computed: {
piecePerPage() {
return this.piecePerPageText || t('uni-pagination.piecePerPage')
},
prevPageText() { prevPageText() {
return this.prevText || t('uni-pagination.prevText') return this.prevText || t('uni-pagination.prevText')
}, },
@ -199,9 +229,31 @@
this.currentIndex = val this.currentIndex = val
} }
} }
},
pageSizeIndex(val) {
this.$emit('pageSizeChange', this.pageSizeRange[val])
} }
}, },
methods: { methods: {
pickerChange(e) {
this.pageSizeIndex = e.detail.value
this.pickerClick()
},
pickerClick() {
// #ifdef H5
const body = document.querySelector('body')
if (!body) return
const className = 'uni-pagination-picker-show'
this.pickerShow = !this.pickerShow
if (this.pickerShow) {
body.classList.add(className)
} else {
setTimeout(() => body.classList.remove(className), 300)
}
// #endif
},
// //
selectPage(e, index) { selectPage(e, index) {
if (parseInt(e)) { if (parseInt(e)) {
@ -256,8 +308,8 @@
} }
</script> </script>
<style lang="scss" > <style lang="scss" scoped>
$uni-primary: #2979ff; $uni-primary: #2979ff !default;
.uni-pagination { .uni-pagination {
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@ -352,6 +404,10 @@
font-size: 15px; font-size: 15px;
} }
.current-index-text{
color: $uni-primary;
}
.uni-pagination--enabled { .uni-pagination--enabled {
color: #333333; color: #333333;
opacity: 1; opacity: 1;

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-pagination", "id": "uni-pagination",
"displayName": "uni-pagination 分页器", "displayName": "uni-pagination 分页器",
"version": "1.2.1", "version": "1.2.4",
"description": "Pagination 分页器组件,用于展示页码、请求数据等。", "description": "Pagination 分页器组件,用于展示页码、请求数据等。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -17,10 +17,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -37,7 +33,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss","uni-icons"], "dependencies": ["uni-scss","uni-icons"],

View File

@ -9,5 +9,3 @@
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-pagination) ### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-pagination)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839 #### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@ -1,3 +1,11 @@
## 1.8.32023-04-17
- 修复 uni-popup 重复打开时的 bug
## 1.8.22023-02-02
- uni-popup-dialog 组件新增 inputType 属性
## 1.8.12022-12-01
- 修复 nvue 下 v-show 报错
## 1.8.02022-11-29
- 优化 主题样式
## 1.7.92022-04-02 ## 1.7.92022-04-02
- 修复 弹出层内部无法滚动的bug - 修复 弹出层内部无法滚动的bug
## 1.7.82022-03-28 ## 1.7.82022-03-28

View File

@ -10,7 +10,7 @@
</view> </view>
<view v-else class="uni-dialog-content"> <view v-else class="uni-dialog-content">
<slot> <slot>
<input class="uni-dialog-input" v-model="val" type="text" :placeholder="placeholderText" :focus="focus" > <input class="uni-dialog-input" v-model="val" :type="inputType" :placeholder="placeholderText" :focus="focus" >
</slot> </slot>
</view> </view>
<view class="uni-dialog-button-group"> <view class="uni-dialog-button-group">
@ -57,6 +57,10 @@
mixins: [popup], mixins: [popup],
emits:['confirm','close'], emits:['confirm','close'],
props: { props: {
inputType:{
type: String,
default: 'text'
},
value: { value: {
type: [String, Number], type: [String, Number],
default: '' default: ''

View File

@ -269,8 +269,7 @@
open(direction) { open(direction) {
// fix by mehaotian // fix by mehaotian
if (this.showPopup) { if (this.showPopup) {
clearTimeout(this.timer) return
this.showPopup = false
} }
let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share'] let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share']
if (!(direction && innerType.indexOf(direction) !== -1)) { if (!(direction && innerType.indexOf(direction) !== -1)) {

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-popup", "id": "uni-popup",
"displayName": "uni-popup 弹出层", "displayName": "uni-popup 弹出层",
"version": "1.7.9", "version": "1.8.3",
"description": " Popup 组件,提供常用的弹层", "description": " Popup 组件,提供常用的弹层",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -18,10 +18,6 @@
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -38,7 +34,8 @@
"data": "无", "data": "无",
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui" "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
}, },
"uni_modules": { "uni_modules": {
"dependencies": [ "dependencies": [

View File

@ -258,20 +258,21 @@
* 获取星星个数 * 获取星星个数
*/ */
_getRateCount(clientX) { _getRateCount(clientX) {
this._getSize() const _this = this;
const size = Number(this.size) this._getSize(function() {
const size = Number(_this.size)
if (isNaN(size)) { if (isNaN(size)) {
return new Error('size 属性只能设置为数字') return new Error('size 属性只能设置为数字')
} }
const rateMoveRange = clientX - this._rateBoxLeft const rateMoveRange = clientX - _this._rateBoxLeft
let index = parseInt(rateMoveRange / (size + this.marginNumber)) let index = parseInt(rateMoveRange / (size + _this.marginNumber))
index = index < 0 ? 0 : index; index = index < 0 ? 0 : index;
index = index > this.max ? this.max : index; index = index > _this.max ? _this.max : index;
const range = parseInt(rateMoveRange - (size + this.marginNumber) * index); const range = parseInt(rateMoveRange - (size + _this.marginNumber) * index);
let value = 0; let value = 0;
if (this._oldValue === index && !this.PC) return; if (_this._oldValue === index && !_this.PC) return;
this._oldValue = index; _this._oldValue = index;
if (this.allowHalf) { if (_this.allowHalf) {
if (range > (size / 2)) { if (range > (size / 2)) {
value = index + 1 value = index + 1
} else { } else {
@ -281,9 +282,10 @@
value = index + 1 value = index + 1
} }
value = Math.max(0.5, Math.min(value, this.max)) value = Math.max(0.5, Math.min(value, _this.max))
this.valueSync = value _this.valueSync = value
this._onChange() _this._onChange()
})
}, },
/** /**
@ -300,7 +302,7 @@
/** /**
* 获取星星距离屏幕左侧距离 * 获取星星距离屏幕左侧距离
*/ */
_getSize() { _getSize(fn) {
// #ifndef APP-NVUE // #ifndef APP-NVUE
uni.createSelectorQuery() uni.createSelectorQuery()
.in(this) .in(this)
@ -309,6 +311,7 @@
.exec(ret => { .exec(ret => {
if (ret) { if (ret) {
this._rateBoxLeft = ret[0].left this._rateBoxLeft = ret[0].left
fn && fn()
} }
}) })
// #endif // #endif
@ -317,6 +320,7 @@
const size = ret.size const size = ret.size
if (size) { if (size) {
this._rateBoxLeft = size.left this._rateBoxLeft = size.left
fn && fn()
} }
}) })
// #endif // #endif

View File

@ -5,7 +5,7 @@
index === currentIndex&&styleType === 'button' ? 'segmented-control__item--button--active': '', index === currentIndex&&styleType === 'button' ? 'segmented-control__item--button--active': '',
index === 0&&styleType === 'button' ? 'segmented-control__item--button--first': '', index === 0&&styleType === 'button' ? 'segmented-control__item--button--first': '',
index === values.length - 1&&styleType === 'button' ? 'segmented-control__item--button--last': '' ]" :key="index" index === values.length - 1&&styleType === 'button' ? 'segmented-control__item--button--last': '' ]" :key="index"
:style="{ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',borderColor: index === currentIndex&&styleType === 'text'||styleType === 'button'?activeColor:'transparent' }" :style="{ backgroundColor: index === currentIndex && styleType === 'button' ? activeColor : '',borderColor: index === currentIndex&&(styleType === 'text'||styleType === 'button')?activeColor:'#d9d9d9' }"
class="segmented-control__item" @click="_onClick(index)"> class="segmented-control__item" @click="_onClick(index)">
<view> <view>
<text :style="{color: <text :style="{color:

View File

@ -1,3 +1,5 @@
## 1.3.82023-04-13
- 修复`uni-swipe-action`和`uni-swipe-action-item`不同时使用导致 closeOther 方法报错的 bug
## 1.3.72022-06-06 ## 1.3.72022-06-06
- 修复 vue3 下使用组件不能正常运行的Bug - 修复 vue3 下使用组件不能正常运行的Bug
## 1.3.62022-05-31 ## 1.3.62022-05-31

View File

@ -31,7 +31,7 @@ bindIngXMixins = {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -74,7 +74,7 @@ bindIngXMixins = {
// 每次只触发一次,避免多次监听造成闪烁 // 每次只触发一次,避免多次监听造成闪烁
if (this.stop) return if (this.stop) return
this.stop = true this.stop = true
if (this.autoClose) { if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
} }

View File

@ -21,7 +21,7 @@ export default {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -65,7 +65,9 @@ export default {
touchstart(e) { touchstart(e) {
this.transition = false this.transition = false
this.isclose = true this.isclose = true
this.autoClose && this.swipeaction.closeOther(this) if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this)
}
}, },
touchmove(e) {}, touchmove(e) {},
touchend(e) { touchend(e) {

View File

@ -36,7 +36,7 @@ otherMixins = {
}, },
mounted() { mounted() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
this.init() this.init()
@ -53,8 +53,9 @@ otherMixins = {
}, },
closeSwipe(e) { closeSwipe(e) {
if (!this.autoClose) return if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
}
}, },
appTouchStart(e) { appTouchStart(e) {
const { const {

View File

@ -21,7 +21,7 @@ mpMixins = {
}, },
created() { created() {
this.swipeaction = this.getSwipeAction() this.swipeaction = this.getSwipeAction()
if (this.swipeaction.children !== undefined) { if (this.swipeaction && Array.isArray(this.swipeaction.children)) {
this.swipeaction.children.push(this) this.swipeaction.children.push(this)
} }
}, },
@ -31,8 +31,9 @@ mpMixins = {
methods: { methods: {
// wxs 中调用 // wxs 中调用
closeSwipe(e) { closeSwipe(e) {
if (!this.autoClose) return if (this.autoClose && this.swipeaction) {
this.swipeaction.closeOther(this) this.swipeaction.closeOther(this)
}
}, },
change(e) { change(e) {

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-swipe-action", "id": "uni-swipe-action",
"displayName": "uni-swipe-action 滑动操作", "displayName": "uni-swipe-action 滑动操作",
"version": "1.3.7", "version": "1.3.8",
"description": "SwipeAction 滑动操作操作组件", "description": "SwipeAction 滑动操作操作组件",
"keywords": [ "keywords": [
"", "",

View File

@ -1,3 +1,7 @@
## 1.2.32023-03-28
- 修复 在vue3模式下可能会出现错误的问题
## 1.2.22022-11-29
- 优化 主题样式
## 1.2.12022-06-06 ## 1.2.12022-06-06
- 修复 微信小程序存在无使用组件的问题 - 修复 微信小程序存在无使用组件的问题
## 1.2.02021-11-19 ## 1.2.02021-11-19

View File

@ -3,9 +3,9 @@
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<table class="uni-table" border="0" cellpadding="0" cellspacing="0" :class="{ 'table--stripe': stripe }" :style="{ 'min-width': minWidth + 'px' }"> <table class="uni-table" border="0" cellpadding="0" cellspacing="0" :class="{ 'table--stripe': stripe }" :style="{ 'min-width': minWidth + 'px' }">
<slot></slot> <slot></slot>
<view v-if="noData" class="uni-table-loading"> <tr v-if="noData" class="uni-table-loading">
<view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view> <td class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</td>
</view> </tr>
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view> <view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
</table> </table>
<!-- #endif --> <!-- #endif -->
@ -125,7 +125,7 @@ export default {
} else { } else {
startIndex = theadChildren.rowspan - 1 startIndex = theadChildren.rowspan - 1
} }
let isHaveData = this.data && this.data.length.length > 0 let isHaveData = this.data && this.data.length > 0
theadChildren.checked = true theadChildren.checked = true
theadChildren.indeterminate = false theadChildren.indeterminate = false
this.trChildren.forEach((item, index) => { this.trChildren.forEach((item, index) => {

View File

@ -112,6 +112,12 @@
value: 'value' value: 'value'
} }
} }
},
filterDefaultValue: {
type: [Array,String],
default () {
return ""
}
} }
}, },
computed: { computed: {
@ -157,7 +163,7 @@
enabled: true, enabled: true,
isOpened: false, isOpened: false,
dataList: [], dataList: [],
filterValue: '', filterValue: this.filterDefaultValue,
checkedValues: [], checkedValues: [],
gtValue: '', gtValue: '',
ltValue: '', ltValue: '',
@ -286,6 +292,8 @@
</script> </script>
<style lang="scss"> <style lang="scss">
$uni-primary: #1890ff !default;
.flex-r { .flex-r {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -315,8 +323,8 @@
} }
.icon-select.active { .icon-select.active {
background-color: #1890ff; background-color: $uni-primary;
border-top-color: #1890ff; border-top-color: $uni-primary;
} }
.icon-search { .icon-search {
@ -343,11 +351,11 @@
} }
.icon-search.active .icon-search-0 { .icon-search.active .icon-search-0 {
border-color: #1890ff; border-color: $uni-primary;
} }
.icon-search.active .icon-search-1 { .icon-search.active .icon-search-1 {
background-color: #1890ff; background-color: $uni-primary;
} }
.icon-calendar { .icon-calendar {
@ -387,14 +395,14 @@
} }
.icon-calendar.active { .icon-calendar.active {
color: #1890ff; color: $uni-primary;
} }
.icon-calendar.active .icon-calendar-0, .icon-calendar.active .icon-calendar-0,
.icon-calendar.active .icon-calendar-1, .icon-calendar.active .icon-calendar-1,
.icon-calendar.active .icon-calendar-0:before, .icon-calendar.active .icon-calendar-0:before,
.icon-calendar.active .icon-calendar-0:after { .icon-calendar.active .icon-calendar-0:after {
background-color: #1890ff; background-color: $uni-primary;
} }
.uni-filter-dropdown { .uni-filter-dropdown {
@ -497,7 +505,7 @@
} }
.btn-submit { .btn-submit {
background-color: #1890ff; background-color: $uni-primary;
color: #ffffff; color: #ffffff;
} }
</style> </style>

Some files were not shown because too many files have changed in this diff Show More