init
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/node_modules
|
||||||
|
/unpackage
|
27
App.vue
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<script>
|
||||||
|
import pageAnimation from './components/page-animation'
|
||||||
|
export default {
|
||||||
|
mixins: [pageAnimation],
|
||||||
|
onLaunch: function() {
|
||||||
|
console.log('App Launch')
|
||||||
|
},
|
||||||
|
onShow: function() {
|
||||||
|
console.log('App Show')
|
||||||
|
},
|
||||||
|
onHide: function() {
|
||||||
|
console.log('App Hide')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang='scss'>
|
||||||
|
/*每个页面公共css */
|
||||||
|
/* 引入的uview-ui的index.scss放第一行引入 */
|
||||||
|
@import "uview-ui/index.scss";
|
||||||
|
/*每个页面公共css */
|
||||||
|
page {
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-attachment: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
</style>
|
25
common/index.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* 非空验证 */
|
||||||
|
const vefEmpty = (key,msg) => {
|
||||||
|
if (key === '' || key === undefined || key === null) {
|
||||||
|
uni.showToast({
|
||||||
|
title: msg,
|
||||||
|
duration: 2000,
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const addZero = (num) => {
|
||||||
|
if (num < 10) {
|
||||||
|
num = `0${num}`;
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
vefEmpty,
|
||||||
|
addZero
|
||||||
|
}
|
BIN
common/updown/oa-app.keystore
Normal file
28
components/page-animation/index.css
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* #ifdef H5 */
|
||||||
|
uni-page {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni-page.animation-before {
|
||||||
|
/* 在页面上使用 transform 会导致页面内的 fixed 定位渲染为 absolute,需要在动画完成后移除 */
|
||||||
|
transform: translateY(20px);
|
||||||
|
}
|
||||||
|
|
||||||
|
uni-page.animation-leave {
|
||||||
|
transition: all .3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni-page.animation-enter {
|
||||||
|
transition: all .3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni-page.animation-show {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni-page.animation-after {
|
||||||
|
/* 在页面上使用 transform 会导致页面内的 fixed 定位渲染为 absolute,需要在动画完成后移除 */
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endif */
|
37
components/page-animation/index.vue
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<script>
|
||||||
|
import './index.css'
|
||||||
|
export default {
|
||||||
|
// #ifdef H5
|
||||||
|
onLaunch: function() {
|
||||||
|
this.show()
|
||||||
|
this.$router.beforeEach((to, from, next) => {
|
||||||
|
this.hide(next)
|
||||||
|
})
|
||||||
|
this.$router.afterEach(() => {
|
||||||
|
setTimeout(this.show, 50)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
hide(callback) {
|
||||||
|
const classList = document.querySelector('uni-page').classList
|
||||||
|
classList.add('animation-before', 'animation-leave')
|
||||||
|
classList.remove('animation-show')
|
||||||
|
setTimeout(() => {
|
||||||
|
classList.remove('animation-before', 'animation-leave')
|
||||||
|
callback && callback()
|
||||||
|
}, 300)
|
||||||
|
},
|
||||||
|
show() {
|
||||||
|
const classList = document.querySelector('uni-page').classList
|
||||||
|
classList.add('animation-before')
|
||||||
|
setTimeout(() => {
|
||||||
|
classList.add('animation-enter', 'animation-after', 'animation-show')
|
||||||
|
setTimeout(() => {
|
||||||
|
classList.remove('animation-before', 'animation-after', 'animation-enter')
|
||||||
|
}, 300)
|
||||||
|
}, 20)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
</script>
|
142
components/tabBar/tabBar.vue
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view
|
||||||
|
class="status_bar"
|
||||||
|
v-if="isStartBar">
|
||||||
|
<!-- 这里是状态栏 -->
|
||||||
|
</view>
|
||||||
|
<u-tabbar
|
||||||
|
:value="current"
|
||||||
|
@change="changeTab"
|
||||||
|
:fixed="true"
|
||||||
|
:placeholder="false"
|
||||||
|
:safeAreaInsetBottom="true"
|
||||||
|
:border="false"
|
||||||
|
activeColor="#0095FF"
|
||||||
|
inactiveColor="#000000">
|
||||||
|
<u-tabbar-item
|
||||||
|
v-for="(item, index) in tabBarList"
|
||||||
|
:key="index"
|
||||||
|
:text="item.text"
|
||||||
|
:badge="item.text === '审批' ? doingTotal : 0">
|
||||||
|
<image
|
||||||
|
class="u-page__item__slot-icon"
|
||||||
|
slot="inactive-icon"
|
||||||
|
:src="item.iconPath"></image>
|
||||||
|
<image
|
||||||
|
class="u-page__item__slot-icon"
|
||||||
|
slot="active-icon"
|
||||||
|
:src="item.selectedIconPath"></image>
|
||||||
|
</u-tabbar-item>
|
||||||
|
</u-tabbar>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapGetters } from "vuex";
|
||||||
|
export default {
|
||||||
|
name: "tabBar",
|
||||||
|
props: {
|
||||||
|
currentPage: String,
|
||||||
|
isStartBar: Boolean,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
current: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["tabBarList", "doingTotal"]),
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
changeTab(e) {
|
||||||
|
let page = "/" + this.tabBarList[e].pagePath;
|
||||||
|
uni.switchTab({
|
||||||
|
url: page,
|
||||||
|
success: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
|
||||||
|
},
|
||||||
|
fail: (e) => {
|
||||||
|
console.log(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//获取审批列表
|
||||||
|
async getAppList() {
|
||||||
|
let data = {
|
||||||
|
ApplyUserID: uni.getStorageSync("oa-userInfo").ID,
|
||||||
|
Page: 1,
|
||||||
|
PageSize: 9999,
|
||||||
|
applyStatus: [1],
|
||||||
|
applyType: [
|
||||||
|
"leave",
|
||||||
|
"sick",
|
||||||
|
"dayOff",
|
||||||
|
"annualLeave",
|
||||||
|
"annualLeaveApply",
|
||||||
|
"maritalLeave",
|
||||||
|
"maritalLeaveApply",
|
||||||
|
"matingCheckLeave",
|
||||||
|
"matingCheckLeaveApply",
|
||||||
|
"maternityLeave",
|
||||||
|
"maternityLeaveApply",
|
||||||
|
"paternityLeave",
|
||||||
|
"paternityLeaveApply",
|
||||||
|
"parentalLeave",
|
||||||
|
"parentalLeaveApply",
|
||||||
|
"nursingLeave",
|
||||||
|
"nursingLeaveApply",
|
||||||
|
"funeralLeave",
|
||||||
|
"funeralLeaveApply",
|
||||||
|
"makeUp",
|
||||||
|
"overtime",
|
||||||
|
"outWork",
|
||||||
|
"turnOver",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
let res = await this.$api.approval.approvalList(data);
|
||||||
|
if (res.status == 0) {
|
||||||
|
// 存储待审批数量
|
||||||
|
this.$store.commit("getDoingTotal", res.data.Total);
|
||||||
|
console.log(this.doingTotal);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
uni.$u.toast(res.msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
//隐藏原生tabbar
|
||||||
|
uni.hideTabBar();
|
||||||
|
// 当前选中的菜单
|
||||||
|
this.getAppList();
|
||||||
|
this.tabBarList.forEach((i, index) => {
|
||||||
|
if (i.pagePath == this.currentPage) {
|
||||||
|
this.current = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.status_bar {
|
||||||
|
height: var(--status-bar-height);
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.u-page__item__slot-icon {
|
||||||
|
width: 68rpx;
|
||||||
|
height: 68rpx;
|
||||||
|
}
|
||||||
|
.u-tabbar /deep/ .u-tabbar--fixed {
|
||||||
|
width: 92%;
|
||||||
|
padding: 9px;
|
||||||
|
background: #fff;
|
||||||
|
background-size: 100% 100%;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 1.7%;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
}
|
||||||
|
</style>
|
190
components/tki-barcode/barcode.js
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
const barcodes = require('./barcodes/index.js')['default'];
|
||||||
|
let barcode = {};
|
||||||
|
(function () {
|
||||||
|
// 初始化
|
||||||
|
barcode = function (cont, ctxid, options, ctxsize, result) {
|
||||||
|
let ops = {}, newOptions, encodings, globaContext, ctx, globaCtxid, cbCanvasSize, cbResult;
|
||||||
|
globaCtxid = ctxid
|
||||||
|
cbCanvasSize = ctxsize
|
||||||
|
cbResult = result
|
||||||
|
newOptions = Object.assign(ops, options);
|
||||||
|
// 修成margin
|
||||||
|
fixMargin(newOptions)
|
||||||
|
// 处理options 数据
|
||||||
|
if (newOptions.text == '' || cont == '') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 获取ctx
|
||||||
|
globaContext = cont
|
||||||
|
ctx = uni.createCanvasContext(globaCtxid, globaContext)
|
||||||
|
// 获取编码数据
|
||||||
|
encodings = new barcodes[newOptions.format.toUpperCase()](newOptions.text, newOptions).encode()
|
||||||
|
let fixencodings = fixEncodings(encodings, newOptions)
|
||||||
|
// 返回canvas实际大小
|
||||||
|
cbCanvasSize({ width: fixencodings.width, height: fixencodings.height })
|
||||||
|
// 绘制canvas
|
||||||
|
setTimeout(() => {
|
||||||
|
drawCanvas.render(newOptions, fixencodings)
|
||||||
|
}, 50);
|
||||||
|
// 绘制canvas
|
||||||
|
let drawCanvas = {
|
||||||
|
render(options, encoding) {
|
||||||
|
this.prepare(options, encoding)
|
||||||
|
encoding.encodings.forEach((v, i) => {
|
||||||
|
this.barcode(options, v)
|
||||||
|
this.text(options, v)
|
||||||
|
this.move(v)
|
||||||
|
});
|
||||||
|
this.draw(options, encoding)
|
||||||
|
},
|
||||||
|
barcode(options, encoding) {
|
||||||
|
let binary = encoding.data;
|
||||||
|
let yFrom;
|
||||||
|
if (options.textPosition == "top") {
|
||||||
|
yFrom = options.marginTop + options.fontSize + options.textMargin;
|
||||||
|
} else {
|
||||||
|
yFrom = options.marginTop;
|
||||||
|
}
|
||||||
|
// 绘制条码
|
||||||
|
ctx.fillStyle = options.lineColor;
|
||||||
|
for (let b = 0; b < binary.length; b++) {
|
||||||
|
let x = b * options.width + encoding.barcodePadding;
|
||||||
|
let height = options.height
|
||||||
|
if (encoding.options) {
|
||||||
|
if (encoding.options.height != undefined) {
|
||||||
|
height = encoding.options.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (binary[b] === "1") {
|
||||||
|
ctx.fillRect(x, yFrom, options.width, height);
|
||||||
|
} else if (binary[b]) {
|
||||||
|
ctx.fillRect(x, yFrom, options.width, height * binary[b]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
text(options, encoding) {
|
||||||
|
if (options.displayValue) {
|
||||||
|
let x, y, align, size;
|
||||||
|
if (options.textPosition == "top") {
|
||||||
|
y = options.marginTop + options.fontSize;
|
||||||
|
} else {
|
||||||
|
y = options.height + options.textMargin + options.marginTop + options.fontSize;
|
||||||
|
}
|
||||||
|
if (encoding.options) {
|
||||||
|
if (encoding.options.textAlign != undefined) {
|
||||||
|
align = encoding.options.textAlign
|
||||||
|
}
|
||||||
|
if (encoding.options.fontSize != undefined) {
|
||||||
|
size = encoding.options.fontSize
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
align = options.textAlign
|
||||||
|
size = options.fontSize
|
||||||
|
}
|
||||||
|
ctx.setFontSize(size)
|
||||||
|
if (align == "left" || encoding.barcodePadding > 0) {
|
||||||
|
x = 0;
|
||||||
|
ctx.setTextAlign('left')
|
||||||
|
} else if (align == "right") {
|
||||||
|
x = encoding.width - 1;
|
||||||
|
ctx.setTextAlign('right')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = encoding.width / 2;
|
||||||
|
ctx.setTextAlign('center');
|
||||||
|
}
|
||||||
|
ctx.fillStyle = options.fontColor;
|
||||||
|
if (encoding.text != undefined) {
|
||||||
|
ctx.fillText(encoding.text, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
move(encoding) {
|
||||||
|
ctx.translate(encoding.width, 0);
|
||||||
|
},
|
||||||
|
prepare(options, encoding) {
|
||||||
|
// 绘制背景
|
||||||
|
if (options.background) {
|
||||||
|
ctx.fillStyle = options.background;
|
||||||
|
ctx.fillRect(0, 0, encoding.width, encoding.height);
|
||||||
|
}
|
||||||
|
ctx.translate(options.marginLeft, 0);
|
||||||
|
},
|
||||||
|
draw(options, encoding) {
|
||||||
|
ctx.draw(false, () => {
|
||||||
|
this.toImgs(options, encoding)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toImgs(options, encoding) {
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.canvasToTempFilePath({
|
||||||
|
width: encoding.width,
|
||||||
|
height: encoding.height,
|
||||||
|
destWidth: encoding.width,
|
||||||
|
destHeight: encoding.height,
|
||||||
|
canvasId: globaCtxid,
|
||||||
|
fileType: 'png',
|
||||||
|
success: function (res) {
|
||||||
|
cbResult(res.tempFilePath)
|
||||||
|
},
|
||||||
|
fail: function (res) {
|
||||||
|
cbResult(res)
|
||||||
|
},
|
||||||
|
complete: function () {
|
||||||
|
uni.hideLoading();
|
||||||
|
},
|
||||||
|
}, globaContext);
|
||||||
|
}, options.text.length + 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 混入canvas数据
|
||||||
|
function fixEncodings(encoding, options) {
|
||||||
|
let encodingArr = [], width = options.marginLeft + options.marginRight, height;
|
||||||
|
if (!Array.isArray(encoding)) {
|
||||||
|
encodingArr[0] = JSON.parse(JSON.stringify(encoding))
|
||||||
|
} else {
|
||||||
|
encodingArr = [...encoding]
|
||||||
|
}
|
||||||
|
encodingArr.forEach((v, i) => {
|
||||||
|
// 获取文本宽度
|
||||||
|
let textWidth = ctx.measureText(encodingArr[i].text ? encodingArr[i].text : '').width;
|
||||||
|
// 获取条形码宽度
|
||||||
|
let barcodeWidth = encodingArr[i].data.length * options.width;
|
||||||
|
// 获取内边距
|
||||||
|
let barcodePadding = 0;
|
||||||
|
if (options.displayValue && barcodeWidth < textWidth) {
|
||||||
|
if (options.textAlign == "center") {
|
||||||
|
barcodePadding = Math.floor((textWidth - barcodeWidth) / 2);
|
||||||
|
} else if (options.textAlign == "left") {
|
||||||
|
barcodePadding = 0;
|
||||||
|
} else if (options.textAlign == "right") {
|
||||||
|
barcodePadding = Math.floor(textWidth - barcodeWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 混入encodingArr[i]
|
||||||
|
encodingArr[i].barcodePadding = barcodePadding
|
||||||
|
encodingArr[i].width = Math.ceil(Math.max(textWidth, barcodeWidth))
|
||||||
|
width += encodingArr[i].width
|
||||||
|
if (encodingArr[i].options) {
|
||||||
|
if (encodingArr[i].options.height != undefined) {
|
||||||
|
encodingArr[i].height = encodingArr[i].options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
|
||||||
|
} else {
|
||||||
|
encodingArr[i].height = height = options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
encodingArr[i].height = height = options.height + (options.displayValue && (encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options.fontSize + options.textMargin : 0) + options.marginTop + options.marginBottom;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return { encodings: encodingArr, width, height };
|
||||||
|
}
|
||||||
|
// 修正Margin
|
||||||
|
function fixMargin(options) {
|
||||||
|
options.marginTop = options.marginTop == undefined ? options.margin : options.marginTop;
|
||||||
|
options.marginBottom = options.marginBottom == undefined ? options.margin : options.marginBottom;
|
||||||
|
options.marginRight = options.marginRight == undefined ? options.margin : options.marginRight;
|
||||||
|
options.marginLeft = options.marginLeft == undefined ? options.margin : options.marginLeft;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})()
|
||||||
|
|
||||||
|
export default barcode
|
17
components/tki-barcode/barcodes/Barcode.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
var Barcode = function Barcode(data, options) {
|
||||||
|
_classCallCheck(this, Barcode);
|
||||||
|
|
||||||
|
this.data = data;
|
||||||
|
this.text = options.text || data;
|
||||||
|
this.options = options;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.default = Barcode;
|
167
components/tki-barcode/barcodes/CODE128/CODE128.js
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode.js');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
// This is the master class,
|
||||||
|
// it does require the start code to be included in the string
|
||||||
|
var CODE128 = function (_Barcode) {
|
||||||
|
_inherits(CODE128, _Barcode);
|
||||||
|
|
||||||
|
function CODE128(data, options) {
|
||||||
|
_classCallCheck(this, CODE128);
|
||||||
|
|
||||||
|
// Get array of ascii codes from data
|
||||||
|
var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
|
||||||
|
|
||||||
|
_this.bytes = data.split('').map(function (char) {
|
||||||
|
return char.charCodeAt(0);
|
||||||
|
});
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(CODE128, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
// ASCII value ranges 0-127, 200-211
|
||||||
|
return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The public encoding function
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
var bytes = this.bytes;
|
||||||
|
// Remove the start code from the bytes and set its index
|
||||||
|
var startIndex = bytes.shift() - 105;
|
||||||
|
// Get start set by index
|
||||||
|
var startSet = _constants.SET_BY_CODE[startIndex];
|
||||||
|
|
||||||
|
if (startSet === undefined) {
|
||||||
|
throw new RangeError('The encoding does not start with a start character.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.shouldEncodeAsEan128() === true) {
|
||||||
|
bytes.unshift(_constants.FNC1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start encode with the right type
|
||||||
|
var encodingResult = CODE128.next(bytes, 1, startSet);
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
|
||||||
|
data:
|
||||||
|
// Add the start bits
|
||||||
|
CODE128.getBar(startIndex) +
|
||||||
|
// Add the encoded bits
|
||||||
|
encodingResult.result +
|
||||||
|
// Add the checksum
|
||||||
|
CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
|
||||||
|
// Add the end bits
|
||||||
|
CODE128.getBar(_constants.STOP)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// GS1-128/EAN-128
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'shouldEncodeAsEan128',
|
||||||
|
value: function shouldEncodeAsEan128() {
|
||||||
|
var isEAN128 = this.options.ean128 || false;
|
||||||
|
if (typeof isEAN128 === 'string') {
|
||||||
|
isEAN128 = isEAN128.toLowerCase() === 'true';
|
||||||
|
}
|
||||||
|
return isEAN128;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a bar symbol by index
|
||||||
|
|
||||||
|
}], [{
|
||||||
|
key: 'getBar',
|
||||||
|
value: function getBar(index) {
|
||||||
|
return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Correct an index by a set and shift it from the bytes array
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'correctIndex',
|
||||||
|
value: function correctIndex(bytes, set) {
|
||||||
|
if (set === _constants.SET_A) {
|
||||||
|
var charCode = bytes.shift();
|
||||||
|
return charCode < 32 ? charCode + 64 : charCode - 32;
|
||||||
|
} else if (set === _constants.SET_B) {
|
||||||
|
return bytes.shift() - 32;
|
||||||
|
} else {
|
||||||
|
return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'next',
|
||||||
|
value: function next(bytes, pos, set) {
|
||||||
|
if (!bytes.length) {
|
||||||
|
return { result: '', checksum: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextCode = void 0,
|
||||||
|
index = void 0;
|
||||||
|
|
||||||
|
// Special characters
|
||||||
|
if (bytes[0] >= 200) {
|
||||||
|
index = bytes.shift() - 105;
|
||||||
|
var nextSet = _constants.SWAP[index];
|
||||||
|
|
||||||
|
// Swap to other set
|
||||||
|
if (nextSet !== undefined) {
|
||||||
|
nextCode = CODE128.next(bytes, pos + 1, nextSet);
|
||||||
|
}
|
||||||
|
// Continue on current set but encode a special character
|
||||||
|
else {
|
||||||
|
// Shift
|
||||||
|
if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
|
||||||
|
// Convert the next character so that is encoded correctly
|
||||||
|
bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
|
||||||
|
}
|
||||||
|
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Continue encoding
|
||||||
|
else {
|
||||||
|
index = CODE128.correctIndex(bytes, set);
|
||||||
|
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the correct binary encoding and calculate the weight
|
||||||
|
var enc = CODE128.getBar(index);
|
||||||
|
var weight = index * pos;
|
||||||
|
|
||||||
|
return {
|
||||||
|
result: enc + nextCode.result,
|
||||||
|
checksum: weight + nextCode.checksum
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return CODE128;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.default = CODE128;
|
42
components/tki-barcode/barcodes/CODE128/CODE128A.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _CODE2 = require('./CODE128.js');
|
||||||
|
|
||||||
|
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var CODE128A = function (_CODE) {
|
||||||
|
_inherits(CODE128A, _CODE);
|
||||||
|
|
||||||
|
function CODE128A(string, options) {
|
||||||
|
_classCallCheck(this, CODE128A);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(CODE128A, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return CODE128A;
|
||||||
|
}(_CODE3.default);
|
||||||
|
|
||||||
|
exports.default = CODE128A;
|
42
components/tki-barcode/barcodes/CODE128/CODE128B.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _CODE2 = require('./CODE128.js');
|
||||||
|
|
||||||
|
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var CODE128B = function (_CODE) {
|
||||||
|
_inherits(CODE128B, _CODE);
|
||||||
|
|
||||||
|
function CODE128B(string, options) {
|
||||||
|
_classCallCheck(this, CODE128B);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(CODE128B, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return CODE128B;
|
||||||
|
}(_CODE3.default);
|
||||||
|
|
||||||
|
exports.default = CODE128B;
|
42
components/tki-barcode/barcodes/CODE128/CODE128C.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _CODE2 = require('./CODE128.js');
|
||||||
|
|
||||||
|
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var CODE128C = function (_CODE) {
|
||||||
|
_inherits(CODE128C, _CODE);
|
||||||
|
|
||||||
|
function CODE128C(string, options) {
|
||||||
|
_classCallCheck(this, CODE128C);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(CODE128C, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return CODE128C;
|
||||||
|
}(_CODE3.default);
|
||||||
|
|
||||||
|
exports.default = CODE128C;
|
41
components/tki-barcode/barcodes/CODE128/CODE128_AUTO.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _CODE2 = require('./CODE128');
|
||||||
|
|
||||||
|
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||||
|
|
||||||
|
var _auto = require('./auto');
|
||||||
|
|
||||||
|
var _auto2 = _interopRequireDefault(_auto);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var CODE128AUTO = function (_CODE) {
|
||||||
|
_inherits(CODE128AUTO, _CODE);
|
||||||
|
|
||||||
|
function CODE128AUTO(data, options) {
|
||||||
|
_classCallCheck(this, CODE128AUTO);
|
||||||
|
|
||||||
|
// ASCII value ranges 0-127, 200-211
|
||||||
|
if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
|
||||||
|
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
|
||||||
|
} else {
|
||||||
|
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
|
||||||
|
}
|
||||||
|
return _possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return CODE128AUTO;
|
||||||
|
}(_CODE3.default);
|
||||||
|
|
||||||
|
exports.default = CODE128AUTO;
|
73
components/tki-barcode/barcodes/CODE128/auto.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
// Match Set functions
|
||||||
|
var matchSetALength = function matchSetALength(string) {
|
||||||
|
return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
|
||||||
|
};
|
||||||
|
var matchSetBLength = function matchSetBLength(string) {
|
||||||
|
return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
|
||||||
|
};
|
||||||
|
var matchSetC = function matchSetC(string) {
|
||||||
|
return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
// CODE128A or CODE128B
|
||||||
|
function autoSelectFromAB(string, isA) {
|
||||||
|
var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
|
||||||
|
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
|
||||||
|
|
||||||
|
if (untilC) {
|
||||||
|
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
|
||||||
|
}
|
||||||
|
|
||||||
|
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
|
||||||
|
|
||||||
|
if (chars.length === string.length) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CODE128C
|
||||||
|
function autoSelectFromC(string) {
|
||||||
|
var cMatch = matchSetC(string);
|
||||||
|
var length = cMatch.length;
|
||||||
|
|
||||||
|
if (length === string.length) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
string = string.substring(length);
|
||||||
|
|
||||||
|
// Select A/B depending on the longest match
|
||||||
|
var isA = matchSetALength(string) >= matchSetBLength(string);
|
||||||
|
return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect Code Set (A, B or C) and format the string
|
||||||
|
|
||||||
|
exports.default = function (string) {
|
||||||
|
var newString = void 0;
|
||||||
|
var cLength = matchSetC(string).length;
|
||||||
|
|
||||||
|
// Select 128C if the string start with enough digits
|
||||||
|
if (cLength >= 2) {
|
||||||
|
newString = _constants.C_START_CHAR + autoSelectFromC(string);
|
||||||
|
} else {
|
||||||
|
// Select A/B depending on the longest match
|
||||||
|
var isA = matchSetALength(string) > matchSetBLength(string);
|
||||||
|
newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
|
||||||
|
function (match, char) {
|
||||||
|
return String.fromCharCode(203) + char;
|
||||||
|
});
|
||||||
|
};
|
54
components/tki-barcode/barcodes/CODE128/constants.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _SET_BY_CODE;
|
||||||
|
|
||||||
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||||
|
|
||||||
|
// constants for internal usage
|
||||||
|
var SET_A = exports.SET_A = 0;
|
||||||
|
var SET_B = exports.SET_B = 1;
|
||||||
|
var SET_C = exports.SET_C = 2;
|
||||||
|
|
||||||
|
// Special characters
|
||||||
|
var SHIFT = exports.SHIFT = 98;
|
||||||
|
var START_A = exports.START_A = 103;
|
||||||
|
var START_B = exports.START_B = 104;
|
||||||
|
var START_C = exports.START_C = 105;
|
||||||
|
var MODULO = exports.MODULO = 103;
|
||||||
|
var STOP = exports.STOP = 106;
|
||||||
|
var FNC1 = exports.FNC1 = 207;
|
||||||
|
|
||||||
|
// Get set by start code
|
||||||
|
var SET_BY_CODE = exports.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
|
||||||
|
|
||||||
|
// Get next set by code
|
||||||
|
var SWAP = exports.SWAP = {
|
||||||
|
101: SET_A,
|
||||||
|
100: SET_B,
|
||||||
|
99: SET_C
|
||||||
|
};
|
||||||
|
|
||||||
|
var A_START_CHAR = exports.A_START_CHAR = String.fromCharCode(208); // START_A + 105
|
||||||
|
var B_START_CHAR = exports.B_START_CHAR = String.fromCharCode(209); // START_B + 105
|
||||||
|
var C_START_CHAR = exports.C_START_CHAR = String.fromCharCode(210); // START_C + 105
|
||||||
|
|
||||||
|
// 128A (Code Set A)
|
||||||
|
// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
|
||||||
|
var A_CHARS = exports.A_CHARS = "[\x00-\x5F\xC8-\xCF]";
|
||||||
|
|
||||||
|
// 128B (Code Set B)
|
||||||
|
// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
|
||||||
|
var B_CHARS = exports.B_CHARS = "[\x20-\x7F\xC8-\xCF]";
|
||||||
|
|
||||||
|
// 128C (Code Set C)
|
||||||
|
// 00–99 (encodes two digits with a single code point) and FNC1
|
||||||
|
var C_CHARS = exports.C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
|
||||||
|
|
||||||
|
// CODE128 includes 107 symbols:
|
||||||
|
// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
|
||||||
|
// Each symbol consist of three black bars (1) and three white spaces (0).
|
||||||
|
var BARS = exports.BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000, 10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000, 11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010, 11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000, 11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100, 10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110, 10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 11010010000, 11010011100, 1100011101011];
|
29
components/tki-barcode/barcodes/CODE128/index.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined;
|
||||||
|
|
||||||
|
var _CODE128_AUTO = require('./CODE128_AUTO.js');
|
||||||
|
|
||||||
|
var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO);
|
||||||
|
|
||||||
|
var _CODE128A = require('./CODE128A.js');
|
||||||
|
|
||||||
|
var _CODE128A2 = _interopRequireDefault(_CODE128A);
|
||||||
|
|
||||||
|
var _CODE128B = require('./CODE128B.js');
|
||||||
|
|
||||||
|
var _CODE128B2 = _interopRequireDefault(_CODE128B);
|
||||||
|
|
||||||
|
var _CODE128C = require('./CODE128C.js');
|
||||||
|
|
||||||
|
var _CODE128C2 = _interopRequireDefault(_CODE128C);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
exports.CODE128 = _CODE128_AUTO2.default;
|
||||||
|
exports.CODE128A = _CODE128A2.default;
|
||||||
|
exports.CODE128B = _CODE128B2.default;
|
||||||
|
exports.CODE128C = _CODE128C2.default;
|
104
components/tki-barcode/barcodes/CODE39/index.js
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.CODE39 = undefined;
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/Code_39#Encoding
|
||||||
|
|
||||||
|
var CODE39 = function (_Barcode) {
|
||||||
|
_inherits(CODE39, _Barcode);
|
||||||
|
|
||||||
|
function CODE39(data, options) {
|
||||||
|
_classCallCheck(this, CODE39);
|
||||||
|
|
||||||
|
data = data.toUpperCase();
|
||||||
|
|
||||||
|
// Calculate mod43 checksum if enabled
|
||||||
|
if (options.mod43) {
|
||||||
|
data += getCharacter(mod43checksum(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(CODE39, [{
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
// First character is always a *
|
||||||
|
var result = getEncoding("*");
|
||||||
|
|
||||||
|
// Take every character and add the binary representation to the result
|
||||||
|
for (var i = 0; i < this.data.length; i++) {
|
||||||
|
result += getEncoding(this.data[i]) + "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last character is always a *
|
||||||
|
result += getEncoding("*");
|
||||||
|
return {
|
||||||
|
data: result,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return CODE39;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
// All characters. The position in the array is the (checksum) value
|
||||||
|
|
||||||
|
|
||||||
|
var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%", "*"];
|
||||||
|
|
||||||
|
// The decimal representation of the characters, is converted to the
|
||||||
|
// corresponding binary with the getEncoding function
|
||||||
|
var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385, 29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770];
|
||||||
|
|
||||||
|
// Get the binary representation of a character by converting the encodings
|
||||||
|
// from decimal to binary
|
||||||
|
function getEncoding(character) {
|
||||||
|
return getBinary(characterValue(character));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBinary(characterValue) {
|
||||||
|
return encodings[characterValue].toString(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCharacter(characterValue) {
|
||||||
|
return characters[characterValue];
|
||||||
|
}
|
||||||
|
|
||||||
|
function characterValue(character) {
|
||||||
|
return characters.indexOf(character);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mod43checksum(data) {
|
||||||
|
var checksum = 0;
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
checksum += characterValue(data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
checksum = checksum % 43;
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.CODE39 = CODE39;
|
92
components/tki-barcode/barcodes/EAN_UPC/EAN.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
var _encoder = require('./encoder');
|
||||||
|
|
||||||
|
var _encoder2 = _interopRequireDefault(_encoder);
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
// Base class for EAN8 & EAN13
|
||||||
|
var EAN = function (_Barcode) {
|
||||||
|
_inherits(EAN, _Barcode);
|
||||||
|
|
||||||
|
function EAN(data, options) {
|
||||||
|
_classCallCheck(this, EAN);
|
||||||
|
|
||||||
|
// Make sure the font is not bigger than the space between the guard bars
|
||||||
|
var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data, options));
|
||||||
|
|
||||||
|
_this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options.fontSize;
|
||||||
|
|
||||||
|
// Make the guard bars go down half the way of the text
|
||||||
|
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(EAN, [{
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftText',
|
||||||
|
value: function leftText(from, to) {
|
||||||
|
return this.text.substr(from, to);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftEncode',
|
||||||
|
value: function leftEncode(data, structure) {
|
||||||
|
return (0, _encoder2.default)(data, structure);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightText',
|
||||||
|
value: function rightText(from, to) {
|
||||||
|
return this.text.substr(from, to);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightEncode',
|
||||||
|
value: function rightEncode(data, structure) {
|
||||||
|
return (0, _encoder2.default)(data, structure);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encodeGuarded',
|
||||||
|
value: function encodeGuarded() {
|
||||||
|
var textOptions = { fontSize: this.fontSize };
|
||||||
|
var guardOptions = { height: this.guardHeight };
|
||||||
|
|
||||||
|
return [{ data: _constants.SIDE_BIN, options: guardOptions }, { data: this.leftEncode(), text: this.leftText(), options: textOptions }, { data: _constants.MIDDLE_BIN, options: guardOptions }, { data: this.rightEncode(), text: this.rightText(), options: textOptions }, { data: _constants.SIDE_BIN, options: guardOptions }];
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encodeFlat',
|
||||||
|
value: function encodeFlat() {
|
||||||
|
var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this.rightEncode(), _constants.SIDE_BIN];
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: data.join(''),
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return EAN;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.default = EAN;
|
119
components/tki-barcode/barcodes/EAN_UPC/EAN13.js
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
var _EAN2 = require('./EAN');
|
||||||
|
|
||||||
|
var _EAN3 = _interopRequireDefault(_EAN2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
|
||||||
|
|
||||||
|
// Calculate the checksum digit
|
||||||
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||||
|
var checksum = function checksum(number) {
|
||||||
|
var res = number.substr(0, 12).split('').map(function (n) {
|
||||||
|
return +n;
|
||||||
|
}).reduce(function (sum, a, idx) {
|
||||||
|
return idx % 2 ? sum + a * 3 : sum + a;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return (10 - res % 10) % 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
var EAN13 = function (_EAN) {
|
||||||
|
_inherits(EAN13, _EAN);
|
||||||
|
|
||||||
|
function EAN13(data, options) {
|
||||||
|
_classCallCheck(this, EAN13);
|
||||||
|
|
||||||
|
// Add checksum if it does not exist
|
||||||
|
if (data.search(/^[0-9]{12}$/) !== -1) {
|
||||||
|
data += checksum(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a last character to the end of the barcode
|
||||||
|
var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options));
|
||||||
|
|
||||||
|
_this.lastChar = options.lastChar;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(EAN13, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftText',
|
||||||
|
value: function leftText() {
|
||||||
|
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftEncode',
|
||||||
|
value: function leftEncode() {
|
||||||
|
var data = this.data.substr(1, 6);
|
||||||
|
var structure = _constants.EAN13_STRUCTURE[this.data[0]];
|
||||||
|
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightText',
|
||||||
|
value: function rightText() {
|
||||||
|
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightEncode',
|
||||||
|
value: function rightEncode() {
|
||||||
|
var data = this.data.substr(7, 6);
|
||||||
|
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR');
|
||||||
|
}
|
||||||
|
|
||||||
|
// The "standard" way of printing EAN13 barcodes with guard bars
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'encodeGuarded',
|
||||||
|
value: function encodeGuarded() {
|
||||||
|
var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this);
|
||||||
|
|
||||||
|
// Extend data with left digit & last character
|
||||||
|
if (this.options.displayValue) {
|
||||||
|
data.unshift({
|
||||||
|
data: '000000000000',
|
||||||
|
text: this.text.substr(0, 1),
|
||||||
|
options: { textAlign: 'left', fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.options.lastChar) {
|
||||||
|
data.push({
|
||||||
|
data: '00'
|
||||||
|
});
|
||||||
|
data.push({
|
||||||
|
data: '00000',
|
||||||
|
text: this.options.lastChar,
|
||||||
|
options: { fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return EAN13;
|
||||||
|
}(_EAN3.default);
|
||||||
|
|
||||||
|
exports.default = EAN13;
|
58
components/tki-barcode/barcodes/EAN_UPC/EAN2.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
var _encoder = require('./encoder');
|
||||||
|
|
||||||
|
var _encoder2 = _interopRequireDefault(_encoder);
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/EAN_2#Encoding
|
||||||
|
|
||||||
|
var EAN2 = function (_Barcode) {
|
||||||
|
_inherits(EAN2, _Barcode);
|
||||||
|
|
||||||
|
function EAN2(data, options) {
|
||||||
|
_classCallCheck(this, EAN2);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(EAN2, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{2}$/) !== -1;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
// Choose the structure based on the number mod 4
|
||||||
|
var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
|
||||||
|
return {
|
||||||
|
// Start bits + Encode the two digits with 01 in between
|
||||||
|
data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return EAN2;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.default = EAN2;
|
65
components/tki-barcode/barcodes/EAN_UPC/EAN5.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
var _encoder = require('./encoder');
|
||||||
|
|
||||||
|
var _encoder2 = _interopRequireDefault(_encoder);
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/EAN_5#Encoding
|
||||||
|
|
||||||
|
var checksum = function checksum(data) {
|
||||||
|
var result = data.split('').map(function (n) {
|
||||||
|
return +n;
|
||||||
|
}).reduce(function (sum, a, idx) {
|
||||||
|
return idx % 2 ? sum + a * 9 : sum + a * 3;
|
||||||
|
}, 0);
|
||||||
|
return result % 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
var EAN5 = function (_Barcode) {
|
||||||
|
_inherits(EAN5, _Barcode);
|
||||||
|
|
||||||
|
function EAN5(data, options) {
|
||||||
|
_classCallCheck(this, EAN5);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(EAN5, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{5}$/) !== -1;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
|
||||||
|
return {
|
||||||
|
data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return EAN5;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.default = EAN5;
|
81
components/tki-barcode/barcodes/EAN_UPC/EAN8.js
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
||||||
|
|
||||||
|
var _EAN2 = require('./EAN');
|
||||||
|
|
||||||
|
var _EAN3 = _interopRequireDefault(_EAN2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// http://www.barcodeisland.com/ean8.phtml
|
||||||
|
|
||||||
|
// Calculate the checksum digit
|
||||||
|
var checksum = function checksum(number) {
|
||||||
|
var res = number.substr(0, 7).split('').map(function (n) {
|
||||||
|
return +n;
|
||||||
|
}).reduce(function (sum, a, idx) {
|
||||||
|
return idx % 2 ? sum + a : sum + a * 3;
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return (10 - res % 10) % 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
var EAN8 = function (_EAN) {
|
||||||
|
_inherits(EAN8, _EAN);
|
||||||
|
|
||||||
|
function EAN8(data, options) {
|
||||||
|
_classCallCheck(this, EAN8);
|
||||||
|
|
||||||
|
// Add checksum if it does not exist
|
||||||
|
if (data.search(/^[0-9]{7}$/) !== -1) {
|
||||||
|
data += checksum(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(EAN8, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftText',
|
||||||
|
value: function leftText() {
|
||||||
|
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'leftEncode',
|
||||||
|
value: function leftEncode() {
|
||||||
|
var data = this.data.substr(0, 4);
|
||||||
|
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(this, data, 'LLLL');
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightText',
|
||||||
|
value: function rightText() {
|
||||||
|
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'rightEncode',
|
||||||
|
value: function rightEncode() {
|
||||||
|
var data = this.data.substr(4, 4);
|
||||||
|
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(this, data, 'RRRR');
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return EAN8;
|
||||||
|
}(_EAN3.default);
|
||||||
|
|
||||||
|
exports.default = EAN8;
|
165
components/tki-barcode/barcodes/EAN_UPC/UPC.js
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
exports.checksum = checksum;
|
||||||
|
|
||||||
|
var _encoder = require("./encoder");
|
||||||
|
|
||||||
|
var _encoder2 = _interopRequireDefault(_encoder);
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||||
|
|
||||||
|
var UPC = function (_Barcode) {
|
||||||
|
_inherits(UPC, _Barcode);
|
||||||
|
|
||||||
|
function UPC(data, options) {
|
||||||
|
_classCallCheck(this, UPC);
|
||||||
|
|
||||||
|
// Add checksum if it does not exist
|
||||||
|
if (data.search(/^[0-9]{11}$/) !== -1) {
|
||||||
|
data += checksum(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
|
||||||
|
|
||||||
|
_this.displayValue = options.displayValue;
|
||||||
|
|
||||||
|
// Make sure the font is not bigger than the space between the guard bars
|
||||||
|
if (options.fontSize > options.width * 10) {
|
||||||
|
_this.fontSize = options.width * 10;
|
||||||
|
} else {
|
||||||
|
_this.fontSize = options.fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the guard bars go down half the way of the text
|
||||||
|
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(UPC, [{
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
if (this.options.flat) {
|
||||||
|
return this.flatEncoding();
|
||||||
|
} else {
|
||||||
|
return this.guardedEncoding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "flatEncoding",
|
||||||
|
value: function flatEncoding() {
|
||||||
|
var result = "";
|
||||||
|
|
||||||
|
result += "101";
|
||||||
|
result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
|
||||||
|
result += "01010";
|
||||||
|
result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
|
||||||
|
result += "101";
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: result,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "guardedEncoding",
|
||||||
|
value: function guardedEncoding() {
|
||||||
|
var result = [];
|
||||||
|
|
||||||
|
// Add the first digit
|
||||||
|
if (this.displayValue) {
|
||||||
|
result.push({
|
||||||
|
data: "00000000",
|
||||||
|
text: this.text.substr(0, 1),
|
||||||
|
options: { textAlign: "left", fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the guard bars
|
||||||
|
result.push({
|
||||||
|
data: "101" + (0, _encoder2.default)(this.data[0], "L"),
|
||||||
|
options: { height: this.guardHeight }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the left side
|
||||||
|
result.push({
|
||||||
|
data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
|
||||||
|
text: this.text.substr(1, 5),
|
||||||
|
options: { fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the middle bits
|
||||||
|
result.push({
|
||||||
|
data: "01010",
|
||||||
|
options: { height: this.guardHeight }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the right side
|
||||||
|
result.push({
|
||||||
|
data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
|
||||||
|
text: this.text.substr(6, 5),
|
||||||
|
options: { fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the end bits
|
||||||
|
result.push({
|
||||||
|
data: (0, _encoder2.default)(this.data[11], "R") + "101",
|
||||||
|
options: { height: this.guardHeight }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the last digit
|
||||||
|
if (this.displayValue) {
|
||||||
|
result.push({
|
||||||
|
data: "00000000",
|
||||||
|
text: this.text.substr(11, 1),
|
||||||
|
options: { textAlign: "right", fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return UPC;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
// Calulate the checksum digit
|
||||||
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||||
|
|
||||||
|
|
||||||
|
function checksum(number) {
|
||||||
|
var result = 0;
|
||||||
|
|
||||||
|
var i;
|
||||||
|
for (i = 1; i < 11; i += 2) {
|
||||||
|
result += parseInt(number[i]);
|
||||||
|
}
|
||||||
|
for (i = 0; i < 11; i += 2) {
|
||||||
|
result += parseInt(number[i]) * 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (10 - result % 10) % 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.default = UPC;
|
185
components/tki-barcode/barcodes/EAN_UPC/UPCE.js
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _encoder = require('./encoder');
|
||||||
|
|
||||||
|
var _encoder2 = _interopRequireDefault(_encoder);
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode.js');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
var _UPC = require('./UPC.js');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||||
|
//
|
||||||
|
// UPC-E documentation:
|
||||||
|
// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
|
||||||
|
|
||||||
|
var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
|
||||||
|
|
||||||
|
var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
|
||||||
|
|
||||||
|
var UPCE = function (_Barcode) {
|
||||||
|
_inherits(UPCE, _Barcode);
|
||||||
|
|
||||||
|
function UPCE(data, options) {
|
||||||
|
_classCallCheck(this, UPCE);
|
||||||
|
|
||||||
|
var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
|
||||||
|
// Code may be 6 or 8 digits;
|
||||||
|
// A 7 digit code is ambiguous as to whether the extra digit
|
||||||
|
// is a UPC-A check or number system digit.
|
||||||
|
|
||||||
|
|
||||||
|
_this.isValid = false;
|
||||||
|
if (data.search(/^[0-9]{6}$/) !== -1) {
|
||||||
|
_this.middleDigits = data;
|
||||||
|
_this.upcA = expandToUPCA(data, "0");
|
||||||
|
_this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
|
||||||
|
_this.isValid = true;
|
||||||
|
} else if (data.search(/^[01][0-9]{7}$/) !== -1) {
|
||||||
|
_this.middleDigits = data.substring(1, data.length - 1);
|
||||||
|
_this.upcA = expandToUPCA(_this.middleDigits, data[0]);
|
||||||
|
|
||||||
|
if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
|
||||||
|
_this.isValid = true;
|
||||||
|
} else {
|
||||||
|
// checksum mismatch
|
||||||
|
return _possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return _possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
_this.displayValue = options.displayValue;
|
||||||
|
|
||||||
|
// Make sure the font is not bigger than the space between the guard bars
|
||||||
|
if (options.fontSize > options.width * 10) {
|
||||||
|
_this.fontSize = options.width * 10;
|
||||||
|
} else {
|
||||||
|
_this.fontSize = options.fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the guard bars go down half the way of the text
|
||||||
|
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(UPCE, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.isValid;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
if (this.options.flat) {
|
||||||
|
return this.flatEncoding();
|
||||||
|
} else {
|
||||||
|
return this.guardedEncoding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'flatEncoding',
|
||||||
|
value: function flatEncoding() {
|
||||||
|
var result = "";
|
||||||
|
|
||||||
|
result += "101";
|
||||||
|
result += this.encodeMiddleDigits();
|
||||||
|
result += "010101";
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: result,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'guardedEncoding',
|
||||||
|
value: function guardedEncoding() {
|
||||||
|
var result = [];
|
||||||
|
|
||||||
|
// Add the UPC-A number system digit beneath the quiet zone
|
||||||
|
if (this.displayValue) {
|
||||||
|
result.push({
|
||||||
|
data: "00000000",
|
||||||
|
text: this.text[0],
|
||||||
|
options: { textAlign: "left", fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the guard bars
|
||||||
|
result.push({
|
||||||
|
data: "101",
|
||||||
|
options: { height: this.guardHeight }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the 6 UPC-E digits
|
||||||
|
result.push({
|
||||||
|
data: this.encodeMiddleDigits(),
|
||||||
|
text: this.text.substring(1, 7),
|
||||||
|
options: { fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the end bits
|
||||||
|
result.push({
|
||||||
|
data: "010101",
|
||||||
|
options: { height: this.guardHeight }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the UPC-A check digit beneath the quiet zone
|
||||||
|
if (this.displayValue) {
|
||||||
|
result.push({
|
||||||
|
data: "00000000",
|
||||||
|
text: this.text[7],
|
||||||
|
options: { textAlign: "right", fontSize: this.fontSize }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encodeMiddleDigits',
|
||||||
|
value: function encodeMiddleDigits() {
|
||||||
|
var numberSystem = this.upcA[0];
|
||||||
|
var checkDigit = this.upcA[this.upcA.length - 1];
|
||||||
|
var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
|
||||||
|
return (0, _encoder2.default)(this.middleDigits, parity);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return UPCE;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
function expandToUPCA(middleDigits, numberSystem) {
|
||||||
|
var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
|
||||||
|
var expansion = EXPANSIONS[lastUpcE];
|
||||||
|
|
||||||
|
var result = "";
|
||||||
|
var digitIndex = 0;
|
||||||
|
for (var i = 0; i < expansion.length; i++) {
|
||||||
|
var c = expansion[i];
|
||||||
|
if (c === 'X') {
|
||||||
|
result += middleDigits[digitIndex++];
|
||||||
|
} else {
|
||||||
|
result += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = '' + numberSystem + result;
|
||||||
|
return '' + result + (0, _UPC.checksum)(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.default = UPCE;
|
30
components/tki-barcode/barcodes/EAN_UPC/constants.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
// Standard start end and middle bits
|
||||||
|
var SIDE_BIN = exports.SIDE_BIN = '101';
|
||||||
|
var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
|
||||||
|
|
||||||
|
var BINARIES = exports.BINARIES = {
|
||||||
|
'L': [// The L (left) type of encoding
|
||||||
|
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
|
||||||
|
'G': [// The G type of encoding
|
||||||
|
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
|
||||||
|
'R': [// The R (right) type of encoding
|
||||||
|
'1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
|
||||||
|
'O': [// The O (odd) encoding for UPC-E
|
||||||
|
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
|
||||||
|
'E': [// The E (even) encoding for UPC-E
|
||||||
|
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define the EAN-2 structure
|
||||||
|
var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
|
||||||
|
|
||||||
|
// Define the EAN-5 structure
|
||||||
|
var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
|
||||||
|
|
||||||
|
// Define the EAN-13 structure
|
||||||
|
var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];
|
27
components/tki-barcode/barcodes/EAN_UPC/encoder.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
// Encode data string
|
||||||
|
var encode = function encode(data, structure, separator) {
|
||||||
|
var encoded = data.split('').map(function (val, idx) {
|
||||||
|
return _constants.BINARIES[structure[idx]];
|
||||||
|
}).map(function (val, idx) {
|
||||||
|
return val ? val[data[idx]] : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (separator) {
|
||||||
|
var last = data.length - 1;
|
||||||
|
encoded = encoded.map(function (val, idx) {
|
||||||
|
return idx < last ? val + separator : val;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return encoded.join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.default = encode;
|
39
components/tki-barcode/barcodes/EAN_UPC/index.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
|
||||||
|
|
||||||
|
var _EAN = require('./EAN13.js');
|
||||||
|
|
||||||
|
var _EAN2 = _interopRequireDefault(_EAN);
|
||||||
|
|
||||||
|
var _EAN3 = require('./EAN8.js');
|
||||||
|
|
||||||
|
var _EAN4 = _interopRequireDefault(_EAN3);
|
||||||
|
|
||||||
|
var _EAN5 = require('./EAN5.js');
|
||||||
|
|
||||||
|
var _EAN6 = _interopRequireDefault(_EAN5);
|
||||||
|
|
||||||
|
var _EAN7 = require('./EAN2.js');
|
||||||
|
|
||||||
|
var _EAN8 = _interopRequireDefault(_EAN7);
|
||||||
|
|
||||||
|
var _UPC = require('./UPC.js');
|
||||||
|
|
||||||
|
var _UPC2 = _interopRequireDefault(_UPC);
|
||||||
|
|
||||||
|
var _UPCE = require('./UPCE.js');
|
||||||
|
|
||||||
|
var _UPCE2 = _interopRequireDefault(_UPCE);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
exports.EAN13 = _EAN2.default;
|
||||||
|
exports.EAN8 = _EAN4.default;
|
||||||
|
exports.EAN5 = _EAN6.default;
|
||||||
|
exports.EAN2 = _EAN8.default;
|
||||||
|
exports.UPC = _UPC2.default;
|
||||||
|
exports.UPCE = _UPCE2.default;
|
55
components/tki-barcode/barcodes/GenericBarcode/index.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.GenericBarcode = undefined;
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var GenericBarcode = function (_Barcode) {
|
||||||
|
_inherits(GenericBarcode, _Barcode);
|
||||||
|
|
||||||
|
function GenericBarcode(data, options) {
|
||||||
|
_classCallCheck(this, GenericBarcode);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the corresponding binary numbers for the data provided
|
||||||
|
|
||||||
|
|
||||||
|
_createClass(GenericBarcode, [{
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
return {
|
||||||
|
data: "10101010101010101010101010101010101010101",
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resturn true/false if the string provided is valid for this encoder
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return GenericBarcode;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.GenericBarcode = GenericBarcode;
|
69
components/tki-barcode/barcodes/ITF/ITF.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _constants = require('./constants');
|
||||||
|
|
||||||
|
var _Barcode2 = require('../Barcode');
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var ITF = function (_Barcode) {
|
||||||
|
_inherits(ITF, _Barcode);
|
||||||
|
|
||||||
|
function ITF() {
|
||||||
|
_classCallCheck(this, ITF);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(ITF, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^([0-9]{2})+$/) !== -1;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'encode',
|
||||||
|
value: function encode() {
|
||||||
|
var _this2 = this;
|
||||||
|
|
||||||
|
// Calculate all the digit pairs
|
||||||
|
var encoded = this.data.match(/.{2}/g).map(function (pair) {
|
||||||
|
return _this2.encodePair(pair);
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: _constants.START_BIN + encoded + _constants.END_BIN,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the data of a number pair
|
||||||
|
|
||||||
|
}, {
|
||||||
|
key: 'encodePair',
|
||||||
|
value: function encodePair(pair) {
|
||||||
|
var second = _constants.BINARIES[pair[1]];
|
||||||
|
|
||||||
|
return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
|
||||||
|
return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return ITF;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.default = ITF;
|
55
components/tki-barcode/barcodes/ITF/ITF14.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _ITF2 = require('./ITF');
|
||||||
|
|
||||||
|
var _ITF3 = _interopRequireDefault(_ITF2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
// Calculate the checksum digit
|
||||||
|
var checksum = function checksum(data) {
|
||||||
|
var res = data.substr(0, 13).split('').map(function (num) {
|
||||||
|
return parseInt(num, 10);
|
||||||
|
}).reduce(function (sum, n, idx) {
|
||||||
|
return sum + n * (3 - idx % 2 * 2);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return Math.ceil(res / 10) * 10 - res;
|
||||||
|
};
|
||||||
|
|
||||||
|
var ITF14 = function (_ITF) {
|
||||||
|
_inherits(ITF14, _ITF);
|
||||||
|
|
||||||
|
function ITF14(data, options) {
|
||||||
|
_classCallCheck(this, ITF14);
|
||||||
|
|
||||||
|
// Add checksum if it does not exist
|
||||||
|
if (data.search(/^[0-9]{13}$/) !== -1) {
|
||||||
|
data += checksum(data);
|
||||||
|
}
|
||||||
|
return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(ITF14, [{
|
||||||
|
key: 'valid',
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data);
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return ITF14;
|
||||||
|
}(_ITF3.default);
|
||||||
|
|
||||||
|
exports.default = ITF14;
|
9
components/tki-barcode/barcodes/ITF/constants.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
var START_BIN = exports.START_BIN = '1010';
|
||||||
|
var END_BIN = exports.END_BIN = '11101';
|
||||||
|
|
||||||
|
var BINARIES = exports.BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010'];
|
19
components/tki-barcode/barcodes/ITF/index.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.ITF14 = exports.ITF = undefined;
|
||||||
|
|
||||||
|
var _ITF = require('./ITF');
|
||||||
|
|
||||||
|
var _ITF2 = _interopRequireDefault(_ITF);
|
||||||
|
|
||||||
|
var _ITF3 = require('./ITF14');
|
||||||
|
|
||||||
|
var _ITF4 = _interopRequireDefault(_ITF3);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
exports.ITF = _ITF2.default;
|
||||||
|
exports.ITF14 = _ITF4.default;
|
74
components/tki-barcode/barcodes/MSI/MSI.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
|
||||||
|
// https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup
|
||||||
|
|
||||||
|
var MSI = function (_Barcode) {
|
||||||
|
_inherits(MSI, _Barcode);
|
||||||
|
|
||||||
|
function MSI(data, options) {
|
||||||
|
_classCallCheck(this, MSI);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (MSI.__proto__ || Object.getPrototypeOf(MSI)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(MSI, [{
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
// Start bits
|
||||||
|
var ret = "110";
|
||||||
|
|
||||||
|
for (var i = 0; i < this.data.length; i++) {
|
||||||
|
// Convert the character to binary (always 4 binary digits)
|
||||||
|
var digit = parseInt(this.data[i]);
|
||||||
|
var bin = digit.toString(2);
|
||||||
|
bin = addZeroes(bin, 4 - bin.length);
|
||||||
|
|
||||||
|
// Add 100 for every zero and 110 for every 1
|
||||||
|
for (var b = 0; b < bin.length; b++) {
|
||||||
|
ret += bin[b] == "0" ? "100" : "110";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// End bits
|
||||||
|
ret += "1001";
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: ret,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[0-9]+$/) !== -1;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return MSI;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
function addZeroes(number, n) {
|
||||||
|
for (var i = 0; i < n; i++) {
|
||||||
|
number = "0" + number;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.default = MSI;
|
33
components/tki-barcode/barcodes/MSI/MSI10.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _MSI2 = require('./MSI.js');
|
||||||
|
|
||||||
|
var _MSI3 = _interopRequireDefault(_MSI2);
|
||||||
|
|
||||||
|
var _checksums = require('./checksums.js');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var MSI10 = function (_MSI) {
|
||||||
|
_inherits(MSI10, _MSI);
|
||||||
|
|
||||||
|
function MSI10(data, options) {
|
||||||
|
_classCallCheck(this, MSI10);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (MSI10.__proto__ || Object.getPrototypeOf(MSI10)).call(this, data + (0, _checksums.mod10)(data), options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MSI10;
|
||||||
|
}(_MSI3.default);
|
||||||
|
|
||||||
|
exports.default = MSI10;
|
35
components/tki-barcode/barcodes/MSI/MSI1010.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _MSI2 = require('./MSI.js');
|
||||||
|
|
||||||
|
var _MSI3 = _interopRequireDefault(_MSI2);
|
||||||
|
|
||||||
|
var _checksums = require('./checksums.js');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var MSI1010 = function (_MSI) {
|
||||||
|
_inherits(MSI1010, _MSI);
|
||||||
|
|
||||||
|
function MSI1010(data, options) {
|
||||||
|
_classCallCheck(this, MSI1010);
|
||||||
|
|
||||||
|
data += (0, _checksums.mod10)(data);
|
||||||
|
data += (0, _checksums.mod10)(data);
|
||||||
|
return _possibleConstructorReturn(this, (MSI1010.__proto__ || Object.getPrototypeOf(MSI1010)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MSI1010;
|
||||||
|
}(_MSI3.default);
|
||||||
|
|
||||||
|
exports.default = MSI1010;
|
33
components/tki-barcode/barcodes/MSI/MSI11.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _MSI2 = require('./MSI.js');
|
||||||
|
|
||||||
|
var _MSI3 = _interopRequireDefault(_MSI2);
|
||||||
|
|
||||||
|
var _checksums = require('./checksums.js');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var MSI11 = function (_MSI) {
|
||||||
|
_inherits(MSI11, _MSI);
|
||||||
|
|
||||||
|
function MSI11(data, options) {
|
||||||
|
_classCallCheck(this, MSI11);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (MSI11.__proto__ || Object.getPrototypeOf(MSI11)).call(this, data + (0, _checksums.mod11)(data), options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MSI11;
|
||||||
|
}(_MSI3.default);
|
||||||
|
|
||||||
|
exports.default = MSI11;
|
35
components/tki-barcode/barcodes/MSI/MSI1110.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _MSI2 = require('./MSI.js');
|
||||||
|
|
||||||
|
var _MSI3 = _interopRequireDefault(_MSI2);
|
||||||
|
|
||||||
|
var _checksums = require('./checksums.js');
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var MSI1110 = function (_MSI) {
|
||||||
|
_inherits(MSI1110, _MSI);
|
||||||
|
|
||||||
|
function MSI1110(data, options) {
|
||||||
|
_classCallCheck(this, MSI1110);
|
||||||
|
|
||||||
|
data += (0, _checksums.mod11)(data);
|
||||||
|
data += (0, _checksums.mod10)(data);
|
||||||
|
return _possibleConstructorReturn(this, (MSI1110.__proto__ || Object.getPrototypeOf(MSI1110)).call(this, data, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MSI1110;
|
||||||
|
}(_MSI3.default);
|
||||||
|
|
||||||
|
exports.default = MSI1110;
|
29
components/tki-barcode/barcodes/MSI/checksums.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.mod10 = mod10;
|
||||||
|
exports.mod11 = mod11;
|
||||||
|
function mod10(number) {
|
||||||
|
var sum = 0;
|
||||||
|
for (var i = 0; i < number.length; i++) {
|
||||||
|
var n = parseInt(number[i]);
|
||||||
|
if ((i + number.length) % 2 === 0) {
|
||||||
|
sum += n;
|
||||||
|
} else {
|
||||||
|
sum += n * 2 % 10 + Math.floor(n * 2 / 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (10 - sum % 10) % 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mod11(number) {
|
||||||
|
var sum = 0;
|
||||||
|
var weights = [2, 3, 4, 5, 6, 7];
|
||||||
|
for (var i = 0; i < number.length; i++) {
|
||||||
|
var n = parseInt(number[number.length - 1 - i]);
|
||||||
|
sum += weights[i % weights.length] * n;
|
||||||
|
}
|
||||||
|
return (11 - sum % 11) % 11;
|
||||||
|
}
|
34
components/tki-barcode/barcodes/MSI/index.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.MSI1110 = exports.MSI1010 = exports.MSI11 = exports.MSI10 = exports.MSI = undefined;
|
||||||
|
|
||||||
|
var _MSI = require('./MSI.js');
|
||||||
|
|
||||||
|
var _MSI2 = _interopRequireDefault(_MSI);
|
||||||
|
|
||||||
|
var _MSI3 = require('./MSI10.js');
|
||||||
|
|
||||||
|
var _MSI4 = _interopRequireDefault(_MSI3);
|
||||||
|
|
||||||
|
var _MSI5 = require('./MSI11.js');
|
||||||
|
|
||||||
|
var _MSI6 = _interopRequireDefault(_MSI5);
|
||||||
|
|
||||||
|
var _MSI7 = require('./MSI1010.js');
|
||||||
|
|
||||||
|
var _MSI8 = _interopRequireDefault(_MSI7);
|
||||||
|
|
||||||
|
var _MSI9 = require('./MSI1110.js');
|
||||||
|
|
||||||
|
var _MSI10 = _interopRequireDefault(_MSI9);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
exports.MSI = _MSI2.default;
|
||||||
|
exports.MSI10 = _MSI4.default;
|
||||||
|
exports.MSI11 = _MSI6.default;
|
||||||
|
exports.MSI1010 = _MSI8.default;
|
||||||
|
exports.MSI1110 = _MSI10.default;
|
92
components/tki-barcode/barcodes/codabar/index.js
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.codabar = undefined;
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding specification:
|
||||||
|
// http://www.barcodeisland.com/codabar.phtml
|
||||||
|
|
||||||
|
var codabar = function (_Barcode) {
|
||||||
|
_inherits(codabar, _Barcode);
|
||||||
|
|
||||||
|
function codabar(data, options) {
|
||||||
|
_classCallCheck(this, codabar);
|
||||||
|
|
||||||
|
if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) {
|
||||||
|
data = "A" + data + "A";
|
||||||
|
}
|
||||||
|
|
||||||
|
var _this = _possibleConstructorReturn(this, (codabar.__proto__ || Object.getPrototypeOf(codabar)).call(this, data.toUpperCase(), options));
|
||||||
|
|
||||||
|
_this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(codabar, [{
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
var result = [];
|
||||||
|
var encodings = this.getEncodings();
|
||||||
|
for (var i = 0; i < this.data.length; i++) {
|
||||||
|
result.push(encodings[this.data.charAt(i)]);
|
||||||
|
// for all characters except the last, append a narrow-space ("0")
|
||||||
|
if (i !== this.data.length - 1) {
|
||||||
|
result.push("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
text: this.text,
|
||||||
|
data: result.join('')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "getEncodings",
|
||||||
|
value: function getEncodings() {
|
||||||
|
return {
|
||||||
|
"0": "101010011",
|
||||||
|
"1": "101011001",
|
||||||
|
"2": "101001011",
|
||||||
|
"3": "110010101",
|
||||||
|
"4": "101101001",
|
||||||
|
"5": "110101001",
|
||||||
|
"6": "100101011",
|
||||||
|
"7": "100101101",
|
||||||
|
"8": "100110101",
|
||||||
|
"9": "110100101",
|
||||||
|
"-": "101001101",
|
||||||
|
"$": "101100101",
|
||||||
|
":": "1101011011",
|
||||||
|
"/": "1101101011",
|
||||||
|
".": "1101101101",
|
||||||
|
"+": "101100110011",
|
||||||
|
"A": "1011001001",
|
||||||
|
"B": "1001001011",
|
||||||
|
"C": "1010010011",
|
||||||
|
"D": "1010011001"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return codabar;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.codabar = codabar;
|
34
components/tki-barcode/barcodes/index.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _CODE = require('./CODE39/');
|
||||||
|
|
||||||
|
var _CODE2 = require('./CODE128/');
|
||||||
|
|
||||||
|
var _EAN_UPC = require('./EAN_UPC/');
|
||||||
|
|
||||||
|
var _ITF = require('./ITF/');
|
||||||
|
|
||||||
|
var _MSI = require('./MSI/');
|
||||||
|
|
||||||
|
var _pharmacode = require('./pharmacode/');
|
||||||
|
|
||||||
|
var _codabar = require('./codabar');
|
||||||
|
|
||||||
|
var _GenericBarcode = require('./GenericBarcode/');
|
||||||
|
|
||||||
|
exports.default = {
|
||||||
|
CODE39: _CODE.CODE39,
|
||||||
|
CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C,
|
||||||
|
EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2,
|
||||||
|
UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE,
|
||||||
|
ITF14: _ITF.ITF14,
|
||||||
|
ITF: _ITF.ITF,
|
||||||
|
MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110,
|
||||||
|
PHARMACODE: _pharmacode.pharmacode,
|
||||||
|
CODABAR: _codabar.codabar,
|
||||||
|
GENERICBARCODE: _GenericBarcode.GenericBarcode
|
||||||
|
};
|
73
components/tki-barcode/barcodes/pharmacode/index.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.pharmacode = undefined;
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _Barcode2 = require("../Barcode.js");
|
||||||
|
|
||||||
|
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation
|
||||||
|
// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
|
||||||
|
|
||||||
|
var pharmacode = function (_Barcode) {
|
||||||
|
_inherits(pharmacode, _Barcode);
|
||||||
|
|
||||||
|
function pharmacode(data, options) {
|
||||||
|
_classCallCheck(this, pharmacode);
|
||||||
|
|
||||||
|
var _this = _possibleConstructorReturn(this, (pharmacode.__proto__ || Object.getPrototypeOf(pharmacode)).call(this, data, options));
|
||||||
|
|
||||||
|
_this.number = parseInt(data, 10);
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(pharmacode, [{
|
||||||
|
key: "encode",
|
||||||
|
value: function encode() {
|
||||||
|
var z = this.number;
|
||||||
|
var result = "";
|
||||||
|
|
||||||
|
// http://i.imgur.com/RMm4UDJ.png
|
||||||
|
// (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
|
||||||
|
while (!isNaN(z) && z != 0) {
|
||||||
|
if (z % 2 === 0) {
|
||||||
|
// Even
|
||||||
|
result = "11100" + result;
|
||||||
|
z = (z - 2) / 2;
|
||||||
|
} else {
|
||||||
|
// Odd
|
||||||
|
result = "100" + result;
|
||||||
|
z = (z - 1) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the two last zeroes
|
||||||
|
result = result.slice(0, -2);
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: result,
|
||||||
|
text: this.text
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: "valid",
|
||||||
|
value: function valid() {
|
||||||
|
return this.number >= 3 && this.number <= 131070;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return pharmacode;
|
||||||
|
}(_Barcode3.default);
|
||||||
|
|
||||||
|
exports.pharmacode = pharmacode;
|
206
components/tki-barcode/tki-barcode.vue
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
<template xlang="wxml" minapp="mpvue">
|
||||||
|
<view class="tki-barcode">
|
||||||
|
<!-- #ifndef MP-ALIPAY -->
|
||||||
|
<canvas class="tki-barcode-canvas" :canvas-id="cid" :style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
|
||||||
|
<!-- #endif -->
|
||||||
|
<!-- #ifdef MP-ALIPAY -->
|
||||||
|
<canvas :id="cid" :width="canvasWidth" :height="canvasHeight" class="tki-barcode-canvas" />
|
||||||
|
<!-- #endif -->
|
||||||
|
<image v-show="show" :src="result" :style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// const barcode = require('./barcode.js');
|
||||||
|
import barCode from "./barcode.js"
|
||||||
|
const opations = {
|
||||||
|
// format: "CODE128",//选择要使用的条形码类型 微信支持的条码类型有 code128\code39\ena13\ean8\upc\itf14\
|
||||||
|
width: 4,//设置条之间的宽度
|
||||||
|
height: 120,//高度
|
||||||
|
displayValue: true,//是否在条形码下方显示文字
|
||||||
|
// text: "1234567890",//覆盖显示的文本
|
||||||
|
textAlign: "center",//设置文本的水平对齐方式
|
||||||
|
textPosition: "bottom",//设置文本的垂直位置
|
||||||
|
textMargin: 0,//设置条形码和文本之间的间距
|
||||||
|
fontSize: 24,//设置文本的大小
|
||||||
|
fontColor: "#000000",//设置文本的颜色
|
||||||
|
lineColor: "#000000",//设置条形码的颜色
|
||||||
|
background: "#FFFFFF",//设置条形码的背景色
|
||||||
|
margin: 0,//设置条形码周围的空白边距
|
||||||
|
marginTop: undefined,//设置条形码周围的上边距
|
||||||
|
marginBottom: undefined,//设置条形码周围的下边距
|
||||||
|
marginLeft: undefined,//设置条形码周围的左边距
|
||||||
|
marginRight: undefined,//设置条形码周围的右边距
|
||||||
|
}
|
||||||
|
export default {
|
||||||
|
name: "tkiBarcode",
|
||||||
|
props: {
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
cid: {
|
||||||
|
type: String,
|
||||||
|
default: 'tki-barcode-canvas'
|
||||||
|
},
|
||||||
|
unit: {
|
||||||
|
type: String,
|
||||||
|
default: 'upx'
|
||||||
|
},
|
||||||
|
val: {
|
||||||
|
type: String,
|
||||||
|
default: '1234567890128'
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
type: String,
|
||||||
|
default: 'CODE128'
|
||||||
|
},
|
||||||
|
opations: {
|
||||||
|
type: Object,
|
||||||
|
default: function () {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onval: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
loadMake: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
result: '',
|
||||||
|
canvasWidth: 0,
|
||||||
|
canvasHeight: 0,
|
||||||
|
defaultOpations: Object.assign({}, opations)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUnload: function () {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
_makeCode() {
|
||||||
|
let that = this
|
||||||
|
// 合并参数
|
||||||
|
Object.assign(this.defaultOpations, this.opations)
|
||||||
|
if (that.unit == "upx") {
|
||||||
|
if (that.defaultOpations.width) {
|
||||||
|
that.defaultOpations.width = uni.upx2px(that.defaultOpations.width)
|
||||||
|
}
|
||||||
|
if (that.defaultOpations.height) {
|
||||||
|
that.defaultOpations.height = uni.upx2px(that.defaultOpations.height)
|
||||||
|
}
|
||||||
|
if (that.defaultOpations.fontSize) {
|
||||||
|
that.defaultOpations.fontSize = uni.upx2px(that.defaultOpations.fontSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (that._empty(that.defaultOpations.text)) {
|
||||||
|
that.defaultOpations.text = that.val
|
||||||
|
}
|
||||||
|
if (that._empty(that.defaultOpations.format)) {
|
||||||
|
that.defaultOpations.format = that.format
|
||||||
|
}
|
||||||
|
// console.log(JSON.stringify(that.defaultOpations))
|
||||||
|
new barCode(that, that.cid, that.defaultOpations,
|
||||||
|
function (res) { // 生成条形码款高回调
|
||||||
|
that.canvasWidth = res.width
|
||||||
|
that.canvasHeight = res.height
|
||||||
|
},
|
||||||
|
function (res) { // 生成条形码的回调
|
||||||
|
// 返回值
|
||||||
|
that._result(res)
|
||||||
|
// 重置默认参数
|
||||||
|
that.defaultOpations = opations
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
_clearCode() {
|
||||||
|
this._result('')
|
||||||
|
},
|
||||||
|
_saveCode() {
|
||||||
|
let that = this;
|
||||||
|
if (this.result != "") {
|
||||||
|
uni.saveImageToPhotosAlbum({
|
||||||
|
filePath: that.result,
|
||||||
|
success: function () {
|
||||||
|
uni.showToast({
|
||||||
|
title: '条形码保存成功',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_result(res) {
|
||||||
|
this.result = res;
|
||||||
|
this.$emit('result', res)
|
||||||
|
},
|
||||||
|
_result(res) {
|
||||||
|
this.result = res;
|
||||||
|
this.$emit('result', res)
|
||||||
|
},
|
||||||
|
_empty(v) {
|
||||||
|
let tp = typeof v,
|
||||||
|
rt = false;
|
||||||
|
if (tp == "number" && String(v) == "") {
|
||||||
|
rt = true
|
||||||
|
} else if (tp == "undefined") {
|
||||||
|
rt = true
|
||||||
|
} else if (tp == "object") {
|
||||||
|
if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
|
||||||
|
} else if (tp == "string") {
|
||||||
|
if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
|
||||||
|
} else if (tp == "function") {
|
||||||
|
rt = false
|
||||||
|
}
|
||||||
|
return rt
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
val(n, o) {
|
||||||
|
if (this.onval) {
|
||||||
|
if (n != o && !this._empty(n)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._makeCode()
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
opations: {
|
||||||
|
handler(n,o){
|
||||||
|
if (this.onval) {
|
||||||
|
if (!this._empty(n)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._makeCode()
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted: function () {
|
||||||
|
if (this.loadMake) {
|
||||||
|
if (!this._empty(this.val)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._makeCode()
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.tki-barcode {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.tki-barcode-canvas {
|
||||||
|
position: fixed;
|
||||||
|
top: -99999upx;
|
||||||
|
left: -99999upx;
|
||||||
|
z-index: -99999;
|
||||||
|
}
|
||||||
|
</style>
|
10
http/index.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import http from './interface'
|
||||||
|
import login from './login'
|
||||||
|
import mine from './mine'
|
||||||
|
import management from './management'
|
||||||
|
export default {
|
||||||
|
login,
|
||||||
|
mine,
|
||||||
|
management
|
||||||
|
}
|
||||||
|
|
203
http/interface.js
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/**
|
||||||
|
* 通用uni-app网络请求
|
||||||
|
* 基于 Promise 对象实现更简单的 request 使用方式,支持请求和响应拦截
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
config: {
|
||||||
|
|
||||||
|
baseUrl: 'http://114.218.158.24:9020',
|
||||||
|
header: {
|
||||||
|
"Content-Type": "application/json;charset=UTF-8",
|
||||||
|
// 'Content-Type':'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
data: {},
|
||||||
|
method: "GET",
|
||||||
|
dataType: "json" /* 如设为json,会对返回的数据做一次 JSON.parse */,
|
||||||
|
responseType: "text",
|
||||||
|
success() {},
|
||||||
|
fail() {},
|
||||||
|
complete() {},
|
||||||
|
},
|
||||||
|
interceptor: {
|
||||||
|
request: null,
|
||||||
|
response: null,
|
||||||
|
},
|
||||||
|
|
||||||
|
request(options) {
|
||||||
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
options.baseUrl = options.baseUrl || this.config.baseUrl;
|
||||||
|
options.dataType = options.dataType || this.config.dataType;
|
||||||
|
options.url = options.baseUrl + options.url;
|
||||||
|
options.data = options.data || {};
|
||||||
|
options.method = options.method || this.config.method;
|
||||||
|
//TODO 加密数据
|
||||||
|
options.header = options.header || this.config.header;
|
||||||
|
//TODO 数据签名
|
||||||
|
let _token = {
|
||||||
|
Authorization: uni.getStorageSync("repari-token") || "undefined",
|
||||||
|
};
|
||||||
|
options.header = Object.assign({}, options.header, _token);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let _config = null;
|
||||||
|
|
||||||
|
options.complete = async (response) => {
|
||||||
|
let statusCode = response.statusCode;
|
||||||
|
response.config = _config;
|
||||||
|
if (this.interceptor.response) {
|
||||||
|
let newResponse = this.interceptor.response(response);
|
||||||
|
if (newResponse) {
|
||||||
|
response = newResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (response.data.status === 401) {
|
||||||
|
// 若token过期则尝试获取RefreshToken重新获取token
|
||||||
|
const newToken = await this.getRefreshToken();
|
||||||
|
if (newToken) {
|
||||||
|
// 更新token
|
||||||
|
options.header.Authorization = newToken;
|
||||||
|
// 重新发起请求
|
||||||
|
uni.request(options);
|
||||||
|
} else {
|
||||||
|
// 若获取RefreshToken失败,则跳转到登录页
|
||||||
|
uni.removeStorageSync("repari-token");
|
||||||
|
uni.removeStorageSync("repari-user-info");
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/login/index",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 统一的响应日志记录
|
||||||
|
_reslog(response);
|
||||||
|
if (statusCode === 200) {
|
||||||
|
//成功
|
||||||
|
resolve(response.data);
|
||||||
|
} else {
|
||||||
|
reject(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_config = Object.assign({}, this.config, options);
|
||||||
|
_config.requestId = new Date().getTime();
|
||||||
|
|
||||||
|
if (this.interceptor.request) {
|
||||||
|
this.interceptor.request(_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.request(_config);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isRefreshing: false,
|
||||||
|
refreshSubscribers: [],
|
||||||
|
async getRefreshToken() {
|
||||||
|
let res
|
||||||
|
if (!this.isRefreshing) {
|
||||||
|
this.isRefreshing = true;
|
||||||
|
const refreshToken = uni.getStorageSync("repari-refresh-token");
|
||||||
|
if (refreshToken) {
|
||||||
|
try {
|
||||||
|
const data = { refreshToken };
|
||||||
|
res = await this.post("/user/refresh/token", data);
|
||||||
|
if (res.code === 200) {
|
||||||
|
uni.setStorageSync("repari-token", res.data.Token);
|
||||||
|
uni.setStorageSync("repari-user-info", res.data.AccountInfo);
|
||||||
|
uni.setStorageSync("repari-refresh-token", res.data.RefreshToken);
|
||||||
|
// 返回新的token
|
||||||
|
return res.data.Token;
|
||||||
|
} else {
|
||||||
|
// 获取RefreshToken失败
|
||||||
|
uni.removeStorageSync("repari-token");
|
||||||
|
uni.removeStorageSync("repari-user-info");
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pages/login/index",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
} finally {
|
||||||
|
this.isRefreshing = false;
|
||||||
|
this.refreshSubscribers.forEach((cb) => cb(res.data.Token));
|
||||||
|
// 重置队列
|
||||||
|
this.refreshSubscribers = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 若没有RefreshToken,则跳转到登录页
|
||||||
|
webUni.postMessage({
|
||||||
|
data: {
|
||||||
|
params: 401,
|
||||||
|
action: 'login'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/* uni.redirectTo({
|
||||||
|
url: "/pages/login/index",
|
||||||
|
}); */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 若正在获取RefreshToken,则返回一个Promise,等待获取到新的token后再继续之前的请求
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this.refreshSubscribers.push((token) => {
|
||||||
|
resolve(token);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
get(url, data, options) {
|
||||||
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
options.url = url;
|
||||||
|
options.data = data;
|
||||||
|
options.method = "GET";
|
||||||
|
return this.request(options);
|
||||||
|
},
|
||||||
|
post(url, data, options, header) {
|
||||||
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
options.url = url;
|
||||||
|
options.data = data;
|
||||||
|
options.header = header;
|
||||||
|
options.method = "POST";
|
||||||
|
return this.request(options);
|
||||||
|
},
|
||||||
|
put(url, data, options) {
|
||||||
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
options.url = url;
|
||||||
|
options.data = data;
|
||||||
|
options.method = "PUT";
|
||||||
|
return this.request(options);
|
||||||
|
},
|
||||||
|
delete(url, data, options) {
|
||||||
|
if (!options) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
options.url = url;
|
||||||
|
options.data = data;
|
||||||
|
options.method = "DELETE";
|
||||||
|
return this.request(options);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应接口日志记录
|
||||||
|
*/
|
||||||
|
function _reslog(res) {
|
||||||
|
let _statusCode = res.data.status;
|
||||||
|
//TODO 除了接口服务错误外,其他日志调接口异步写入日志数据库
|
||||||
|
switch (_statusCode) {
|
||||||
|
case 200:
|
||||||
|
break;
|
||||||
|
case 401:
|
||||||
|
break;
|
||||||
|
case 404:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
35
http/login.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import http from './interface'
|
||||||
|
|
||||||
|
// 签到
|
||||||
|
export const goLogin = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: '/user/login',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 验证码
|
||||||
|
export const code = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: '/user/send',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 获取详情
|
||||||
|
export const getDetail = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: '/api/appointment/train/info',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
goLogin,
|
||||||
|
code,
|
||||||
|
getDetail
|
||||||
|
|
||||||
|
}
|
24
http/management.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import http from "./interface";
|
||||||
|
|
||||||
|
// 库存列表
|
||||||
|
export const detail = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: "/artwork/repair-detail",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
export const update = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: "/artwork/repair-update",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
detail,
|
||||||
|
update,
|
||||||
|
};
|
22
http/mine.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import http from './interface'
|
||||||
|
|
||||||
|
// 考勤信息
|
||||||
|
export const getWorkingTime = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: '/oa/working-time/best',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 获取员工列表
|
||||||
|
export const getEmpList = (data) => {
|
||||||
|
return http.request({
|
||||||
|
url: '/department/users',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export default {
|
||||||
|
getWorkingTime,
|
||||||
|
getEmpList
|
||||||
|
}
|
198
http/readme.md
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
**插件使用说明**
|
||||||
|
|
||||||
|
- 基于 Promise 对象实现更简单的 request 使用方式,支持请求和响应拦截
|
||||||
|
- 下载后把 vmeitime-http 文件夹 copy 到项目 common/ 目录下
|
||||||
|
|
||||||
|
## 1. 配置
|
||||||
|
|
||||||
|
### 1.1 全局配置修改(修改vmeitime-http/interface.js中config和interceptor)
|
||||||
|
``` javascript
|
||||||
|
config: {
|
||||||
|
baseUrl: "https://api.com/api/",
|
||||||
|
header: {
|
||||||
|
'Content-Type':'application/json;charset=UTF-8',
|
||||||
|
'Content-Type':'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
dataType: "json",
|
||||||
|
responseType: "text"
|
||||||
|
},
|
||||||
|
interceptor: {
|
||||||
|
request: null,
|
||||||
|
response: null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.2 具体接口调用时修改(在vmeitime-http/index.js文件中具体业务接口中配置)
|
||||||
|
``` javascript
|
||||||
|
//设置baseUrl
|
||||||
|
http.config.baseUrl = "http://localhost:8080/api/"
|
||||||
|
//设置请求前拦截器
|
||||||
|
http.interceptor.request = (config) => {
|
||||||
|
//添加通用参数
|
||||||
|
config.header = {
|
||||||
|
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//设置请求结束后拦截器
|
||||||
|
http.interceptor.response = (response) => {
|
||||||
|
//判断返回状态 执行相应操作
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 2. 使用
|
||||||
|
|
||||||
|
### 2.1 全局使用(在main.js注册)
|
||||||
|
|
||||||
|
``` // main.js
|
||||||
|
import api from '@/common/vmeitime-http/'
|
||||||
|
|
||||||
|
// 全局挂载后使用
|
||||||
|
Vue.prototype.$api = api
|
||||||
|
```
|
||||||
|
|
||||||
|
``` // pages/index/index.vue
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="content">
|
||||||
|
|
||||||
|
<view class="uni-padding-wrap uni-common-mt">
|
||||||
|
<view class="uni-textarea uni-common-mt">
|
||||||
|
<textarea :value="res"></textarea>
|
||||||
|
</view>
|
||||||
|
<view class="uni-btn-v uni-common-mt">
|
||||||
|
<button type="primary" @click="sendRequest" :loading="loading">发起请求</button>
|
||||||
|
<button type="default" @click="sendRequest1" :loading="loading">发起请求(async/await)</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
res: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(option) {
|
||||||
|
//this.sendRequest();
|
||||||
|
//this.sendRequest1();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 方式一
|
||||||
|
sendRequest: function() {
|
||||||
|
this.loading = true
|
||||||
|
this.$api.test({noncestr: Date.now()}).then((res)=>{
|
||||||
|
this.loading = false;
|
||||||
|
console.log('request success', res)
|
||||||
|
uni.showToast({
|
||||||
|
title: '请求成功',
|
||||||
|
icon: 'success',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
this.res = '请求结果 : ' + JSON.stringify(res);
|
||||||
|
}).catch((err)=>{
|
||||||
|
this.loading = false;
|
||||||
|
console.log('request fail', err);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//方式二 https://segmentfault.com/a/1190000013292562?utm_source=channel-newest
|
||||||
|
async sendRequest1() {
|
||||||
|
this.loading = true
|
||||||
|
let res = await this.$api.test({noncestr: Date.now()});
|
||||||
|
this.loading = false;
|
||||||
|
this.res = '请求结果 : ' + JSON.stringify(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### 2.2 局部使用(局部使用,不需要在 main.js 中注册)
|
||||||
|
|
||||||
|
``` // pages/index/index.vue
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="content">
|
||||||
|
|
||||||
|
<view class="uni-padding-wrap uni-common-mt">
|
||||||
|
<view class="uni-textarea uni-common-mt">
|
||||||
|
<textarea :value="res"></textarea>
|
||||||
|
</view>
|
||||||
|
<view class="uni-btn-v uni-common-mt">
|
||||||
|
<button type="primary" @click="sendRequest" :loading="loading">发起请求</button>
|
||||||
|
<button type="default" @click="sendRequest1" :loading="loading">发起请求(async/await)</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import api from '@/common/vmeitime-http/'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
res: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(option) {
|
||||||
|
//this.sendRequest();
|
||||||
|
//this.sendRequest1();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 方式一
|
||||||
|
sendRequest: function() {
|
||||||
|
this.loading = true
|
||||||
|
api.test({noncestr: Date.now()}).then((res)=>{
|
||||||
|
this.loading = false;
|
||||||
|
console.log('request success', res)
|
||||||
|
uni.showToast({
|
||||||
|
title: '请求成功',
|
||||||
|
icon: 'success',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
this.res = '请求结果 : ' + JSON.stringify(res);
|
||||||
|
}).catch((err)=>{
|
||||||
|
this.loading = false;
|
||||||
|
console.log('request fail', err);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
//方式二
|
||||||
|
async sendRequest1() {
|
||||||
|
this.loading = true
|
||||||
|
let res = await this.api.test({noncestr: Date.now()});
|
||||||
|
this.loading = false;
|
||||||
|
this.res = '请求结果 : ' + JSON.stringify(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 3. 接口数据加密、接口签名核验
|
||||||
|
|
||||||
|
在vmeitime-http/interface.js文件中的request(Object)方法中补充修改相应的代码
|
||||||
|
|
||||||
|
## 4. 接口请求/响应日志记录
|
||||||
|
|
||||||
|
在vmeitime-http/interface.js文件中的request(Object)方法中补充修改相应的代码
|
||||||
|
|
||||||
|
## 5. 业务相关接口编写
|
||||||
|
|
||||||
|
在vmeitime-http/index.js文件中的编写具体业务相关的接口,参考test()方法
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
20
index.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<script>
|
||||||
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||||
|
CSS.supports('top: constant(a)'))
|
||||||
|
document.write(
|
||||||
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||||
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||||
|
</script>
|
||||||
|
<title></title>
|
||||||
|
<!--preload-links-->
|
||||||
|
<!--app-context-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"><!--app-html--></div>
|
||||||
|
<script type="module" src="/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
48
main.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import App from './App'
|
||||||
|
import Vue from 'vue'
|
||||||
|
import uView from 'uview-ui'
|
||||||
|
import store from './store/index.js'
|
||||||
|
import common from './common/index.js'
|
||||||
|
import api from '@/http/'
|
||||||
|
Vue.use(uView)
|
||||||
|
Vue.prototype.$common = common;
|
||||||
|
Vue.prototype.$api = api;
|
||||||
|
Vue.prototype.$baseUrl = "http://114.218.158.24:9020"; // "http://114.218.158.24:9022", "http://58.210.42.242:9085"
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
App.mpType = 'app'
|
||||||
|
|
||||||
|
try {
|
||||||
|
function isPromise(obj) {
|
||||||
|
return (
|
||||||
|
!!obj &&
|
||||||
|
(typeof obj === "object" || typeof obj === "function") &&
|
||||||
|
typeof obj.then === "function"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统一 vue2 API Promise 化返回格式与 vue3 保持一致
|
||||||
|
uni.addInterceptor({
|
||||||
|
returnValue(res) {
|
||||||
|
if (!isPromise(res)) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
res.then((res) => {
|
||||||
|
if (res[0]) {
|
||||||
|
reject(res[0]);
|
||||||
|
} else {
|
||||||
|
resolve(res[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) { }
|
||||||
|
|
||||||
|
const app = new Vue({
|
||||||
|
...App,
|
||||||
|
store
|
||||||
|
})
|
||||||
|
app.$mount()
|
||||||
|
|
||||||
|
|
79
manifest.json
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"name" : "sing-h5",
|
||||||
|
"appid" : "__UNI__9473E40",
|
||||||
|
"description" : "",
|
||||||
|
"versionName" : "1.0.0",
|
||||||
|
"versionCode" : "100",
|
||||||
|
"transformPx" : false,
|
||||||
|
/* 5+App特有相关 */
|
||||||
|
"app-plus" : {
|
||||||
|
"usingComponents" : true,
|
||||||
|
"nvueStyleCompiler" : "uni-app",
|
||||||
|
"compilerVersion" : 3,
|
||||||
|
"splashscreen" : {
|
||||||
|
"alwaysShowBeforeRender" : true,
|
||||||
|
"waiting" : true,
|
||||||
|
"autoclose" : true,
|
||||||
|
"delay" : 0
|
||||||
|
},
|
||||||
|
/* 模块配置 */
|
||||||
|
"modules" : {
|
||||||
|
"Barcode" : {},
|
||||||
|
"Camera" : {}
|
||||||
|
},
|
||||||
|
/* 应用发布信息 */
|
||||||
|
"distribute" : {
|
||||||
|
/* android打包配置 */
|
||||||
|
"android" : {
|
||||||
|
"permissions" : [
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* ios打包配置 */
|
||||||
|
"ios" : {
|
||||||
|
"dSYMs" : false
|
||||||
|
},
|
||||||
|
/* SDK配置 */
|
||||||
|
"sdkConfigs" : {
|
||||||
|
"ad" : {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/* 快应用特有相关 */
|
||||||
|
"quickapp" : {},
|
||||||
|
/* 小程序特有相关 */
|
||||||
|
"mp-weixin" : {
|
||||||
|
"appid" : "",
|
||||||
|
"setting" : {
|
||||||
|
"urlCheck" : false
|
||||||
|
},
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-alipay" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-baidu" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-toutiao" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"uniStatistics" : {
|
||||||
|
"enable" : false
|
||||||
|
},
|
||||||
|
"vueVersion" : "2"
|
||||||
|
}
|
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "inv-app",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
5
package.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4"
|
||||||
|
}
|
||||||
|
}
|
45
pages.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"easycom": {
|
||||||
|
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
|
||||||
|
},
|
||||||
|
"pages": [
|
||||||
|
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||||
|
{
|
||||||
|
"path": "pages/start/start",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "画作破损修复",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"app-plus": {
|
||||||
|
"titleNView": false // 禁用原生导航
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/login/login",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "画作破损修复",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"app-plus": {
|
||||||
|
"titleNView": false // 禁用原生导航
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/repair/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "画作破损修复",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"app-plus": {
|
||||||
|
"titleNView": false // 禁用原生导航
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"globalStyle": {
|
||||||
|
"navigationBarTextStyle": "black",
|
||||||
|
"navigationBarTitleText": "uni-app",
|
||||||
|
"navigationBarBackgroundColor": "#F8F8F8",
|
||||||
|
"backgroundColor": "#F8F8F8"
|
||||||
|
},
|
||||||
|
"uniIdRouter": {}
|
||||||
|
}
|
256
pages/login/login.vue
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<u-notify ref="uNotify" message="Hi uView"></u-notify>
|
||||||
|
<u-code
|
||||||
|
:seconds="seconds"
|
||||||
|
ref="uCode"
|
||||||
|
@change="codeChange"
|
||||||
|
startText="重新发送"
|
||||||
|
endText="重新发送"
|
||||||
|
changeText="重新发送(X)"
|
||||||
|
></u-code>
|
||||||
|
<image src="../../static/log.png" class="logo"></image>
|
||||||
|
|
||||||
|
<view class="title"><span style="color: #000">登录</span>画作破损修复</view>
|
||||||
|
<view class="no">使用你的手机号登录</view>
|
||||||
|
<view
|
||||||
|
v-show="showCode"
|
||||||
|
style="
|
||||||
|
margin-top: 10rpx;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
color: #888888;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
"
|
||||||
|
>已发送验证码至<span style="color: #000; margin-left: 10px">{{
|
||||||
|
telNum
|
||||||
|
}}</span></view
|
||||||
|
>
|
||||||
|
<u-code-input
|
||||||
|
v-show="showCode"
|
||||||
|
v-model="code"
|
||||||
|
space="11"
|
||||||
|
@finish="goLogin"
|
||||||
|
:maxlength="6"
|
||||||
|
></u-code-input>
|
||||||
|
<u--input
|
||||||
|
v-show="!showCode"
|
||||||
|
placeholder="请输入手机号"
|
||||||
|
class="art-input"
|
||||||
|
border="none"
|
||||||
|
clearable
|
||||||
|
v-model="telNum"
|
||||||
|
>
|
||||||
|
<u--text
|
||||||
|
text="手机号"
|
||||||
|
slot="prefix"
|
||||||
|
margin="0 3px 0 19px"
|
||||||
|
type="tips"
|
||||||
|
></u--text
|
||||||
|
></u--input>
|
||||||
|
<u--input
|
||||||
|
v-if="loginType === 'pwd'"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
class="art-input"
|
||||||
|
border="none"
|
||||||
|
type="password"
|
||||||
|
clearable
|
||||||
|
v-model="password"
|
||||||
|
>
|
||||||
|
<u--text
|
||||||
|
text="密码"
|
||||||
|
slot="prefix"
|
||||||
|
margin="0 20px 0 19px"
|
||||||
|
type="tips"
|
||||||
|
></u--text
|
||||||
|
></u--input>
|
||||||
|
<view
|
||||||
|
style="display: flex; justify-content: space-between; margin-top: 20rpx"
|
||||||
|
>
|
||||||
|
<view @tap="getCode" style="color: #486661;">
|
||||||
|
{{ showCode ? tips : "" }}
|
||||||
|
</view>
|
||||||
|
<view style="text-align: right; color: #486661" @click="changeType">{{
|
||||||
|
loginType === "pwd" ? "验证码登录" : "密码登录"
|
||||||
|
}}</view>
|
||||||
|
</view>
|
||||||
|
<u-button
|
||||||
|
v-if="loginType === 'pwd'"
|
||||||
|
type="primary"
|
||||||
|
class="search"
|
||||||
|
@click="goLogin"
|
||||||
|
>登录</u-button
|
||||||
|
>
|
||||||
|
<u-button
|
||||||
|
v-else-if="loginType === 'code' && !showCode"
|
||||||
|
type="primary"
|
||||||
|
class="search"
|
||||||
|
@click="getCode"
|
||||||
|
:disabled="!telNum"
|
||||||
|
>获取验证码</u-button
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
telNum: "",
|
||||||
|
password: "",
|
||||||
|
code: "",
|
||||||
|
loginType: "pwd",
|
||||||
|
showCode: false,
|
||||||
|
msg: "",
|
||||||
|
showtips: false,
|
||||||
|
tips: "",
|
||||||
|
seconds: 60,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
codeChange(text) {
|
||||||
|
this.tips = text;
|
||||||
|
},
|
||||||
|
// 获取信息
|
||||||
|
async goLogin() {
|
||||||
|
let data = {
|
||||||
|
telNum: this.telNum,
|
||||||
|
password: this.password,
|
||||||
|
code: this.code,
|
||||||
|
};
|
||||||
|
let res = await this.$api.login.goLogin(data);
|
||||||
|
if (res.status == 0) {
|
||||||
|
uni.setStorageSync("repari-token", res.data.Token);
|
||||||
|
uni.setStorageSync("repari-user-info", res.data.AccountInfo);
|
||||||
|
uni.setStorageSync("repari-refresh-token", res.data.RefreshToken);
|
||||||
|
this.$u.toast("登陆成功!");
|
||||||
|
this.$router.push({
|
||||||
|
path: "/pages/start/start",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: res.msg,
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 切换登录方式
|
||||||
|
changeType() {
|
||||||
|
this.loginType = this.loginType === "pwd" ? "code" : "pwd";
|
||||||
|
this.showCode = false;
|
||||||
|
this.password = "";
|
||||||
|
this.code = "";
|
||||||
|
},
|
||||||
|
// 切换为验证码登录
|
||||||
|
async getCode() {
|
||||||
|
this.showCode = true;
|
||||||
|
if (this.$refs.uCode.canGetCode) {
|
||||||
|
let data = {
|
||||||
|
telNum: this.telNum,
|
||||||
|
};
|
||||||
|
let res = await this.$api.login.code(data);
|
||||||
|
if (res.status == 0) {
|
||||||
|
this.$refs.uCode.start();
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "success",
|
||||||
|
message: "验证码已发送",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: res.msg,
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uni.$u.toast("倒计时结束后再发送");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
// this.getTrainInfo();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-size: auto 100%;
|
||||||
|
background-attachment: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
background-image: url("../../static/backg.png");
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
height: 100vh;
|
||||||
|
background-size: auto 100%;
|
||||||
|
padding-left: 60rpx;
|
||||||
|
padding-right: 60rpx;
|
||||||
|
background-attachment: fixed;
|
||||||
|
text-align: center;
|
||||||
|
.logo {
|
||||||
|
width: 70rpx;
|
||||||
|
height: 70rpx;
|
||||||
|
left: 48%;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 50rpx;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
font-size: 64rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
color: #45645f;
|
||||||
|
padding-top: 120rpx;
|
||||||
|
}
|
||||||
|
.no {
|
||||||
|
font-size: 32rpx;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 5rpx;
|
||||||
|
margin-bottom: 130rpx;
|
||||||
|
}
|
||||||
|
.art-input {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
height: 100rpx;
|
||||||
|
}
|
||||||
|
/deep/ .u-code-input__item {
|
||||||
|
width: 86rpx !important;
|
||||||
|
height: 98rpx !important;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
/deep/ .u-input__content__field-wrapper__field {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000000;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
}
|
||||||
|
/deep/ .u-text__value {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
/deep/ .u-button--disabled {
|
||||||
|
background-image: none !important;
|
||||||
|
background-color: #cecece !important;
|
||||||
|
color: #ffffff !important;
|
||||||
|
}
|
||||||
|
.search {
|
||||||
|
margin-top: 120rpx;
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
font-size: 34rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
background-image: linear-gradient(to right, #698883, #45645f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
471
pages/repair/index.vue
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<u-notify ref="uNotify" message="Hi uView"></u-notify>
|
||||||
|
<!-- <view class="sk" v-if="loading">
|
||||||
|
<u-skeleton
|
||||||
|
rows="1"
|
||||||
|
:title="false"
|
||||||
|
loading
|
||||||
|
:rowsHeight="120"
|
||||||
|
></u-skeleton>
|
||||||
|
<u-skeleton
|
||||||
|
style="margin-top: 20rpx"
|
||||||
|
rows="1"
|
||||||
|
:title="false"
|
||||||
|
loading
|
||||||
|
:rowsHeight="720"
|
||||||
|
></u-skeleton>
|
||||||
|
</view> -->
|
||||||
|
<view class="detail">
|
||||||
|
<view class="artwork">
|
||||||
|
<view class="info">
|
||||||
|
<view class="left">
|
||||||
|
<view class="title">画作名称</view>
|
||||||
|
<view class="name">{{ detailData.ArtworkName }}</view>
|
||||||
|
</view>
|
||||||
|
<image class="artwork-image" :src="detailData.PreviewImg"></image>
|
||||||
|
</view>
|
||||||
|
<u-collapse>
|
||||||
|
<u-collapse-item title="" name="Docs guide">
|
||||||
|
<view class="list">
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">商城编号</view>
|
||||||
|
<view class="sub2">{{ detailData.Tfnum }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">画家姓名</view>
|
||||||
|
<view class="sub2">{{ detailData.ArtistName }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">画作类型</view>
|
||||||
|
<view class="sub2">{{ detailData.ArtworkType }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="list">
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">长度</view>
|
||||||
|
<view class="sub2">{{ detailData.Length }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">宽度</view>
|
||||||
|
<view class="sub2">{{ detailData.Width }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="item">
|
||||||
|
<view class="sub1">平尺数</view>
|
||||||
|
<view class="sub2">{{ detailData.Ruler }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-collapse-item>
|
||||||
|
</u-collapse>
|
||||||
|
</view>
|
||||||
|
<view class="repair">
|
||||||
|
<u-tabs
|
||||||
|
@change="changeTab"
|
||||||
|
:list="tabList"
|
||||||
|
:lineColor="'#46645F'"
|
||||||
|
:inactiveStyle="{
|
||||||
|
color: '#666666',
|
||||||
|
}"
|
||||||
|
:activeStyle="{
|
||||||
|
color: '#000000',
|
||||||
|
fontSize: '32rpx',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
}"
|
||||||
|
></u-tabs>
|
||||||
|
<view v-if="actName === '破损'">
|
||||||
|
<view style="margin-top: 30rpx; text-align: center">
|
||||||
|
<u-upload
|
||||||
|
:fileList="fileList"
|
||||||
|
@delete="deletePic"
|
||||||
|
@afterRead="afterRead"
|
||||||
|
name="3"
|
||||||
|
width="100"
|
||||||
|
height="100"
|
||||||
|
multiple
|
||||||
|
:previewFullImage="true"
|
||||||
|
></u-upload>
|
||||||
|
</view>
|
||||||
|
<view class="tips">
|
||||||
|
备注:
|
||||||
|
<u--textarea
|
||||||
|
v-model="DamagedRemark"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
></u--textarea>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-else>
|
||||||
|
<view style="margin-top: 30rpx; text-align: center">
|
||||||
|
<u-upload
|
||||||
|
:fileList="repFileList"
|
||||||
|
@delete="repDeletePic"
|
||||||
|
@afterRead="repAfterRead"
|
||||||
|
name="3"
|
||||||
|
width="100"
|
||||||
|
height="100"
|
||||||
|
multiple
|
||||||
|
:previewFullImage="true"
|
||||||
|
></u-upload>
|
||||||
|
</view>
|
||||||
|
<view class="tips">
|
||||||
|
备注:
|
||||||
|
<u--textarea
|
||||||
|
v-model="RepairedRemark"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
></u--textarea>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<u-button type="primary" :loading="loading" class="search" @click="goSubmit">提交</u-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
detailData: {},
|
||||||
|
tabList: [
|
||||||
|
{
|
||||||
|
name: "破损",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "修复",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fileList: [],
|
||||||
|
DamagedRemark: "",
|
||||||
|
RepairedRemark: "",
|
||||||
|
repFileList: [],
|
||||||
|
actName: "破损",
|
||||||
|
loading: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
changeTab(e) {
|
||||||
|
this.actName = e.name;
|
||||||
|
},
|
||||||
|
// 删除图片
|
||||||
|
deletePic(event) {
|
||||||
|
this[`fileList`].splice(event.index, 1);
|
||||||
|
},
|
||||||
|
async afterRead(event) {
|
||||||
|
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
||||||
|
let lists = [].concat(event.file);
|
||||||
|
let fileListLen = this[`fileList`].length;
|
||||||
|
lists.map((item) => {
|
||||||
|
this[`fileList`].push({
|
||||||
|
...item,
|
||||||
|
status: "uploading",
|
||||||
|
message: "上传中",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
for (let i = 0; i < lists.length; i++) {
|
||||||
|
const result = await this.uploadFilePromise(lists[i].url);
|
||||||
|
console.log(result, "result");
|
||||||
|
let item = this[`fileList`][fileListLen];
|
||||||
|
this[`fileList`].splice(
|
||||||
|
fileListLen,
|
||||||
|
1,
|
||||||
|
Object.assign(item, {
|
||||||
|
status: "success",
|
||||||
|
message: "",
|
||||||
|
url: result,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
fileListLen++;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
uploadFilePromise(url) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
const Authorization = uni.getStorageSync("repari-token");
|
||||||
|
const userId = uni.getStorageSync("repari-refresh-token").ID;
|
||||||
|
let a = uni.uploadFile({
|
||||||
|
url: this.$baseUrl + "/upload/img",
|
||||||
|
filePath: url,
|
||||||
|
name: "file",
|
||||||
|
formData: {
|
||||||
|
type: "image",
|
||||||
|
source: "user",
|
||||||
|
mask: userId,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
Authorization,
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
console.log(res, "res");
|
||||||
|
res.data = JSON.parse(res.data);
|
||||||
|
resolve(res.data.data.ori_url);
|
||||||
|
this.uploadFlag = true;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 删除图片
|
||||||
|
repDeletePic(event) {
|
||||||
|
this[`repFileList`].splice(event.index, 1);
|
||||||
|
},
|
||||||
|
async repAfterRead(event) {
|
||||||
|
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
||||||
|
let lists = [].concat(event.file);
|
||||||
|
let fileListLen = this[`repFileList`].length;
|
||||||
|
lists.map((item) => {
|
||||||
|
this[`repFileList`].push({
|
||||||
|
...item,
|
||||||
|
status: "uploading",
|
||||||
|
message: "上传中",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
for (let i = 0; i < lists.length; i++) {
|
||||||
|
const result = await this.uploadFilePromise(lists[i].url);
|
||||||
|
console.log(result, "result");
|
||||||
|
let item = this[`repFileList`][fileListLen];
|
||||||
|
this[`repFileList`].splice(
|
||||||
|
fileListLen,
|
||||||
|
1,
|
||||||
|
Object.assign(item, {
|
||||||
|
status: "success",
|
||||||
|
message: "",
|
||||||
|
url: result,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
fileListLen++;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 提交
|
||||||
|
async goSubmit() {
|
||||||
|
// 图片和备注都是必填,如果没有则提示
|
||||||
|
if (this.actName === "破损") {
|
||||||
|
if (this.fileList.length === 0) {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: "请上传破损图片",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.DamagedRemark) {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: "请填写破损备注",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.repFileList.length === 0) {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: "请上传修复图片",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.RepairedRemark) {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: "请填写修复备注",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
let data = {
|
||||||
|
RepairID: this.detailData.RepairID,
|
||||||
|
DamagedImgs: this.fileList.map((item) => item.url),
|
||||||
|
DamagedRemark: this.DamagedRemark,
|
||||||
|
RepairedImgs: this.repFileList.map((item) => item.url),
|
||||||
|
RepairedRemark: this.RepairedRemark,
|
||||||
|
ArtworkUuid: this.detailData.ArtworkUuid,
|
||||||
|
CreateSource: 2,
|
||||||
|
};
|
||||||
|
let res = await this.$api.management.update(data);
|
||||||
|
if (res.status == 0) {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "success",
|
||||||
|
message: "提交成功",
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$router.push({
|
||||||
|
path: "/",
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
this.loading = false;
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: res.msg,
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad(item) {
|
||||||
|
|
||||||
|
this.detailData = JSON.parse(item.detailData);
|
||||||
|
this.fileList = this.detailData.DamagedImgs ? this.detailData.DamagedImgs.map((item) => {
|
||||||
|
return {
|
||||||
|
url: item,
|
||||||
|
status: "success",
|
||||||
|
message: "",
|
||||||
|
};
|
||||||
|
}) : [];
|
||||||
|
this.repFileList = this.detailData.RepairedImgs ? this.detailData.RepairedImgs.map((item) => {
|
||||||
|
return {
|
||||||
|
url: item,
|
||||||
|
status: "success",
|
||||||
|
message: "",
|
||||||
|
};
|
||||||
|
}) : [];
|
||||||
|
this.DamagedRemark = this.detailData.DamagedRemark;
|
||||||
|
this.RepairedRemark = this.detailData.RepairedRemark;
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-size: auto 100%;
|
||||||
|
background-attachment: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
background-image: url("../../static/backg.png");
|
||||||
|
}
|
||||||
|
/deep/ .u-skeleton {
|
||||||
|
flex: none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
/deep/ .u-skeleton__wrapper__content__rows {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
/deep/ .u-cell__body {
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
/deep/ .u-cell__body__content {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
/deep/ .u-line {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-attachment: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
padding: 0rpx 40rpx 0 40rpx;
|
||||||
|
.sk {
|
||||||
|
padding-top: 60rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.detail {
|
||||||
|
padding-top: 60rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.artwork {
|
||||||
|
min-height: 240rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 30rpx;
|
||||||
|
}
|
||||||
|
.left {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000000;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.name {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #666666;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.list {
|
||||||
|
padding: 30rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
.sub2 {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #666666;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
// 文字超出部分隐藏
|
||||||
|
width: 140rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.sub1 {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.artwork-image {
|
||||||
|
width: 380rpx;
|
||||||
|
height: 180rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
}
|
||||||
|
.repair {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
background-color: #ffffff;
|
||||||
|
min-height: 1200rpx;
|
||||||
|
}
|
||||||
|
.tips {
|
||||||
|
// 文字在左边,输入框在右边
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
margin-top: 30rpx;
|
||||||
|
.u-textarea {
|
||||||
|
margin-left: 30rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000000;
|
||||||
|
padding: 20rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.search {
|
||||||
|
margin-top: 70rpx;
|
||||||
|
width: 60%;
|
||||||
|
border: 0;
|
||||||
|
font-size: 34rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
background-image: linear-gradient(to right, #698883, #45645f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
120
pages/start/start.vue
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<image src="../../static/log.png" class="logo"></image>
|
||||||
|
<u-notify ref="uNotify" message="Hi uView"></u-notify>
|
||||||
|
<view class="title">画作破损修复</view>
|
||||||
|
<view class="no">画作编号</view>
|
||||||
|
<u--input
|
||||||
|
placeholder="请输入画作编号"
|
||||||
|
class="art-input"
|
||||||
|
border="none"
|
||||||
|
v-model="Tfnum"
|
||||||
|
></u--input>
|
||||||
|
<u-button type="primary" class="search" @click="goSearch">搜索</u-button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { detail } from '../../http/management';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
Tfnum: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
// 检查登录状态
|
||||||
|
checkLogin() {
|
||||||
|
// 获取用户信息
|
||||||
|
let userInfo = uni.getStorageSync("repari-user-info");
|
||||||
|
// 没有登录信息,跳转到登录页面
|
||||||
|
if (!userInfo) {
|
||||||
|
this.$router.push({
|
||||||
|
path: "/pages/login/login",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 搜索
|
||||||
|
async goSearch() {
|
||||||
|
let data = {
|
||||||
|
Tfnum: this.Tfnum,
|
||||||
|
};
|
||||||
|
let res = await this.$api.management.detail(data);
|
||||||
|
if (res.status == 0) {
|
||||||
|
this.$router.push({
|
||||||
|
path: "/pages/repair/index",
|
||||||
|
query: {
|
||||||
|
detailData:JSON.stringify(res.data),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$refs.uNotify.show({
|
||||||
|
top: 10,
|
||||||
|
type: "error",
|
||||||
|
message: res.msg,
|
||||||
|
duration: 1000 * 3,
|
||||||
|
fontSize: 20,
|
||||||
|
safeAreaInsetTop: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
// 检查登录状态
|
||||||
|
this.checkLogin();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-size: auto 100%;
|
||||||
|
background-attachment: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
background-image: url("../../static/backg.png");
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
height: 100vh;
|
||||||
|
background-size: auto 100%;
|
||||||
|
padding-left: 60rpx;
|
||||||
|
padding-right: 60rpx;
|
||||||
|
background-attachment: fixed;
|
||||||
|
text-align: center;
|
||||||
|
.logo {
|
||||||
|
width: 170rpx;
|
||||||
|
height: 170rpx;
|
||||||
|
margin-top: 180rpx;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.no {
|
||||||
|
font-size: 32rpx;
|
||||||
|
text-align: left;
|
||||||
|
margin-top: 150rpx;
|
||||||
|
}
|
||||||
|
.art-input {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
height: 100rpx;
|
||||||
|
}
|
||||||
|
/deep/ .u-input__content__field-wrapper__field {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #000000;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
}
|
||||||
|
.search {
|
||||||
|
margin-top: 70rpx;
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
font-size: 34rpx;
|
||||||
|
height: 90rpx;
|
||||||
|
background-image: linear-gradient(to right, #698883, #45645f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
BIN
static/backg.png
Normal file
After Width: | Height: | Size: 510 KiB |
BIN
static/background.png
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
static/close.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
static/default.png
Normal file
After Width: | Height: | Size: 705 KiB |
BIN
static/log.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
static/login.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
static/mine.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
static/search.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
39
store/index.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import Vue from "vue";
|
||||||
|
import Vuex from "vuex";
|
||||||
|
import tabBar from "../untils/tabBar.js";
|
||||||
|
|
||||||
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
let type = "user_supervisors"; // uni.getStorageSync('sale-user-info').isLeader ? 'user_supervisors' : 'user_staff'
|
||||||
|
|
||||||
|
const store = new Vuex.Store({
|
||||||
|
state: {
|
||||||
|
list: tabBar[type],
|
||||||
|
doingTotal: 0, // 待办事项总数
|
||||||
|
},
|
||||||
|
//对数据的处理
|
||||||
|
getters: {
|
||||||
|
tabBarList: (state) => state.list,
|
||||||
|
doingTotal: (state) => state.doingTotal,
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
//放置mutations方法
|
||||||
|
leaderType(state, payload) {
|
||||||
|
let type = payload ? "user_supervisors" : "user_staff";
|
||||||
|
state.list = tabBar[type].map((item) => {
|
||||||
|
// if (item.text == "审批") {
|
||||||
|
// item.badge = "4";
|
||||||
|
// } else {
|
||||||
|
// item.badge = null;
|
||||||
|
// }
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 获取待办事项总数
|
||||||
|
getDoingTotal(state, doingTotal) {
|
||||||
|
state.doingTotal = doingTotal;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default store;
|
76
uni.scss
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
@import 'uview-ui/theme.scss';
|
||||||
|
/* 颜色变量 */
|
||||||
|
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
$uni-color-primary: #007aff;
|
||||||
|
$uni-color-success: #4cd964;
|
||||||
|
$uni-color-warning: #f0ad4e;
|
||||||
|
$uni-color-error: #dd524d;
|
||||||
|
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
$uni-text-color:#333;//基本色
|
||||||
|
$uni-text-color-inverse:#fff;//反色
|
||||||
|
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
|
||||||
|
$uni-text-color-placeholder: #808080;
|
||||||
|
$uni-text-color-disable:#c0c0c0;
|
||||||
|
|
||||||
|
/* 背景颜色 */
|
||||||
|
$uni-bg-color:#ffffff;
|
||||||
|
$uni-bg-color-grey:#f8f8f8;
|
||||||
|
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
|
||||||
|
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
|
||||||
|
|
||||||
|
/* 边框颜色 */
|
||||||
|
$uni-border-color:#c8c7cc;
|
||||||
|
|
||||||
|
/* 尺寸变量 */
|
||||||
|
|
||||||
|
/* 文字尺寸 */
|
||||||
|
$uni-font-size-sm:12px;
|
||||||
|
$uni-font-size-base:14px;
|
||||||
|
$uni-font-size-lg:16;
|
||||||
|
|
||||||
|
/* 图片尺寸 */
|
||||||
|
$uni-img-size-sm:20px;
|
||||||
|
$uni-img-size-base:26px;
|
||||||
|
$uni-img-size-lg:40px;
|
||||||
|
|
||||||
|
/* Border Radius */
|
||||||
|
$uni-border-radius-sm: 2px;
|
||||||
|
$uni-border-radius-base: 3px;
|
||||||
|
$uni-border-radius-lg: 6px;
|
||||||
|
$uni-border-radius-circle: 50%;
|
||||||
|
|
||||||
|
/* 水平间距 */
|
||||||
|
$uni-spacing-row-sm: 5px;
|
||||||
|
$uni-spacing-row-base: 10px;
|
||||||
|
$uni-spacing-row-lg: 15px;
|
||||||
|
|
||||||
|
/* 垂直间距 */
|
||||||
|
$uni-spacing-col-sm: 4px;
|
||||||
|
$uni-spacing-col-base: 8px;
|
||||||
|
$uni-spacing-col-lg: 12px;
|
||||||
|
|
||||||
|
/* 透明度 */
|
||||||
|
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
|
||||||
|
|
||||||
|
/* 文章场景相关 */
|
||||||
|
$uni-color-title: #2C405A; // 文章标题颜色
|
||||||
|
$uni-font-size-title:20px;
|
||||||
|
$uni-color-subtitle: #555555; // 二级标题颜色
|
||||||
|
$uni-font-size-subtitle:26px;
|
||||||
|
$uni-color-paragraph: #3F536E; // 文章段落颜色
|
||||||
|
$uni-font-size-paragraph:15px;
|
22
uni_modules/superwei-combox/changelog.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## 1.0.10(2022-10-19)
|
||||||
|
- 修改文档,更改为不兼容小程序(存在下拉框滑动会自动关闭的问题,后期改进后再兼容,若各位有好的解决方法的话欢迎评论)
|
||||||
|
## 1.0.9(2022-07-28)
|
||||||
|
- 完善是否创建新条目功能,并将默认值改为允许
|
||||||
|
## 1.0.8(2022-07-26)
|
||||||
|
- 新增禁用选项和是否创建新条目功能,新增disabledColor和isAllowCreate属性
|
||||||
|
## 1.0.7(2022-05-05)
|
||||||
|
- 解决传入JSON数组后,在模糊匹配项中进行选择,@select事件返回值为undefined且报错的问题
|
||||||
|
## 1.0.6(2022-03-24)
|
||||||
|
- 新增@select事件
|
||||||
|
## 1.0.5(2022-03-22)
|
||||||
|
- 修改文档
|
||||||
|
## 1.0.4(2022-03-18)
|
||||||
|
- 新增isJSON和keyName属性,candidates支持JSON数组格式
|
||||||
|
## 1.0.3(2022-03-01)
|
||||||
|
- 调整为uni_modules目录规范
|
||||||
|
## 1.0.2(2022-03-01)
|
||||||
|
- 基于官方uni-combox组件,解决选择后再次选择不展示全部选项的问题,同时新增选中项默认的文字和背景颜色,也可自定义进行样式覆盖
|
||||||
|
## 1.0.1(2022-03-01)
|
||||||
|
- 无
|
||||||
|
## 1.0.0(2022-03-01)
|
||||||
|
- 无
|
@ -0,0 +1,381 @@
|
|||||||
|
<template>
|
||||||
|
<view class="superwei-combox" :class="border ? '' : 'superwei-combox__no-border'">
|
||||||
|
<view v-if="label" class="superwei-combox__label" :style="labelStyle">
|
||||||
|
<text>{{label}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="superwei-combox__input-box">
|
||||||
|
<input class="superwei-combox__input" type="text" :placeholder="placeholder"
|
||||||
|
placeholder-class="superwei-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus"
|
||||||
|
@blur="onBlur" />
|
||||||
|
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
|
||||||
|
</uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="superwei-combox__selector" v-if="showSelector">
|
||||||
|
<view class="uni-popper__arrow"></view>
|
||||||
|
<scroll-view scroll-y="true" class="superwei-combox__selector-scroll">
|
||||||
|
<view class="superwei-combox__selector-empty" v-if="filterCandidatesLength === 0">
|
||||||
|
<text>{{emptyTips}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="superwei-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index">
|
||||||
|
<template v-if="(isJSON?(item.disabled?true:false):false)">
|
||||||
|
<text
|
||||||
|
:style="'color:'+disabledColor+';cursor: not-allowed;'">{{isJSON?item[keyName]?item[keyName]:'字段'+keyName+'不存在':item}}</text>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<text @click="onSelectorClick(index)"
|
||||||
|
:style="(isJSON?item[keyName]?item[keyName]==inputVal:false:item==inputVal)?'font-weight: bold;background-color: '+selectedBackground+';color: '+selectedColor:''">{{isJSON?item[keyName]?item[keyName]:'字段'+keyName+'不存在':item}}</text>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* Combox 组合输入框
|
||||||
|
* @description 组合输入框一般用于既可以输入也可以选择的场景
|
||||||
|
* @property {String} label 左侧文字
|
||||||
|
* @property {String} labelWidth 左侧内容宽度
|
||||||
|
* @property {String} placeholder 输入框占位符
|
||||||
|
* @property {Array} candidates 候选项列表
|
||||||
|
* @property {String} emptyTips 筛选结果为空时显示的文字
|
||||||
|
* @property {String} value 组合框的值
|
||||||
|
* @property {String} selectedBackground 选中项背景颜色
|
||||||
|
* @property {String} selectedColor 选中项文字颜色
|
||||||
|
* @property {Boolean} isJSON 是否是json数组
|
||||||
|
* @property {String} keyName json数组显示的字段值
|
||||||
|
* @property {String} disabledColor 禁用项文字颜色
|
||||||
|
* @property {Boolean} isAllowCreate 是否允许用户创建新条目
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'superweiCombox',
|
||||||
|
emits: ['input', 'update:modelValue', 'select'],
|
||||||
|
props: {
|
||||||
|
isAllowCreate: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
disabledColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#ababac'
|
||||||
|
},
|
||||||
|
isJSON: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
keyName: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
selectedBackground: {
|
||||||
|
type: String,
|
||||||
|
default: '#f5f7fa'
|
||||||
|
},
|
||||||
|
selectedColor: {
|
||||||
|
type: String,
|
||||||
|
default: '#409eff'
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
labelWidth: {
|
||||||
|
type: String,
|
||||||
|
default: 'auto'
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
candidates: {
|
||||||
|
type: Array,
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emptyTips: {
|
||||||
|
type: String,
|
||||||
|
default: '无匹配项'
|
||||||
|
},
|
||||||
|
// #ifndef VUE3
|
||||||
|
value: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isInput: false,
|
||||||
|
showSelector: false,
|
||||||
|
isSelector: false,
|
||||||
|
inputVal: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
labelStyle() {
|
||||||
|
if (this.labelWidth === 'auto') {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return `width: ${this.labelWidth}`
|
||||||
|
},
|
||||||
|
filterCandidates() {
|
||||||
|
if (this.isInput) {
|
||||||
|
if (this.isJSON) {
|
||||||
|
return this.candidates.filter((item) => {
|
||||||
|
return item[this.keyName].toString().indexOf(this.inputVal) > -1
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return this.candidates.filter((item) => {
|
||||||
|
return item.toString().indexOf(this.inputVal) > -1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return this.candidates
|
||||||
|
}
|
||||||
|
},
|
||||||
|
filterCandidatesLength() {
|
||||||
|
return this.filterCandidates.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// #ifndef VUE3
|
||||||
|
value: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.inputVal = newVal
|
||||||
|
this.isInput = true
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.inputVal = newVal
|
||||||
|
this.isInput = true
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleSelector() {
|
||||||
|
this.showSelector = !this.showSelector
|
||||||
|
this.isInput = false
|
||||||
|
},
|
||||||
|
onFocus() {
|
||||||
|
this.showSelector = true
|
||||||
|
this.isInput = false
|
||||||
|
},
|
||||||
|
onChange() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showSelector = false
|
||||||
|
this.isInput = false
|
||||||
|
}, 200)
|
||||||
|
},
|
||||||
|
onBlur() {
|
||||||
|
if (!this.isInput) {
|
||||||
|
this.onChange()
|
||||||
|
} else {
|
||||||
|
if (this.inputVal && !this.isAllowCreate) {
|
||||||
|
let index = this.candidates.findIndex((item) => {
|
||||||
|
if (this.isJSON) {
|
||||||
|
return item[this.keyName].toString() == this.inputVal && !item.disabled
|
||||||
|
} else {
|
||||||
|
return item.toString() == this.inputVal
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (index == -1) {
|
||||||
|
if (this.filterCandidatesLength > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showSelector = false
|
||||||
|
this.isInput = false
|
||||||
|
if (!this.isSelector) {
|
||||||
|
this.inputVal = ''
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
this.isSelector = false
|
||||||
|
} else {
|
||||||
|
this.showSelector = false
|
||||||
|
this.isInput = false
|
||||||
|
this.inputVal = ''
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.onChange()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.onChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSelectorClick(index) {
|
||||||
|
let item = this.filterCandidates[index]
|
||||||
|
if (this.isJSON) {
|
||||||
|
this.inputVal = item[this.keyName]
|
||||||
|
} else {
|
||||||
|
this.inputVal = item
|
||||||
|
}
|
||||||
|
this.showSelector = false
|
||||||
|
this.isSelector = true
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
this.$emit('select', item)
|
||||||
|
},
|
||||||
|
onInput() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.superwei-combox {
|
||||||
|
font-size: 24upx;
|
||||||
|
// border: 1px solid #DCDFE6;
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
// height: 40px;
|
||||||
|
flex-direction: row;
|
||||||
|
box-sizing: border-box;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 32upx;
|
||||||
|
height: 60upx;
|
||||||
|
padding: 0 10upx;
|
||||||
|
// border-bottom: solid 1px #DDDDDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__label {
|
||||||
|
font-size: 24upx;
|
||||||
|
line-height: 22px;
|
||||||
|
padding-right: 10px;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__input-box {
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__input {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 24upx;
|
||||||
|
height: 22px;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__input-plac {
|
||||||
|
font-size: 24upx;
|
||||||
|
color: #ccc; //placeholder-style="color:#FFFFFF"
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
box-sizing: border-box;
|
||||||
|
/* #endif */
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 12px);
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border: 1px solid #EBEEF5;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 2;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector-scroll {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
max-height: 200px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector-empty,
|
||||||
|
.superwei-combox__selector-item {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
line-height: 36px;
|
||||||
|
font-size: 14px;
|
||||||
|
text-align: center;
|
||||||
|
// border-bottom: solid 1px #DDDDDD;
|
||||||
|
padding: 0px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector-empty text,
|
||||||
|
.superwei-combox__selector-item text {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector-item:hover {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__selector-empty:last-child,
|
||||||
|
.superwei-combox__selector-item:last-child {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
border-bottom: none;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
// picker 弹出层通用的指示小三角
|
||||||
|
.uni-popper__arrow,
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-color: transparent;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-popper__arrow {
|
||||||
|
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
|
||||||
|
top: -6px;
|
||||||
|
left: 10%;
|
||||||
|
margin-right: 3px;
|
||||||
|
border-top-width: 0;
|
||||||
|
border-bottom-color: #EBEEF5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
content: " ";
|
||||||
|
top: 1px;
|
||||||
|
margin-left: -6px;
|
||||||
|
border-top-width: 0;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.superwei-combox__no-border {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
</style>
|
89
uni_modules/superwei-combox/package.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"id": "superwei-combox",
|
||||||
|
"displayName": "superwei-combox 组合框",
|
||||||
|
"version": "1.0.10",
|
||||||
|
"description": "下拉搜索选择组合框,基于官方uni-combox组件,解决选择后再次选择不展示全部选项的问题,支持模糊搜索和JSON数组格式,可设置选中项文字和背景颜色(若使用请一定下载uni_modules版本)",
|
||||||
|
"keywords": [
|
||||||
|
"combox",
|
||||||
|
"组合框",
|
||||||
|
"select",
|
||||||
|
"下拉选择",
|
||||||
|
"搜索选择"
|
||||||
|
],
|
||||||
|
"repository": "",
|
||||||
|
"engines": {
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"example": "../../temps/example_temps"
|
||||||
|
},
|
||||||
|
"dcloudext": {
|
||||||
|
"category": [
|
||||||
|
"前端组件",
|
||||||
|
"通用组件"
|
||||||
|
],
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"qq": ""
|
||||||
|
},
|
||||||
|
"declaration": {
|
||||||
|
"ads": "无",
|
||||||
|
"data": "无",
|
||||||
|
"permissions": "无"
|
||||||
|
},
|
||||||
|
"npmurl": ""
|
||||||
|
},
|
||||||
|
"uni_modules": {
|
||||||
|
"dependencies": [
|
||||||
|
"uni-scss",
|
||||||
|
"uni-icons"
|
||||||
|
],
|
||||||
|
"encrypt": [],
|
||||||
|
"platforms": {
|
||||||
|
"cloud": {
|
||||||
|
"tcb": "y",
|
||||||
|
"aliyun": "y"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "u",
|
||||||
|
"app-nvue": "u"
|
||||||
|
},
|
||||||
|
"H5-mobile": {
|
||||||
|
"Safari": "y",
|
||||||
|
"Android Browser": "y",
|
||||||
|
"微信浏览器(Android)": "y",
|
||||||
|
"QQ浏览器(Android)": "y"
|
||||||
|
},
|
||||||
|
"H5-pc": {
|
||||||
|
"Chrome": "y",
|
||||||
|
"IE": "y",
|
||||||
|
"Edge": "y",
|
||||||
|
"Firefox": "y",
|
||||||
|
"Safari": "y"
|
||||||
|
},
|
||||||
|
"小程序": {
|
||||||
|
"微信": "u",
|
||||||
|
"阿里": "u",
|
||||||
|
"百度": "u",
|
||||||
|
"字节跳动": "u",
|
||||||
|
"QQ": "u"
|
||||||
|
},
|
||||||
|
"快应用": {
|
||||||
|
"华为": "u",
|
||||||
|
"联盟": "u"
|
||||||
|
},
|
||||||
|
"Vue": {
|
||||||
|
"vue2": "y",
|
||||||
|
"vue3": "y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
104
uni_modules/superwei-combox/readme.md
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
## 基本用法
|
||||||
|
在 ``template`` 中使用组件
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<view class="content">
|
||||||
|
<span class="title">非JSON数组模式</span>
|
||||||
|
<superwei-combox :candidates="candidates" placeholder="请选择或输入" v-model="inputValue" @input="input"
|
||||||
|
@select="select"></superwei-combox>
|
||||||
|
|
||||||
|
<span class="title">JSON数组模式</span>
|
||||||
|
<superwei-combox :candidates="candidates_json" :isJSON="true" keyName="name" placeholder="请选择或输入"
|
||||||
|
v-model="inputValue_json" @input="input_json" @select="select_json"></superwei-combox>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
inputValue: '',
|
||||||
|
candidates: ['选项一', '选项二', '选项三', '选项四', '选项五', '选项六', '...'],
|
||||||
|
|
||||||
|
inputValue_json: '',
|
||||||
|
candidates_json: [{
|
||||||
|
id: '1',
|
||||||
|
name: '选项一'
|
||||||
|
}, {
|
||||||
|
id: '2',
|
||||||
|
name: '选项二',
|
||||||
|
disabled: true // 单独设置disabled后即可禁用该选项
|
||||||
|
}, {
|
||||||
|
id: '3',
|
||||||
|
name: '选项三'
|
||||||
|
}, {
|
||||||
|
id: '4',
|
||||||
|
name: '选项四'
|
||||||
|
}, {
|
||||||
|
id: '5',
|
||||||
|
name: '选项五',
|
||||||
|
disabled: true // 单独设置disabled后即可禁用该选项
|
||||||
|
}, {
|
||||||
|
id: '6',
|
||||||
|
name: '...'
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
input(e) {
|
||||||
|
console.log(e) // 选项一
|
||||||
|
},
|
||||||
|
select(e) {
|
||||||
|
console.log(e) // 选项一
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
input_json(e) {
|
||||||
|
console.log(e) // 选项一
|
||||||
|
},
|
||||||
|
select_json(e) {
|
||||||
|
console.log(e) // {id: '1',name: '选项一'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### Combox Props
|
||||||
|
|
||||||
|
|属性名 |类型 |默认值 |说明 |
|
||||||
|
|:-: |:-: |:-: |:-: |
|
||||||
|
|label |String |- |标签文字 |
|
||||||
|
|value |String |- |combox的值 |
|
||||||
|
|labelWidth |String |auto |标签宽度,有单位字符串,如:'100px' |
|
||||||
|
|placeholder|String |- |输入框占位符 |
|
||||||
|
|candidates |Array/String |[] |候选字段 |
|
||||||
|
|emptyTips |String |无匹配项 |无匹配项时的提示语 |
|
||||||
|
|selectedBackground |String |#f5f7fa |选中项背景颜色 |
|
||||||
|
|selectedColor |String |#409eff |选中项文字颜色 |
|
||||||
|
|isJSON |Boolean |false |候选字段是否是json数组 |
|
||||||
|
|keyName |String |- |json数组显示的字段值 |
|
||||||
|
|disabledColor |String |#ababac |禁用项文字颜色 |
|
||||||
|
|isAllowCreate |Boolean |true |是否允许用户创建新条目 |
|
||||||
|
|
||||||
|
### Combox Events
|
||||||
|
|
||||||
|
|事件称名 |说明 |返回值 |
|
||||||
|
|:-: |:-: |:-: |
|
||||||
|
|@input |combox输入事件 |返回combox输入值|
|
||||||
|
|@select|combox选择事件 |返回combox选项值|
|
15
uni_modules/uni-combox/changelog.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
## 1.0.1(2021-11-23)
|
||||||
|
- 优化 label、label-width 属性
|
||||||
|
## 1.0.0(2021-11-19)
|
||||||
|
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
|
||||||
|
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-combox](https://uniapp.dcloud.io/component/uniui/uni-combox)
|
||||||
|
## 0.1.0(2021-07-30)
|
||||||
|
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
|
||||||
|
## 0.0.6(2021-05-12)
|
||||||
|
- 新增 组件示例地址
|
||||||
|
## 0.0.5(2021-04-21)
|
||||||
|
- 优化 添加依赖 uni-icons, 导入后自动下载依赖
|
||||||
|
## 0.0.4(2021-02-05)
|
||||||
|
- 优化 组件引用关系,通过uni_modules引用组件
|
||||||
|
## 0.0.3(2021-02-04)
|
||||||
|
- 调整为uni_modules目录规范
|
275
uni_modules/uni-combox/components/uni-combox/uni-combox.vue
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
<template>
|
||||||
|
<view class="uni-combox" :class="border ? '' : 'uni-combox__no-border'">
|
||||||
|
<view v-if="label" class="uni-combox__label" :style="labelStyle">
|
||||||
|
<text>{{label}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-combox__input-box">
|
||||||
|
<input class="uni-combox__input" type="text" :placeholder="placeholder"
|
||||||
|
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus"
|
||||||
|
@blur="onBlur" />
|
||||||
|
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
|
||||||
|
</uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="uni-combox__selector" v-if="showSelector">
|
||||||
|
<view class="uni-popper__arrow"></view>
|
||||||
|
<scroll-view scroll-y="true" class="uni-combox__selector-scroll">
|
||||||
|
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
|
||||||
|
<text>{{emptyTips}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index"
|
||||||
|
@click="onSelectorClick(index)">
|
||||||
|
<text>{{item}}</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* Combox 组合输入框
|
||||||
|
* @description 组合输入框一般用于既可以输入也可以选择的场景
|
||||||
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=1261
|
||||||
|
* @property {String} label 左侧文字
|
||||||
|
* @property {String} labelWidth 左侧内容宽度
|
||||||
|
* @property {String} placeholder 输入框占位符
|
||||||
|
* @property {Array} candidates 候选项列表
|
||||||
|
* @property {String} emptyTips 筛选结果为空时显示的文字
|
||||||
|
* @property {String} value 组合框的值
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'uniCombox',
|
||||||
|
emits: ['input', 'update:modelValue'],
|
||||||
|
props: {
|
||||||
|
border: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
labelWidth: {
|
||||||
|
type: String,
|
||||||
|
default: 'auto'
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
candidates: {
|
||||||
|
type: Array,
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emptyTips: {
|
||||||
|
type: String,
|
||||||
|
default: '无匹配项'
|
||||||
|
},
|
||||||
|
// #ifndef VUE3
|
||||||
|
value: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showSelector: false,
|
||||||
|
inputVal: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
labelStyle() {
|
||||||
|
if (this.labelWidth === 'auto') {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return `width: ${this.labelWidth}`
|
||||||
|
},
|
||||||
|
filterCandidates() {
|
||||||
|
return this.candidates.filter((item) => {
|
||||||
|
return item.toString().indexOf(this.inputVal) > -1
|
||||||
|
})
|
||||||
|
},
|
||||||
|
filterCandidatesLength() {
|
||||||
|
return this.filterCandidates.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// #ifndef VUE3
|
||||||
|
value: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.inputVal = newVal
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
// #ifdef VUE3
|
||||||
|
modelValue: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.inputVal = newVal
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleSelector() {
|
||||||
|
this.showSelector = !this.showSelector
|
||||||
|
},
|
||||||
|
onFocus() {
|
||||||
|
this.showSelector = true
|
||||||
|
},
|
||||||
|
onBlur() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showSelector = false
|
||||||
|
}, 153)
|
||||||
|
},
|
||||||
|
onSelectorClick(index) {
|
||||||
|
this.inputVal = this.filterCandidates[index]
|
||||||
|
this.showSelector = false
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
},
|
||||||
|
onInput() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit('input', this.inputVal)
|
||||||
|
this.$emit('update:modelValue', this.inputVal)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.uni-combox {
|
||||||
|
font-size: 14px;
|
||||||
|
border: 1px solid #DCDFE6;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
// height: 40px;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
// border-bottom: solid 1px #DDDDDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__label {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 22px;
|
||||||
|
padding-right: 10px;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__input-box {
|
||||||
|
position: relative;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__input {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 14px;
|
||||||
|
height: 22px;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__input-plac {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__selector {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
box-sizing: border-box;
|
||||||
|
/* #endif */
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 12px);
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border: 1px solid #EBEEF5;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
z-index: 2;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__selector-scroll {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
max-height: 200px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__selector-empty,
|
||||||
|
.uni-combox__selector-item {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
display: flex;
|
||||||
|
cursor: pointer;
|
||||||
|
/* #endif */
|
||||||
|
line-height: 36px;
|
||||||
|
font-size: 14px;
|
||||||
|
text-align: center;
|
||||||
|
// border-bottom: solid 1px #DDDDDD;
|
||||||
|
padding: 0px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__selector-item:hover {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__selector-empty:last-child,
|
||||||
|
.uni-combox__selector-item:last-child {
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
border-bottom: none;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
|
||||||
|
// picker 弹出层通用的指示小三角
|
||||||
|
.uni-popper__arrow,
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-color: transparent;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-popper__arrow {
|
||||||
|
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
|
||||||
|
top: -6px;
|
||||||
|
left: 10%;
|
||||||
|
margin-right: 3px;
|
||||||
|
border-top-width: 0;
|
||||||
|
border-bottom-color: #EBEEF5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-popper__arrow::after {
|
||||||
|
content: " ";
|
||||||
|
top: 1px;
|
||||||
|
margin-left: -6px;
|
||||||
|
border-top-width: 0;
|
||||||
|
border-bottom-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uni-combox__no-border {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
</style>
|
90
uni_modules/uni-combox/package.json
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-combox",
|
||||||
|
"displayName": "uni-combox 组合框",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"description": "可以选择也可以输入的表单项 ",
|
||||||
|
"keywords": [
|
||||||
|
"uni-ui",
|
||||||
|
"uniui",
|
||||||
|
"combox",
|
||||||
|
"组合框",
|
||||||
|
"select"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
uni_modules/uni-combox/readme.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
## Combox 组合框
|
||||||
|
> **组件名:uni-combox**
|
||||||
|
> 代码块: `uCombox`
|
||||||
|
|
||||||
|
|
||||||
|
组合框组件。
|
||||||
|
|
||||||
|
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-combox)
|
||||||
|
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
103
uni_modules/uni-datetime-picker/changelog.md
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
## 2.2.11(2022-09-19)
|
||||||
|
- 修复,支付宝小程序样式错乱,[详情](https://github.com/dcloudio/uni-app/issues/3861)
|
||||||
|
## 2.2.10(2022-09-19)
|
||||||
|
- 修复,反向选择日期范围,日期显示异常,[详情](https://ask.dcloud.net.cn/question/153401?item_id=212892&rf=false)
|
||||||
|
## 2.2.9(2022-09-16)
|
||||||
|
- 可以使用 uni-scss 控制主题色
|
||||||
|
## 2.2.8(2022-09-08)
|
||||||
|
- 修复 close事件无效的 bug
|
||||||
|
## 2.2.7(2022-09-05)
|
||||||
|
- 修复 移动端 maskClick 无效的 bug,详见:[https://ask.dcloud.net.cn/question/140824?item_id=209458&rf=false](https://ask.dcloud.net.cn/question/140824?item_id=209458&rf=false)
|
||||||
|
## 2.2.6(2022-06-30)
|
||||||
|
- 优化 组件样式,调整了组件图标大小、高度、颜色等,与uni-ui风格保持一致
|
||||||
|
## 2.2.5(2022-06-24)
|
||||||
|
- 修复 日历顶部年月及底部确认未国际化 bug
|
||||||
|
## 2.2.4(2022-03-31)
|
||||||
|
- 修复 Vue3 下动态赋值,单选类型未响应的 bug
|
||||||
|
## 2.2.3(2022-03-28)
|
||||||
|
- 修复 Vue3 下动态赋值未响应的 bug
|
||||||
|
## 2.2.2(2021-12-10)
|
||||||
|
- 修复 clear-icon 属性在小程序平台不生效的 bug
|
||||||
|
## 2.2.1(2021-12-10)
|
||||||
|
- 修复 日期范围选在小程序平台,必须多点击一次才能取消选中状态的 bug
|
||||||
|
## 2.2.0(2021-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.5(2021-11-09)
|
||||||
|
- 新增 提供组件设计资源,组件样式调整
|
||||||
|
## 2.1.4(2021-09-10)
|
||||||
|
- 修复 hide-second 在移动端的 bug
|
||||||
|
- 修复 单选赋默认值时,赋值日期未高亮的 bug
|
||||||
|
- 修复 赋默认值时,移动端未正确显示时间的 bug
|
||||||
|
## 2.1.3(2021-09-09)
|
||||||
|
- 新增 hide-second 属性,支持只使用时分,隐藏秒
|
||||||
|
## 2.1.2(2021-09-03)
|
||||||
|
- 优化 取消选中时(范围选)直接开始下一次选择, 避免多点一次
|
||||||
|
- 优化 移动端支持清除按钮,同时支持通过 ref 调用组件的 clear 方法
|
||||||
|
- 优化 调整字号大小,美化日历界面
|
||||||
|
- 修复 因国际化导致的 placeholder 失效的 bug
|
||||||
|
## 2.1.1(2021-08-24)
|
||||||
|
- 新增 支持国际化
|
||||||
|
- 优化 范围选择器在 pc 端过宽的问题
|
||||||
|
## 2.1.0(2021-08-09)
|
||||||
|
- 新增 适配 vue3
|
||||||
|
## 2.0.19(2021-08-09)
|
||||||
|
- 新增 支持作为 uni-forms 子组件相关功能
|
||||||
|
- 修复 在 uni-forms 中使用时,选择时间报 NAN 错误的 bug
|
||||||
|
## 2.0.18(2021-08-05)
|
||||||
|
- 修复 type 属性动态赋值无效的 bug
|
||||||
|
- 修复 ‘确认’按钮被 tabbar 遮盖 bug
|
||||||
|
- 修复 组件未赋值时范围选左、右日历相同的 bug
|
||||||
|
## 2.0.17(2021-08-04)
|
||||||
|
- 修复 范围选未正确显示当前值的 bug
|
||||||
|
- 修复 h5 平台(移动端)报错 'cale' of undefined 的 bug
|
||||||
|
## 2.0.16(2021-07-21)
|
||||||
|
- 新增 return-type 属性支持返回 date 日期对象
|
||||||
|
## 2.0.15(2021-07-14)
|
||||||
|
- 修复 单选日期类型,初始赋值后不在当前日历的 bug
|
||||||
|
- 新增 clearIcon 属性,显示框的清空按钮可配置显示隐藏(仅 pc 有效)
|
||||||
|
- 优化 移动端移除显示框的清空按钮,无实际用途
|
||||||
|
## 2.0.14(2021-07-14)
|
||||||
|
- 修复 组件赋值为空,界面未更新的 bug
|
||||||
|
- 修复 start 和 end 不能动态赋值的 bug
|
||||||
|
- 修复 范围选类型,用户选择后再次选择右侧日历(结束日期)显示不正确的 bug
|
||||||
|
## 2.0.13(2021-07-08)
|
||||||
|
- 修复 范围选择不能动态赋值的 bug
|
||||||
|
## 2.0.12(2021-07-08)
|
||||||
|
- 修复 范围选择的初始时间在一个月内时,造成无法选择的bug
|
||||||
|
## 2.0.11(2021-07-08)
|
||||||
|
- 优化 弹出层在超出视窗边缘定位不准确的问题
|
||||||
|
## 2.0.10(2021-07-08)
|
||||||
|
- 修复 范围起始点样式的背景色与今日样式的字体前景色融合,导致日期字体看不清的 bug
|
||||||
|
- 优化 弹出层在超出视窗边缘被遮盖的问题
|
||||||
|
## 2.0.9(2021-07-07)
|
||||||
|
- 新增 maskClick 事件
|
||||||
|
- 修复 特殊情况日历 rpx 布局错误的 bug,rpx -> px
|
||||||
|
- 修复 范围选择时清空返回值不合理的bug,['', ''] -> []
|
||||||
|
## 2.0.8(2021-07-07)
|
||||||
|
- 新增 日期时间显示框支持插槽
|
||||||
|
## 2.0.7(2021-07-01)
|
||||||
|
- 优化 添加 uni-icons 依赖
|
||||||
|
## 2.0.6(2021-05-22)
|
||||||
|
- 修复 图标在小程序上不显示的 bug
|
||||||
|
- 优化 重命名引用组件,避免潜在组件命名冲突
|
||||||
|
## 2.0.5(2021-05-20)
|
||||||
|
- 优化 代码目录扁平化
|
||||||
|
## 2.0.4(2021-05-12)
|
||||||
|
- 新增 组件示例地址
|
||||||
|
## 2.0.3(2021-05-10)
|
||||||
|
- 修复 ios 下不识别 '-' 日期格式的 bug
|
||||||
|
- 优化 pc 下弹出层添加边框和阴影
|
||||||
|
## 2.0.2(2021-05-08)
|
||||||
|
- 修复 在 admin 中获取弹出层定位错误的bug
|
||||||
|
## 2.0.1(2021-05-08)
|
||||||
|
- 修复 type 属性向下兼容,默认值从 date 变更为 datetime
|
||||||
|
## 2.0.0(2021-04-30)
|
||||||
|
- 支持日历形式的日期+时间的范围选择
|
||||||
|
> 注意:此版本不向后兼容,不再支持单独时间选择(type=time)及相关的 hide-second 属性(时间选可使用内置组件 picker)
|
||||||
|
## 1.0.6(2021-03-18)
|
||||||
|
- 新增 hide-second 属性,时间支持仅选择时、分
|
||||||
|
- 修复 选择跟显示的日期不一样的 bug
|
||||||
|
- 修复 chang事件触发2次的 bug
|
||||||
|
- 修复 分、秒 end 范围错误的 bug
|
||||||
|
- 优化 更好的 nvue 适配
|
@ -0,0 +1,187 @@
|
|||||||
|
<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-primary: #007aff !default;
|
||||||
|
|
||||||
|
.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: darken($color: $uni-primary, $amount: 40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: $uni-primary;
|
||||||
|
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: $uni-primary;
|
||||||
|
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>
|
@ -0,0 +1,924 @@
|
|||||||
|
<template>
|
||||||
|
<view class="uni-calendar" @mouseleave="leaveCale">
|
||||||
|
<view v-if="!insert&&show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
|
||||||
|
@click="clean();maskClick()"></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>
|
||||||
|
<view style="line-height: 50px;">
|
||||||
|
<uni-icons type="arrowthinright" color="#999"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="uni-date-changed--time-end">
|
||||||
|
<view class="uni-date-changed--time-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()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 蒙版点击事件
|
||||||
|
maskClick() {
|
||||||
|
this.$emit('maskClose')
|
||||||
|
},
|
||||||
|
|
||||||
|
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
|
||||||
|
const beforeStatus = this.cale.multipleStatus.before
|
||||||
|
const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
|
||||||
|
const afterDate = new Date(this.cale.multipleStatus.after).getTime()
|
||||||
|
if (beforeDate > afterDate && afterDate) {
|
||||||
|
this.tempRange.before = this.cale.multipleStatus.after
|
||||||
|
this.tempRange.after = this.cale.multipleStatus.before
|
||||||
|
} else {
|
||||||
|
this.tempRange.before = this.cale.multipleStatus.before
|
||||||
|
this.tempRange.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-primary: #007aff !default;
|
||||||
|
|
||||||
|
.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: $uni-primary;
|
||||||
|
/* #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: $uni-primary;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
.uni-datetime-picker--btn:active {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
|
</style>
|
@ -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"
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
@ -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": "确认"
|
||||||
|
}
|
@ -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": "確認"
|
||||||
|
}
|
@ -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
|
@ -0,0 +1,930 @@
|
|||||||
|
<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)) //兼容 iOS、safari 日期格式
|
||||||
|
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') //兼容 iOS、safari 日期格式
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
handler(newVal) {
|
||||||
|
this.parseDatetimeRange(this.fixIosDateFormat(newVal), 'end') //兼容 iOS、safari 日期格式
|
||||||
|
},
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析可选择时间范围 start、end,年月日字符串、时间戳
|
||||||
|
* @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();
|
||||||
|
},
|
||||||
|
|
||||||
|
//兼容 iOS、safari 日期格式
|
||||||
|
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 lang="scss">
|
||||||
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
|
.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: $uni-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
line-height: 50px
|
||||||
|
}
|
||||||
|
|
||||||
|
.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>
|
@ -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
|
87
uni_modules/uni-datetime-picker/package.json
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-datetime-picker",
|
||||||
|
"displayName": "uni-datetime-picker 日期选择器",
|
||||||
|
"version": "2.2.11",
|
||||||
|
"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": {
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"qq": ""
|
||||||
|
},
|
||||||
|
"declaration": {
|
||||||
|
"ads": "无",
|
||||||
|
"data": "无",
|
||||||
|
"permissions": "无"
|
||||||
|
},
|
||||||
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
|
||||||
|
"type": "component-vue"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
uni_modules/uni-datetime-picker/readme.md
Normal 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
|
22
uni_modules/uni-icons/changelog.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## 1.3.5(2022-01-24)
|
||||||
|
- 优化 size 属性可以传入不带单位的字符串数值
|
||||||
|
## 1.3.4(2022-01-24)
|
||||||
|
- 优化 size 支持其他单位
|
||||||
|
## 1.3.3(2022-01-17)
|
||||||
|
- 修复 nvue 有些图标不显示的bug,兼容老版本图标
|
||||||
|
## 1.3.2(2021-12-01)
|
||||||
|
- 优化 示例可复制图标名称
|
||||||
|
## 1.3.1(2021-11-23)
|
||||||
|
- 优化 兼容旧组件 type 值
|
||||||
|
## 1.3.0(2021-11-19)
|
||||||
|
- 新增 更多图标
|
||||||
|
- 优化 自定义图标使用方式
|
||||||
|
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
|
||||||
|
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-icons](https://uniapp.dcloud.io/component/uniui/uni-icons)
|
||||||
|
## 1.1.7(2021-11-08)
|
||||||
|
## 1.2.0(2021-07-30)
|
||||||
|
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
|
||||||
|
## 1.1.5(2021-05-12)
|
||||||
|
- 新增 组件示例地址
|
||||||
|
## 1.1.4(2021-02-05)
|
||||||
|
- 调整为uni_modules目录规范
|
1169
uni_modules/uni-icons/components/uni-icons/icons.js
Normal file
96
uni_modules/uni-icons/components/uni-icons/uni-icons.vue
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<template>
|
||||||
|
<!-- #ifdef APP-NVUE -->
|
||||||
|
<text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" @click="_onClick">{{unicode}}</text>
|
||||||
|
<!-- #endif -->
|
||||||
|
<!-- #ifndef APP-NVUE -->
|
||||||
|
<text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" :class="['uniui-'+type,customPrefix,customPrefix?type:'']" @click="_onClick"></text>
|
||||||
|
<!-- #endif -->
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import icons from './icons.js';
|
||||||
|
const getVal = (val) => {
|
||||||
|
const reg = /^[0-9]*$/g
|
||||||
|
return (typeof val === 'number' || reg.test(val) )? val + 'px' : val;
|
||||||
|
}
|
||||||
|
// #ifdef APP-NVUE
|
||||||
|
var domModule = weex.requireModule('dom');
|
||||||
|
import iconUrl from './uniicons.ttf'
|
||||||
|
domModule.addRule('fontFace', {
|
||||||
|
'fontFamily': "uniicons",
|
||||||
|
'src': "url('"+iconUrl+"')"
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Icons 图标
|
||||||
|
* @description 用于展示 icons 图标
|
||||||
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=28
|
||||||
|
* @property {Number} size 图标大小
|
||||||
|
* @property {String} type 图标图案,参考示例
|
||||||
|
* @property {String} color 图标颜色
|
||||||
|
* @property {String} customPrefix 自定义图标
|
||||||
|
* @event {Function} click 点击 Icon 触发事件
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'UniIcons',
|
||||||
|
emits:['click'],
|
||||||
|
props: {
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
type: String,
|
||||||
|
default: '#333333'
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 16
|
||||||
|
},
|
||||||
|
customPrefix:{
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
icons: icons.glyphs
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
unicode(){
|
||||||
|
let code = this.icons.find(v=>v.font_class === this.type)
|
||||||
|
if(code){
|
||||||
|
return unescape(`%u${code.unicode}`)
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
},
|
||||||
|
iconSize(){
|
||||||
|
return getVal(this.size)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
_onClick() {
|
||||||
|
this.$emit('click')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
|
@import './uniicons.css';
|
||||||
|
@font-face {
|
||||||
|
font-family: uniicons;
|
||||||
|
src: url('./uniicons.ttf') format('truetype');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #endif */
|
||||||
|
.uni-icons {
|
||||||
|
font-family: uniicons;
|
||||||
|
text-decoration: none;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
663
uni_modules/uni-icons/components/uni-icons/uniicons.css
Normal file
@ -0,0 +1,663 @@
|
|||||||
|
.uniui-color:before {
|
||||||
|
content: "\e6cf";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-wallet:before {
|
||||||
|
content: "\e6b1";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-settings-filled:before {
|
||||||
|
content: "\e6ce";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-auth-filled:before {
|
||||||
|
content: "\e6cc";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-shop-filled:before {
|
||||||
|
content: "\e6cd";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-staff-filled:before {
|
||||||
|
content: "\e6cb";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-vip-filled:before {
|
||||||
|
content: "\e6c6";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-plus-filled:before {
|
||||||
|
content: "\e6c7";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-folder-add-filled:before {
|
||||||
|
content: "\e6c8";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-color-filled:before {
|
||||||
|
content: "\e6c9";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-tune-filled:before {
|
||||||
|
content: "\e6ca";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-calendar-filled:before {
|
||||||
|
content: "\e6c0";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-notification-filled:before {
|
||||||
|
content: "\e6c1";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-wallet-filled:before {
|
||||||
|
content: "\e6c2";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-medal-filled:before {
|
||||||
|
content: "\e6c3";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-gift-filled:before {
|
||||||
|
content: "\e6c4";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-fire-filled:before {
|
||||||
|
content: "\e6c5";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-refreshempty:before {
|
||||||
|
content: "\e6bf";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-location-filled:before {
|
||||||
|
content: "\e6af";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-person-filled:before {
|
||||||
|
content: "\e69d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-personadd-filled:before {
|
||||||
|
content: "\e698";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-back:before {
|
||||||
|
content: "\e6b9";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-forward:before {
|
||||||
|
content: "\e6ba";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrow-right:before {
|
||||||
|
content: "\e6bb";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowthinright:before {
|
||||||
|
content: "\e6bb";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrow-left:before {
|
||||||
|
content: "\e6bc";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowthinleft:before {
|
||||||
|
content: "\e6bc";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrow-up:before {
|
||||||
|
content: "\e6bd";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowthinup:before {
|
||||||
|
content: "\e6bd";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrow-down:before {
|
||||||
|
content: "\e6be";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowthindown:before {
|
||||||
|
content: "\e6be";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-bottom:before {
|
||||||
|
content: "\e6b8";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowdown:before {
|
||||||
|
content: "\e6b8";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-right:before {
|
||||||
|
content: "\e6b5";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowright:before {
|
||||||
|
content: "\e6b5";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-top:before {
|
||||||
|
content: "\e6b6";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowup:before {
|
||||||
|
content: "\e6b6";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-left:before {
|
||||||
|
content: "\e6b7";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-arrowleft:before {
|
||||||
|
content: "\e6b7";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-eye:before {
|
||||||
|
content: "\e651";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-eye-filled:before {
|
||||||
|
content: "\e66a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-eye-slash:before {
|
||||||
|
content: "\e6b3";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-eye-slash-filled:before {
|
||||||
|
content: "\e6b4";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-info-filled:before {
|
||||||
|
content: "\e649";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-reload:before {
|
||||||
|
content: "\e6b2";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-micoff-filled:before {
|
||||||
|
content: "\e6b0";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-map-pin-ellipse:before {
|
||||||
|
content: "\e6ac";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-map-pin:before {
|
||||||
|
content: "\e6ad";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-location:before {
|
||||||
|
content: "\e6ae";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-starhalf:before {
|
||||||
|
content: "\e683";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-star:before {
|
||||||
|
content: "\e688";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-star-filled:before {
|
||||||
|
content: "\e68f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-calendar:before {
|
||||||
|
content: "\e6a0";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-fire:before {
|
||||||
|
content: "\e6a1";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-medal:before {
|
||||||
|
content: "\e6a2";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-font:before {
|
||||||
|
content: "\e6a3";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-gift:before {
|
||||||
|
content: "\e6a4";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-link:before {
|
||||||
|
content: "\e6a5";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-notification:before {
|
||||||
|
content: "\e6a6";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-staff:before {
|
||||||
|
content: "\e6a7";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-vip:before {
|
||||||
|
content: "\e6a8";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-folder-add:before {
|
||||||
|
content: "\e6a9";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-tune:before {
|
||||||
|
content: "\e6aa";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-auth:before {
|
||||||
|
content: "\e6ab";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-person:before {
|
||||||
|
content: "\e699";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-email-filled:before {
|
||||||
|
content: "\e69a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-phone-filled:before {
|
||||||
|
content: "\e69b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-phone:before {
|
||||||
|
content: "\e69c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-email:before {
|
||||||
|
content: "\e69e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-personadd:before {
|
||||||
|
content: "\e69f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chatboxes-filled:before {
|
||||||
|
content: "\e692";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-contact:before {
|
||||||
|
content: "\e693";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chatbubble-filled:before {
|
||||||
|
content: "\e694";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-contact-filled:before {
|
||||||
|
content: "\e695";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chatboxes:before {
|
||||||
|
content: "\e696";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chatbubble:before {
|
||||||
|
content: "\e697";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-upload-filled:before {
|
||||||
|
content: "\e68e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-upload:before {
|
||||||
|
content: "\e690";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-weixin:before {
|
||||||
|
content: "\e691";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-compose:before {
|
||||||
|
content: "\e67f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-qq:before {
|
||||||
|
content: "\e680";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-download-filled:before {
|
||||||
|
content: "\e681";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-pyq:before {
|
||||||
|
content: "\e682";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-sound:before {
|
||||||
|
content: "\e684";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-trash-filled:before {
|
||||||
|
content: "\e685";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-sound-filled:before {
|
||||||
|
content: "\e686";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-trash:before {
|
||||||
|
content: "\e687";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-videocam-filled:before {
|
||||||
|
content: "\e689";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-spinner-cycle:before {
|
||||||
|
content: "\e68a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-weibo:before {
|
||||||
|
content: "\e68b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-videocam:before {
|
||||||
|
content: "\e68c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-download:before {
|
||||||
|
content: "\e68d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-help:before {
|
||||||
|
content: "\e679";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-navigate-filled:before {
|
||||||
|
content: "\e67a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-plusempty:before {
|
||||||
|
content: "\e67b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-smallcircle:before {
|
||||||
|
content: "\e67c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-minus-filled:before {
|
||||||
|
content: "\e67d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-micoff:before {
|
||||||
|
content: "\e67e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-closeempty:before {
|
||||||
|
content: "\e66c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-clear:before {
|
||||||
|
content: "\e66d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-navigate:before {
|
||||||
|
content: "\e66e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-minus:before {
|
||||||
|
content: "\e66f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-image:before {
|
||||||
|
content: "\e670";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-mic:before {
|
||||||
|
content: "\e671";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-paperplane:before {
|
||||||
|
content: "\e672";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-close:before {
|
||||||
|
content: "\e673";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-help-filled:before {
|
||||||
|
content: "\e674";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-paperplane-filled:before {
|
||||||
|
content: "\e675";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-plus:before {
|
||||||
|
content: "\e676";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-mic-filled:before {
|
||||||
|
content: "\e677";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-image-filled:before {
|
||||||
|
content: "\e678";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-locked-filled:before {
|
||||||
|
content: "\e668";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-info:before {
|
||||||
|
content: "\e669";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-locked:before {
|
||||||
|
content: "\e66b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-camera-filled:before {
|
||||||
|
content: "\e658";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chat-filled:before {
|
||||||
|
content: "\e659";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-camera:before {
|
||||||
|
content: "\e65a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-circle:before {
|
||||||
|
content: "\e65b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-checkmarkempty:before {
|
||||||
|
content: "\e65c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-chat:before {
|
||||||
|
content: "\e65d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-circle-filled:before {
|
||||||
|
content: "\e65e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-flag:before {
|
||||||
|
content: "\e65f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-flag-filled:before {
|
||||||
|
content: "\e660";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-gear-filled:before {
|
||||||
|
content: "\e661";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-home:before {
|
||||||
|
content: "\e662";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-home-filled:before {
|
||||||
|
content: "\e663";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-gear:before {
|
||||||
|
content: "\e664";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-smallcircle-filled:before {
|
||||||
|
content: "\e665";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-map-filled:before {
|
||||||
|
content: "\e666";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-map:before {
|
||||||
|
content: "\e667";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-refresh-filled:before {
|
||||||
|
content: "\e656";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-refresh:before {
|
||||||
|
content: "\e657";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cloud-upload:before {
|
||||||
|
content: "\e645";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cloud-download-filled:before {
|
||||||
|
content: "\e646";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cloud-download:before {
|
||||||
|
content: "\e647";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cloud-upload-filled:before {
|
||||||
|
content: "\e648";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-redo:before {
|
||||||
|
content: "\e64a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-images-filled:before {
|
||||||
|
content: "\e64b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-undo-filled:before {
|
||||||
|
content: "\e64c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-more:before {
|
||||||
|
content: "\e64d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-more-filled:before {
|
||||||
|
content: "\e64e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-undo:before {
|
||||||
|
content: "\e64f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-images:before {
|
||||||
|
content: "\e650";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-paperclip:before {
|
||||||
|
content: "\e652";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-settings:before {
|
||||||
|
content: "\e653";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-search:before {
|
||||||
|
content: "\e654";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-redo-filled:before {
|
||||||
|
content: "\e655";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-list:before {
|
||||||
|
content: "\e644";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-mail-open-filled:before {
|
||||||
|
content: "\e63a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-hand-down-filled:before {
|
||||||
|
content: "\e63c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-hand-down:before {
|
||||||
|
content: "\e63d";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-hand-up-filled:before {
|
||||||
|
content: "\e63e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-hand-up:before {
|
||||||
|
content: "\e63f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-heart-filled:before {
|
||||||
|
content: "\e641";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-mail-open:before {
|
||||||
|
content: "\e643";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-heart:before {
|
||||||
|
content: "\e639";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-loop:before {
|
||||||
|
content: "\e633";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-pulldown:before {
|
||||||
|
content: "\e632";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-scan:before {
|
||||||
|
content: "\e62a";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-bars:before {
|
||||||
|
content: "\e627";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cart-filled:before {
|
||||||
|
content: "\e629";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-checkbox:before {
|
||||||
|
content: "\e62b";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-checkbox-filled:before {
|
||||||
|
content: "\e62c";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-shop:before {
|
||||||
|
content: "\e62f";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-headphones:before {
|
||||||
|
content: "\e630";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uniui-cart:before {
|
||||||
|
content: "\e631";
|
||||||
|
}
|
BIN
uni_modules/uni-icons/components/uni-icons/uniicons.ttf
Normal file
86
uni_modules/uni-icons/package.json
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-icons",
|
||||||
|
"displayName": "uni-icons 图标",
|
||||||
|
"version": "1.3.5",
|
||||||
|
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
|
||||||
|
"keywords": [
|
||||||
|
"uni-ui",
|
||||||
|
"uniui",
|
||||||
|
"icon",
|
||||||
|
"图标"
|
||||||
|
],
|
||||||
|
"repository": "https://github.com/dcloudio/uni-ui",
|
||||||
|
"engines": {
|
||||||
|
"HBuilderX": "^3.2.14"
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"example": "../../temps/example_temps"
|
||||||
|
},
|
||||||
|
"dcloudext": {
|
||||||
|
"category": [
|
||||||
|
"前端组件",
|
||||||
|
"通用组件"
|
||||||
|
],
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"qq": ""
|
||||||
|
},
|
||||||
|
"declaration": {
|
||||||
|
"ads": "无",
|
||||||
|
"data": "无",
|
||||||
|
"permissions": "无"
|
||||||
|
},
|
||||||
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
||||||
|
},
|
||||||
|
"uni_modules": {
|
||||||
|
"dependencies": ["uni-scss"],
|
||||||
|
"encrypt": [],
|
||||||
|
"platforms": {
|
||||||
|
"cloud": {
|
||||||
|
"tcb": "y",
|
||||||
|
"aliyun": "y"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "y",
|
||||||
|
"app-nvue": "y"
|
||||||
|
},
|
||||||
|
"H5-mobile": {
|
||||||
|
"Safari": "y",
|
||||||
|
"Android Browser": "y",
|
||||||
|
"微信浏览器(Android)": "y",
|
||||||
|
"QQ浏览器(Android)": "y"
|
||||||
|
},
|
||||||
|
"H5-pc": {
|
||||||
|
"Chrome": "y",
|
||||||
|
"IE": "y",
|
||||||
|
"Edge": "y",
|
||||||
|
"Firefox": "y",
|
||||||
|
"Safari": "y"
|
||||||
|
},
|
||||||
|
"小程序": {
|
||||||
|
"微信": "y",
|
||||||
|
"阿里": "y",
|
||||||
|
"百度": "y",
|
||||||
|
"字节跳动": "y",
|
||||||
|
"QQ": "y"
|
||||||
|
},
|
||||||
|
"快应用": {
|
||||||
|
"华为": "u",
|
||||||
|
"联盟": "u"
|
||||||
|
},
|
||||||
|
"Vue": {
|
||||||
|
"vue2": "y",
|
||||||
|
"vue3": "y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
uni_modules/uni-icons/readme.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Icons 图标
|
||||||
|
> **组件名:uni-icons**
|
||||||
|
> 代码块: `uIcons`
|
||||||
|
|
||||||
|
用于展示 icons 图标 。
|
||||||
|
|
||||||
|
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-icons)
|
||||||
|
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
8
uni_modules/uni-scss/changelog.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## 1.0.3(2022-01-21)
|
||||||
|
- 优化 组件示例
|
||||||
|
## 1.0.2(2021-11-22)
|
||||||
|
- 修复 / 符号在 vue 不同版本兼容问题引起的报错问题
|
||||||
|
## 1.0.1(2021-11-22)
|
||||||
|
- 修复 vue3中scss语法兼容问题
|
||||||
|
## 1.0.0(2021-11-18)
|
||||||
|
- init
|
1
uni_modules/uni-scss/index.scss
Normal file
@ -0,0 +1 @@
|
|||||||
|
@import './styles/index.scss';
|
82
uni_modules/uni-scss/package.json
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-scss",
|
||||||
|
"displayName": "uni-scss 辅助样式",
|
||||||
|
"version": "1.0.3",
|
||||||
|
"description": "uni-sass是uni-ui提供的一套全局样式 ,通过一些简单的类名和sass变量,实现简单的页面布局操作,比如颜色、边距、圆角等。",
|
||||||
|
"keywords": [
|
||||||
|
"uni-scss",
|
||||||
|
"uni-ui",
|
||||||
|
"辅助样式"
|
||||||
|
],
|
||||||
|
"repository": "https://github.com/dcloudio/uni-ui",
|
||||||
|
"engines": {
|
||||||
|
"HBuilderX": "^3.1.0"
|
||||||
|
},
|
||||||
|
"dcloudext": {
|
||||||
|
"category": [
|
||||||
|
"JS SDK",
|
||||||
|
"通用 SDK"
|
||||||
|
],
|
||||||
|
"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": [],
|
||||||
|
"encrypt": [],
|
||||||
|
"platforms": {
|
||||||
|
"cloud": {
|
||||||
|
"tcb": "y",
|
||||||
|
"aliyun": "y"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "y",
|
||||||
|
"app-nvue": "u"
|
||||||
|
},
|
||||||
|
"H5-mobile": {
|
||||||
|
"Safari": "y",
|
||||||
|
"Android Browser": "y",
|
||||||
|
"微信浏览器(Android)": "y",
|
||||||
|
"QQ浏览器(Android)": "y"
|
||||||
|
},
|
||||||
|
"H5-pc": {
|
||||||
|
"Chrome": "y",
|
||||||
|
"IE": "y",
|
||||||
|
"Edge": "y",
|
||||||
|
"Firefox": "y",
|
||||||
|
"Safari": "y"
|
||||||
|
},
|
||||||
|
"小程序": {
|
||||||
|
"微信": "y",
|
||||||
|
"阿里": "y",
|
||||||
|
"百度": "y",
|
||||||
|
"字节跳动": "y",
|
||||||
|
"QQ": "y"
|
||||||
|
},
|
||||||
|
"快应用": {
|
||||||
|
"华为": "n",
|
||||||
|
"联盟": "n"
|
||||||
|
},
|
||||||
|
"Vue": {
|
||||||
|
"vue2": "y",
|
||||||
|
"vue3": "y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|