This commit is contained in:
lnn19986213 2022-08-12 17:28:56 +08:00
parent 4efecdade6
commit 4fa3918c67
58 changed files with 8519 additions and 85 deletions

262
package-lock.json generated
View File

@ -5645,6 +5645,15 @@
"keygrip": "~1.1.0"
}
},
"copy-anything": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.6.tgz",
"integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==",
"dev": true,
"requires": {
"is-what": "^3.14.1"
}
},
"copy-concurrently": {
"version": "1.0.5",
"resolved": "https://registry.npmmirror.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz",
@ -8296,6 +8305,13 @@
"integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==",
"dev": true
},
"image-size": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz",
"integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==",
"dev": true,
"optional": true
},
"immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmmirror.com/immediate/-/immediate-3.0.6.tgz",
@ -8889,6 +8905,12 @@
"call-bind": "^1.0.2"
}
},
"is-what": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz",
"integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==",
"dev": true
},
"is-windows": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/is-windows/-/is-windows-1.0.2.tgz",
@ -11013,6 +11035,119 @@
"invert-kv": "^3.0.0"
}
},
"less": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/less/-/less-4.1.3.tgz",
"integrity": "sha512-w16Xk/Ta9Hhyei0Gpz9m7VS8F28nieJaL/VyShID7cYvP6IL5oHeL6p4TXSDJqZE/lNv0oJ2pGVjJsRkfwm5FA==",
"dev": true,
"requires": {
"copy-anything": "^2.0.1",
"errno": "^0.1.1",
"graceful-fs": "^4.1.2",
"image-size": "~0.5.0",
"make-dir": "^2.1.0",
"mime": "^1.4.1",
"needle": "^3.1.0",
"parse-node-version": "^1.0.1",
"source-map": "~0.6.0",
"tslib": "^2.3.0"
},
"dependencies": {
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true,
"optional": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"optional": true
}
}
},
"less-loader": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/less-loader/-/less-loader-6.2.0.tgz",
"integrity": "sha512-Cl5h95/Pz/PWub/tCBgT1oNMFeH1WTD33piG80jn5jr12T4XbxZcjThwNXDQ7AG649WEynuIzO4b0+2Tn9Qolg==",
"dev": true,
"requires": {
"clone": "^2.1.2",
"less": "^3.11.3",
"loader-utils": "^2.0.0",
"schema-utils": "^2.7.0"
},
"dependencies": {
"clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
"dev": true
},
"less": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/less/-/less-3.13.1.tgz",
"integrity": "sha512-SwA1aQXGUvp+P5XdZslUOhhLnClSLIjWvJhmd+Vgib5BFIr9lMNlQwmwUNOjXThF/A0x+MCYYPeWEfeWiLRnTw==",
"dev": true,
"requires": {
"copy-anything": "^2.0.1",
"errno": "^0.1.1",
"graceful-fs": "^4.1.2",
"image-size": "~0.5.0",
"make-dir": "^2.1.0",
"mime": "^1.4.1",
"native-request": "^1.0.5",
"source-map": "~0.6.0",
"tslib": "^1.10.0"
}
},
"loader-utils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz",
"integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true,
"optional": true
},
"schema-utils": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz",
"integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.5",
"ajv": "^6.12.4",
"ajv-keywords": "^3.5.2"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"optional": true
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"leven": {
"version": "3.1.0",
"resolved": "https://registry.npmmirror.com/leven/-/leven-3.1.0.tgz",
@ -11722,12 +11857,53 @@
"to-regex": "^3.0.1"
}
},
"native-request": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/native-request/-/native-request-1.1.0.tgz",
"integrity": "sha512-uZ5rQaeRn15XmpgE0xoPL8YWqcX90VtCFglYwAgkvKM5e8fog+vePLAhHxuuv/gRkrQxIeh5U3q9sMNUrENqWw==",
"dev": true,
"optional": true
},
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true
},
"needle": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/needle/-/needle-3.1.0.tgz",
"integrity": "sha512-gCE9weDhjVGCRqS8dwDR/D3GTAeyXLXuqp7I8EzH6DllZGXSUyxuqqLh+YX9rMAWaaTFyVAg6rHGL25dqvczKw==",
"dev": true,
"optional": true,
"requires": {
"debug": "^3.2.6",
"iconv-lite": "^0.6.3",
"sax": "^1.2.4"
},
"dependencies": {
"debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dev": true,
"optional": true,
"requires": {
"ms": "^2.1.1"
}
},
"iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"optional": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
}
}
},
"negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-0.6.3.tgz",
@ -12400,6 +12576,12 @@
"lines-and-columns": "^1.1.6"
}
},
"parse-node-version": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parse-node-version/-/parse-node-version-1.0.1.tgz",
"integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==",
"dev": true
},
"parse5": {
"version": "3.0.3",
"resolved": "https://registry.npmmirror.com/parse5/-/parse5-3.0.3.tgz",
@ -14278,6 +14460,86 @@
}
}
},
"sass-resources-loader": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/sass-resources-loader/-/sass-resources-loader-2.2.5.tgz",
"integrity": "sha512-po8rfETH9cOQACWxubT/1CCu77KjxwRtCDm6QAXZH99aUHBydwSoxdIjC40SGp/dcS/FkSNJl0j1VEojGZqlvQ==",
"dev": true,
"requires": {
"async": "^3.2.3",
"chalk": "^4.1.0",
"glob": "^7.1.6",
"loader-utils": "^2.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==",
"dev": true
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"loader-utils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz",
"integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmmirror.com/sax/-/sax-1.2.4.tgz",

View File

@ -89,11 +89,14 @@
"babel-plugin-import": "^1.11.0",
"cross-env": "^7.0.2",
"jest": "^25.4.0",
"less": "^4.1.3",
"less-loader": "^6.2.0",
"mini-types": "*",
"miniprogram-api-typings": "*",
"node-sass": "^4.14.1",
"postcss-comment": "^2.0.0",
"sass-loader": "^10.0.1",
"sass-resources-loader": "^2.2.5",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
@ -102,5 +105,13 @@
],
"uni-app": {
"scripts": {}
}
},
"description": "```\r yarn install\r ```",
"main": "babel.config.js",
"repository": {
"type": "git",
"url": "git@git.zdool.com:xs/yyx/h5.git"
},
"author": "",
"license": "ISC"
}

View File

@ -0,0 +1,58 @@
<template>
<view>
<view class="div">
<view v-if="loadingFinish" class="image">没有更多内容了</view>
<view v-else class="loading">
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
loadingFinish: {
type: Boolean,
default: false
}
}
}
</script>
<style>
.div{
width: 100%;
height: 50px;
flex-direction: row;
display: flex;
align-items: center;
justify-content: center;
}
.image{
font-size: 13px;
color: #ccc;
}
.loading {
width: 18px;
height: 18px;
border: 2px solid #ccc;
border-bottom: #cccccc00 2px solid;
border-radius: 50%;
-webkit-animation: load 1.1s infinite linear;
}
@-webkit-keyframes load {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>

View File

@ -0,0 +1,217 @@
<template>
<view>
<uni-swipe-action>
<uni-swipe-action-item @click="swLlick($event,item)" :options="options" v-for="(item,index) in list" :key='index'>
<view class="item" @tap.stop="toTalk(item)" v-if="item.userChat.chatType == 1">
<view class="msgnum" v-if="item.userChat.unreadCount">
{{item.userChat.unreadCount}}
</view>
<image v-if="item.userChat.chatType == 1" class="header" :src="item.headImgUrl" mode="aspectFill"></image>
<view class="right">
<view class="name" v-if="item.userChat.chatType == 1">
{{item.toUserAsName}}
</view>
<view class="name" v-else>
{{item.userChat.chatType | getOname}}
</view>
<view v-if="item.userChat.chatType == 1">
<view class="centerdes" v-if="item.userChat.lastMsg.type == 0">
{{item.userChat.lastMsg.msg}}
</view>
<view class="centerdes" v-else>
{{item.userChat.lastMsg.type | getType}}
</view>
</view>
<view class="lasttime">
{{item.userChat.lastTime | getTextTimex}}
</view>
</view>
</view>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
</template>
<script>
import uniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue'
import uniSwipeActionItem from '@/components/uni-swipe-action-item/uni-swipe-action-item.vue'
export default {
components: {
uniSwipeAction,
uniSwipeActionItem
},
data() {
return {
options: [{
text: '删除',
style: {
backgroundColor: '#E22B34'
}
}]
};
},
filters: {
getType(type) {
switch (type) {
case 1:
return "[图片]"
break;
case 2:
return "[语音]"
break;
case 3:
return "[视频]"
break;
case 4:
return "[位置]"
break;
case 5:
return "[消息]"
break;
case 6:
return "[文件]"
break;
case 7:
return "[商品]"
break;
default:
break;
}
},
getOname(type) {
switch (type) {
case 2:
return "系统消息"
break;
case 3:
return "订单消息"
break;
case 4:
return "求购消息"
break;
default:
break;
}
}
},
props: {
list: {
type: Array,
default: () => {
return []
}
}
},
methods: {
swLlick(e, item) {
console.log(item.userChat.id)
this.$emit("swLlick", item.userChat.id)
},
//
toTalk(item) {
if (this.utils.checkLocToken()) {
if (item.userChat.chatType == 1) {
uni.navigateTo({
url: "/pages/im/talkPage/talkPage?toId=" + item.userChat.fromId + "&chatId=" + item.userChat.chatId
})
// // #ifdef APP-PLUS
// uni.navigateTo({
// url: "/pages/im/talkPageNvue/talkPageNvue?toId=" + item.userChat.fromId + "&id=" + item.userChat.id
// })
// // #endif
// // #ifdef MP-WEIXIN
// uni.navigateTo({
// url: "/pages/im/talkPage/talkPage?toId=" + item.userChat.fromId + "&id=" + item.userChat.id
// })
// // #endif
}
//
if (item.userChat.chatType == 3) {
uni.navigateTo({
url: "/pages/im/orderInfo/orderInfo?type=1"
})
}
//
if (item.userChat.chatType == 4) {
uni.navigateTo({
url: "/pages/im/orderInfo/orderInfo?type=3"
})
}
//
if (item.userChat.chatType == 2) {
uni.navigateTo({
url: "/pages/im/orderInfo/orderInfo?type=2"
})
}
}
}
}
}
</script>
<style lang="scss">
.item {
background-color: #fff;
border-bottom: 1upx solid #efefef;
display: flex;
align-items: flex-start;
padding: 12px;
width: 100%;
position: relative;
.msgnum {
position: absolute;
right: 12px;
top: 14px;
padding-left: 10px;
padding-right: 10px;
height: 19px;
line-height: 19px;
background: linear-gradient(90deg, rgba(224, 32, 32, 1) 0%, rgba(245, 105, 1, 1) 100%);
border-radius: 10px;
font-size: 16px;
color: #fff;
}
.header {
width: 44px;
height: 44px;
border-radius: 50%;
}
.right {
flex: 1;
margin-left: 10px;
display: flex;
flex-direction: column;
.name {
height: 26px;
font-size: 16px;
font-weight: 800;
color: rgba(51, 51, 51, 1);
line-height: 26px;
}
.centerdes {
height: 34px;
font-size: 16px;
color: rgba(153, 153, 153, 1);
line-height: 34px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box; //
-webkit-box-orient: vertical; //--
-webkit-line-clamp: 1; //
flex-shrink: 0;
}
.lasttime {
height: 20px;
font-size: 14px;
color: rgba(153, 153, 153, 1);
line-height: 20px;
}
}
}
</style>

View File

@ -0,0 +1,36 @@
<template>
<view>
<view class="notihs">
<image src="../../static/nogoods.png" ></image>
暂无数据
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
}
}
</script>
<style lang="less">
.notihs{
width: 100%;
margin-top: 20vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-size: 15px;
color: #999;
image{
width: 80px;
margin-bottom: 10px;
height: 80px;
}
}
</style>

View File

@ -0,0 +1,89 @@
<template>
<view>
<view v-if="show" class="bgPage" :class="hideClass" @touchmove.stop.prevent>
<!-- <image src="../static/logo.png" class="logoimage" ></image> -->
<topLoading width="50"></topLoading>
</view>
</view>
</template>
<script>
import topLoading from '@/components/topLoading.vue'
export default {
data() {
return {
show:true,
hideClass:""
};
},
props: {
loadingFinish: {
type: Boolean,
default: false
}
},
watch:{
loadingFinish(val){
if(val){
this.hideClass = "hidePage"
setTimeout(()=>{
this.show = false
},450)
}
}
},
components: {
topLoading
},
}
</script>
<style lang="less">
.bgPage{
width: 100vw;
height: 100vh;
position: fixed;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
z-index: 9999;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
}
.hidePage{
animation:mymovePage .5s forwards;
-webkit-animation:mymovePage .5s forwards; /*Safari and Chrome*/
}
@keyframes mymovePage
{
from {opacity:1;}
to {opacity:0;}
}
@-webkit-keyframes mymovePage /*Safari and Chrome*/
{
from {opacity:1;}
to {opacity:0;}
}
.logoimage{
width: 50px;
height: 50px;
-webkit-animation:rotateImg 1s linear infinite;
}
@keyframes rotateImg {
0% {transform : rotate(0deg);}
100% {transform : rotate(360deg);}
}
@-webkit-keyframes rotateImg {
0%{-webkit-transform : rotate(0deg);}
100%{-webkit-transform : rotate(360deg);}
}
</style>

View File

@ -0,0 +1,71 @@
<template>
<view>
<view class="goods" v-bind:style="{ paddingBottom: getMer() + 'px' }">
<image class="imagexxxxx" v-bind:style="{ height: width + 'px',width: width + 'px' }" src="../static/icon10.png" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
methods:{
getMer(){
return parseFloat(this.mart)
}
},
props: {
mart: {
type: [String,Number],
default: 0
},
width: {
type: [String,Number],
default: 30
}
},
}
</script>
<style>
* {
margin: 0;
padding: 0;
}
.imagexxxxx {
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
}
.goods {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
.goods image {
animation: myfirst .8s infinite;
}
@keyframes myfirst {
0% {
transform: translate(0px, 0px);
}
50% {
transform: translate(0px, 10px);
}
100% {
transform: translate(0px, 0px);
}
}
</style>

View File

@ -0,0 +1,245 @@
const BindingX = uni.requireNativePlugin('bindingx');
const dom = uni.requireNativePlugin('dom');
const animation = uni.requireNativePlugin('animation');
export default {
data() {
return {
right: 0,
button: [],
preventGesture: false
}
},
watch: {
show(newVal) {
if (!this.position || JSON.stringify(this.position) === '{}') return;
if (this.autoClose) return
if (this.isInAnimation) return
if (newVal) {
this.open()
} else {
this.close()
}
},
},
created() {
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
mounted() {
this.boxSelector = this.getEl(this.$refs['selector-box-hock']);
this.selector = this.getEl(this.$refs['selector-content-hock']);
this.buttonSelector = this.getEl(this.$refs['selector-button-hock']);
this.position = {}
this.x = 0
setTimeout(() => {
this.getSelectorQuery()
}, 200)
},
beforeDestroy() {
if (this.timing) {
BindingX.unbind({
token: this.timing.token,
eventType: 'timing'
})
}
if (this.eventpan) {
BindingX.unbind({
token: this.eventpan.token,
eventType: 'pan'
})
}
this.swipeaction.children.forEach((item, index) => {
if (item === this) {
this.swipeaction.children.splice(index, 1)
}
})
},
methods: {
onClick(index, item) {
this.$emit('click', {
content: item,
index
})
},
touchstart(e) {
if (this.isInAnimation) return
if (this.stop) return
this.stop = true
if (this.autoClose) {
this.swipeaction.closeOther(this)
}
let endWidth = this.right
let boxStep = `(x+${this.x})`
let pageX = `${boxStep}> ${-endWidth} && ${boxStep} < 0?${boxStep}:(x+${this.x} < 0? ${-endWidth}:0)`
let props = [{
element: this.selector,
property: 'transform.translateX',
expression: pageX
}]
let left = 0
for (let i = 0; i < this.options.length; i++) {
let buttonSelectors = this.getEl(this.$refs['button-hock'][i]);
if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return
let moveMix = endWidth - left
left += this.button[i].width
let step = `(${this.x}+x)/${endWidth}`
let moveX = `(${step}) * ${moveMix}`
let pageButtonX = `${moveX}&& (x+${this.x} > ${-endWidth})?${moveX}:${-moveMix}`
props.push({
element: buttonSelectors,
property: 'transform.translateX',
expression: pageButtonX
})
}
this.eventpan = this._bind(this.boxSelector, props, 'pan', (e) => {
if (e.state === 'end') {
this.x = e.deltaX + this.x;
if (this.x < -endWidth) {
this.x = -endWidth
}
if (this.x > 0) {
this.x = 0
}
this.stop = false
this.bindTiming();
}
})
},
touchend(e) {
this.$nextTick(() => {
if (this.isopen && !this.isDrag && !this.isInAnimation) {
this.close()
}
})
},
bindTiming() {
if (this.isopen) {
this.move(this.x, -this.right)
} else {
this.move(this.x, -40)
}
},
move(left, value) {
if (left >= value) {
this.close()
} else {
this.open()
}
},
/**
* 开启swipe
*/
open() {
this.animation(true)
},
/**
* 关闭swipe
*/
close() {
this.animation(false)
},
/**
* 开启关闭动画
* @param {Object} type
*/
animation(type) {
this.isDrag = true
let endWidth = this.right
let time = 200
this.isInAnimation = true;
let exit = `t>${time}`;
let translate_x_expression = `easeOutExpo(t,${this.x},${type?(-endWidth-this.x):(-this.x)},${time})`
let props = [{
element: this.selector,
property: 'transform.translateX',
expression: translate_x_expression
}]
let left = 0
for (let i = 0; i < this.options.length; i++) {
let buttonSelectors = this.getEl(this.$refs['button-hock'][i]);
if (this.button.length === 0 || !this.button[i] || !this.button[i].width) return
let moveMix = endWidth - left
left += this.button[i].width
let step = `${this.x}/${endWidth}`
let moveX = `(${step}) * ${moveMix}`
let pageButtonX = `easeOutExpo(t,${moveX},${type ? -moveMix + '-' + moveX: 0 + '-' + moveX},${time})`
props.push({
element: buttonSelectors,
property: 'transform.translateX',
expression: pageButtonX
})
}
this.timing = BindingX.bind({
eventType: 'timing',
exitExpression: exit,
props: props
}, (e) => {
if (e.state === 'end' || e.state === 'exit') {
this.x = type ? -endWidth : 0
this.isInAnimation = false;
this.isopen = this.isopen || false
if (this.isopen !== type) {
this.$emit('change', type)
}
this.isopen = type
this.isDrag = false
}
});
},
/**
* 绑定 BindingX
* @param {Object} anchor
* @param {Object} props
* @param {Object} fn
*/
_bind(anchor, props, eventType, fn) {
return BindingX.bind({
anchor,
eventType,
props
}, (e) => {
typeof(fn) === 'function' && fn(e)
});
},
/**
* 获取ref
* @param {Object} el
*/
getEl(el) {
return el.ref
},
/**
* 获取节点信息
*/
getSelectorQuery() {
dom.getComponentRect(this.$refs['selector-content-hock'], (data) => {
if (this.position.content) return
this.position.content = data.size
})
for (let i = 0; i < this.options.length; i++) {
dom.getComponentRect(this.$refs['button-hock'][i], (data) => {
if (!this.button) {
this.button = []
}
if (this.options.length === this.button.length) return
this.button.push(data.size)
this.right += data.size.width
if (this.autoClose) return
if (this.show) {
this.open()
}
})
}
}
}
}

View File

@ -0,0 +1,204 @@
/**
* 监听页面内值的变化,主要用于动态开关swipe-action
* @param {Object} newValue
* @param {Object} oldValue
* @param {Object} ownerInstance
* @param {Object} instance
*/
function sizeReady(newValue, oldValue, ownerInstance, instance) {
var state = instance.getState()
state.position = JSON.parse(newValue)
if (!state.position || state.position.length === 0) return
var show = state.position[0].show
state.left = state.left || state.position[0].left;
// 通过用户变量,开启或关闭
if (show) {
openState(true, instance, ownerInstance)
} else {
openState(false, instance, ownerInstance)
}
}
/**
* 开始触摸操作
* @param {Object} e
* @param {Object} ins
*/
function touchstart(e, ins) {
var instance = e.instance;
var state = instance.getState();
var pageX = e.touches[0].pageX;
// 开始触摸时移除动画类
instance.removeClass('ani');
var owner = ins.selectAllComponents('.button-hock')
for (var i = 0; i < owner.length; i++) {
owner[i].removeClass('ani');
}
// state.position = JSON.parse(instance.getDataset().position);
state.left = state.left || state.position[0].left;
// 获取最终按钮组的宽度
state.width = pageX - state.left;
ins.callMethod('closeSwipe')
}
/**
* 开始滑动操作
* @param {Object} e
* @param {Object} ownerInstance
*/
function touchmove(e, ownerInstance) {
var instance = e.instance;
var disabled = instance.getDataset().disabled
var state = instance.getState()
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
if (disabled) return
var pageX = e.touches[0].pageX;
move(pageX - state.width, instance, ownerInstance)
}
/**
* 结束触摸操作
* @param {Object} e
* @param {Object} ownerInstance
*/
function touchend(e, ownerInstance) {
var instance = e.instance;
var disabled = instance.getDataset().disabled
var state = instance.getState()
// fix by mehaotian, TODO 兼容 app-vue 获取dataset为字符串 , h5 获取 为 undefined 的问题,待框架修复
disabled = (typeof(disabled) === 'string' ? JSON.parse(disabled) : disabled) || false;
if (disabled) return
// 滑动过程中触摸结束,通过阙值判断是开启还是关闭
// fixed by mehaotian 定时器解决点击按钮touchend 触发比 click 事件时机早的问题 ,主要是 ios13
moveDirection(state.left, -40, instance, ownerInstance)
}
/**
* 设置移动距离
* @param {Object} value
* @param {Object} instance
* @param {Object} ownerInstance
*/
function move(value, instance, ownerInstance) {
var state = instance.getState()
// 获取可滑动范围
var x = Math.max(-state.position[1].width, Math.min((value), 0));
state.left = x;
instance.setStyle({
transform: 'translateX(' + x + 'px)',
'-webkit-transform': 'translateX(' + x + 'px)'
})
// 折叠按钮动画
buttonFold(x, instance, ownerInstance)
}
/**
* 移动方向判断
* @param {Object} left
* @param {Object} value
* @param {Object} ownerInstance
* @param {Object} ins
*/
function moveDirection(left, value, ins, ownerInstance) {
var state = ins.getState()
var position = state.position
var isopen = state.isopen
if (!position[1].width) {
openState(false, ins, ownerInstance)
return
}
// 如果已经是打开状态,进行判断是否关闭,还是保留打开状态
if (isopen) {
if (-left <= position[1].width) {
openState(false, ins, ownerInstance)
} else {
openState(true, ins, ownerInstance)
}
return
}
// 如果是关闭状态,进行判断是否打开,还是保留关闭状态
if (left <= value) {
openState(true, ins, ownerInstance)
} else {
openState(false, ins, ownerInstance)
}
}
/**
* 设置按钮移动距离
* @param {Object} value
* @param {Object} instance
* @param {Object} ownerInstance
*/
function buttonFold(value, instance, ownerInstance) {
var ins = ownerInstance.selectAllComponents('.button-hock');
var state = instance.getState();
var position = state.position;
var arr = [];
var w = 0;
for (var i = 0; i < ins.length; i++) {
if (!ins[i].getDataset().button) return
var btnData = JSON.parse(ins[i].getDataset().button)
// fix by mehaotian TODO 在 app-vue 中,字符串转对象,需要转两次,这里先这么兼容
if (typeof(btnData) === 'string') {
btnData = JSON.parse(btnData)
}
var button = btnData[i] && btnData[i].width || 0
w += button
arr.push(-w)
// 动态计算按钮组每个按钮的折叠动画移动距离
var distance = arr[i - 1] + value * (arr[i - 1] / position[1].width)
if (i != 0) {
ins[i].setStyle({
transform: 'translateX(' + distance + 'px)',
})
}
}
}
/**
* 开启状态
* @param {Boolean} type
* @param {Object} ins
* @param {Object} ownerInstance
*/
function openState(type, ins, ownerInstance) {
var state = ins.getState()
var position = state.position
if (state.isopen === undefined) {
state.isopen = false
}
// 只有状态有改变才会通知页面改变状态
if (state.isopen !== type) {
// 通知页面,已经打开
ownerInstance.callMethod('change', {
open: type
})
}
// 设置打开和移动状态
state.isopen = type
// 添加动画类
ins.addClass('ani');
var owner = ownerInstance.selectAllComponents('.button-hock')
for (var i = 0; i < owner.length; i++) {
owner[i].addClass('ani');
}
// 设置最终移动位置
move(type ? -position[1].width : 0, ins, ownerInstance)
}
module.exports = {
sizeReady: sizeReady,
touchstart: touchstart,
touchmove: touchmove,
touchend: touchend
}

View File

@ -0,0 +1,160 @@
export default {
data() {
return {
isshow: false,
viewWidth: 0,
buttonWidth: 0,
disabledView: false,
x: 0,
transition: false
}
},
watch: {
show(newVal) {
if (this.autoClose) return
if (newVal) {
this.open()
} else {
this.close()
}
},
},
created() {
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
beforeDestroy() {
this.swipeaction.children.forEach((item, index) => {
if (item === this) {
this.swipeaction.children.splice(index, 1)
}
})
},
mounted() {
this.isopen = false
this.transition = true
setTimeout(() => {
this.getQuerySelect()
}, 50)
},
methods: {
onClick(index, item) {
this.$emit('click', {
content: item,
index
})
},
touchstart(e) {
let {
pageX,
pageY
} = e.changedTouches[0]
this.transition = false
this.startX = pageX
if (this.autoClose) {
this.swipeaction.closeOther(this)
}
},
touchmove(e) {
let {
pageX,
} = e.changedTouches[0]
this.slide = this.getSlide(pageX)
if (this.slide === 0) {
this.disabledView = false
}
},
touchend(e) {
this.stop = false
this.transition = true
if (this.isopen) {
if (this.moveX === -this.buttonWidth) {
this.close()
return
}
this.move()
} else {
if (this.moveX === 0) {
this.close()
return
}
this.move()
}
},
open() {
this.x = this.moveX
this.$nextTick(() => {
this.x = -this.buttonWidth
this.moveX = this.x
if(!this.isopen){
this.isopen = true
this.$emit('change', true)
}
})
},
close() {
this.x = this.moveX
this.$nextTick(() => {
this.x = 0
this.moveX = this.x
if(this.isopen){
this.isopen = false
this.$emit('change', false)
}
})
},
move() {
if (this.slide === 0) {
this.open()
} else {
this.close()
}
},
onChange(e) {
let x = e.detail.x
this.moveX = x
if (x >= this.buttonWidth) {
this.disabledView = true
this.$nextTick(() => {
this.x = this.buttonWidth
})
}
},
getSlide(x) {
if (x >= this.startX) {
this.startX = x
return 1
} else {
this.startX = x
return 0
}
},
getQuerySelect() {
const query = uni.createSelectorQuery().in(this);
query.selectAll('.viewWidth-hook').boundingClientRect(data => {
this.viewWidth = data[0].width
this.buttonWidth = data[1].width
this.transition = false
this.$nextTick(() => {
this.transition = true
})
if (!this.buttonWidth) {
this.disabledView = true
}
if (this.autoClose) return
if (this.show) {
this.open()
}
}).exec();
}
}
}

View File

@ -0,0 +1,158 @@
// #ifdef APP-NVUE
const dom = weex.requireModule('dom');
// #endif
export default {
data() {
return {
uniShow: false,
left: 0
}
},
computed: {
moveLeft() {
return `translateX(${this.left}px)`
}
},
watch: {
show(newVal) {
if (!this.position || JSON.stringify(this.position) === '{}') return;
if (this.autoClose) return
if (newVal) {
this.$emit('change', true)
this.open()
} else {
this.$emit('change', false)
this.close()
}
}
},
mounted() {
this.position = {}
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
setTimeout(() => {
this.getSelectorQuery()
}, 100)
},
beforeDestoy() {
this.swipeaction.children.forEach((item, index) => {
if (item === this) {
this.swipeaction.children.splice(index, 1)
}
})
},
methods: {
onClick(index, item) {
this.$emit('click', {
content: item,
index
})
this.close()
},
touchstart(e) {
const {
pageX
} = e.touches[0]
if (this.disabled) return
const left = this.position.content.left
if (this.autoClose) {
this.swipeaction.closeOther(this)
}
this.width = pageX - left
if (this.isopen) return
if (this.uniShow) {
this.uniShow = false
this.isopen = true
this.openleft = this.left + this.position.button.width
}
},
touchmove(e, index) {
if (this.disabled) return
const {
pageX
} = e.touches[0]
this.setPosition(pageX)
},
touchend() {
if (this.disabled) return
if (this.isopen) {
this.move(this.openleft, 0)
return
}
this.move(this.left, -40)
},
setPosition(x, y) {
if (!this.position.button.width) {
return
}
// this.left = x - this.width
this.setValue(x - this.width)
},
setValue(value) {
// 设置最大最小值
this.left = Math.max(-this.position.button.width, Math.min(parseInt(value), 0))
this.position.content.left = this.left
if (this.isopen) {
this.openleft = this.left + this.position.button.width
}
},
move(left, value) {
if (left >= value) {
this.$emit('change', false)
this.close()
} else {
this.$emit('change', true)
this.open()
}
},
open() {
this.uniShow = true
this.left = -this.position.button.width
this.setValue(-this.position.button.width)
},
close() {
this.uniShow = true
this.setValue(0)
setTimeout(() => {
this.uniShow = false
this.isopen = false
}, 300)
},
getSelectorQuery() {
// #ifndef APP-NVUE
const views = uni.createSelectorQuery()
.in(this)
views
.selectAll('.selector-query-hock')
.boundingClientRect(data => {
this.position.content = data[1]
this.position.button = data[0]
if (this.autoClose) return
if (this.show) {
this.open()
} else {
this.close()
}
})
.exec()
// #endif
// #ifdef APP-NVUE
dom.getComponentRect(this.$refs['selector-content-hock'], (data) => {
if (this.position.content) return
this.position.content = data.size
})
dom.getComponentRect(this.$refs['selector-button-hock'], (data) => {
if (this.position.button) return
this.position.button = data.size
if (this.autoClose) return
if (this.show) {
this.open()
} else {
this.close()
}
})
// #endif
}
}
}

View File

@ -0,0 +1,97 @@
export default {
data() {
return {
position: [],
button: []
}
},
computed: {
pos() {
return JSON.stringify(this.position)
},
btn() {
return JSON.stringify(this.button)
}
},
watch: {
show(newVal) {
if (this.autoClose) return
let valueObj = this.position[0]
if (!valueObj) {
this.init()
return
}
valueObj.show = newVal
this.$set(this.position, 0, valueObj)
}
},
created() {
if (this.swipeaction.children !== undefined) {
this.swipeaction.children.push(this)
}
},
mounted() {
this.init()
},
beforeDestroy() {
this.swipeaction.children.forEach((item, index) => {
if (item === this) {
this.swipeaction.children.splice(index, 1)
}
})
},
methods: {
init() {
setTimeout(() => {
this.getSize()
this.getButtonSize()
}, 50)
},
closeSwipe(e) {
if (!this.autoClose) return
this.swipeaction.closeOther(this)
},
change(e) {
this.$emit('change', e.open)
let valueObj = this.position[0]
if (valueObj.show !== e.open) {
valueObj.show = e.open
this.$set(this.position, 0, valueObj)
}
},
onClick(index, item) {
this.$emit('click', {
content: item,
index
})
},
appTouchStart(){},
appTouchEnd(){},
getSize() {
const views = uni.createSelectorQuery().in(this)
views
.selectAll('.selector-query-hock')
.boundingClientRect(data => {
if (this.autoClose) {
data[0].show = false
} else {
data[0].show = this.show
}
this.position = data
})
.exec()
},
getButtonSize() {
const views = uni.createSelectorQuery().in(this)
views
.selectAll('.button-hock')
.boundingClientRect(data => {
this.button = data
})
.exec()
}
}
}

View File

@ -0,0 +1,270 @@
<template>
<view class="uni-swipe">
<!-- 在微信小程序 app vue端 h5 使用wxs 实现-->
<!-- #ifdef APP-VUE || MP-WEIXIN || H5 -->
<view class="uni-swipe_content">
<view :data-disabled="disabled" :data-position="pos" :change:prop="swipe.sizeReady" :prop="pos" class="uni-swipe_move-box selector-query-hock move-hock"
@touchstart="swipe.touchstart" @touchmove="swipe.touchmove" @touchend="swipe.touchend" @change="change">
<view class="uni-swipe_box">
<slot />
</view>
<view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock">
<!-- 使用 touchend 解决 ios 13 不触发按钮事件的问题-->
<view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}"
class="uni-swipe_button button-hock" @touchend="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view>
</view>
</view>
</view>
<!-- #endif -->
<!-- app nvue端 使用 bindingx -->
<!-- #ifdef APP-NVUE -->
<view ref="selector-box-hock" class="uni-swipe_content" @horizontalpan="touchstart" @touchend="touchend">
<view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock" :style="{width:right+'px'}">
<view ref="button-hock" v-for="(item,index) in options" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',left: right+'px'}"
class="uni-swipe_button " @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'}">{{ item.text }}</text></view>
</view>
<view ref='selector-content-hock' class="uni-swipe_move-box selector-query-hock">
<view class="uni-swipe_box">
<slot />
</view>
</view>
</view>
<!-- #endif -->
<!-- 在非 app 非微信小程序支付宝小程序h5端使用 js -->
<!-- #ifndef APP-PLUS || MP-WEIXIN || MP-ALIPAY || H5 -->
<view class="uni-swipe_content">
<view ref="selector-button-hock" class="uni-swipe_button-group selector-query-hock move-hock">
<view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}"
class="uni-swipe_button button-hock" @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view>
</view>
<view ref='selector-content-hock' class="selector-query-hock" @touchstart="touchstart" @touchmove="touchmove"
@touchend="touchend" :class="{'ani':uniShow}" :style="{transform:moveLeft}">
<view class="uni-swipe_move-box" >
<view class="uni-swipe_box">
<slot />
</view>
</view>
</view>
</view>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="uni-swipe-box" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend">
<view class="viewWidth-hook">
<movable-area v-if="viewWidth !== 0" class="movable-area" :style="{width:(viewWidth-buttonWidth)+'px'}">
<movable-view class="movable-view" direction="horizontal" :animation="!transition" :style="{width:viewWidth+'px'}"
:class="[transition?'transition':'']" :x="x" :disabled="disabledView" @change="onChange">
<view class="movable-view-box">
<slot></slot>
</view>
</movable-view>
</movable-area>
</view>
<view ref="selector-button-hock" class="uni-swipe_button-group viewWidth-hook">
<view v-for="(item,index) in options" :data-button="btn" :key="index" :style="{
backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD',
fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px'
}"
class="uni-swipe_button button-hock" @click.stop="onClick(index,item)"><text class="uni-swipe_button-text" :style="{color: item.style && item.style.color ? item.style.color : '#FFFFFF',}">{{ item.text }}</text></view>
</view>
</view>
<!-- #endif -->
</view>
</template>
<script src="./index.wxs" module="swipe" lang="wxs"></script>
<script>
// #ifdef APP-VUE|| MP-WEIXIN || H5
import mpwxs from './mpwxs'
// #endif
// #ifdef APP-NVUE
import bindingx from './bindingx.js'
// #endif
// #ifndef APP-PLUS|| MP-WEIXIN || MP-ALIPAY || H5
import mixins from './mpother'
// #endif
// #ifdef MP-ALIPAY
import mpalipay from './mpalipay'
// #endif
/**
* SwipeActionItem 滑动操作子组件
* @description 通过滑动触发选项的容器
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
* @property {Boolean} show = [true|false] 开启关闭组件auto-close = false 时生效
* @property {Boolean} disabled = [true|false] 是否禁止滑动
* @property {Boolean} autoClose = [true|false] 其他组件开启的时候当前组件是否自动关闭
* @property {Array} options 组件选项内容及样式
* @event {Function} click 点击选项按钮时触发事件e = {content,index} content点击内容index下标)
* @event {Function} change 组件打开或关闭时触发true开启状态false关闭状态
*/
export default {
// #ifdef APP-VUE|| MP-WEIXIN||H5
mixins: [mpwxs],
// #endif
// #ifdef APP-NVUE
mixins: [bindingx],
// #endif
// #ifndef APP-PLUS|| MP-WEIXIN || MP-ALIPAY || H5
mixins: [mixins],
// #endif
// #ifdef MP-ALIPAY
mixins: [mpalipay],
// #endif
props: {
/**
* 按钮内容
*/
options: {
type: Array,
default () {
return []
}
},
/**
* 禁用
*/
disabled: {
type: Boolean,
default: false
},
/**
* 变量控制开关
*/
show: {
type: Boolean,
default: false
},
/**
* 是否自动关闭
*/
autoClose: {
type: Boolean,
default: true
}
},
inject: ['swipeaction']
}
</script>
<style lang="scss" scoped>
.uni-swipe {
overflow: hidden;
}
.uni-swipe-box {
position: relative;
width: 100%;
}
.uni-swipe_content {
flex: 1;
position: relative;
}
.uni-swipe_move-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
position: relative;
flex-direction: row;
}
.uni-swipe_box {
/* #ifndef APP-NVUE */
display: flex;
flex-direction: row;
width: 100%;
flex-shrink: 0;
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
font-size: 14px;
background-color: #fff;
}
.uni-swipe_button-group {
/* #ifndef APP-VUE|| MP-WEIXIN||H5 */
position: absolute;
top: 0;
right: 0;
bottom: 0;
z-index: 0;
/* #endif */
/* #ifndef APP-NVUE */
display: flex;
flex-shrink: 0;
/* #endif */
flex-direction: row;
}
.uni-swipe_button {
/* #ifdef APP-NVUE */
position: absolute;
left: 0;
top: 0;
bottom: 0;
/* #endif */
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
padding: 0 20px;
}
.uni-swipe_button-text {
/* #ifndef APP-NVUE */
flex-shrink: 0;
/* #endif */
font-size: 14px;
}
.ani {
transition-property: transform;
transition-duration: 0.3s;
transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
/* #ifdef MP-ALIPAY */
.movable-area {
width: 300px;
height: 100%;
height: 45px;
}
.movable-view {
position: relative;
width: 160%;
height: 45px;
z-index: 2;
}
.transition {
transition: all 0.3s;
}
.movable-view-box {
width: 100%;
height: 100%;
background-color: #fff;
}
/* #endif */
</style>

View File

@ -0,0 +1,58 @@
<template>
<view>
<slot></slot>
</view>
</template>
<script>
/**
* SwipeAction 滑动操作
* @description 通过滑动触发选项的容器
* @tutorial https://ext.dcloud.net.cn/plugin?id=181
*/
export default {
data() {
return {};
},
provide() {
return {
swipeaction: this
}
},
created() {
this.children = []
},
methods: {
closeOther(vm) {
let children = this.children
children.forEach((item, index) => {
if (vm === item) return
//
// #ifdef MP-ALIPAY
if (item.isopen) {
item.close()
}
// #endif
// app vue h5
// #ifdef APP-VUE || H5 || MP-WEIXIN
let position = item.position[0]
let show = position.show
if (show) {
position.show = false
}
// #endif
// nvue
// #ifdef APP-NVUE || MP-BAIDU || MP-QQ || MP-TOUTIAO
item.close()
// #endif
})
}
}
}
</script>
<style>
</style>

View File

@ -21,7 +21,8 @@
"path": "pages/famousArts/artistList",
"style": {
"navigationBarTitleText": "文艺名家",
"enablePullDownRefresh": false
"enablePullDownRefresh": true,
"onReachBottomDistance": 20
}
},
{
@ -561,6 +562,24 @@
}
],
"subPackages":[
{
"root": "pagesA/",
"pages": [{
"path": "msgTalk/msgTalk",
"style": {
"navigationBarTitleText": "我的消息"
}
},
{
"path": "talkPage/talkPage",
"style": {
"navigationBarTitleText": "消息"
}
}
]
}
],
"globalStyle": {
"navigationBarTitleText": "艺象心",
"navigationBarTextStyle": "black", // black/white

View File

@ -19,7 +19,28 @@
};
},
onLoad() {
this.getData()
},
methods:{
getData(){
let _this = this
this.http.request('/policy/list', {}, "GET").then(res => {
if (res.code == 200) {
// res.data.forEach(function(item) {
// _this.list.push(item.imagePath)
// })
// this.load = false
// this.getEnjoy()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
},
toDetail(val){
uni.navigateTo({
url: "/pages/PolicyExpress/PolicyExpressDetail?id=" + val

View File

@ -50,7 +50,7 @@
</u-checkbox-group>
</u-popup>
<u--textarea style="padding: 32rpx;" v-model="detailValue" placeholder="请输入作品说明" border="none">
<u--textarea style="padding: 32rpx;" v-model="detailValue" placeholder="请输入作品说明" border="none" maxlength="-1">
</u--textarea>
<view class="gap">
作品内容可上传图片(png/jpg/jpeg/bmp/gif/tif/tiff)或pdf

View File

@ -23,6 +23,8 @@
return {
load: true,
writerList: [],
pages: 1,
size: 20,
};
},
onReady() {
@ -37,23 +39,43 @@
// #endif
},
onShow() {
this.pages = 1
this.writerList = []
this.getArtist()
},
//
onPullDownRefresh() {
this.pages = 1
this.writerList = []
this.getArtist()
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
//
onReachBottom() {
this.pages++
this.getArtist();
},
methods: {
getArtist(){
let _this = this
this.http.request('/indexImage/artists', {}, "GET").then(res => {
this.http.request('/indexImage/artists', {page:this.pages,size:this.size}, "GET").then(res => {
if (res.code == 200) {
res.data.forEach(function(item) {
if (item.images != undefined) {
let img = JSON.parse(item.images)
item.images = img[0]
}
})
this.writerList = res.data
console.log(this.writerList)
if(res.data.records.length > 0){
res.data.records.forEach(function(item) {
if (item.images) {
let img = JSON.parse(item.images)
item.images = img[0]
}else{
item.images = '../../static/txIcon.png'
}
_this.writerList.push(item)
})
}else{
this.pages--
}
this.load = false
// this.getEnjoy()
}
}).catch(e => {
uni.showToast({

View File

@ -38,7 +38,7 @@
</view>
<view class="famous_bot" v-show="id=='1'">
<u-empty v-if="achievement.length < 1" mode="data" icon="../../static/orderE.png" marginTop="120">
<u-empty v-if="achievement.length == 1" mode="data" icon="../../static/orderE.png" marginTop="120">
</u-empty>
<view class="famous_bot_itm" v-for="(v,i) in achievement" :key="i">
<view class="ico">
@ -51,7 +51,7 @@
</view>
<view class="famous_bot" v-show="id=='2'">
<u-empty v-if="honor.length < 1" mode="data" icon="../../static/orderE.png" marginTop="120">
<u-empty v-if="honor.length == 1" mode="data" icon="../../static/orderE.png" marginTop="120">
</u-empty>
<view class="famous_bot_itm" v-for="(v,i) in honor" :key="i">
<view class="ico" style="padding-right: 8rpx;">
@ -65,7 +65,7 @@
</view>
<view class="famous_bot" v-show="id=='3'">
<u-empty v-if="represe.length < 1" mode="data" icon="../../static/orderE.png" marginTop="120">
<u-empty v-if="represe.length == 1" mode="data" icon="../../static/orderE.png" marginTop="120">
</u-empty>
<view class="famous_bot_itm" style="display: block;" v-for="(v,i) in represe" :key="i">
<view class="works" v-for="(a,b) in v.value" :key="b">
@ -117,25 +117,28 @@
let _this = this
this.http.request('/indexImage/artistsDetails', {id:this.userId}, "GET").then(res => {
if (res.code == 200) {
console.log(res.data)
if (res.data.images != undefined) {
if (res.data.images) {
let img = JSON.parse(res.data.images)
_this.userImg = img[0]
}else{
_this.userImg = '../../static/txIcon.png'
}
//
if (res.data.artAtt != undefined) {
if (res.data.artAtt) {
let art = JSON.parse(res.data.artAtt)
_this.achievement = art
}
//
if (res.data.greats != undefined) {
if (res.data.greats) {
let great = JSON.parse(res.data.greats)
_this.honor = great
}
//
if (res.data.opus != undefined) {
if (res.data.opus) {
let opu = JSON.parse(res.data.opus)
_this.represe = opu
}else{
_this.represe = []
}
this.userName = res.data.userName
this.load = false

View File

@ -13,11 +13,17 @@
<view class="user_name">
<view class="user_name_de">
{{userName}}
<view class="sf_text">
<image src="../../static/sfFws.png" v-if="yhsf == '服务商'"></image>
<image src="../../static/sfRc.png" v-if="yhsf == '文艺人才'"></image>
<image src="../../static/sfHy.png" v-if="yhsf == '协会会员'"></image>
<image src="../../static/sfZyz.png" v-if="yhsf == '文艺志愿者'"></image>
<view class="sf_textA" v-if="yhsf == '服务商'">
<image src="../../static/sfFws.png" ></image>
</view>
<view class="sf_textB" v-if="yhsf == '文艺人才'">
<image src="../../static/sfRc.png" ></image>
</view>
<view class="sf_textB" v-if="yhsf == '协会会员'">
<image src="../../static/sfHy.png" ></image>
</view>
<view class="sf_textC" v-if="yhsf == '文艺志愿者'">
<image src="../../static/sfZyz.png"></image>
</view>
</view>
</view>
@ -111,7 +117,7 @@
<view class="content_bott_itm">
<view class="content_bott_wods">
<view class="content_bott_wods" @click="myNews()">
消息
</view>
<view class="content_bott_arrow">
@ -280,6 +286,12 @@
uni.navigateTo({
url: "/pages/my/logOut"
})
},
//
myNews(){
uni.navigateTo({
url: "/pagesA/msgTalk/msgTalk"
})
}
}
}
@ -296,7 +308,7 @@
}
.top {
height: 280rpx;
height: 180rpx;
border: 1px solid transparent;
position: relative;
@ -307,14 +319,14 @@
box-sizing: border-box;
position: absolute;
bottom: 0px;
height: 80px;
height: 160rpx;
border: 1px solid transparent;
width: 100%;
padding: 2px 16px;
padding: 4rpx 32rpx;
.tou {
width: 72px;
height: 72px;
width: 144rpx;
height: 144rpx;
border: 1px solid transparent;
border-radius: 50%;
overflow: hidden;
@ -322,29 +334,40 @@
.user_name {
flex-grow: 1;
margin-left: 12px;
margin-left: 24rpx;
.user_name_de {
color: #251B1D;
font-size: 40rpx;
font-weight: 600;
.sf_text {
width: 180rpx;
height: 56rpx;
.sf_textA {
width: 146rpx;
height: 48rpx;
margin-top: 12rpx;
}
.sf_textB {
width: 166rpx;
height: 48rpx;
margin-top: 12rpx;
}
.sf_textC {
width: 186rpx;
height: 48rpx;
margin-top: 16rpx;
}
}
.words {
margin-top: 8px;
margin-top: 16rpx;
color: #AFADB0;
font-size: 12px;
font-size: 24rpx;
}
}
.arrow {
width: 24px;
height: 24px;
width: 48rpx;
height: 48rpx;
}
}
@ -352,14 +375,15 @@
.content_area {
padding: 0 16px;
margin-bottom: 60px;
padding: 0 32rpx;
margin-bottom: 120rpx;
margin-top: 20rpx;
.fans_box {
display: flex;
justify-content: space-around;
align-items: center;
height: 80px;
height: 160rpx;
border: 1px solid transparent;
border-radius: 8px;
background-color: #FFFFFF;
@ -374,56 +398,55 @@
.itms_name {
color: #AFADB0;
font-size: 12px;
margin-top: 8px;
font-size: 24rpx;
margin-top: 16rpx;
}
}
}
.jifen_box {
padding: 16px 0px;
padding: 32rpx 0px;
display: flex;
justify-content: space-between;
align-items: center;
.jifen_box_itm {
box-sizing: border-box;
padding: 12px;
padding: 24rpx;
display: flex;
width: 166px;
height: 68px;
width: 332rpx;
height: 136rpx;
background-color: #FFFFFF;
border-radius: 8px;
.ji_ico {
width: 22px;
height: 22px;
width: 44rpx;
height: 44rpx;
border-radius: 50%;
overflow: hidden;
}
.ji_word_box {
margin-left: 8px;
margin-left: 16rpx;
.ji_word_title {
font-size: 14px;
font-size: 28rpx;
color: #251B1D;
font-weight: 600;
}
.ji_con {
color: #AFADB0;
font-size: 12px;
font-size: 24rpx;
font-weight: 400;
margin-top: 4px;
margin-top: 8rpx;
}
}
}
}
.content_bott {
padding: 16px;
padding: 32rpx;
background-color: #FFFFFF;
border-radius: 8px;
@ -431,17 +454,17 @@
display: flex;
justify-content: space-between;
align-items: center;
margin: 26px 0px;
margin: 52rpx 0px;
.content_bott_wods {
font-size: 14px;
font-size: 28rpx;
color: #251B1D;
font-weight: 600;
}
.content_bott_arrow {
width: 16px;
height: 16px;
width: 32rpx;
height: 32rpx;
}
}
}

View File

@ -50,24 +50,27 @@
<view class="form_left">
截止时间
</view>
<view class="form_right" @click="chooseTime(0)">
<u--input placeholder="请选择" clearable border="none" inputAlign="right" style="color: #251B1D;"
<view class="form_right">
<uni-datetime-picker type="datetime" v-model="eTime" :border="false" :clearIcon="false"/>
<!-- <u--input placeholder="请选择" clearable border="none" inputAlign="right" style="color: #251B1D;"
suffixIcon="calendar" readonly v-model="eTime" disabledColor="#ffffff">
</u--input>
</u--input> -->
</view>
</view>
<view class="form_line">
<view class="form_left">
活动时间
</view>
<view class="form_right" @click="chooseTime(1)">
<u--input placeholder="请选择" clearable border="none" inputAlign="right" style="color: #251B1D;"
<view class="form_right">
<uni-datetime-picker type="datetime" v-model="wTime" :border="false" :clearIcon="false"/>
<!-- <u--input placeholder="请选择" clearable border="none" inputAlign="right" style="color: #251B1D;"
suffixIcon="calendar" readonly v-model="wTime" disabledColor="#ffffff">
</u--input>
</u--input> -->
</view>
</view>
<u-datetime-picker :show="showTime" v-model="timeValue" value-format="yyyy-MM-dd" mode="date" @close="close"
@cancel="close" @confirm="sureTime"></u-datetime-picker>
<!-- <u-datetime-picker :show="showTime" v-model="timeValue" value-format="yyyy-MM-dd hh:MM:ss" mode="datetime" @close="close"
@cancel="close" @confirm="sureTime"></u-datetime-picker> -->
<view class="gap">
接单设置
</view>
@ -215,9 +218,9 @@
},
sureTime(e) {
if (this.timeTab == 0) {
this.eTime = uni.$u.timeFormat(e.value)
this.eTime = uni.$u.timeFormat(e.value,'yyyy-mm-dd hh:MM')
} else {
this.wTime = uni.$u.timeFormat(e.value)
this.wTime = uni.$u.timeFormat(e.value,'yyyy-mm-dd hh:MM')
}
this.showTime = false
},
@ -329,7 +332,7 @@
}
if(this.eTime == ''){
uni.showToast({
title: '请选择截止时间',
title: '请选择截止日期',
icon: "none",
});
this.ok = false
@ -337,7 +340,23 @@
}
if(this.wTime == ''){
uni.showToast({
title: '请请选择活动时间',
title: '请选择活动日期',
icon: "none",
});
this.ok = false
return
}
if(this.eTime.length < 12){
uni.showToast({
title: '请选择截止时间',
icon: "none",
});
this.ok = false
return
}
if(this.wTime.length < 12){
uni.showToast({
title: '请选择活动时间',
icon: "none",
});
this.ok = false
@ -412,7 +431,18 @@
}
</script>
<style>
</style>
<style lang="scss" scoped>
/deep/ .uni-icons{
display: none;
}
/deep/ .uni-date-x{
text-align: right;
padding: 0;
}
.form_line {
width: 686rpx;
padding: 0 32rpx;

View File

@ -159,6 +159,8 @@
],
enjoyList: [],
writerList: [],
pages: 1,
size: 5,
};
},
onReady() {
@ -224,19 +226,17 @@
//
getArtist(){
let _this = this
this.http.request('/indexImage/artists', {}, "GET").then(res => {
this.http.request('/indexImage/artists', {page:this.pages,size:this.size}, "GET").then(res => {
if (res.code == 200) {
res.data.forEach(function(item) {
if (item.images != undefined) {
res.data.records.forEach(function(item) {
if (item.images) {
let img = JSON.parse(item.images)
item.images = img[0]
}else{
item.images = '../../static/txIcon.png'
}
})
if(res.data.length > 5){
this.writerList = res.data.slice(0,5)
}else{
this.writerList = res.data
}
this.writerList = res.data.records
this.load = false
// this.getEnjoy()
}

View File

@ -148,10 +148,13 @@
}, "GET").then(res => {
if (res.code == 200) {
res.data.records.forEach(function(item) {
if (item.domainInfo.file != undefined) {
console.log(1)
if (item.domainInfo.file) {
let fileArr = item.domainInfo.file.split(',')
let gs = fileArr[0].substr(fileArr[0].lastIndexOf(".") + 1)
console.log(2)
if (gs == 'jpg' || gs == 'jpeg' || gs == 'png' || gs == 'bmp' || gs == 'gif' || gs == 'tif' || gs == 'tiff') {
console.log(3)
item.domainInfo.file = fileArr[0]
} else if (gs == 'pdf') {
item.domainInfo.file = '../../static/fileImg/pdfS.png'

View File

@ -0,0 +1,145 @@
<template>
<view>
<pageLoading :loadingFinish="pageLoadingFinish"></pageLoading>
<msgList @swLlick="delectChat" :list="chatList"></msgList>
<nothing v-if="chatList.length==0"></nothing>
</view>
</template>
<script>
import nothing from '@/components/nothing/nothing.vue'
import pageLoading from '@/components/pageLoading.vue'
import msgList from "@/components/msgList2/msgList2.vue"
export default {
components:{
msgList,
pageLoading,
nothing
},
data() {
return {
pageLoadingFinish:false,
chatList:[],
object:{
DemandCount: 0,
OrderCount: 0,
SysCount: 0
}
};
},
onShow() {
this.utils.checkLocToken()
if(uni.getStorageSync("token")){
this.getUserChatLsit()
}else{
setTimeout(()=>{
this.pageLoadingFinish = true
},300)
}
},
onPullDownRefresh() {
if(uni.getStorageSync("token")){
this.getUserChatLsit()
}else{
setTimeout(()=>{
this.pageLoadingFinish = true
uni.stopPullDownRefresh()
},300)
}
},
methods:{
getUserChatLsit(){
this.http.request('/n/IM/getUserChatLsit', {
page: 1,
limit: 10000,
type:0
}, "get").then(res => {
this.chatList = res.data
this.object = res.object
this.chatList.map(e=>{
e.userChat.lastMsg = JSON.parse(e.userChat.lastMsg)
})
this.pageLoadingFinish = true
try{
uni.stopPullDownRefresh()
}catch(e){
//TODO handle the exception
}
}).catch(e=>{
this.pageLoadingFinish = true
try{
uni.stopPullDownRefresh()
}catch(e){
//TODO handle the exception
}
})
},
delectChat(id){
// console.log(1111111)
this.http.request('/n/IM/delectChat', {
id
}, "DELETE",false,true).then(res => {
if(res.code==0){
this.getUserChatLsit()
}
})
},
toList(chatType) {
if (this.utils.checkLocToken()) {
uni.navigateTo({
url: "/pages/im/orderInfo/orderInfo?type="+chatType
})
}
}
}
}
</script>
<style lang="scss">
.top{
width: 100%;
height: 68px;
// background:$main-color;
position: relative;
.center{
position: absolute;
height:93px;
left: 12px;
right: 12px;
top: 10px;
background:rgba(255,255,255,1);
border-radius:8px;
display: flex;
align-items: center;
.item{
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size:14px;
color:rgba(51,51,51,1);
line-height:21px;
position: relative;
image{
width: 45px;
height: 45px;
margin-bottom: 5px;
}
.xiaodian{
position: absolute;
right: 50%;
margin-right: -24px;
top: 12px;
z-index: 5;
background-color: #E22B34;
border-radius: 50%;
width: 10px;
height: 10px;
}
}
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ export default {
config: {
// baseUrl: "http://192.168.0.57:8080/h5/api", //王锡
// baseUrl: "http://192.168.124.110:8088/api", //周源
// baseUrl: "http://10.0.0.78:8080/h5/api", //俞燕红
// baseUrl: "http://10.0.0.48:8080/h5/api", //俞燕红
baseUrl: "https://yxx.ydool.net/h5/api", //线上
header: {
'Content-Type': 'application/json;charset=UTF-8',

BIN
src/static/nogoods.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
src/static/play.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
src/static/talk/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/static/talk/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/static/talk/cyy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/static/talk/dg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/static/talk/jp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/static/talk/myt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

BIN
src/static/talk/push.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
src/static/talk/t1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
src/static/talk/t2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
src/static/talk/t3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
src/static/talk/t4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
src/static/talk/t5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
src/static/talk/talk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
src/static/talk/tt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
src/static/txIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -12,6 +12,7 @@
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量同时无需 import 这个文件
*/
@import 'uview-ui/theme.scss';
@import "uview-ui/index.scss";
/* 颜色变量 */
$red:#99241B;
$black:#251B1D;

View File

@ -0,0 +1,93 @@
## 2.2.62022-06-30
- 优化 组件样式调整了组件图标大小、高度、颜色等与uni-ui风格保持一致
## 2.2.52022-06-24
- 修复 日历顶部年月及底部确认未国际化 bug
## 2.2.42022-03-31
- 修复 Vue3 下动态赋值,单选类型未响应的 bug
## 2.2.32022-03-28
- 修复 Vue3 下动态赋值未响应的 bug
## 2.2.22021-12-10
- 修复 clear-icon 属性在小程序平台不生效的 bug
## 2.2.12021-12-10
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的 bug
## 2.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](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)
## 2.1.52021-11-09
- 新增 提供组件设计资源,组件样式调整
## 2.1.42021-09-10
- 修复 hide-second 在移动端的 bug
- 修复 单选赋默认值时,赋值日期未高亮的 bug
- 修复 赋默认值时,移动端未正确显示时间的 bug
## 2.1.32021-09-09
- 新增 hide-second 属性,支持只使用时分,隐藏秒
## 2.1.22021-09-03
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
- 优化 调整字号大小,美化日历界面
- 修复 因国际化导致的 placeholder 失效的 bug
## 2.1.12021-08-24
- 新增 支持国际化
- 优化 范围选择器在 pc 端过宽的问题
## 2.1.02021-08-09
- 新增 适配 vue3
## 2.0.192021-08-09
- 新增 支持作为 uni-forms 子组件相关功能
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的 bug
## 2.0.182021-08-05
- 修复 type 属性动态赋值无效的 bug
- 修复 ‘确认’按钮被 tabbar 遮盖 bug
- 修复 组件未赋值时范围选左、右日历相同的 bug
## 2.0.172021-08-04
- 修复 范围选未正确显示当前值的 bug
- 修复 h5 平台(移动端)报错 'cale' of undefined 的 bug
## 2.0.162021-07-21
- 新增 return-type 属性支持返回 date 日期对象
## 2.0.152021-07-14
- 修复 单选日期类型,初始赋值后不在当前日历的 bug
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
- 优化 移动端移除显示框的清空按钮,无实际用途
## 2.0.142021-07-14
- 修复 组件赋值为空,界面未更新的 bug
- 修复 start 和 end 不能动态赋值的 bug
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的 bug
## 2.0.132021-07-08
- 修复 范围选择不能动态赋值的 bug
## 2.0.122021-07-08
- 修复 范围选择的初始时间在一个月内时造成无法选择的bug
## 2.0.112021-07-08
- 优化 弹出层在超出视窗边缘定位不准确的问题
## 2.0.102021-07-08
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的 bug
- 优化 弹出层在超出视窗边缘被遮盖的问题
## 2.0.92021-07-07
- 新增 maskClick 事件
- 修复 特殊情况日历 rpx 布局错误的 bugrpx -> px
- 修复 范围选择时清空返回值不合理的bug['', ''] -> []
## 2.0.82021-07-07
- 新增 日期时间显示框支持插槽
## 2.0.72021-07-01
- 优化 添加 uni-icons 依赖
## 2.0.62021-05-22
- 修复 图标在小程序上不显示的 bug
- 优化 重命名引用组件,避免潜在组件命名冲突
## 2.0.52021-05-20
- 优化 代码目录扁平化
## 2.0.42021-05-12
- 新增 组件示例地址
## 2.0.32021-05-10
- 修复 ios 下不识别 '-' 日期格式的 bug
- 优化 pc 下弹出层添加边框和阴影
## 2.0.22021-05-08
- 修复 在 admin 中获取弹出层定位错误的bug
## 2.0.12021-05-08
- 修复 type 属性向下兼容,默认值从 date 变更为 datetime
## 2.0.02021-04-30
- 支持日历形式的日期+时间的范围选择
> 注意此版本不向后兼容不再支持单独时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker
## 1.0.62021-03-18
- 新增 hide-second 属性,时间支持仅选择时、分
- 修复 选择跟显示的日期不一样的 bug
- 修复 chang事件触发2次的 bug
- 修复 分、秒 end 范围错误的 bug
- 优化 更好的 nvue 适配

View File

@ -0,0 +1,185 @@
<template>
<view class="uni-calendar-item__weeks-box" :class="{
'uni-calendar-item--disable':weeks.disable,
'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked-x':weeks.afterMultiple,
}" @click="choiceDate(weeks)" @mouseenter="handleMousemove(weeks)">
<view class="uni-calendar-item__weeks-box-item" :class="{
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
'uni-calendar-item--checked-range-text': checkHover,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">
<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>
</view>
<view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view>
</view>
</template>
<script>
export default {
props: {
weeks: {
type: Object,
default () {
return {}
}
},
calendar: {
type: Object,
default: () => {
return {}
}
},
selected: {
type: Array,
default: () => {
return []
}
},
lunar: {
type: Boolean,
default: false
},
checkHover: {
type: Boolean,
default: false
}
},
methods: {
choiceDate(weeks) {
this.$emit('change', weeks)
},
handleMousemove(weeks) {
this.$emit('handleMouse', weeks)
}
}
}
</script>
<style lang="scss" >
.uni-calendar-item__weeks-box {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
margin: 1px 0;
position: relative;
}
.uni-calendar-item__weeks-box-text {
font-size: 14px;
// font-family: Lato-Bold, Lato;
font-weight: bold;
color: #455997;
}
.uni-calendar-item__weeks-lunar-text {
font-size: 12px;
color: #333;
}
.uni-calendar-item__weeks-box-item {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.uni-calendar-item__weeks-box-circle {
position: absolute;
top: 5px;
right: 5px;
width: 8px;
height: 8px;
border-radius: 8px;
background-color: #dd524d;
}
.uni-calendar-item__weeks-box .uni-calendar-item--disable {
// background-color: rgba(249, 249, 249, $uni-opacity-disabled);
cursor: default;
}
.uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
color: #D1D1D1;
}
.uni-calendar-item--isDay {
position: absolute;
top: 10px;
right: 17%;
background-color: #dd524d;
width:6px;
height: 6px;
border-radius: 50%;
}
.uni-calendar-item--extra {
color: #dd524d;
opacity: 0.8;
}
.uni-calendar-item__weeks-box .uni-calendar-item--checked {
background-color: #007aff;
border-radius: 50%;
box-sizing: border-box;
border: 3px solid #fff;
}
.uni-calendar-item--checked .uni-calendar-item--checked-text {
color: #fff;
}
.uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
color: #333;
}
.uni-calendar-item--multiple {
background-color: #F6F7FC;
// color: #fff;
}
.uni-calendar-item--multiple .uni-calendar-item--before-checked,
.uni-calendar-item--multiple .uni-calendar-item--after-checked {
background-color: #409eff;
border-radius: 50%;
box-sizing: border-box;
border: 3px solid #F6F7FC;
}
.uni-calendar-item--before-checked .uni-calendar-item--checked-text,
.uni-calendar-item--after-checked .uni-calendar-item--checked-text {
color: #fff;
}
.uni-calendar-item--before-checked-x {
border-top-left-radius: 50px;
border-bottom-left-radius: 50px;
box-sizing: border-box;
background-color: #F6F7FC;
}
.uni-calendar-item--after-checked-x {
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
background-color: #F6F7FC;
}
</style>

View File

@ -0,0 +1,907 @@
<template>
<view class="uni-calendar" @mouseleave="leaveCale">
<view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
@click="clean"></view>
<view v-if="insert || show" class="uni-calendar__content"
: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 v-if="left" class="uni-calendar__header-btn-box" @click.stop="pre">
<view class="uni-calendar__header-btn uni-calendar--left"></view>
</view>
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
<text
class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
</picker>
<view v-if="right" class="uni-calendar__header-btn-box" @click.stop="next">
<view class="uni-calendar__header-btn uni-calendar--right"></view>
</view>
<view v-if="!insert" class="dialog-close" @click="clean">
<view class="dialog-close-plus" data-id="close"></view>
<view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
</view>
<!-- <text class="uni-calendar__backtoday" @click="backtoday">回到今天</text> -->
</view>
<view class="uni-calendar__box">
<view v-if="showMonth" class="uni-calendar__box-bg">
<text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
</view>
<view class="uni-calendar__weeks" style="padding-bottom: 7px;">
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{MONText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{THUText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
</view>
<view class="uni-calendar__weeks-day">
<text class="uni-calendar__weeks-day-text">{{SATText}}</text>
</view>
</view>
<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">
<calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate"
@handleMouse="handleMouse">
</calendar-item>
</view>
</view>
</view>
<view v-if="!insert && !range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top"
style="padding: 0 80px;">
<view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
<time-picker type="time" :start="reactStartTime" :end="reactEndTime" v-model="time"
:disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
</time-picker>
</view>
<view v-if="!insert && range && typeHasTime" class="uni-date-changed uni-calendar--fixed-top">
<view class="uni-date-changed--time-start">
<view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
</view>
<time-picker type="time" :start="reactStartTime" v-model="timeRange.startTime" :border="false"
:hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
</time-picker>
</view>
<uni-icons type="arrowthinright" color="#999" style="line-height: 50px;"></uni-icons>
<view class="uni-date-changed--time-end">
<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"
:hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
</time-picker>
</view>
</view>
<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>
</view>
</view>
</template>
<script>
import Calendar from './util.js';
import calendarItem from './calendar-item.vue'
import timePicker from './time-picker.vue'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from './i18n/index.js'
const {
t
} = initVueI18n(messages)
/**
* Calendar 日历
* @description 日历组件可以查看日期选择任意范围内的日期打点操作常用场景如酒店日期预订火车机票选择购买日期上下班打卡等
* @tutorial https://ext.dcloud.net.cn/plugin?id=56
* @property {String} date 自定义当前时间默认为今天
* @property {Boolean} lunar 显示农历
* @property {String} startDate 日期选择范围-开始日期
* @property {String} endDate 日期选择范围-结束日期
* @property {Boolean} range 范围选择
* @property {Boolean} insert = [true|false] 插入模式,默认为false
* @value true 弹窗模式
* @value false 插入模式
* @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
* @property {Array} selected 打点期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
* @property {Boolean} showMonth 是否选择月份为背景
* @event {Function} change 日期改变`insert :ture` 时生效
* @event {Function} confirm 确认选择`insert :false` 时生效
* @event {Function} monthSwitch 切换月份时触发
* @example <uni-calendar :insert="true":lunar="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
*/
export default {
components: {
calendarItem,
timePicker
},
props: {
date: {
type: String,
default: ''
},
defTime: {
type: [String, Object],
default: ''
},
selectableTimes: {
type: [Object],
default () {
return {}
}
},
selected: {
type: Array,
default () {
return []
}
},
lunar: {
type: Boolean,
default: false
},
startDate: {
type: String,
default: ''
},
endDate: {
type: String,
default: ''
},
range: {
type: Boolean,
default: false
},
typeHasTime: {
type: Boolean,
default: false
},
insert: {
type: Boolean,
default: true
},
showMonth: {
type: Boolean,
default: true
},
clearDate: {
type: Boolean,
default: true
},
left: {
type: Boolean,
default: true
},
right: {
type: Boolean,
default: true
},
checkHover: {
type: Boolean,
default: true
},
hideSecond: {
type: [Boolean],
default: false
},
pleStatus: {
type: Object,
default () {
return {
before: '',
after: '',
data: [],
fulldate: ''
}
}
}
},
data() {
return {
show: false,
weeks: [],
calendar: {},
nowDate: '',
aniMaskShow: false,
firstEnter: true,
time: '',
timeRange: {
startTime: '',
endTime: ''
},
tempSingleDate: '',
tempRange: {
before: '',
after: ''
}
}
},
watch: {
date: {
immediate: true,
handler(newVal, oldVal) {
if (!this.range) {
this.tempSingleDate = newVal
setTimeout(() => {
this.init(newVal)
}, 100)
}
}
},
defTime: {
immediate: true,
handler(newVal, oldVal) {
if (!this.range) {
this.time = newVal
} else {
// console.log('-----', newVal);
this.timeRange.startTime = newVal.start
this.timeRange.endTime = newVal.end
}
}
},
startDate(val) {
this.cale.resetSatrtDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
endDate(val) {
this.cale.resetEndDate(val)
this.cale.setDate(this.nowDate.fullDate)
this.weeks = this.cale.weeks
},
selected(newVal) {
this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks
},
pleStatus: {
immediate: true,
handler(newVal, oldVal) {
const {
before,
after,
fulldate,
which
} = newVal
this.tempRange.before = before
this.tempRange.after = after
setTimeout(() => {
if (fulldate) {
this.cale.setHoverMultiple(fulldate)
if (before && after) {
this.cale.lastHover = true
if (this.rangeWithinMonth(after, before)) return
this.setDate(before)
} else {
this.cale.setMultiple(fulldate)
this.setDate(this.nowDate.fullDate)
this.calendar.fullDate = ''
this.cale.lastHover = false
}
} else {
this.cale.setDefaultMultiple(before, after)
if (which === 'left') {
this.setDate(before)
this.weeks = this.cale.weeks
} else {
this.setDate(after)
this.weeks = this.cale.weeks
}
this.cale.lastHover = true
}
}, 16)
}
}
},
computed: {
reactStartTime() {
const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
const res = activeDate === this.startDate ? this.selectableTimes.start : ''
return res
},
reactEndTime() {
const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
const res = activeDate === this.endDate ? this.selectableTimes.end : ''
return res
},
/**
* for i18n
*/
selectDateText() {
return t("uni-datetime-picker.selectDate")
},
startDateText() {
return this.startPlaceholder || t("uni-datetime-picker.startDate")
},
endDateText() {
return this.endPlaceholder || t("uni-datetime-picker.endDate")
},
okText() {
return t("uni-datetime-picker.ok")
},
yearText() {
return t("uni-datetime-picker.year")
},
monthText() {
return t("uni-datetime-picker.month")
},
MONText() {
return t("uni-calender.MON")
},
TUEText() {
return t("uni-calender.TUE")
},
WEDText() {
return t("uni-calender.WED")
},
THUText() {
return t("uni-calender.THU")
},
FRIText() {
return t("uni-calender.FRI")
},
SATText() {
return t("uni-calender.SAT")
},
SUNText() {
return t("uni-calender.SUN")
},
confirmText() {
return t("uni-calender.confirm")
},
},
created() {
//
this.cale = new Calendar({
// date: new Date(),
selected: this.selected,
startDate: this.startDate,
endDate: this.endDate,
range: this.range,
// multipleStatus: this.pleStatus
})
//
// this.cale.setDate(this.date)
this.init(this.date)
// this.setDay
},
methods: {
leaveCale() {
this.firstEnter = true
},
handleMouse(weeks) {
if (weeks.disable) return
if (this.cale.lastHover) return
let {
before,
after
} = this.cale.multipleStatus
if (!before) return
this.calendar = weeks
//
this.cale.setHoverMultiple(this.calendar.fullDate)
this.weeks = this.cale.weeks
// hover
if (this.firstEnter) {
this.$emit('firstEnterCale', this.cale.multipleStatus)
this.firstEnter = false
}
},
rangeWithinMonth(A, B) {
const [yearA, monthA] = A.split('-')
const [yearB, monthB] = B.split('-')
return yearA === yearB && monthA === monthB
},
// 穿
clean() {
this.close()
},
clearCalender() {
if (this.range) {
this.timeRange.startTime = ''
this.timeRange.endTime = ''
this.tempRange.before = ''
this.tempRange.after = ''
this.cale.multipleStatus.before = ''
this.cale.multipleStatus.after = ''
this.cale.multipleStatus.data = []
this.cale.lastHover = false
} else {
this.time = ''
this.tempSingleDate = ''
}
this.calendar.fullDate = ''
this.setDate()
},
bindDateChange(e) {
const value = e.detail.value + '-1'
this.init(value)
},
/**
* 初始化日期显示
* @param {Object} date
*/
init(date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.calendar = this.cale.getInfo(date)
},
// 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()
// },
/**
* 打开日历弹窗
*/
open() {
//
if (this.clearDate && !this.insert) {
this.cale.cleanMultipleStatus()
// this.cale.setDate(this.date)
this.init(this.date)
}
this.show = true
this.$nextTick(() => {
setTimeout(() => {
this.aniMaskShow = true
}, 50)
})
},
/**
* 关闭日历弹窗
*/
close() {
this.aniMaskShow = false
this.$nextTick(() => {
setTimeout(() => {
this.show = false
this.$emit('close')
}, 300)
})
},
/**
* 确认按钮
*/
confirm() {
this.setEmit('confirm')
this.close()
},
/**
* 变化触发
*/
change() {
if (!this.insert) return
this.setEmit('change')
},
/**
* 选择月份触发
*/
monthSwitch() {
let {
year,
month
} = this.nowDate
this.$emit('monthSwitch', {
year,
month: Number(month)
})
},
/**
* 派发事件
* @param {Object} name
*/
setEmit(name) {
let {
year,
month,
date,
fullDate,
lunar,
extraInfo
} = this.calendar
this.$emit(name, {
range: this.cale.multipleStatus,
year,
month,
date,
time: this.time,
timeRange: this.timeRange,
fulldate: fullDate,
lunar,
extraInfo: extraInfo || {}
})
},
/**
* 选择天触发
* @param {Object} weeks
*/
choiceDate(weeks) {
if (weeks.disable) return
this.calendar = weeks
this.calendar.userChecked = true
//
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()
},
/**
* 回到今天
*/
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
}
},
/**
* 上个月
*/
pre() {
const preDate = this.cale.getDate(this.nowDate.fullDate, -1, 'month').fullDate
this.setDate(preDate)
this.monthSwitch()
},
/**
* 下个月
*/
next() {
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate)
this.monthSwitch()
},
/**
* 设置日期
* @param {Object} date
*/
setDate(date) {
this.cale.setDate(date)
this.weeks = this.cale.weeks
this.nowDate = this.cale.getInfo(date)
}
}
}
</script>
<style lang="scss" >
.uni-calendar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
}
.uni-calendar__mask {
position: fixed;
bottom: 0;
top: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.4);
transition-property: opacity;
transition-duration: 0.3s;
opacity: 0;
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
}
.uni-calendar--mask-show {
opacity: 1
}
.uni-calendar--fixed {
position: fixed;
bottom: calc(var(--window-bottom));
left: 0;
right: 0;
transition-property: transform;
transition-duration: 0.3s;
transform: translateY(460px);
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
}
.uni-calendar--ani-show {
transform: translateY(0);
}
.uni-calendar__content {
background-color: #fff;
}
.uni-calendar__content-mobile {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
}
.uni-calendar__header {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
height: 50px;
}
.uni-calendar__header-mobile {
padding: 10px;
padding-bottom: 0;
}
.uni-calendar--fixed-top {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: space-between;
border-top-color: rgba(0, 0, 0, 0.4);
border-top-style: solid;
border-top-width: 1px;
}
.uni-calendar--fixed-width {
width: 50px;
}
.uni-calendar__backtoday {
position: absolute;
right: 0;
top: 25rpx;
padding: 0 5px;
padding-left: 10px;
height: 25px;
line-height: 25px;
font-size: 12px;
border-top-left-radius: 25px;
border-bottom-left-radius: 25px;
color: #fff;
background-color: #f1f1f1;
}
.uni-calendar__header-text {
text-align: center;
width: 100px;
font-size: 15px;
color: #666;
}
.uni-calendar__button-text {
text-align: center;
width: 100px;
font-size: 14px;
color: #007aff;
/* #ifndef APP-NVUE */
letter-spacing: 3px;
/* #endif */
}
.uni-calendar__header-btn-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
}
.uni-calendar__header-btn {
width: 9px;
height: 9px;
border-left-color: #808080;
border-left-style: solid;
border-left-width: 1px;
border-top-color: #555555;
border-top-style: solid;
border-top-width: 1px;
}
.uni-calendar--left {
transform: rotate(-45deg);
}
.uni-calendar--right {
transform: rotate(135deg);
}
.uni-calendar__weeks {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-calendar__weeks-item {
flex: 1;
}
.uni-calendar__weeks-day {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
height: 40px;
border-bottom-color: #F5F5F5;
border-bottom-style: solid;
border-bottom-width: 1px;
}
.uni-calendar__weeks-day-text {
font-size: 12px;
color: #B2B2B2;
}
.uni-calendar__box {
position: relative;
// padding: 0 10px;
padding-bottom: 7px;
}
.uni-calendar__box-bg {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.uni-calendar__box-bg-text {
font-size: 200px;
font-weight: bold;
color: #999;
opacity: 0.1;
text-align: center;
/* #ifndef APP-NVUE */
line-height: 1;
/* #endif */
}
.uni-date-changed {
padding: 0 10px;
// line-height: 50px;
text-align: center;
color: #333;
border-top-color: #DCDCDC;
;
border-top-style: solid;
border-top-width: 1px;
flex: 1;
}
.uni-date-btn--ok {
padding: 20px 15px;
}
.uni-date-changed--time-start {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
align-items: center;
}
.uni-date-changed--time-end {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
align-items: center;
}
.uni-date-changed--time-date {
color: #999;
line-height: 50px;
margin-right: 5px;
// opacity: 0.6;
}
.time-picker-style {
// width: 62px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center
}
.mr-10 {
margin-right: 10px;
}
.dialog-close {
position: absolute;
top: 0;
right: 0;
bottom: 0;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
padding: 0 25px;
margin-top: 10px;
}
.dialog-close-plus {
width: 16px;
height: 2px;
background-color: #737987;
border-radius: 2px;
transform: rotate(45deg);
}
.dialog-close-rotate {
position: absolute;
transform: rotate(-45deg);
}
.uni-datetime-picker--btn {
border-radius: 100px;
height: 40px;
line-height: 40px;
background-color: #007aff;
color: #fff;
font-size: 16px;
letter-spacing: 2px;
}
/* #ifndef APP-NVUE */
.uni-datetime-picker--btn:active {
opacity: 0.7;
}
/* #endif */
</style>

View File

@ -0,0 +1,22 @@
{
"uni-datetime-picker.selectDate": "select date",
"uni-datetime-picker.selectTime": "select time",
"uni-datetime-picker.selectDateTime": "select datetime",
"uni-datetime-picker.startDate": "start date",
"uni-datetime-picker.endDate": "end date",
"uni-datetime-picker.startTime": "start time",
"uni-datetime-picker.endTime": "end time",
"uni-datetime-picker.ok": "ok",
"uni-datetime-picker.clear": "clear",
"uni-datetime-picker.cancel": "cancel",
"uni-datetime-picker.year": "-",
"uni-datetime-picker.month": "",
"uni-calender.MON": "MON",
"uni-calender.TUE": "TUE",
"uni-calender.WED": "WED",
"uni-calender.THU": "THU",
"uni-calender.FRI": "FRI",
"uni-calender.SAT": "SAT",
"uni-calender.SUN": "SUN",
"uni-calender.confirm": "confirm"
}

View File

@ -0,0 +1,8 @@
import en from './en.json'
import zhHans from './zh-Hans.json'
import zhHant from './zh-Hant.json'
export default {
en,
'zh-Hans': zhHans,
'zh-Hant': zhHant
}

View File

@ -0,0 +1,22 @@
{
"uni-datetime-picker.selectDate": "选择日期",
"uni-datetime-picker.selectTime": "选择时间",
"uni-datetime-picker.selectDateTime": "选择日期时间",
"uni-datetime-picker.startDate": "开始日期",
"uni-datetime-picker.endDate": "结束日期",
"uni-datetime-picker.startTime": "开始时间",
"uni-datetime-picker.endTime": "结束时间",
"uni-datetime-picker.ok": "确定",
"uni-datetime-picker.clear": "清除",
"uni-datetime-picker.cancel": "取消",
"uni-datetime-picker.year": "年",
"uni-datetime-picker.month": "月",
"uni-calender.SUN": "日",
"uni-calender.MON": "一",
"uni-calender.TUE": "二",
"uni-calender.WED": "三",
"uni-calender.THU": "四",
"uni-calender.FRI": "五",
"uni-calender.SAT": "六",
"uni-calender.confirm": "确认"
}

View File

@ -0,0 +1,22 @@
{
"uni-datetime-picker.selectDate": "選擇日期",
"uni-datetime-picker.selectTime": "選擇時間",
"uni-datetime-picker.selectDateTime": "選擇日期時間",
"uni-datetime-picker.startDate": "開始日期",
"uni-datetime-picker.endDate": "結束日期",
"uni-datetime-picker.startTime": "開始时间",
"uni-datetime-picker.endTime": "結束时间",
"uni-datetime-picker.ok": "確定",
"uni-datetime-picker.clear": "清除",
"uni-datetime-picker.cancel": "取消",
"uni-datetime-picker.year": "年",
"uni-datetime-picker.month": "月",
"uni-calender.SUN": "日",
"uni-calender.MON": "一",
"uni-calender.TUE": "二",
"uni-calender.WED": "三",
"uni-calender.THU": "四",
"uni-calender.FRI": "五",
"uni-calender.SAT": "六",
"uni-calender.confirm": "確認"
}

View File

@ -0,0 +1,45 @@
// #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

@ -0,0 +1,927 @@
<template>
<view class="uni-datetime-picker">
<view @click="initTimePicker">
<slot>
<view class="uni-datetime-picker-timebox-pointer"
:class="{'uni-datetime-picker-disabled': disabled, 'uni-datetime-picker-timebox': border}">
<text class="uni-datetime-picker-text">{{time}}</text>
<view v-if="!time" class="uni-datetime-picker-time">
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
</view>
</view>
</slot>
</view>
<view v-if="visible" id="mask" class="uni-datetime-picker-mask" @click="tiggerTimePicker"></view>
<view v-if="visible" class="uni-datetime-picker-popup" :class="[dateShow && timeShow ? '' : 'fix-nvue-height']"
:style="fixNvueBug">
<view class="uni-title">
<text class="uni-datetime-picker-text">{{selectTimeText}}</text>
</view>
<view v-if="dateShow" class="uni-datetime-picker__container-box">
<picker-view class="uni-datetime-picker-view" :indicator-style="indicatorStyle" :value="ymd"
@change="bindDateChange">
<picker-view-column>
<view class="uni-datetime-picker-item" v-for="(item,index) in years" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
<picker-view-column>
<view class="uni-datetime-picker-item" v-for="(item,index) in months" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
<picker-view-column>
<view class="uni-datetime-picker-item" v-for="(item,index) in days" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
</picker-view>
<!-- 兼容 nvue 不支持伪类 -->
<text class="uni-datetime-picker-sign sign-left">-</text>
<text class="uni-datetime-picker-sign sign-right">-</text>
</view>
<view v-if="timeShow" class="uni-datetime-picker__container-box">
<picker-view class="uni-datetime-picker-view" :class="[hideSecond ? 'time-hide-second' : '']"
:indicator-style="indicatorStyle" :value="hms" @change="bindTimeChange">
<picker-view-column>
<view class="uni-datetime-picker-item" v-for="(item,index) in hours" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
<picker-view-column>
<view class="uni-datetime-picker-item" v-for="(item,index) in minutes" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
<picker-view-column v-if="!hideSecond">
<view class="uni-datetime-picker-item" v-for="(item,index) in seconds" :key="index">
<text class="uni-datetime-picker-item">{{lessThanTen(item)}}</text>
</view>
</picker-view-column>
</picker-view>
<!-- 兼容 nvue 不支持伪类 -->
<text class="uni-datetime-picker-sign" :class="[hideSecond ? 'sign-center' : 'sign-left']">:</text>
<text v-if="!hideSecond" class="uni-datetime-picker-sign sign-right">:</text>
</view>
<view class="uni-datetime-picker-btn">
<view @click="clearTime">
<text class="uni-datetime-picker-btn-text">{{clearText}}</text>
</view>
<view class="uni-datetime-picker-btn-group">
<view class="uni-datetime-picker-cancel" @click="tiggerTimePicker">
<text class="uni-datetime-picker-btn-text">{{cancelText}}</text>
</view>
<view @click="setTime">
<text class="uni-datetime-picker-btn-text">{{okText}}</text>
</view>
</view>
</view>
</view>
<!-- #ifdef H5 -->
<!-- <keypress v-if="visible" @esc="tiggerTimePicker" @enter="setTime" /> -->
<!-- #endif -->
</view>
</template>
<script>
// #ifdef H5
import keypress from './keypress'
// #endif
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from './i18n/index.js'
const { t } = initVueI18n(messages)
/**
* DatetimePicker 时间选择器
* @description 可以同时选择日期和时间的选择器
* @tutorial https://ext.dcloud.net.cn/plugin?id=xxx
* @property {String} type = [datetime | date | time] 显示模式
* @property {Boolean} multiple = [true|false] 是否多选
* @property {String|Number} value 默认值
* @property {String|Number} start 起始日期或时间
* @property {String|Number} end 起始日期或时间
* @property {String} return-type = [timestamp | string]
* @event {Function} change 选中发生变化触发
*/
export default {
name: 'UniDatetimePicker',
components: {
// #ifdef H5
keypress
// #endif
},
data() {
return {
indicatorStyle: `height: 50px;`,
visible: false,
fixNvueBug: {},
dateShow: true,
timeShow: true,
title: '日期和时间',
//
time: '',
//
year: 1920,
month: 0,
day: 0,
hour: 0,
minute: 0,
second: 0,
//
startYear: 1920,
startMonth: 1,
startDay: 1,
startHour: 0,
startMinute: 0,
startSecond: 0,
//
endYear: 2120,
endMonth: 12,
endDay: 31,
endHour: 23,
endMinute: 59,
endSecond: 59,
}
},
props: {
type: {
type: String,
default: 'datetime'
},
value: {
type: [String, Number],
default: ''
},
modelValue: {
type: [String, Number],
default: ''
},
start: {
type: [Number, String],
default: ''
},
end: {
type: [Number, String],
default: ''
},
returnType: {
type: String,
default: 'string'
},
disabled: {
type: [Boolean, String],
default: false
},
border: {
type: [Boolean, String],
default: true
},
hideSecond: {
type: [Boolean, String],
default: false
}
},
watch: {
value: {
handler(newVal, oldVal) {
if (newVal) {
this.parseValue(this.fixIosDateFormat(newVal)) // iOSsafari
this.initTime(false)
} else {
this.time = ''
this.parseValue(Date.now())
}
},
immediate: true
},
type: {
handler(newValue) {
if (newValue === 'date') {
this.dateShow = true
this.timeShow = false
this.title = '日期'
} else if (newValue === 'time') {
this.dateShow = false
this.timeShow = true
this.title = '时间'
} else {
this.dateShow = true
this.timeShow = true
this.title = '日期和时间'
}
},
immediate: true
},
start: {
handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'start') // iOSsafari
},
immediate: true
},
end: {
handler(newVal) {
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') // iOSsafari
},
immediate: true
},
//
months(newVal) {
this.checkValue('month', this.month, newVal)
},
days(newVal) {
this.checkValue('day', this.day, newVal)
},
hours(newVal) {
this.checkValue('hour', this.hour, newVal)
},
minutes(newVal) {
this.checkValue('minute', this.minute, newVal)
},
seconds(newVal) {
this.checkValue('second', this.second, newVal)
}
},
computed: {
//
years() {
return this.getCurrentRange('year')
},
months() {
return this.getCurrentRange('month')
},
days() {
return this.getCurrentRange('day')
},
hours() {
return this.getCurrentRange('hour')
},
minutes() {
return this.getCurrentRange('minute')
},
seconds() {
return this.getCurrentRange('second')
},
// picker
ymd() {
return [this.year - this.minYear, this.month - this.minMonth, this.day - this.minDay]
},
hms() {
return [this.hour - this.minHour, this.minute - this.minMinute, this.second - this.minSecond]
},
// date start
currentDateIsStart() {
return this.year === this.startYear && this.month === this.startMonth && this.day === this.startDay
},
// date end
currentDateIsEnd() {
return this.year === this.endYear && this.month === this.endMonth && this.day === this.endDay
},
//
minYear() {
return this.startYear
},
maxYear() {
return this.endYear
},
minMonth() {
if (this.year === this.startYear) {
return this.startMonth
} else {
return 1
}
},
maxMonth() {
if (this.year === this.endYear) {
return this.endMonth
} else {
return 12
}
},
minDay() {
if (this.year === this.startYear && this.month === this.startMonth) {
return this.startDay
} else {
return 1
}
},
maxDay() {
if (this.year === this.endYear && this.month === this.endMonth) {
return this.endDay
} else {
return this.daysInMonth(this.year, this.month)
}
},
minHour() {
if (this.type === 'datetime') {
if (this.currentDateIsStart) {
return this.startHour
} else {
return 0
}
}
if (this.type === 'time') {
return this.startHour
}
},
maxHour() {
if (this.type === 'datetime') {
if (this.currentDateIsEnd) {
return this.endHour
} else {
return 23
}
}
if (this.type === 'time') {
return this.endHour
}
},
minMinute() {
if (this.type === 'datetime') {
if (this.currentDateIsStart && this.hour === this.startHour) {
return this.startMinute
} else {
return 0
}
}
if (this.type === 'time') {
if (this.hour === this.startHour) {
return this.startMinute
} else {
return 0
}
}
},
maxMinute() {
if (this.type === 'datetime') {
if (this.currentDateIsEnd && this.hour === this.endHour) {
return this.endMinute
} else {
return 59
}
}
if (this.type === 'time') {
if (this.hour === this.endHour) {
return this.endMinute
} else {
return 59
}
}
},
minSecond() {
if (this.type === 'datetime') {
if (this.currentDateIsStart && this.hour === this.startHour && this.minute === this.startMinute) {
return this.startSecond
} else {
return 0
}
}
if (this.type === 'time') {
if (this.hour === this.startHour && this.minute === this.startMinute) {
return this.startSecond
} else {
return 0
}
}
},
maxSecond() {
if (this.type === 'datetime') {
if (this.currentDateIsEnd && this.hour === this.endHour && this.minute === this.endMinute) {
return this.endSecond
} else {
return 59
}
}
if (this.type === 'time') {
if (this.hour === this.endHour && this.minute === this.endMinute) {
return this.endSecond
} else {
return 59
}
}
},
/**
* for i18n
*/
selectTimeText() {
return t("uni-datetime-picker.selectTime")
},
okText() {
return t("uni-datetime-picker.ok")
},
clearText() {
return t("uni-datetime-picker.clear")
},
cancelText() {
return t("uni-datetime-picker.cancel")
}
},
mounted() {
// #ifdef APP-NVUE
const res = uni.getSystemInfoSync();
this.fixNvueBug = {
top: res.windowHeight / 2,
left: res.windowWidth / 2
}
// #endif
},
methods: {
/**
* @param {Object} item
* 小于 10 在前面加个 0
*/
lessThanTen(item) {
return item < 10 ? '0' + item : item
},
/**
* 解析时分秒字符串例如00:00:00
* @param {String} timeString
*/
parseTimeType(timeString) {
if (timeString) {
let timeArr = timeString.split(':')
this.hour = Number(timeArr[0])
this.minute = Number(timeArr[1])
this.second = Number(timeArr[2])
}
},
/**
* 解析选择器初始值类型可以是字符串时间戳例如2000-10-02'08:30:00' 1610695109000
* @param {String | Number} datetime
*/
initPickerValue(datetime) {
let defaultValue = null
if (datetime) {
defaultValue = this.compareValueWithStartAndEnd(datetime, this.start, this.end)
} else {
defaultValue = Date.now()
defaultValue = this.compareValueWithStartAndEnd(defaultValue, this.start, this.end)
}
this.parseValue(defaultValue)
},
/**
* 初始值规则
* - 用户设置初始值 value
* - 设置了起始时间 start终止时间 end start < value < end初始值为 value 否则初始值为 start
* - 只设置了起始时间 start start < value初始值为 value否则初始值为 start
* - 只设置了终止时间 end value < end初始值为 value否则初始值为 end
* - 无起始终止时间则初始值为 value
* - 无初始值 value则初始值为当前本地时间 Date.now()
* @param {Object} value
* @param {Object} dateBase
*/
compareValueWithStartAndEnd(value, start, end) {
let winner = null
value = this.superTimeStamp(value)
start = this.superTimeStamp(start)
end = this.superTimeStamp(end)
if (start && end) {
if (value < start) {
winner = new Date(start)
} else if (value > end) {
winner = new Date(end)
} else {
winner = new Date(value)
}
} else if (start && !end) {
winner = start <= value ? new Date(value) : new Date(start)
} else if (!start && end) {
winner = value <= end ? new Date(value) : new Date(end)
} else {
winner = new Date(value)
}
return winner
},
/**
* 转换为可比较的时间戳接受日期时分秒时间戳
* @param {Object} value
*/
superTimeStamp(value) {
let dateBase = ''
if (this.type === 'time' && value && typeof value === 'string') {
const now = new Date()
const year = now.getFullYear()
const month = now.getMonth() + 1
const day = now.getDate()
dateBase = year + '/' + month + '/' + day + ' '
}
if (Number(value) && typeof value !== NaN) {
value = parseInt(value)
dateBase = 0
}
return this.createTimeStamp(dateBase + value)
},
/**
* 解析默认值 value字符串时间戳
* @param {Object} defaultTime
*/
parseValue(value) {
if (!value) {
return
}
if (this.type === 'time' && typeof value === "string") {
this.parseTimeType(value)
} else {
let defaultDate = null
defaultDate = new Date(value)
if (this.type !== 'time') {
this.year = defaultDate.getFullYear()
this.month = defaultDate.getMonth() + 1
this.day = defaultDate.getDate()
}
if (this.type !== 'date') {
this.hour = defaultDate.getHours()
this.minute = defaultDate.getMinutes()
this.second = defaultDate.getSeconds()
}
}
if (this.hideSecond) {
this.second = 0
}
},
/**
* 解析可选择时间范围 startend年月日字符串时间戳
* @param {Object} defaultTime
*/
parseDatetimeRange(point, pointType) {
//
if (!point) {
if (pointType === 'start') {
this.startYear = 1920
this.startMonth = 1
this.startDay = 1
this.startHour = 0
this.startMinute = 0
this.startSecond = 0
}
if (pointType === 'end') {
this.endYear = 2120
this.endMonth = 12
this.endDay = 31
this.endHour = 23
this.endMinute = 59
this.endSecond = 59
}
return
}
if (this.type === 'time') {
const pointArr = point.split(':')
this[pointType + 'Hour'] = Number(pointArr[0])
this[pointType + 'Minute'] = Number(pointArr[1])
this[pointType + 'Second'] = Number(pointArr[2])
} else {
if (!point) {
pointType === 'start' ? this.startYear = this.year - 60 : this.endYear = this.year + 60
return
}
if (Number(point) && Number(point) !== NaN) {
point = parseInt(point)
}
// datetime end ,
const hasTime = /[0-9]:[0-9]/
if (this.type === 'datetime' && pointType === 'end' && typeof point === 'string' && !hasTime.test(
point)) {
point = point + ' 23:59:59'
}
const pointDate = new Date(point)
this[pointType + 'Year'] = pointDate.getFullYear()
this[pointType + 'Month'] = pointDate.getMonth() + 1
this[pointType + 'Day'] = pointDate.getDate()
if (this.type === 'datetime') {
this[pointType + 'Hour'] = pointDate.getHours()
this[pointType + 'Minute'] = pointDate.getMinutes()
this[pointType + 'Second'] = pointDate.getSeconds()
}
}
},
//
getCurrentRange(value) {
const range = []
for (let i = this['min' + this.capitalize(value)]; i <= this['max' + this.capitalize(value)]; i++) {
range.push(i)
}
return range
},
//
capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
},
//
checkValue(name, value, values) {
if (values.indexOf(value) === -1) {
this[name] = values[0]
}
},
//
daysInMonth(year, month) { // Use 1 for January, 2 for February, etc.
return new Date(year, month, 0).getDate();
},
// iOSsafari
fixIosDateFormat(value) {
if (typeof value === 'string') {
value = value.replace(/-/g, '/')
}
return value
},
/**
* 生成时间戳
* @param {Object} time
*/
createTimeStamp(time) {
if (!time) return
if (typeof time === "number") {
return time
} else {
time = time.replace(/-/g, '/')
if (this.type === 'date') {
time = time + ' ' + '00:00:00'
}
return Date.parse(time)
}
},
/**
* 生成日期或时间的字符串
*/
createDomSting() {
const yymmdd = this.year +
'-' +
this.lessThanTen(this.month) +
'-' +
this.lessThanTen(this.day)
let hhmmss = this.lessThanTen(this.hour) +
':' +
this.lessThanTen(this.minute)
if (!this.hideSecond) {
hhmmss = hhmmss + ':' + this.lessThanTen(this.second)
}
if (this.type === 'date') {
return yymmdd
} else if (this.type === 'time') {
return hhmmss
} else {
return yymmdd + ' ' + hhmmss
}
},
/**
* 初始化返回值并抛出 change 事件
*/
initTime(emit = true) {
this.time = this.createDomSting()
if (!emit) return
if (this.returnType === 'timestamp' && this.type !== 'time') {
this.$emit('change', this.createTimeStamp(this.time))
this.$emit('input', this.createTimeStamp(this.time))
this.$emit('update:modelValue', this.createTimeStamp(this.time))
} else {
this.$emit('change', this.time)
this.$emit('input', this.time)
this.$emit('update:modelValue', this.time)
}
},
/**
* 用户选择日期或时间更新 data
* @param {Object} e
*/
bindDateChange(e) {
const val = e.detail.value
this.year = this.years[val[0]]
this.month = this.months[val[1]]
this.day = this.days[val[2]]
},
bindTimeChange(e) {
const val = e.detail.value
this.hour = this.hours[val[0]]
this.minute = this.minutes[val[1]]
this.second = this.seconds[val[2]]
},
/**
* 初始化弹出层
*/
initTimePicker() {
if (this.disabled) return
const value = this.fixIosDateFormat(this.value)
this.initPickerValue(value)
this.visible = !this.visible
},
/**
* 触发或关闭弹框
*/
tiggerTimePicker(e) {
this.visible = !this.visible
},
/**
* 用户点击清空按钮清空当前值
*/
clearTime() {
this.time = ''
this.$emit('change', this.time)
this.$emit('input', this.time)
this.$emit('update:modelValue', this.time)
this.tiggerTimePicker()
},
/**
* 用户点击确定按钮
*/
setTime() {
this.initTime()
this.tiggerTimePicker()
}
}
}
</script>
<style>
.uni-datetime-picker {
/* #ifndef APP-NVUE */
/* width: 100%; */
/* #endif */
}
.uni-datetime-picker-view {
height: 130px;
width: 270px;
/* #ifndef APP-NVUE */
cursor: pointer;
/* #endif */
}
.uni-datetime-picker-item {
height: 50px;
line-height: 50px;
text-align: center;
font-size: 14px;
}
.uni-datetime-picker-btn {
margin-top: 60px;
/* #ifndef APP-NVUE */
display: flex;
cursor: pointer;
/* #endif */
flex-direction: row;
justify-content: space-between;
}
.uni-datetime-picker-btn-text {
font-size: 14px;
color: #007AFF;
}
.uni-datetime-picker-btn-group {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.uni-datetime-picker-cancel {
margin-right: 30px;
}
.uni-datetime-picker-mask {
position: fixed;
bottom: 0px;
top: 0px;
left: 0px;
right: 0px;
background-color: rgba(0, 0, 0, 0.4);
transition-duration: 0.3s;
z-index: 998;
}
.uni-datetime-picker-popup {
border-radius: 8px;
padding: 30px;
width: 270px;
/* #ifdef APP-NVUE */
height: 500px;
/* #endif */
/* #ifdef APP-NVUE */
width: 330px;
/* #endif */
background-color: #fff;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition-duration: 0.3s;
z-index: 999;
}
.fix-nvue-height {
/* #ifdef APP-NVUE */
height: 330px;
/* #endif */
}
.uni-datetime-picker-time {
color: grey;
}
.uni-datetime-picker-column {
height: 50px;
}
.uni-datetime-picker-timebox {
border: 1px solid #E5E5E5;
border-radius: 5px;
padding: 7px 10px;
/* #ifndef APP-NVUE */
box-sizing: border-box;
cursor: pointer;
/* #endif */
}
.uni-datetime-picker-timebox-pointer {
/* #ifndef APP-NVUE */
cursor: pointer;
/* #endif */
}
.uni-datetime-picker-disabled {
opacity: 0.4;
/* #ifdef H5 */
cursor: not-allowed !important;
/* #endif */
}
.uni-datetime-picker-text {
font-size: 14px;
}
.uni-datetime-picker-sign {
position: absolute;
top: 53px;
/* 减掉 10px 的元素高度兼容nvue */
color: #999;
/* #ifdef APP-NVUE */
font-size: 16px;
/* #endif */
}
.sign-left {
left: 86px;
}
.sign-right {
right: 86px;
}
.sign-center {
left: 135px;
}
.uni-datetime-picker__container-box {
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-top: 40px;
}
.time-hide-second {
width: 180px;
}
</style>

View File

@ -0,0 +1,410 @@
class Calendar {
constructor({
date,
selected,
startDate,
endDate,
range,
// multipleStatus
} = {}) {
// 当前日期
this.date = this.getDate(new Date()) // 当前初入日期
// 打点信息
this.selected = selected || [];
// 范围开始
this.startDate = startDate
// 范围结束
this.endDate = endDate
this.range = range
// 多选状态
this.cleanMultipleStatus()
// 每周日期
this.weeks = {}
// this._getWeek(this.date.fullDate)
// this.multipleStatus = multipleStatus
this.lastHover = false
}
/**
* 设置日期
* @param {Object} date
*/
setDate(date) {
this.selectDate = this.getDate(date)
this._getWeek(this.selectDate.fullDate)
}
/**
* 清理多选状态
*/
cleanMultipleStatus() {
this.multipleStatus = {
before: '',
after: '',
data: []
}
}
/**
* 重置开始日期
*/
resetSatrtDate(startDate) {
// 范围开始
this.startDate = startDate
}
/**
* 重置结束日期
*/
resetEndDate(endDate) {
// 范围结束
this.endDate = endDate
}
/**
* 获取任意时间
*/
getDate(date, AddDayCount = 0, str = 'day') {
if (!date) {
date = new 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 {
fullDate: y + '-' + m + '-' + d,
year: y,
month: m,
date: d,
day: dd.getDay()
}
}
/**
* 获取上月剩余天数
*/
_getLastMonthDays(firstDay, full) {
let dateArr = []
for (let i = firstDay; i > 0; i--) {
const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
dateArr.push({
date: beforeDate,
month: full.month - 1,
disable: true
})
}
return dateArr
}
/**
* 获取本月天数
*/
_currentMonthDys(dateData, full) {
let dateArr = []
let fullDate = this.date.fullDate
for (let i = 1; i <= dateData; i++) {
let isinfo = false
let nowDate = full.year + '-' + (full.month < 10 ?
full.month : full.month) + '-' + (i < 10 ?
'0' + i : i)
// 是否今天
let isDay = fullDate === nowDate
// 获取打点信息
let info = this.selected && this.selected.find((item) => {
if (this.dateEqual(nowDate, item.date)) {
return item
}
})
// 日期禁用
let disableBefore = true
let disableAfter = true
if (this.startDate) {
// let dateCompBefore = this.dateCompare(this.startDate, fullDate)
// disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
disableBefore = this.dateCompare(this.startDate, nowDate)
}
if (this.endDate) {
// let dateCompAfter = this.dateCompare(fullDate, 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)
}
return dateArr
}
/**
* 获取下月天数
*/
_getNextMonthDays(surplus, full) {
let dateArr = []
for (let i = 1; i < surplus + 1; i++) {
dateArr.push({
date: i,
month: Number(full.month) + 1,
disable: true
})
}
return dateArr
}
/**
* 获取当前日期详情
* @param {Object} date
*/
getInfo(date) {
if (!date) {
date = new Date()
}
const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
return dateInfo
}
/**
* 比较时间大小
*/
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) {
// 计算截止时间
before = new Date(before.replace('-', '/').replace('-', '/'))
// 计算详细项的截止时间
after = new Date(after.replace('-', '/').replace('-', '/'))
if (before.getTime() - after.getTime() === 0) {
return true
} else {
return false
}
}
/**
* 比较真实起始日期
*/
isLogicBefore(currentDay, before, after) {
let logicBefore = before
if (before && after) {
logicBefore = this.dateCompare(before, after) ? before : after
}
return this.dateEqual(logicBefore, currentDay)
}
isLogicAfter(currentDay, before, after) {
let logicAfter = after
if (before && after) {
logicAfter = this.dateCompare(before, after) ? after : before
}
return this.dateEqual(logicAfter, currentDay)
}
/**
* 获取日期范围内所有日期
* @param {Object} begin
* @param {Object} end
*/
geDateAll(begin, end) {
var arr = []
var ab = begin.split('-')
var ae = end.split('-')
var db = new Date()
db.setFullYear(ab[0], ab[1] - 1, ab[2])
var de = new Date()
de.setFullYear(ae[0], ae[1] - 1, ae[2])
var unixDb = db.getTime() - 24 * 60 * 60 * 1000
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
for (var k = unixDb; k <= unixDe;) {
k = k + 24 * 60 * 60 * 1000
arr.push(this.getDate(new Date(parseInt(k))).fullDate)
}
return arr
}
/**
* 获取多选状态
*/
setMultiple(fullDate) {
let {
before,
after
} = this.multipleStatus
if (!this.range) return
if (before && after) {
if (!this.lastHover) {
this.lastHover = true
return
}
this.multipleStatus.before = fullDate
this.multipleStatus.after = ''
this.multipleStatus.data = []
this.multipleStatus.fulldate = ''
this.lastHover = false
} else {
if (!before) {
this.multipleStatus.before = fullDate
this.lastHover = false
} else {
this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
.after);
} else {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
.before);
}
this.lastHover = true
}
}
this._getWeek(fullDate)
}
/**
* 鼠标 hover 更新多选状态
*/
setHoverMultiple(fullDate) {
let {
before,
after
} = this.multipleStatus
if (!this.range) return
if (this.lastHover) return
if (!before) {
this.multipleStatus.before = fullDate
} else {
this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
} else {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
}
}
this._getWeek(fullDate)
}
/**
* 更新默认值多选状态
*/
setDefaultMultiple(before, after) {
this.multipleStatus.before = before
this.multipleStatus.after = after
if (before && after) {
if (this.dateCompare(before, after)) {
this.multipleStatus.data = this.geDateAll(before, after);
this._getWeek(after)
} else {
this.multipleStatus.data = this.geDateAll(after, before);
this._getWeek(before)
}
}
}
/**
* 获取每周数据
* @param {Object} dateData
*/
_getWeek(dateData) {
const {
fullDate,
year,
month,
date,
day
} = this.getDate(dateData)
let firstDay = new Date(year, month - 1, 1).getDay()
let currentDay = new Date(year, month, 0).getDate()
let dates = {
lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
nextMonthDays: [], // 下个月开始几天
weeks: []
}
let canlender = []
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.canlender = canlender
this.weeks = weeks
}
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
}
export default Calendar

View File

@ -0,0 +1,90 @@
{
"id": "uni-datetime-picker",
"displayName": "uni-datetime-picker 日期选择器",
"version": "2.2.6",
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
"keywords": [
"uni-datetime-picker",
"uni-ui",
"uniui",
"日期时间选择器",
"日期时间"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
},
"uni_modules": {
"dependencies": [
"uni-scss",
"uni-icons"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "n"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}

View File

@ -0,0 +1,21 @@
> `重要通知:组件升级更新 2.0.0 后,支持日期+时间范围选择,组件 ui 将使用日历选择日期ui 变化较大,同时支持 PC 和 移动端。此版本不向后兼容不再支持单独的时间选择type=time及相关的 hide-second 属性(时间选可使用内置组件 picker。若仍需使用旧版本可在插件市场下载*非uni_modules版本*,旧版本将不再维护`
## DatetimePicker 时间选择器
> **组件名uni-datetime-picker**
> 代码块: `uDatetimePicker`
该组件的优势是,支持**时间戳**输入和输出(起始时间、终止时间也支持时间戳),可**同时选择**日期和时间。
若只是需要单独选择日期和时间,不需要时间戳输入和输出,可使用原生的 picker 组件。
**_点击 picker 默认值规则_**
- 若设置初始值 value, 会显示在 picker 显示框中
- 若无初始值 value则初始值 value 为当前本地时间 Date.now() 但不会显示在 picker 显示框中
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-datetime-picker)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@ -1,6 +1,648 @@
//返回
function navigateBackFun(){
uni.navigateBack();
// function navigateBackFun(){
// uni.navigateBack();
// }
export default {
isNotANumber(inputData) {
if (!inputData) {
return false
}
//isNaN(inputData)不能判断空串或一个空格
//如果是一个空串或是一个空格而isNaN是做为数字0进行处理的而parseInt与parseFloat是返回一个错误消息这个isNaN检查不严密而导致的。
if (parseFloat(inputData).toString() == "NaN") {
//alert(“请输入数字……”);
return false;
} else {
if (inputData > 0) {
return true;
} else {
return false
}
}
},
//无图标toast
toast(title) {
uni.showToast({
title,
icon: 'none',
mask: true,
duration: 2000
});
},
//验证手机号码部分
chickPhone(phone) {
if (phone.length == 11) {
return true
} else {
return false
}
// let reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
// //var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
// if (!phone) {
// return false
// } else if (!reg.test(phone)) {
// return false
// } else {
// return true
// }
},
formatTime(data) {
if (!data) return ''
let dataArray = data.split(':')
let date0 = dataArray['0'].split('T')
let date1 = dataArray['1']
return date0[1] + ':' + date1
},
toLogin() {
// #ifdef MP-WEIXIN
uni.navigateTo({
url: "/pages/login/wxLogin/wxLogin"
})
// #endif
// #ifndef MP-WEIXIN
uni.navigateTo({
url: "/pages/login/pasLogin/pasLogin"
})
// #endif
},
toastNoIcon(title) {
uni.showToast({
title: title,
icon: "none",
duration: 2000
});
},
showMyLoading(title = "加载中", mask = true) {
uni.showLoading({
title,
mask
})
},
getTodayYMD() {
let myDate = new Date()
let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
let month = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
let date = myDate.getDate(); //获取当前日(1-31)
return `${year}-${month+1}-${date}`
},
/**
* 处理富文本里的图片宽度自适应
* 1.去掉img标签里的stylewidthheight属性
* 2.img标签添加style属性max-width:100%;height:auto
* 3.修改所有style里的width属性为max-width:100%
* 4.去掉<br/>标签
* @param html
* @returns {void|string|*}
*/
formatRichText(html) {
let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
return match;
});
newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;');
return match;
});
newContent = newContent.replace(/<br[^>]*\/>/gi, '');
newContent = newContent.replace(/\<img/gi,
'<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
newContent = newContent.replace(/<section/g, '<div').replace(/\/section>/g, '/div>');
let isCms = '<span>isCMS</span>'
newContent = newContent.split(isCms)[0]
return newContent;
},
hideMyLoading() {
try {
uni.hideLoading()
} catch (e) {
}
},
upLoadImg(filePath, successfn, type = 1) {
// console.log(filePath,"filePath")
// console.log(successfn,"successfn")
uni.uploadFile({
url: 'https://api.ghniu.com/upload/file/img/account', //仅为示例,非真实的接口地址
filePath: filePath,
name: 'files',
formData: {
type
},
success: (uploadFileRes) => {
// console.log(uploadFileRes,"uploadFileRes")
if (uploadFileRes.statusCode != 200) {
this.toast("上传失败")
return
}
if (JSON.parse(uploadFileRes.data).code != "0") {
this.toast("上传失败")
return
}
successfn(JSON.parse(uploadFileRes.data).data[0])
}
});
},
myBackPage(time = 1500) {
setTimeout(() => {
uni.navigateBack()
}, time)
},
toGoodsInfo(type, id) {
switch (type) {
//普通
case 1:
uni.navigateTo({
url: "/pages/goodsInfo/type12Info/type12Info?goodsid=" + id
})
break;
//大众
case 2:
uni.navigateTo({
url: "/pages/goodsInfo/type12Info/type12Info?goodsid=" + id
})
break;
//服务
case 3:
uni.navigateTo({
url: "/pagesA/service/info/info?id=" + id
})
break;
//汽车
case 4:
uni.navigateTo({
url: "/pages/car/info/info?goodsid=" + id
})
break;
//司机
case 5:
uni.navigateTo({
url: "/pagesA/driver/info/info?id=" + id
})
break;
default:
break;
}
},
wxMinShare(imageUrl, title, path) {
this.toast("需要小程序先上架才可以分享")
return
console.log(imageUrl)
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 5,
imageUrl,
title,
miniProgram: {
id: 'wx902fccb81a579f91',
path,
type: 0,
webUrl: 'https://hdc.nbjice.com'
},
success: ret => {
console.log(JSON.stringify(ret));
}
});
},
toFLList(item) {
const type = item.classType
switch (type) {
case 1:
uni.navigateTo({
url: "/pages/tabbar-2/classify/classify?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId +
"&twoId=" + item.twoId + "&type=" + type
})
break;
case 2:
uni.navigateTo({
url: "/pages/tabbar-2/classify/classify?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId +
"&twoId=" + item.twoId + "&type=" + type
})
break;
case 3:
uni.setStorageSync("icoImg", item.icoImg)
uni.navigateTo({
url: "/pages/car/home/home?threeId=" + item.threeId + "&name=" + item.name + "&oneId=" + item.oneId
})
break;
case 4:
uni.navigateTo({
url: "/pagesA/service/list/list?threeId=" + item.threeId + "&name=" + item.name
})
break;
default:
break;
}
},
bannerClick(item) {
// banner类型(1外链 2.商品列表 3.商品详情 4.个人中心)/
switch (item.bannerType) {
case -1:
this.toast("该商品或分类已删除")
return
break;
case 1:
uni.setStorageSync("webviewUrl", item.externalUrl)
uni.navigateTo({
url: "/pages/webview/webview"
})
break;
case 2:
if (item.classType == 4) {
uni.navigateTo({
url: "/pagesA/service/sclass/sclass"
})
} else {
uni.navigateTo({
url: "/pages/tabbar/tabbar-1/classinfo/classinfo?className=" + item.className + "&id=" + item.objectKey +
"&name=" + item.name + "&classType=" + item.classType
})
}
break;
case 3:
this.toGoodsInfo(item.type, item.objectKey)
break;
case 4:
//店铺首页
uni.navigateTo({
url: "/pages/shop/home/home?id=" + item.objectKey
})
break;
case 5:
this.toFLList(item)
break;
default:
break;
}
},
checkLocToken() {
if (uni.getStorageSync("token")) {
return true
} else {
uni.showModal({
title: '提示',
confirmText: "去登录",
confirmColor: "#f56e5d",
cancelText: "取消",
content: '登录后才能使用该功能~',
success: (res) => {
if (res.confirm) {
this.toLogin()
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return false
}
},
//加法函数
accAdd(arg1, arg2) {
var r1, r2, m, c;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
c = Math.abs(r1 - r2);
m = Math.pow(10, Math.max(r1, r2));
if (c > 0) {
var cm = Math.pow(10, c);
if (r1 > r2) {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", "")) * cm;
} else {
arg1 = Number(arg1.toString().replace(".", "")) * cm;
arg2 = Number(arg2.toString().replace(".", ""));
}
} else {
arg1 = Number(arg1.toString().replace(".", ""));
arg2 = Number(arg2.toString().replace(".", ""));
}
return (arg1 + arg2) / m;
},
//减法函数
accSub(arg1, arg2) {
var r1, r2, m, n;
try {
r1 = arg1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度
n = (r1 >= r2) ? r1 : r2;
return ((arg1 * m - arg2 * m) / m).toFixed(n);
},
/**
** 乘法函数用来得到精确的乘法结果
** 说明javascript的乘法结果会有误差在两个浮点数相乘的时候会比较明显这个函数返回较为精确的乘法结果
** 调用accMul(arg1,arg2)
** 返回值arg1乘以 arg2的精确结果
**/
accMul(arg1, arg2) {
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) {}
try {
m += s2.split(".")[1].length;
} catch (e) {}
console.log(s1)
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
},
//除法函数
accDiv(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1, r2;
try {
t1 = arg1.toString().split(".")[1].length;
} catch (e) {}
try {
t2 = arg2.toString().split(".")[1].length;
} catch (e) {}
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
return (r1 / r2) * Math.pow(10, t2 - t1);
},
getSence(data) {
let a = data.split(",")
console.log(a)
let obj = {}
a.forEach(item => {
let sp = item.split(":")
obj[sp[0]] = sp[1]
})
return obj
},
getShowOrHide(state) {
switch (state) {
case 0:
return false
break;
case 1:
return true
break;
case 2:
return true
break;
case 3:
return true
break;
case 4:
return true
break;
case 5:
return true
break;
case 6:
return false
break;
case 7:
return false
break;
case 8:
return true
break;
default:
break;
}
},
getSellShowOrHide(state) {
switch (state) {
case 0:
return false
break;
case 1:
return false
break;
case 2:
return true
break;
case 3:
return false
break;
case 4:
return false
break;
case 5:
return false
break;
case 6:
return true
break;
case 7:
return false
break;
case 8:
return false
break;
default:
break;
}
},
getBtn1ShowOrHide(state) {
switch (state) {
case 0:
return false
break;
case 1:
return true
break;
case 2:
return true
break;
case 3:
return true
break;
case 4:
return true
break;
case 5:
return false
break;
case 6:
return false
break;
case 7:
return false
break;
case 8:
return true
break;
default:
break;
}
},
getBtn2ShowOrHide(state) {
switch (state) {
case 0:
return false
break;
case 1:
return true
break;
case 2:
return true
break;
case 3:
return true
break;
case 4:
return true
break;
case 5:
return true
break;
case 6:
return false
break;
case 7:
return false
break;
case 8:
return true
break;
default:
break;
}
},
getSellBtn1ShowOrHide(item) {
switch (item.state) {
case 0:
return false
break;
case 1:
return false
break;
case 2:
if (item.itemType == '3') {
return true
} else {
return false
}
return false
break;
case 3:
return false
break;
case 4:
return false
break;
case 5:
return false
break;
case 6:
return true
break;
case 7:
return false
break;
case 8:
return false
break;
default:
break;
}
},
getSellBtn2ShowOrHide(state) {
switch (state) {
case 0:
return false
break;
case 1:
return false
break;
case 2:
return true
break;
case 3:
return false
break;
case 4:
return false
break;
case 5:
return false
break;
case 6:
return true
break;
case 7:
return false
break;
case 8:
return false
break;
default:
break;
}
},
//保存图片到本地
saveImgUtils(url) {
this.showMyLoading("保存中")
uni.downloadFile({
url,
success: (res) => {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: (dres) => {
this.toast("图片已保存")
},
fail: (err) => {
this.toast("保存失败,请检查系统权限")
}
})
}
})
},
clearTokenSet() {
if (uni.getStorageSync("setin")) {
let setin = uni.getStorageSync("setin")
clearInterval(setin)
}
},
toTalk(toId) {
if (this.checkLocToken()) {
uni.navigateTo({
url: "/pages/im/talkPage/talkPage?toId=" + toId
})
}
},
chickCanSee(item) {
if (item.isMyself != 1 && item.state != 3) {
uni.showModal({
title: '提示',
confirmText: "确定",
confirmColor: "#f56e5d",
showCancel: false,
content: '该商品已下架',
success: (res) => {
if (res.confirm) {
uni.navigateBack()
}
}
});
}
}
}