提交 20b38073 作者: wk

一物一码移植 消息中心 今日待办

父级 94176b08
...@@ -164,6 +164,54 @@ const params = { ...@@ -164,6 +164,54 @@ const params = {
getMessages: { getMessages: {
url: "/api/v1/common_check/msg_notify/list", url: "/api/v1/common_check/msg_notify/list",
method: "get" method: "get"
},
/* 数据智管 */
//获取业务实体列表
getBussinessList: {
url: "/plat/web/v1/qrcode/business_cate/list",
method: "get"
},
//下载录入码
getInputCode: {
url: "/plat/web/v1/qrcode/download/input",
method: "get"
},
//下载数据码
getDataCode: {
url: "/plat/web/v1/qrcode/download/list",
method: "get"
},
//单个下载地址
getSingleDownload: {
url: "/plat/web/v1/qrcode/download/single",
method: "get"
},
//创建合并任务
creaAllTask: {
url: "/plat/web/v1/qrcode/download/batch",
method: "get"
},
//下载全部
downloadAll: {
url: "/plat/web/v1/qrcode/download/zip_url",
method: "get"
},
getFormDetail: {
url: "/plat/api/v1/qrcode/check_item/detail",
method: "get"
},
postForm: {
url: "/plat/api/v1/qrcode/check_item/save",
method: "post"
},
getRealBoxList: {
url: "/api/v1/data/rpt_b_entity_field/real_box_list",
method: "get"
},
//获取表单列表
getFormDetailList: {
url: "/plat/api/v1/common_check/check_record/form_detail_list",
method: "get"
} }
} }
......
export const Base64 = {
// private property
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode: function(input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode: function(input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode: function(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode: function(utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while (i < utftext.length) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
// (function(){
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Global Crypto object
// window.Crypto = {};
let Crypto = {};
// Crypto utilities
var util = Crypto.util = {
// Bit-wise rotate left
rotl: function(n, b) {
return (n << b) | (n >>> (32 - b));
},
// Bit-wise rotate right
rotr: function(n, b) {
return (n << (32 - b)) | (n >>> b);
},
// Swap big-endian to little-endian and vice versa
endian: function(n) {
// If number given, swap endian
if (n.constructor == Number) {
return util.rotl(n, 8) & 0x00FF00FF |
util.rotl(n, 24) & 0xFF00FF00;
}
// Else, assume array and swap all items
for (var i = 0; i < n.length; i++)
n[i] = util.endian(n[i]);
return n;
},
// Generate an array of any length of random bytes
randomBytes: function(n) {
for (var bytes = []; n > 0; n--)
bytes.push(Math.floor(Math.random() * 256));
return bytes;
},
// Convert a string to a byte array
stringToBytes: function(str) {
var bytes = [];
for (var i = 0; i < str.length; i++)
bytes.push(str.charCodeAt(i));
return bytes;
},
// Convert a byte array to a string
bytesToString: function(bytes) {
var str = [];
for (var i = 0; i < bytes.length; i++)
str.push(String.fromCharCode(bytes[i]));
return str.join("");
},
// Convert a string to big-endian 32-bit words
stringToWords: function(str) {
var words = [];
for (var c = 0, b = 0; c < str.length; c++, b += 8)
words[b >>> 5] |= str.charCodeAt(c) << (24 - b % 32);
return words;
},
// Convert a byte array to big-endian 32-bits words
bytesToWords: function(bytes) {
var words = [];
for (var i = 0, b = 0; i < bytes.length; i++, b += 8)
words[b >>> 5] |= bytes[i] << (24 - b % 32);
return words;
},
// Convert big-endian 32-bit words to a byte array
wordsToBytes: function(words) {
var bytes = [];
for (var b = 0; b < words.length * 32; b += 8)
bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
return bytes;
},
// Convert a byte array to a hex string
bytesToHex: function(bytes) {
var hex = [];
for (var i = 0; i < bytes.length; i++) {
hex.push((bytes[i] >>> 4).toString(16));
hex.push((bytes[i] & 0xF).toString(16));
}
return hex.join("");
},
// Convert a hex string to a byte array
hexToBytes: function(hex) {
var bytes = [];
for (var c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return bytes;
},
// Convert a byte array to a base-64 string
bytesToBase64: function(bytes) {
// Use browser-native function if it exists
if (typeof btoa == "function") return btoa(util.bytesToString(bytes));
var base64 = [],
overflow;
for (var i = 0; i < bytes.length; i++) {
switch (i % 3) {
case 0:
base64.push(base64map.charAt(bytes[i] >>> 2));
overflow = (bytes[i] & 0x3) << 4;
break;
case 1:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 4)));
overflow = (bytes[i] & 0xF) << 2;
break;
case 2:
base64.push(base64map.charAt(overflow | (bytes[i] >>> 6)));
base64.push(base64map.charAt(bytes[i] & 0x3F));
overflow = -1;
}
}
// Encode overflow bits, if there are any
if (overflow != undefined && overflow != -1)
base64.push(base64map.charAt(overflow));
// Add padding
while (base64.length % 4 != 0) base64.push("=");
return base64.join("");
},
// Convert a base-64 string to a byte array
base64ToBytes: function(base64) {
// Use browser-native function if it exists
if (typeof atob == "function") return util.stringToBytes(atob(base64));
// Remove non-base-64 characters
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
var bytes = [];
for (var i = 0; i < base64.length; i++) {
switch (i % 4) {
case 1:
bytes.push((base64map.indexOf(base64.charAt(i - 1)) << 2) |
(base64map.indexOf(base64.charAt(i)) >>> 4));
break;
case 2:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0xF) << 4) |
(base64map.indexOf(base64.charAt(i)) >>> 2));
break;
case 3:
bytes.push(((base64map.indexOf(base64.charAt(i - 1)) & 0x3) << 6) |
(base64map.indexOf(base64.charAt(i))));
break;
}
}
return bytes;
}
};
// Crypto mode namespace
Crypto.mode = {};
// })();
export default Crypto;
import Crypto from './crypto.js';
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
(function() {
// Shortcut
var util = Crypto.util;
Crypto.HMAC = function(hasher, message, key, options) {
// Allow arbitrary length keys
key = key.length > hasher._blocksize * 4 ?
hasher(key, {
asBytes: true
}) :
util.stringToBytes(key);
// XOR keys with pad constants
var okey = key,
ikey = key.slice(0);
for (var i = 0; i < hasher._blocksize * 4; i++) {
okey[i] ^= 0x5C;
ikey[i] ^= 0x36;
}
var hmacbytes = hasher(util.bytesToString(okey) +
hasher(util.bytesToString(ikey) + message, {
asString: true
}), {
asBytes: true
});
return options && options.asBytes ? hmacbytes :
options && options.asString ? util.bytesToString(hmacbytes) :
util.bytesToHex(hmacbytes);
};
})();
import Crypto from './crypto.js';
import './hmac.js';
import './sha1.js';
import {
Base64
} from './base64.js';
import base_oss_url from '../config.js'
const uploadFileSize = 1024 * 1024 * 100; // 上传文件的大小限制100m
const accesskey = 'IR6U1vqAnv7noj0qrMCwVFXjMdzFxL'; // 自己去申请
const accessId = 'LTAILXlaleXLe8Cf' // 自己去申请
export default {
_getPolicy() {
let policyText = {
"expiration": "2100-01-01T12:00:00.000Z", //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了
"conditions": [
["content-length-range", 0, uploadFileSize] // 设置上传文件的大小限制
]
};
return Base64.encode(JSON.stringify(policyText))
},
_getSignature(message) {
let bytes = Crypto.HMAC(Crypto.SHA1, message, accesskey, {
asBytes: true
});
return Crypto.util.bytesToBase64(bytes);
},
_getSuffix(filename) {
let pos = filename.lastIndexOf('.')
let suffix = ''
if (pos != -1) {
suffix = filename.substring(pos)
}
return suffix;
},
getFileName(filename) {
console.log('filename:', filename)
return 'wx_img/' + new Date().getTime() + Math.random().toString(36).substring(3, 20) + this._getSuffix(filename)
},
getImage() {
return new Promise((resolve, reject) => {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: (res) => {
resolve(res)
}
})
});
},
getVideo() {
return new Promise((resolve, reject) => {
uni.chooseVideo({
count: 1,
sourceType: ['camera', 'album'],
success: function(res) {
if (res.size > uploadFileSize) {
uni.showToast({
title: '文件大小超过系统上传限制:' + uploadFileSize,
icon: 'none',
duration: 1000
});
return;
}
resolve(res.tempFilePath)
},
fail: () => {
uni.showToast({
title: '取消选择视频',
icon: 'none',
duration: 2000
});
}
})
});
},
// 获取STS签名
get_STS() {
// 读取接口
/* return new Promise((resolve, reject) => {
let name = new Date().getTime() + Math.random();
let operate = 'uploadImg';
let that = this;
uni.request({
method: "GET",
url: "*************",
data: {
name,
operate,
sign: Crypto.MD5(name + operate + "bayinabayin888").toString()
},
success(res) {
if (res.data.code != 200) {
that.$alert(res.data.message || res.data.msg)
} else {
resolve(res.data.data)
}
},
error(err) {
reject(err)
}
})
}) */
// 本地获取
return new Promise((resolve, reject) => {
let policy = this._getPolicy();
let res = {
accessId: accessId,
host: base_oss_url, // 自己去申请
policy,
signature: this._getSignature(policy),
};
resolve(res)
})
},
};
import Crypto from './crypto.js';
/*!
* Crypto-JS v1.1.0
* http://code.google.com/p/crypto-js/
* Copyright (c) 2009, Jeff Mott. All rights reserved.
* http://code.google.com/p/crypto-js/wiki/License
*/
(function() {
// Shortcut
var util = Crypto.util;
// Public API
var SHA1 = Crypto.SHA1 = function(message, options) {
var digestbytes = util.wordsToBytes(SHA1._sha1(message));
return options && options.asBytes ? digestbytes :
options && options.asString ? util.bytesToString(digestbytes) :
util.bytesToHex(digestbytes);
};
// The core
SHA1._sha1 = function(message) {
var m = util.stringToWords(message),
l = message.length * 8,
w = [],
H0 = 1732584193,
H1 = -271733879,
H2 = -1732584194,
H3 = 271733878,
H4 = -1009589776;
// Padding
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >>> 9) << 4) + 15] = l;
for (var i = 0; i < m.length; i += 16) {
var a = H0,
b = H1,
c = H2,
d = H3,
e = H4;
for (var j = 0; j < 80; j++) {
if (j < 16) w[j] = m[i + j];
else {
var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16];
w[j] = (n << 1) | (n >>> 31);
}
var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (
j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :
j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :
j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :
(H1 ^ H2 ^ H3) - 899497514);
H4 = H3;
H3 = H2;
H2 = (H1 << 30) | (H1 >>> 2);
H1 = H0;
H0 = t;
}
H0 += a;
H1 += b;
H2 += c;
H3 += d;
H4 += e;
}
return [H0, H1, H2, H3, H4];
};
// Package private blocksize
SHA1._blocksize = 16;
})();
var row_Height = 0; //行高
var scrollOffsetTop = 0; //滚动条位置
var isAppH5 = false; //是否APPH5端
var isLongTouch = false; //是否开启长按
var longTouchTime = 350; //触发长安事件事件
var isMove = false; //是否可拖动
var touchTimer=false; //长按事件定时器
function scroll(event,instance){
scrollOffsetTop = event.detail.scrollTop;
}
function touchstart(event, instance) {
isMove = false;
if(row_Height==0){
var rowStyle = event.instance.getComputedStyle(['height']);
row_Height = parseInt(rowStyle.height);//获取行高
}
var rowData = event.instance.getDataset();
var rowtype = rowData.type == "A" ? "B" : "A";
//重置样式
resetRowStyle(state, instance, rowtype);
var state = instance.getState();
if (event.touches.length == 1) {
state.point = event.touches[0];
state.initscrollOffsetTop = scrollOffsetTop;
state.islongTap = true;
state.rowData = rowData;
//读取数据
var dataViewDOM = instance.selectComponent('#dataView');
var viewData = dataViewDOM.getDataset();
isAppH5 = viewData.isapph5&&JSON.parse(viewData.isapph5);
isLongTouch = viewData.islongtouch&&JSON.parse(viewData.islongtouch);
longTouchTime = parseInt(viewData.longtouchtime);
state.rowData.rownum = viewData.rownum;
state.rowData.listheight = viewData.listheight;
}
// 计算shadowRow.style.top
var rowIndex = parseInt(rowData.index);
var shadowRowTop = rowIndex*row_Height;
shadowRowTop = shadowRowTop - scrollOffsetTop;
// 加载shadowRow数据
instance.callMethod("loadShadowRow", {rowIndex : rowIndex,shadowRowTop:shadowRowTop});
state.shadowRowTop = shadowRowTop;
var shadowBoxComponent = instance.selectComponent('#shadowRowBox');
shadowBoxComponent.setStyle({'top': shadowRowTop + 'px'})
//长按事件
if(isLongTouch){
if(typeof setTimeout !== "undefined"){
touchTimer && clearTimeout(touchTimer);
touchTimer = setTimeout(function(){
longpress(event,instance);
},longTouchTime)
}
}
}
function longpress(event,instance){
if(isLongTouch){
isMove = true;
moveRow(instance, 0)
}
}
function touchmove(event, instance) {
var state = instance.getState();
var rowData = event.instance.getDataset();
var movePoint = event.touches[0];
var initPoint = state.point;
var moveY = movePoint.pageY - initPoint.pageY;
if(isLongTouch){
if(typeof setTimeout !== "undefined" && Math.abs(moveY)>10){
clearTimeout(touchTimer);
}
if (!isMove) {
return ;
}
}
moveRow(instance, moveY);
//阻止滚动页面
if(event.preventDefault){
event.preventDefault();
}
return false;
}
function touchend(event, instance) {
if(isLongTouch && typeof setTimeout !== "undefined"){
clearTimeout(touchTimer);
}
if(lastCommand!="stop"){
lastCommand = "stop";
instance.callMethod("pageScroll", {'command':"stop"});
}
var state = instance.getState();
var rowtype = state.rowData.type;
if (typeof state.offset !== "undefined" && state.rowData.index != state.offset && state.offset != null) {
instance.callMethod("sort", {
index: state.rowData.index,
offset: state.offset
});
} else {
resetRowStyle(state, instance, rowtype);
resetShadowRowStyle(instance)
feedbackGenerator(instance); //震动反馈
return false;
}
resetShadowRowStyle(instance)
typeof setTimeout !== "undefined" && setTimeout(function() {
resetRowStyle(state, instance, rowtype);
}, 500);
state.offset = null;
oldOffset = null;
feedbackGenerator(instance); //震动反馈
return false;
}
function resetRowStyle(state, instance, rowtype) {
var blockList = instance.selectAllComponents('.row'+rowtype);
for (var i = 0; i < blockList.length; i++) {
blockList[i].setStyle({
'height': row_Height+'px',
'transform': 'none',
'-webkit-transform': 'none'
});
blockList[i].removeClass('ani');
blockList[i].removeClass('hide');
}
}
function resetShadowRowStyle(instance) {
var shadowBoxComponent = instance.selectComponent('#shadowRowBox');
shadowBoxComponent.removeClass('show');
shadowBoxComponent.setStyle({});
shadowBoxComponent.removeClass('move');
}
var lastCommand = '';
// move Row
function moveRow(instance, moveY) {
var state = instance.getState();
var initIndex = parseInt(state.rowData.index);
var rowtype = state.rowData.type;
//显示拖拽行Box
var shadowBoxComponent = instance.selectComponent('#shadowRowBox');
shadowBoxComponent.hasClass('show') || shadowBoxComponent.addClass('show');
//隐藏列表对应行
var rowDom = instance.selectComponent('#row' + rowtype + state.rowData.index);
rowDom.hasClass('hide') || rowDom.addClass('hide');
//拖动shadowRow
var shadowRowDom = instance.selectComponent('#shadowRow');
shadowRowDom.hasClass('move') || shadowRowDom.addClass('move');
shadowRowDom.removeClass('ani');
var style = {
'transform': 'translateY(' + moveY + 'px) translateZ(10px)',
'-webkit-transform': 'translateY(' + moveY + 'px) translateZ(10px)'
}
shadowRowDom.setStyle(style);
var listheight = state.rowData.listheight
var listClientY = state.shadowRowTop + moveY;
var tmpscrollListTop = scrollOffsetTop;
// 拖拽至边缘滚动视图 距离顶部距离1.5行高触发上滚动 下滚动同理
var callMethodData = {
command:listClientY<row_Height*1.5?"up":listClientY>listheight-(row_Height*1.5)?"down":"stop",
scrollTop:tmpscrollListTop,
}
//把滚动指令发给逻辑层
if(lastCommand!=callMethodData.command){
lastCommand = callMethodData.command;
instance.callMethod("pageScroll", callMethodData);
}
var moveOffset = moveY + scrollOffsetTop - state.initscrollOffsetTop;
var offset = calcOffset(initIndex, moveOffset);
if(offset<=2 || offset>=state.rowData.rownum-2){
callMethodData.command = 'stop';
}
//为保证体验,非APP和H5端,在滚动视图期间不进行位置交换
if((!isAppH5) && callMethodData.command!='stop'){
return;
}
oldOffset = oldOffset == null ? initIndex : oldOffset;
if (offset < 0 || offset >= state.rowData.rownum) {
return;
}
if (offset == oldOffset) {
return;
}
oldOffset = offset;
state.offset = offset;
//触发change事件
instance.callMethod("change", {
index: state.rowData.index,
moveTo: state.offset
});
feedbackGenerator(instance); //震动反馈
//根据offset对行进行位置交换
var blockList = instance.selectAllComponents('.row' + rowtype);
for (var i = 0; i < blockList.length; i++) {
if (i == initIndex) {
continue;
}
var translateY = 0;
if ((i >= offset && i < initIndex) || (i <= offset && i > initIndex)) {
translateY = i < initIndex ? row_Height : -row_Height;
}
var style = {
'height': row_Height+'px',
'transform': 'translateY(' + translateY + 'px) translateZ(5px)',
'-webkit-transform': 'translateY(' + translateY + 'px) translateZ(5px)'
}
blockList[i].hasClass('ani') || blockList[i].addClass('ani');
blockList[i].setStyle(style);
}
}
//计算偏移index
var oldOffset = null;
function calcOffset(initIndex, moveY) {
var offset = initIndex + parseInt(moveY / row_Height); //偏移 行高的倍数
var rest = moveY % row_Height;
if (rest > 0) {
offset = offset + (rest / row_Height >= 0.6 ? 1 : 0);
if (offset < oldOffset) {
offset = rest / row_Height <= 0.4 ? offset : oldOffset;
}
} else {
offset = offset + (rest / row_Height <= -0.6 ? -1 : 0);
if (offset > oldOffset) {
offset = rest / row_Height >= -0.4 ? offset : oldOffset;
}
}
return offset;
}
//触感反馈
//wxs 不支持条件编译,所以用此方法判断
var isiOSAPP = typeof plus != "undefined" && plus.os.name == 'iOS';
var UISelectionFeedbackGenerator;
var UIImpactFeedbackGenerator;
var impact
if (isiOSAPP) {
UISelectionFeedbackGenerator = plus.ios.importClass("UISelectionFeedbackGenerator");
impact = new UISelectionFeedbackGenerator();
impact.init();
}
function feedbackGenerator(instance) {
if (isiOSAPP) {
impact.selectionChanged();
} else {
if (typeof plus != "undefined") {
plus.device.vibrate(12)
} else {
instance.callMethod("vibrate");
}
}
}
module.exports = {
scroll:scroll,
longpress:longpress,
touchstart: touchstart,
touchmove: touchmove,
touchend: touchend
}
const aui = {
console: function(str){
console.log(str);
},
/***打开新页面
@param {string} url 页面路径
@param {Object} opts 参数 {id: ''}
@example: aui.openWin("index.html", {id: 1})
*/
openWin(url, opts){
var _this = this;
var str = '?';
for(var i in opts){
if(_this.isDefine(opts[i])){
str += i + '=' + opts[i] + '&';
}
}
uni.navigateTo({
url: _this.isDefine(opts) ? url + str : url
})
},
/***关闭页面
@example: aui.closeWin()
*/
closeWin(callback){
//直接关闭页面,并向后台发送数据
if(typeof callback == "function"){
if(window.addEventListener) {
window.addEventListener("beforeunload", callback, false);
} else {
window.attachEvent("onbeforeunload", callback, false);
}
}
uni.navigateBack({
delta: 1
});
},
/***判断字符串是否为空
@param {string} str 变量
@example: aui.isDefine("变量");
*/
isDefine(str){
if (str == null || str == "" || str == "undefined" || str == undefined || str == "null" || str == "(null)" || str == 'NULL' || typeof (str) == 'undefined'){
return false;
}else{
str = str + "";
str = str.replace(/\s/g, "");
if (str == ""){return false;}
return true;
}
},
}
export {
aui
}
\ No newline at end of file
<template>
<view class="page-section-spacing">
<swiper class="swiper" indicator-dots="true" autoplay="true" interval="3000" duration="1500" circular="true">
<swiper-item v-for="(item , index) in homeSlide" :key="index">
<image :src="item" mode="aspectFill"></image>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
homeSlide: {
type: Array,
default () {
return []
}
}
}
}
</script>
<style lang="scss">
.swiper {
height: 300upx;
}
// swiper-item 里面的图片高度
swiper-item image {
width: 100%;
height: 300upx;
}
</style>
<template>
<view class="share">
<view :class="{'share-box': state}" @click="handleHidden">
</view>
<view class="share-item" :class="{'share-show': state}">
<view class="share-to">
<text>选择项目</text>
</view>
<scroll-view scroll-y="true">
<view class="content">
<view class="block" v-for="(item, index) in list" :key="index" @click="itemClick(index)">
<text>{{item.project_name}}</text>
</view>
</view>
</scroll-view>
<view class="cancel" @click.stop="handleHidden">
<text>取消</text>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
list: {
type: Array,
default () {
return []
}
}
},
data() {
return {
state: false,
};
},
methods: {
// 显示分享
handleShow() {
this.state = true;
},
// 隐藏分享
handleHidden() {
this.state = false;
},
itemClick(index) {
this.state = false;
this.$emit("handleClick", this.list[index])
}
}
}
</script>
<style lang="scss">
.share {
width: 100%;
height: 100%;
}
.share-box {
width: 100%;
height: 100%;
position: fixed;
top: 0rpx;
left: 0rpx;
bottom: 0rpx;
right: 0rpx;
background-color: rgba(0, 0, 0, 0.4);
transition: .3s;
z-index: 999;
}
// 进入分享动画
.share-show {
transition: all 0.3s ease;
transform: translateY(0%) !important;
}
// 离开分享动画
.share-item {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: auto;
background-color: #FFFFFF;
transition: all 0.3s ease;
transform: translateY(100%);
z-index: 1999;
.share-to {
width: 100%;
height: 3rem;
display: flex;
justify-content: center;
align-items: center;
&::after {
content: '';
width: 240rpx;
height: 0rpx;
border-top: 1px solid #E4E7ED;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
margin-left: 30rpx;
}
&::before {
content: '';
width: 240rpx;
height: 0rpx;
border-top: 1px solid #E4E7ED;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
margin-right: 30rpx;
}
}
.content {
width: 100%;
height: 400rpx;
display: flex;
align-items: center;
flex-direction: column;
.block {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20rpx;
image {
width: 80rpx;
height: 80rpx;
}
text {
margin-top: 16rpx;
font-size: 28rpx;
color: #606266;
}
}
}
.cancel {
width: 100%;
height: 3rem;
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid #E4E7ED;
}
}
</style>
<template>
<view class="custom-component-item">
<!-- <view class="custom-component-item-grid-box" v-if="checkContent.control_type==='7'">
<uni-grid :column="4" @change="change">
<uni-grid-item v-for="(item,i) in checkContent.real_value" :index="i" :key="i">
<view class="custom-component-item-grid-item-box" style="width: 80px;height: 80px;padding: 10px;">
<image :src="item" class="image" style="width: 80px;height: 80px;" />
</view>
</uni-grid-item>
</uni-grid>
</view> -->
<uni-single-select v-if="checkContent.control_type==='6'" :componentContent="checkContent" @selectResult="selectResult"></uni-single-select>
<single-text v-if="checkContent.control_type==='1'" :componentContent="checkContent" @inputFinish="inputFinishSingleText"></single-text>
<multi-text v-if="checkContent.control_type==='2'" :componentContent="checkContent" @inputFinish="inputFinishMultText"></multi-text>
<uni-scan-info v-if="checkContent.control_type==='9'" :componentContent="checkContent" :scanItemList="scanUserList"
@deleteItem="deleteScanUser" @addItem="addScanUser" @dataChange="scanUserInfo"></uni-scan-info>
<uni-scan-single-info v-if="checkContent.control_type==='10'" :componentContent="checkContent" :scanItemList="scanSingleInfoList"
@deleteItem="deleteScanSingleInfo" @addItem="addScanSingleInfo" @dataChange="scanSingleInfo"></uni-scan-single-info>
<multi-input-group v-if="checkContent.control_type==='12'" @dataChange="multiInfoChange" :componentContent="checkContent"></multi-input-group>
</view>
</template>
<!-- -->
<script>
export default {
data() {
return {
componentType: "",
defaultUrl: "../../static/icon_take_photo.png",
scanUserList: [{
"name": "",
"post": "",
"phone": ""
}],
scanSingleInfoList: [""]
};
},
props: {
checkContent: {
type: Object,
default () {
return null
}
},
imageList: {
type: Array,
default () {
return []
}
},
index: {
type: Number,
default () {
return 0
}
}
},
methods: {
change(e) {
console.log(e.detail.index);
let _this = this
uni.chooseImage({
sourceType: ['camera'],
sizeType: ['compressed '],
success: (res) => {
console.log(res)
const temfile = res.tempFilePaths[0]
_this.uploadFile(temfile, e.detail.index)
},
fail: (err) => {
uni.showToast({
title: "拍照失败!",
icon: 'none'
})
}
})
},
uploadFile(temfile, index) {
let _this = this
this.$http.upImg({
imgUrl: temfile
}).then((res) => {
let result = JSON.parse(res.data)
console.log("上传图片", result);
if (result.code === 0) {
console.log(index);
let path = result.data.file_path
let imagePath = ""
if (path) {
let array = path.split("://")
if (array[0] === "http") {
array[0] = "https"
imagePath = array[0] + "://" + array[1]
} else {
imagePath = path
}
}
_this.imageList[index] = imagePath
_this.checkContent.real_value = _this.imageList
console.log(_this.checkContent.real_value);
let isNull = true
for (var i = 0; i < _this.imageList.length; i++) {
let imagePath = _this.imageList[i]
if (imagePath === "" || path === null) {
isNull = false
}
}
_this.checkContent.canSubmit = isNull
_this.changeData()
} else {
uni.showToast({
title: result.msg,
icon: 'none'
})
}
})
},
// 驻厂监理 多信息
multiInfoChange(result) {
if (result.name === "" || result.company === "" || result.phone === "") {
this.checkContent.canSubmit = false
} else {
this.checkContent.canSubmit = true
}
if (this.checkContent.real_value) {
if (this.checkContent.real_value.length === 1) {
this.checkContent.real_value[0] = result
} else {
this.checkContent.real_value.push(result)
}
} else {
this.checkContent.real_value = [result]
}
this.changeData()
},
// 单行文本
inputFinishSingleText(val) {
console.log("单行文本值变化", val);
if (val === "") {
this.checkContent.canSubmit = false
} else {
this.checkContent.canSubmit = true
}
this.checkContent.real_value = [{
"value": val
}]
console.log(this.checkContent);
this.changeData()
},
// 多行文本
inputFinishMultText(val) {
console.log(val);
if (val === "") {
this.checkContent.canSubmit = false
} else {
this.checkContent.canSubmit = true
}
this.checkContent.real_value = [{
"value": val
}]
console.log(this.checkContent);
this.changeData()
},
// 人员扫码
scanUserInfo(e) {
this.checkContent.canSubmit = true
this.scanUserList = e
this.checkContent.real_value = this.scanUserList
this.changeData()
},
deleteScanUser() {
this.scanUserList.pop()
},
addScanUser() {
this.scanUserList.push({
"name": "",
"post": "",
"phone": ""
})
},
// 单选
selectResult(e) {
this.checkContent.canSubmit = true
this.checkContent.real_value = [{
"value": e
}]
this.changeData()
},
// 单信息扫码
scanSingleInfo(e) {
this.checkContent.canSubmit = true
this.scanSingleInfoList = e
this.checkContent.real_value = this.scanSingleInfoList
this.changeData()
},
deleteScanSingleInfo() {
this.scanSingleInfoList.pop()
},
addScanSingleInfo() {
this.scanSingleInfoList.push("")
},
changeData() {
this.$emit("dataChange", this.checkContent, this.index)
}
}
}
</script>
<style>
.custom-component-item-grid-box {
padding: 5px 10px;
}
</style>
<template>
<view class="item-home">
<view class="item-title">{{title}}</view>
<view style="display: flex;flex-direction: row;flex-wrap: wrap;">
<view class="item-content" v-for="(value,i) in content" :key="i">{{value}}</view>
</view>
<view class="line-grey" style="margin-top: 20rpx;"></view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
title: {
type: String,
default: ""
},
content: {
type: String,
default: ""
}
},
created: function() {}
}
</script>
<style>
.item-home {
display: flex;
flex-direction: column;
padding: 16rpx 0rpx;
}
.item-title {
color: #999999;
font-size: 32rpx;
}
.item-content {
margin-top: 10rpx;
color: #333333;
font-size: 32rpx;
}
</style>
<template>
<view>
<view v-if="hasSlot" class="e-picker--text" @tap="show">
<slot />
</view>
<view class="e-picker" :style="{'visibility':pickerVisible?'visible':'hidden'}">
<view class="e-picker-mask" :class="{'e-picker-animation':animation}" :style="{'opacity':pickerVisible?0.6:0}" @tap="_cancel"></view>
<view class="e-picker-container" :class="{'e-picker-container--show':pickerVisible,'e-picker-animation':animation}">
<view class="e-picker-action">
<view class="e-picker-action--cancel" @tap="_cancel">取消</view>
<view class="e-picker-action--confirm" @tap="_confirm">确定</view>
</view>
<picker-view :style="{'height':height+'vh'}" indicator-style="height:40px" :value="value" @change="_change">
<picker-view-column v-for="(k,i) in columns" :key="i" class="e-picker-column">
<view class="e-picker-list-item" v-for="(item,index) in container[k]" :key="index">
{{item+mp[k]}}
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</view>
</template>
<script>
import {
PickerRun,
mp
} from './utils.min.js'
export default {
name: 'ePickerPlus',
data() {
return {
mp,
pickerVisible: false,
value: [],
container: {}
}
},
props: {
mode: {
type: String,
default: 'YMD'
},
animation: {
type: Boolean,
default: true
},
height: {
type: Number,
default: 35
},
initOnOpen: {
type: Boolean,
default: false
},
startRule: String,
endRule: String,
defaultValue: String
},
created() {
this.initPicker()
},
computed: {
hasSlot() {
return !!this.$slots['default']
},
columns() {
return this.mode.split('')
}
},
watch: {
mode() {
this.initPicker()
}
},
methods: {
initPicker() {
this.utils = new PickerRun(this);
this.container = this.utils.initContainer()
this.value = this.utils.getValue()
},
show() {
this.pickerVisible = true
if (this.initOnOpen) this.value = this.utils.getValue(false)
},
_cancel() {
this.$emit('cancel')
this.pickerVisible = false
},
_confirm() {
this.$emit('confirm', this._getResult())
this.pickerVisible = false
},
_getResult() {
const obj = this.utils.value2Obj(this.value, this.container)
const r = {
resultArr: this.utils.obj2Arr(obj),
result: this.utils.obj2DateTime(obj)
}
const wholeTime = this.utils.getWholeTime(obj) //当前选择的时间 所在的完整时间线
const current = this.utils.getLocalTime("YMDhms") //当前系统时间
r.isOverTime = false
if (this.utils.time2Timestamp(current) < this.utils.time2Timestamp(wholeTime)) r.isOverTime = true
if (this.mode === 'YMDhms') r.timestamp = this.utils.time2Timestamp(r.result)
return r
},
_change(e) {
const newValue = e.detail.value
if (this._hasModeStr('D') && (newValue[1] != this.value[1] || newValue[0] != this.value[0])) {
let tmp = this.utils.value2Obj(newValue, this.container)
let startNum = 1
let endNum = this.utils.getDays(tmp['Y'], tmp['M'])
if (this.end) endNum = Number(this.utils.datetime2Obj(this.end)['D'])
if (this.start) startNum = Number(this.utils.datetime2Obj(this.start)['D'])
this.$set(this.container, 'D', this.utils.getColumn(startNum, endNum))
}
this.value = newValue
},
_hasModeStr(str) {
return this.mode.includes(str)
}
}
}
</script>
<style scoped lang="scss">
.e-picker--text {}
.e-picker {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 999;
font-size: 30rpx;
}
.e-picker-container {
position: fixed;
bottom: 0;
transform: translateY(100%);
z-index: 999;
width: 100%;
background-color: #fff;
visibility: hidden;
}
.e-picker-container--show {
transform: translateY(0);
visibility: visible;
}
.e-picker-mask {
z-index: 998;
width: 100%;
height: 100%;
background-color: rgb(0, 0, 0);
}
.e-picker-animation {
transition: all 0.3s;
}
.e-picker-action {
width: 100%;
display: flex;
justify-content: space-between;
padding: 20rpx;
box-sizing: border-box;
position: relative;
font-size: 32rpx;
border-bottom: 0.5px solid #e5e5e5
}
.e-picker-action--cancel {
opacity: .7;
}
.e-picker-action--confirm {
color: #007aff;
}
.e-picker-column {
text-align: center;
border: none
}
.e-picker-list-item {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
}
</style>
'use strict';
var _createClass = function() {
function a(b, c) {
for (var g, f = 0; f < c.length; f++) g = c[f], g.enumerable = g.enumerable || !1, g.configurable = !0, 'value' in g &&
(g.writable = !0), Object.defineProperty(b, g.key, g)
}
return function(b, c, f) {
return c && a(b.prototype, c), f && a(b, f), b
}
}();
Object.defineProperty(exports, '__esModule', {
value: !0
});
function _classCallCheck(a, b) {
if (!(a instanceof b)) throw new TypeError('Cannot call a class as a function')
}
var fmt = function(a) {
return 9 < a ? a : '0' + a
},
isLeapYear = function(a) {
return 0 == a % 4 && 0 != a % 100 || 0 == a % 100 && 0 == a % 400
},
modesDef = {
Y: {
startRule: '2000',
endRule: new Date().getFullYear() + 10 + ''
},
YM: {
startRule: '2000-01',
endRule: new Date().getFullYear() + 10 + '-12'
},
YMD: {
startRule: '2000-01-01',
endRule: new Date().getFullYear() + 10 + '-12-31'
},
YMDh: {
startRule: '2000-01-01 00',
endRule: new Date().getFullYear() + 10 + '-12-31 23'
},
YMDhm: {
startRule: '2000-01-01 00:00',
endRule: new Date().getFullYear() + 10 + '-12-31 23:59'
},
YMDhms: {
startRule: '2000-01-01 00:00:00',
endRule: new Date().getFullYear() + 10 + '-12-31 23:59:59'
},
h: {
startRule: '00',
endRule: '23'
},
m: {
startRule: '00',
endRule: '59'
},
s: {
startRule: '00',
endRule: '59'
},
hm: {
startRule: '00:00',
endRule: '23:59'
},
hms: {
startRule: '00:00:00',
endRule: '23:59:59'
},
ms: {
startRule: '00:00',
endRule: '59:59'
}
},
mp = exports.mp = {
Y: '\u5E74',
M: '\u6708',
D: '\u65E5',
h: '\u65F6',
m: '\u5206',
s: '\u79D2'
},
PickerRun = exports.PickerRun = function() {
function a(b) {
_classCallCheck(this, a);
var c = b.mode,
f = b.startRule,
g = b.endRule,
h = b.defaultValue;
this.mode = c, this.columns = c.split(''), this.firstKey = c[0], this.startRule = f || this.getDefRule('startRule'),
this.endRule = g || this.getDefRule('endRule'), this.defaultValue = h || this.getLocalTime()
}
return _createClass(a, [{
key: 'initContainer',
value: function initContainer() {
var b = {},
c = this.datetime2Obj(this.startRule),
f = this.datetime2Obj(this.endRule),
g = !0,
h = !1,
j = void 0;
try {
for (var n, l = this.columns[Symbol.iterator](); !(g = (n = l.next()).done); g = !0) {
var o = n.value,
p = parseInt(c[o]),
q = parseInt(f[o]);
if ('D' === o) {
var r = this.datetime2Obj(this.defaultValue);
q = this.getDays(r.Y, r.M)
}
b[o] = this.getColumn(p, q)
}
} catch (o) {
h = !0, j = o
} finally {
try {
!g && l.return && l.return()
} finally {
if (h) throw j
}
}
return b
}
}, {
key: 'getValue',
value: function getValue() {
var b = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : !0,
c = this.datetime2Obj(this.defaultValue);
return !1 === b && (c = this.datetime2Obj(this.getLocalTime())), this.obj2Value(this.datetime2Obj(this.startRule),
c)
}
}, {
key: 'getDays',
value: function getDays(b, c) {
var f = [31, isLeapYear(b) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
return f[+c - 1]
}
}, {
key: 'getColumn',
value: function getColumn(b, c) {
for (var f = [], g = b; g <= c; g++) f.push(fmt(g) + '');
return f
}
}, {
key: 'value2Obj',
value: function value2Obj(b, c) {
for (var f = {}, g = 0; g < this.columns.length; g++) f[this.columns[g]] = c[this.columns[g]][b[g]];
return f
}
}, {
key: 'time2Timestamp',
value: function time2Timestamp(b) {
return new Date(b).getTime()
}
}, {
key: 'getLocalTime',
value: function getLocalTime(b) {
var c = new Date,
f = {
Y: '' + c.getFullYear(),
YM: c.getFullYear() + '-' + fmt(c.getMonth() + 1),
YMD: c.getFullYear() + '-' + fmt(c.getMonth() + 1) + '-' + fmt(c.getDate()),
YMDh: c.getFullYear() + '-' + fmt(c.getMonth() + 1) + '-' + fmt(c.getDate()) + ' ' + fmt(c.getHours()),
YMDhm: c.getFullYear() + '-' + fmt(c.getMonth() + 1) + '-' + fmt(c.getDate()) + ' ' + fmt(c.getHours()) + ':' +
fmt(c.getMinutes()),
YMDhms: c.getFullYear() + '-' + fmt(c.getMonth() + 1) + '-' + fmt(c.getDate()) + ' ' + fmt(c.getHours()) +
':' + fmt(c.getMinutes()) + ':' + fmt(c.getSeconds()),
h: fmt(c.getHours()) + ':' + fmt(c.getMinutes()) + ':' + fmt(c.getSeconds()),
hm: fmt(c.getHours()) + ':' + fmt(c.getMinutes()) + ':' + fmt(c.getSeconds()),
hms: fmt(c.getHours()) + ':' + fmt(c.getMinutes()) + ':' + fmt(c.getSeconds()),
m: '' + fmt(c.getMinutes()),
s: '' + fmt(c.getSeconds()),
ms: fmt(c.getMinutes()) + ':' + fmt(c.getSeconds())
};
return b ? f[b] : f[this.mode]
}
}, {
key: 'obj2Arr',
value: function obj2Arr(b) {
var c = [];
for (var f in b) c.push(b[f] + mp[f]);
return c
}
}, {
key: 'obj2Value',
value: function obj2Value(b, c) {
var f = [];
for (var g in c) f.push(+c[g] - +b[g]);
return f
}
}, {
key: 'getDefRule',
value: function getDefRule(b) {
return modesDef[this.mode][b]
}
}, {
key: 'datetime2Obj',
value: function datetime2Obj(b, c) {
var f = this.columns;
c && (f = c);
for (var g = {}, h = b.split(/-|:|\s/), j = 0; j < h.length; j++) g[f[j]] = h[j];
return g
}
}, {
key: 'obj2DateTime',
value: function obj2DateTime(b) {
var c = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : !0,
f = '';
for (var h in b) f += b[h] + mp[h];
var g = f.replace('\u5E74', '-').replace('\u6708', '-').replace('\u65E5', ' ').replace('\u65F6', ':').replace(
'\u5206', ':').replace('\u79D2', '');
return !this.mode.endsWith('s') && c && (g = g.substring(0, g.length - 1)), g
}
}, {
key: 'getWholeTime',
value: function getWholeTime(b) {
var c = this.datetime2Obj(this.getLocalTime('YMDhms'), ['Y', 'M', 'D', 'h', 'm', 's']),
f = {};
for (var g in c) f[g] = b[g] ? b[g] : c[g];
return this.obj2DateTime(f, !1)
}
}]), a
}();
<template>
<view class="gi-root">
<view class="gi-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
<text class="text-blue-normal" @click="connect">扫码连接</text>
</view>
<view style="display: flex;flex-direction: row;align-items: center;margin: 22rpx;">
<input v-model="value" style="min-width: 100rpx;flex: 1;" />
<text class="text-black-normal">{{unit}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
value: "",
deviceId: "4C:24:98:9B:B6:EF",
serviceId: "0000FFB0-0000-1000-8000-00805F9B34FB",
characteristicId: "0000FFB2-0000-1000-8000-00805F9B34FB"
};
},
props: {
isMust: {
type: Boolean,
default: false
},
title: {
type: String,
default: "蓝牙设备"
},
unit: {
type: String,
default: "mm"
}
},
methods: {
connect: function() {
//蓝牙权限
uni.openBluetoothAdapter({
success: (res) => {
console.log("蓝牙已打开");
// this.scanConnect()
this.connectBle(this.deviceId)
},
fail: (res) => {
console.log("蓝牙打开失败");
uni.showToast({
icon: 'none',
title: '查看蓝牙是否打开'
})
}
})
},
scanConnect: function() {
uni.scanCode({
success: (res) => {
console.log(res.result);
this.connectBle()
},
fail: (error) => {
uni.showToast({
title: "二维码识别失败",
icon: 'none'
})
}
})
},
connectBle: function(deviceId) {
uni.createBLEConnection({
deviceId: deviceId,
success: (res) => {
uni.showToast({
title: "设备连接成功",
icon: 'none'
})
this.getBLEDeviceServices()
},
fail: (res) => {
uni.showToast({
title: "设备连接失败",
icon: 'none'
})
}
})
},
//获取蓝牙的所有服务
getBLEDeviceServices: function() {
setTimeout(() => {
uni.getBLEDeviceServices({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: this.deviceId,
success: (res) => {
console.log('device services:', res)
res.services.forEach((item) => {
console.log(item.uuid)
// 这里获取回调,读取成功就的值就会在这个地方接收到!!!
})
uni.onBLECharacteristicValueChange((res) => {
console.log("接收到数据", res.value)
//res.value是ArrayBuffer类型的,官方给了一个方法转16进制,我们再进行操作
// this.shiliu = this.ab2hex(res.value)
let vals = ""
let bytes = new Int8Array(res.value)
for (var i = 0; i < bytes.length; i++) {
if (i < 5) {
// let charCode = parseInt(bytes[i], 16)
// console.log("十进制", charCode);
console.log(String.fromCharCode(bytes[i]));
vals += String.fromCharCode(bytes[i])
}
}
this.value = vals
})
this.getBLEDeviceCharacteristics()
}
})
}, 1000)
},
byteToASCII: function(value) {
let result = new String(value, "ascii")
// value.forEach((item) => {
// if (item.charCodeAt() >= 32 && item.charCodeAt() < 127) {
// result += item
// } else {
// result += item & 0xFF
// }
// })
console.log(result);
return result
},
//获取蓝牙特征
getBLEDeviceCharacteristics: function() {
setTimeout(() => {
uni.getBLEDeviceCharacteristics({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: this.deviceId,
// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
serviceId: this.serviceId,
success: (res) => {
console.log(res, '特征getBLEDeviceCharacteristics')
this.characteristics = res.characteristics
console.log(this.characteristics)
//循环所有的uuid
res.characteristics.forEach((item) => {
console.log('characteristicId:', item.uuid)
//利用传参的形势传给下面的notify,这里的uuid如果都需要用到,就不用做判断了,建议使用setTimeout进行间隔性的调用此方法
})
uni.notifyBLECharacteristicValueChange({
deviceId: this.deviceId,
serviceId: this.serviceId,
characteristicId: this.characteristicId,
state: true,
success: (res) => {
console.log("监听成功", res);
},
fail: (res) => {
console.log("监听失败", res);
}
})
},
fail: (res) => {
console.log(res)
}
})
}, 1000)
},
// notifyBLECharacteristicValueChange: function(uuid) {
// uni.onBLECharacteristicValueChange(function(result) {
// console.log("收到数据", result);
// })
// }
}
}
</script>
<style>
</style>
<!-- 处理逻辑和其他流程不同 -->
<template>
<view>
<gi-input></gi-input>
</view>
</template>
<script>
export default {
name: "gi-business-group",
data() {
return {
};
},
props: {
}
}
</script>
<style>
</style>
<template>
<view class="gi-root">
<gi-title class="gi-title" :title="item.content_name"></gi-title>
<view class="selece-area-parent" @click="toSelect">
<view class="text-grey">{{value}}</view>
<image src="../../static/ic_arrow_left.png" style="width: 14rpx;height: 26rpx;"></image>
</view>
</view>
</template>
<script>
export default {
name: "gi-business-select",
data() {
return {
};
},
props: {
item: {
type: Object,
default () {
return {}
}
},
value: {
type: String,
default: "选择业务数据"
},
title: {
type: String,
default: "无标题"
},
config: {
type: Object,
default () {
return {}
}
},
index: {
type: Number,
default: -1
},
project_id: {
type: String,
default: ""
}
},
methods: {
toSelect: function() {
let sourceData = JSON.stringify(this.item)
uni.navigateTo({
url: `../../pages/add-solder-page/add-solder-page?ent_data_id=${this.item.control_cfg.business_ent_data_id}&project_id=${this.project_id}&index=${this.index}`
})
}
}
}
</script>
<style>
.selece-area-parent {
display: flex;
flex-direction: row;
justify-content: space-between;
margin: 20rpx 10rpx;
}
</style>
<template>
<view class="gi-root">
<gi-title :title="item.content_name" class="gi-title" :isMust="item.validate_type==1"></gi-title>
<text class="text-black-normal" style="margin-top: 20rpx;">{{item.real_value[0]||""}}</text>
<view class="line-grey" style="margin-top: 20rpx;"></view>
</view>
</template>
<script>
export default {
name: "gi-common-data-fixed",
data() {
return {
};
},
props: {
item: {
type: Object,
default () {
return {
content_name: "标题",
real_value: "不可修改值"
}
}
}
}
}
</script>
<style>
</style>
<template>
<view class="gi-root">
<gi-title :title="item.content_name" class="gi-title" :isMust="item.validate_type==1"></gi-title>
<input v-model="inputValue" class="input-style" @input="inputChange" />
<view class="line-grey" style="margin-top: 20rpx;"></view>
</view>
</template>
<script>
export default {
name: "gi-common-data-fixed",
data() {
return {
inputValue: ""
};
},
props: {
item: {
type: Object,
default () {
return {
content_name: "标题",
real_value: [{
"value": ""
}]
}
}
},
index: {
type: Number,
default: -1
}
},
created() {
if (this.item.real_value && this.item.real_value.length > 0) {
if (this.item.real_value[0] && this.item.real_value[0] != null) {
this.inputValue = this.item.real_value[0].value
}
}
},
watch: {
item(newVal, oldVal) {
if (newVal.real_value && newVal.real_value.length > 0) {
if (newVal.real_value[0] && newVal.real_value[0] != null) {
this.inputValue = newVal.real_value[0].value
}
}
}
},
methods: {
inputChange: function() {
this.$emit("inputChange", this.inputValue, this.index)
}
}
}
</script>
<style>
.input-style {
margin-top: 20rpx;
font-size: 32rpx;
color: #333333;
}
</style>
<template>
<view style="display: flex;flex-direction: column;padding: 32rpx 32rpx 20rpx 10rpx;background-color: #FFFFFF;">
<view style="display: flex;flex-direction: row;align-items: center;">
<text class="star" v-if="component.validate_type==1">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{component.content_name}}</text>
<image src="../../static/add-ic.png" class="image-add" v-if="component.is_copy==1" @click="addItem"></image>
</view>
<view v-for="(item,i) in childrens" :key="i">
<view style="display: flex;flex-direction: row;align-items: center;padding: 32rpx 0 0 22rpx;">
<view class="text-blue-normal" style="flex: 1;" @click="groupClick(i)">查看详情</view>
<view class="text-grey-black-normal">{{item.status||"未填写"}}</view>
<image src="../../static/close-ic.png" class="image-add" style="margin-left: 32rpx;" v-if="component.is_copy==1"
@click="deleteItem(i)"></image>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
tempComponent: [],
childrens: []
};
},
props: {
status: {
type: String,
default: "未填写"
},
index: {
type: Number,
default: -1
},
component: {
type: Object,
default () {
return {}
}
}
},
created: function() {
this.tempComponent = this.component.control_children[0]
this.childrens = this.component.control_children
},
watch: {
component(newVal, oldVal) {
this.childrens = this.component.control_children
}
},
methods: {
groupClick: function(i) {
let form = JSON.stringify(this.component)
uni.navigateTo({
url: `../component-group-page/component-group-page?form=${form}&index=${this.index}&childIndex=${i}`
})
},
addItem: function() {
this.childrens.push(this.tempComponent)
this.$emit("groupChange", this.index, this.childrens)
},
deleteItem: function(i) {
this.childrens.splice(i, 1)
}
}
}
</script>
<style>
</style>
<template>
<view style="display: flex;flex-direction: column;padding: 32rpx 32rpx 20rpx 10rpx;background-color: #FFFFFF;">
<view style="display: flex;flex-direction: row;align-items: center;">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
</view>
<view style="display: flex;flex-direction: row;align-items: center;padding: 20rpx 0 0 22rpx;" @click="computeClick">
<view class="text-black-normal" style="flex: 1;">实得分数</view>
<view class="text-grey-black-normal">{{form.real_value[0].real_value}}</view>
<image src="../../static/ic_arrow_left.png" style="width: 20rpx;height: 30rpx;margin-left: 32rpx;"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
isMust: {
type: Boolean,
default: true
},
title: {
type: String,
default: "计分控件"
},
form: {
type: Object,
default () {
return {}
}
},
index: {
type: Number,
default: -1
},
isGroup: {
type: Number,
default: 0
}
},
methods: {
computeClick: function() {
let form = JSON.stringify(this.form)
uni.navigateTo({
url: `../gi-compute-page/gi-compute-page?form=${form}&index=${this.index}&type=${this.isGroup}`
})
},
}
}
</script>
<style>
</style>
<template>
<view style="display: flex;flex-direction: column;background-color: #FFFFFF;margin-top: 20rpx;">
<gi-title :isMust="item.validate_type==1" :title="item.content_name"></gi-title>
<view style="display: flex;flex-direction: row;align-items: center;">
<input style="height: 90rpx;padding-left: 10rpx;flex: 1;" v-model="value" @blur="blur" type="text"
placeholder="请输入" maxlength="-1" />
<view class="text-blue-normal" @click="saveData" style="white-space: nowrap;">记忆</view>
<view class="text-grey-black-normal" @click="selectData" style="margin-left: 20rpx;">使用记忆</view>
<image src="../../static/right-arrow-ic.png" @click="selectData"
style="width: 20rpx;height: 32rpx;margin-left: 10rpx;margin-right: 32rpx;"></image>
</view>
</view>
</template>
<script>
export default {
name: "gi-custom-data",
props: {
selectValue: {
type: String,
default: ""
},
item: {
type: Object,
default () {
return {}
}
},
index: {
type: Number,
default: -1
},
project_id: {
type: String,
default: ""
}
},
data() {
return {
value: "",
isSelect: false
};
},
created() {
this.value = this.selectValue
if (this.item.control_cfg.show_default_value == 1) {
let before = uni.getStorageSync(this.item.content_id)
console.log("上次选择", before);
if (before && before != "") {
this.value = before
let data = {
index: this.index,
value: this.value
}
this.$emit("inputFinish", data)
}
}
},
watch: {
selectValue(newVal, oldVal) {
console.log("数据变化", newVal);
this.value = newVal
}
},
methods: {
selectData() {
uni.navigateTo({
url: `../../pages/select-common-data-page/select-common-data-page?field_code=${this.item.content_code}&data_range_type=${this.item.control_cfg.data_range_type}&index=${this.index}&project_id=${this.project_id}&content_id=${this.item.content_id}`
})
},
saveData() {
if (this.value == "") {
this.$toast.showToast("请输入内容")
return
}
let data = {
index: this.index,
value: this.value
}
let rela_id = ""
if (this.item.control_cfg.data_range_type == 1) {
rela_id = "0"
} else if (this.item.control_cfg.data_range_type == 2) {
rela_id = uni.getStorageSync("company_id")
} else if (this.item.control_cfg.data_range_type == 3) {
rela_id = this.project_id
} else if (this.item.control_cfg.data_range_type == 4) {
let userInfo = uni.getStorageSync("user_info")
rela_id = userInfo.user_id
}
this.$http.post({
url: "/api/v1/common_check/custom_control/save",
data: {
field_code: this.item.content_code,
field_value: this.value,
data_range_type: this.item.control_cfg.data_range_type,
rela_id: rela_id
},
header: {
"access_token": this.getToken()
}
}).then((res) => {
let result = res.data
console.log("保存成功", result);
if (result.code != 0) {
this.$toast.showToast(result.msg)
} else {
this.$toast.showToast("记忆成功")
}
})
},
blur(e) {
if (this.value == "") {
return
}
let data = {
index: this.index,
value: this.value
}
uni.setStorageSync(this.item.content_id, this.value)
this.$emit("inputFinish", data)
}
}
}
</script>
<style>
</style>
<template>
<view class="group-detail-home">
<view class="normal-text-grey">{{item.content_name}}</view>
<view v-for="(childItem,childIndex) in item.control_children" :key="childIndex">
<view v-for="(child,m) in childItem.list" :key="m">
<view class="group-detail-item" v-if="child.control_type==16">
<view class="normal-text-grey">{{child.content_name}}</view>
<view v-if="child.control_cfg.value_type==2" class="content-text">
{{child.control_cfg.textVal}}
</view>
<view v-else>
<view v-if="!child.real_value">未填写</view>
<view v-for="(value,i) in child.real_value" :key="i" class="content-text" v-else>
{{value||"未填写"}}
</view>
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==17">
<view class="normal-text-grey">{{child.content_name}}</view>
<view v-if="child.control_cfg.value_type==2"
style="color: #333333;font-size: 32rpx;padding: 20rpx 0;display: flex;flex-wrap: wrap;">
{{child.control_cfg.textVal}}
</view>
<view v-else>
<view v-if="!child.real_value">未填写</view>
<view v-for="(value,i) in child.real_value" :key="i"
style="color: #333333;font-size: 32rpx;padding: 20rpx 0;display: flex;flex-wrap: wrap;"
v-else>
{{value||"未填写"}}
</view>
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==18">
<view class="normal-text-grey">{{child.content_name}}</view>
<view v-for="(value,i) in child.real_value" :key="i" class="content-text">
{{value||"未填写"}}
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==19">
<view class="normal-text-grey">{{child.content_name}}</view>
<view class="content-text" v-if="child.control_cfg.date_type==1">
{{child.real_value[0]||"未填写"}}
</view>
<view class="content-text" v-if="child.control_cfg.date_type==2">
{{child.real_value[0]||""}}——{{child.real_value[1]||""}}
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==20">
<view class="normal-text-grey">{{child.content_name}}</view>
<view v-for="(value,i) in child.real_value" :key="i"
style="color: #333333;font-size: 32rpx;padding: 20rpx 0;flex-direction: row;">
<text class="text-black-normal">{{value.value}}</text>
<text class="text-black-normal" v-if="!(i==child.real_value.length-1)">,</text>
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==21">
<view class="normal-text-grey">{{child.content_name}}</view>
<view style="display: flex;flex-direction: row;">
<view v-for="(value,i) in child.real_value" :key="i"
style="color: #333333;font-size: 32rpx;padding: 20rpx 0;flex-direction: row;">
<text class="text-black-normal">{{value.value}}</text>
<text class="text-black-normal" v-if="!(i==child.real_value.length-1)">,</text>
</view>
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==22">
<view class="normal-text-grey">{{child.content_name}}</view>
<view style="display: flex;flex-direction: column;" v-if="child.real_value">
<uni-grid :column="4" v-if="child.control_cfg.up_type==2">
<uni-grid-item v-for="(image,k) in child.real_value" :key="k" :index="k">
<image style="width: 144rpx;height: 144rpx;margin: 20rpx;" :src="image"
@click="imageClick(child,k)"></image>
</uni-grid-item>
</uni-grid>
<view style="display: flex;flex-direction: column;padding: 32rpx 0 0 32rpx;"
v-if="child.control_cfg.up_type==1">
<view class="gi-upload-file-item" v-for="(file,k) in child.real_value" :key="k">
<image src="../../static/doc-icon.png" style="width: 80rpx;height: 80rpx;">
</image>
<view class="gi-file-info-item" @click="fileClick(child,k)">
<text class="text-black-normal">{{file.name}}</text>
<text class="text-grey" style="margin-top: 10rpx;">{{file.size}}</text>
</view>
</view>
</view>
<uni-grid :column="4" v-if="item.control_cfg.up_type==4">
<uni-grid-item v-for="(video,k) in item.real_value" :key="k" :index="k">
<view class="uni-upload-image">
<view class="video-item" @click="videoItem(video)">
<image :src='video.url+"?x-oss-process=video/snapshot,t_700,w_600,h_600,m_fast"'
style="width: 144rpx;height: 144rpx;"></image>
</view>
</view>
</uni-grid-item>
</uni-grid>
<uni-grid :column="4" v-if="item.control_cfg.up_type==5">
<uni-grid-item v-for="(audio,k) in item.real_value" :key="k" :index="k">
<view class="uni-upload-image">
<view class="record-item" @click="playAudio(audio,k,m)">
<image src="../../static/record-ic.png" style="width: 48rpx;height: 48rpx;">
</image>
<view class="text-grey">{{audio.time}}</view>
</view>
</view>
</uni-grid-item>
</uni-grid>
</view>
<view v-else>未上传内容</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==24">
<view class="item-parent">
{{child.control_cfg.content}}
</view>
<view class="margin-top-line"></view>
</view>
<view class="group-detail-item" v-if="child.control_type==25">
<view class="normal-text-grey">{{child.content_name}}</view>
<view style="display: flex;flex-direction: row;align-items: center;padding: 20rpx 0 0 0rpx;">
<view class="text-black-normal" style="flex: 1;">应得分数</view>
<view class="text-grey-black-normal">{{child.real_value[0].real_value}}</view>
</view>
<view class="margin-top-line"></view>
</view>
<detail-text-item :title="item.content_name" :content="item.real_value"
v-if="item.control_type==23||item.control_type==27"></detail-text-item>
</view>
</view>
</view>
</template>
<script>
export default {
name: "gi-group-detail",
data() {
return {
curIndex: -1,
playIndex: -1
};
},
props: {
item: {
type: Object,
default () {
return {}
}
}
},
methods: {
imageClick: function(item, index) {
uni.previewImage({
current: index,
urls: item.real_value
})
},
playAudio: function(audio, k, index, m) {
const innerAudioContext = uni.createInnerAudioContext();
if (this.playIndex == index && index == this.curIndex) {
innerAudioContext.stop()
this.playIndex = -1
this.curIndex = -1
} else {
innerAudioContext.stop()
innerAudioContext.play()
this.playIndex = index
this.curIndex = index
innerAudioContext.src = audio.url;
}
innerAudioContext.onPlay((res) => {
console.log('开始播放', res);
});
innerAudioContext.onPause(function() {
console.log('暂停播放');
});
innerAudioContext.onEnded(function() {
console.log('播放结束');
});
innerAudioContext.onTimeUpdate(() => {});
innerAudioContext.onError((res) => {
console.log(res.errMsg);
console.log(res.errCode);
uni.showToast({
icon: 'none',
title: res.errMsg
})
});
},
fileClick: function(item, index) {
uni.downloadFile({
url: item.real_value[index].url,
success: (res) => {
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath, //临时路径
success: function(res) {
uni.showToast({
icon: 'none',
mask: true,
title: '文件已保存:' + res.savedFilePath, //保存路径
duration: 3000,
});
setTimeout(() => {
//打开文档查看
uni.openDocument({
filePath: res.savedFilePath,
success: function(res) {
// console.log('打开文档成功');
}
});
}, 1000)
}
});
}
}
})
},
videoItem: function(video) {
uni.navigateTo({
url: `../../pages/play-video-page/play-video-page?url=${video.url}`
})
},
}
}
</script>
<style>
.group-detail-home {
display: flex;
flex-direction: column;
padding: 16rpx 32rpx 0 32rpx;
background-color: #FFFFFF;
margin: 20rpx 0;
}
.group-detail-item {
display: flex;
padding: 16rpx 0;
flex-direction: column;
}
.content-text {
color: #333333;
font-size: 32rpx;
padding: 20rpx 0;
display: flex;
flex-wrap: wrap;
}
</style>
<template>
<view class="gi-root">
<view style="display: flex;flex-direction: row;">
<view v-for="(image,index) in images" :key="index" @click="imageClick(index)">
<image :src="image" :style="{'width':width,'height': height,'margin':'10rpx'}"></image>
</view>
</view>
</view>
</template>
<script>
export default {
name: "gi-image",
data() {
return {
width: "200rpx",
height: "200rpx"
};
},
props: {
images: {
type: Array,
default () {
return []
}
}
},
created: function() {
this.computeWidth()
},
watch: {
images: function(newVal, oldVal) {
this.computeWidth()
}
},
methods: {
computeWidth: function() {
if (this.images.length > 2) {
this.width = "220rpx"
} else if (this.images.length == 2) {
this.width = "350rpx"
} else {
this.width = "700rpx"
}
},
imageClick: function(index) {
uni.previewImage({
urls: this.images,
current: index
})
}
}
}
</script>
<style>
</style>
<template>
<view class="model-view" :style="showModal?'':'display:none;'">
<view class="model-out-box">
<view style="display: flex;flex-direction: row;align-items: center;width: 100%;">
<view class="text-black-normal">输入密码</view>
</view>
<view style="display: flex;flex-direction: row;width: 100%;align-items: center;">
<text class="text-black-normal">密码</text>
<input placeholder="输入密码" v-model="password" :type="type"
style="margin-left: 32rpx;border: 2rpx solid #999999;padding: 20rpx;" />
</view>
<view style="display: flex;flex-direction: row;width: 100%;justify-content: center;">
<view class="btn-dialog-grey" @click="cancel">取消</view>
<view class="btn-dialog-blue" @click="sure">确定</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: "gi-input-modal",
data() {
return {
password: "",
};
},
created() {
this.isShow = this.showModal
},
props: {
showModal: {
type: Boolean,
default: false
},
type: {
type: String,
default: "password"
}
},
methods: {
cancel: function() {
this.$emit("cancel")
},
sure: function() {
this.$emit("sure", this.password)
}
}
}
</script>
<style>
.model-view {
position: fixed;
top: 0;
z-index: 999;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
}
.model-out-box {
width: 600rpx;
height: 400rpx;
background-color: #FFFFFF;
border-radius: 20rpx;
margin-top: 45%;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 32rpx;
align-items: center;
}
.btn-dialog-grey {
display: flex;
width: 200rpx;
height: 80rpx;
font-size: 32rpx;
color: #333333;
align-items: center;
border: 2rpx solid rgba(0, 0, 0, 0.1);
border-radius: 8rpx;
justify-content: center;
}
.btn-dialog-blue {
display: flex;
width: 200rpx;
height: 80rpx;
font-size: 32rpx;
color: #FFFFFF;
background-color: #1890FF;
border-radius: 8rpx;
margin-left: 32rpx;
border: 2rpx solid rgba(0, 0, 0, 0.1);
align-items: center;
justify-content: center;
}
</style>
<!-- 单行文本 -->
<!-- 配置:自由值和固定值 -->
<!-- 自由值:
校验分三种:不校验、手机号、身份证号
字符长度:下限和上限
允许增添:关闭和开启
固定值:写死不可编辑-->
<template>
<view class="gi-input-parent">
<view class="gi-input-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
<image src="../../static/add-ic.png" class="image-add" v-if="isArray" @click="addItem"></image>
</view>
<!-- 自由值 -->
<view style="display: flex;flex-direction: column;" v-if="cfg.value_type==1">
<view class="gi-input-item" v-for="(item,index) in values" :key="index" :index="index">
<view style="display: flex;flex-direction: row;">
<input :placeholder="placeText" placeholder-style="gi-input-placeholder" class="gi-input" @blur="inputFinish" :id="index"
:type="inputType" :value="item" auto-blur="true" @input="inputValue" />
<image src="../../static/close-ic.png" class="image-add" v-if="isArray" @click="deleteItem(index)"></image>
</view>
<view :class="[isTrues[index]?'line-grey':'line-red']" style="margin-top: 20rpx;"></view>
</view>
</view>
<!-- 固定值 -->
<view class="gi-input-text" style="padding-left: 22rpx;" v-else>{{cfg.textVal}}</view>
</view>
</template>
<script>
export default {
data() {
return {
placeText: "请输入",
validType: "no", //默认不校验
values: [""],
cfg: {},
isTrues: [true],
maxlength: 255,
minLength: 0,
isArray: false,
inputType: 'text'
};
},
props: {
title: {
type: String,
default: "标题"
},
index: {
type: Number,
default: -1
},
isMust: {
type: Boolean,
default: true
},
config: {
type: Object,
default () {
return {}
}
},
vals: {
type: Array,
default () {
return [""]
}
},
isCopy: {
type: String,
default: "0"
}
},
created: function() {
this.cfg = this.config
if (this.vals && this.vals.length > 0) {
this.values = this.vals
for (var i = 0; i < this.vals.length; i++) {
this.isTrues.push(true)
}
}
//校验
if (this.config.content_valid_type) {
this.validType = this.config.content_valid_type
if (this.validType == 'phone') {
this.placeText = "请输入手机号"
this.inputType = 'number'
} else if (this.validType == 'id_card') {
this.placeText = "请输入身份证号"
this.inputType = 'idcard'
}
}
//字符长度
this.minLength = parseInt(this.config.min)
this.maxlength = parseInt(this.config.max)
//是否数组
this.isArray = this.isCopy ? this.isCopy == '1' : this.config.is_copy == "1"
},
methods: {
addItem() {
this.values.push("")
this.isTrues.push(true)
console.log(this.values);
},
deleteItem(index) {
console.log(index);
this.values.splice(index, 1)
this.isTrues.splice(index, 1)
console.log(this.values);
this.$emit("inputChange", this.index, this.values)
},
inputValue: function(e) {
let value = e.detail.value
console.log(value);
let indexId = e.target.id
//校验类型
if (this.validType == 'phone') {
if (value.length == 11) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else if (value.length > 11) {
return value.substring(0, 11)
} else {
// this.$set(this.isTrues, indexId, false)
// uni.showToast({
// title: "请输入正确的手机号",
// icon: 'none'
// })
}
} else if (this.validType == 'id_card') {
if (value.length == 15 || value.length == 18) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else if (value.length > 18) {
return value.substring(0, 18)
} else {
// this.$set(this.isTrues, indexId, false)
// uni.showToast({
// title: "请输入正确的身份证号",
// icon: 'none'
// })
}
} else {
if (value.length >= this.minLength && value.length <= this.maxlength) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else if (value.length < this.minLength) {
// this.$set(this.isTrues, indexId, false)
// uni.showToast({
// title: `请输入${this.minLength}到${this.maxlength}内容`,
// icon: 'none'
// })
// this.$emit("inputChange", this.index, this.values)
} else if (value.length > this.maxlength) {
value = value.substring(0, this.maxlength)
}
}
return value
},
inputFinish(e) {
console.log(e);
let value = e.detail.value
let indexId = e.target.id
//校验类型
if (this.validType == 'phone') {
if (value.length == 11) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else {
this.$set(this.isTrues, indexId, false)
uni.showToast({
title: "请输入正确的手机号",
icon: 'none'
})
}
} else if (this.validType == 'id_card') {
if (value.length == 15 || value.length == 18) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else {
this.$set(this.isTrues, indexId, false)
uni.showToast({
title: "请输入正确的手机号",
icon: 'none'
})
}
} else {
if (value.length >= this.minLength && value.length <= this.maxlength) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else {
this.$set(this.isTrues, indexId, false)
uni.showToast({
title: `请输入${this.minLength}${this.maxlength}内容`,
icon: 'none'
})
this.$emit("inputChange", this.index, this.values)
}
}
}
}
}
</script>
<style>
.gi-input-parent {
display: flex;
flex-direction: column;
background-color: #FFF;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.gi-input-title {
display: flex;
align-items: center;
flex-direction: row;
}
.gi-input-placeholder {
font-size: 30rpx;
color: #999999;
}
.gi-input-item {
margin-top: 32rpx;
padding-left: 22rpx;
color: #333333;
display: flex;
flex-direction: column;
}
.gi-input {
font-size: 32rpx;
flex: 1;
color: #333333;
}
.gi-input-text {
margin-top: 32rpx;
font-size: 32rpx;
flex: 1;
color: #333333;
}
.line-red {
height: 2rpx;
background-color: #FF0000;
}
</style>
<!-- 标签选择器
选择类型:单选多选
-->
<template>
<view class="gi-label-select-parent">
<view class="gi-label-select-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
</view>
<view style="display: flex;flex-direction: row;flex-wrap: wrap;margin-top: 20rpx;">
<view v-for="(item,index) in datas" :key="index" :index="index" @click="clickItem(index)">
<view class="gi-label-item-select" v-if="item.isSelect">{{item.value}}</view>
<view class="gi-label-item" v-else>{{item.value}}</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
datas: [],
selects: [],
length: 1
};
},
props: {
title: {
type: String,
default: "标题"
},
index: {
type: Number,
default: -1
},
config: {
type: Object,
default () {
return {}
}
},
selected: {
type: Array,
default () {
return []
}
},
isMust: {
type: Boolean,
default: true
}
},
created: function() {
this.selects = this.selected
this.datas = this.config.labels
for (var i = 0; i < this.datas.length; i++) {
this.datas[i].isSelect = false
}
this.length = parseInt(this.config.select_type)
console.log(this.selected);
this.initStatus()
},
methods: {
initStatus: function() {
for (var i = 0; i < this.datas.length; i++) {
let isSelect = false
for (var j = 0; j < this.selected.length; j++) {
if (this.selected[j].key == this.datas[i].key) {
isSelect = true
}
}
this.datas[i].isSelect = isSelect
this.$set(this.datas, i, this.datas[i])
}
},
clickItem: function(index) {
if (this.length == 1) {
for (var i = 0; i < this.datas.length; i++) {
if (i == index) {
this.datas[index].isSelect = !this.datas[index].isSelect
} else {
this.datas[i].isSelect = false
}
this.$set(this.datas, i, this.datas[i])
}
} else {
this.datas[index].isSelect = !this.datas[index].isSelect
this.$set(this.datas, index, this.datas[index])
}
this.selects = []
for (var i = 0; i < this.datas.length; i++) {
if (this.datas[i].isSelect) {
this.selects.push(this.datas[i])
}
}
this.$emit("change", this.index, this.selects)
}
}
}
</script>
<style lang="scss">
.gi-label-select-parent {
display: flex;
flex-direction: column;
flex-wrap: wrap;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.gi-label-select-title {
display: flex;
align-items: center;
flex-direction: row;
}
.gi-label-item {
display: inline-block;
margin: 10rpx 0rpx 10rpx 22rpx;
border: 2rpx solid #BFBFBF;
padding: 10rpx 32rpx;
border-radius: 36rpx;
font-size: 28rpx;
color: #333333;
}
.gi-label-item-select {
display: inline-block;
margin: 10rpx 0rpx 10rpx 22rpx;
border: 2rpx solid #1890FF;
color: #1890FF;
padding: 10rpx 32rpx;
border-radius: 36rpx;
font-size: 28rpx;
}
</style>
<template>
<view class="gi-root">
<gi-title isMust="true" :title="title"></gi-title>
<view class="gi-location-content" v-if="type==3">
<input class="text-black-normal" style="flex-wrap: wrap;flex: 1;" v-model="address" />
</view>
<view class="gi-location-content" v-else>
<view class="text-black-normal" style="flex-wrap: wrap;flex: 1;">{{address}}</view>
<view class="text-blue-normal" style="margin-left: 20rpx;" @click="getSetting">获取位置</view>
</view>
</view>
</template>
<script>
import qqmapsdk from "../../common/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js"
export default {
data() {
return {
address: "",
type: 2
};
},
props: {
config: {
type: Object,
default () {
return {}
}
},
value: {
type: String,
default: ""
},
index: {
type: Number,
default: -1
},
title: {
type: String,
default: "获取位置"
}
},
created: function() {
this.type = this.config.location_way
if (this.value) {
this.address = this.value
}
},
methods: {
chooseLocation: function() {
uni.chooseLocation({
success: (res) => {
console.log("选择成功", res);
this.address = res.address
this.$emit("change", this.index, this.address)
},
fail: (res) => {
console.log("选择失败", res);
}
})
},
//是否授权
getSetting: function() {
const that = this
uni.getSetting({
success(res) {
console.log(res)
if (res.authSetting['scope.userLocation']) {
if (that.type == 1) {
that.chooseLocation()
} else if (that.type == 2) {
that.getLocation()
}
} else {
that.getAuthorize()
}
}
})
},
// 获取用户的地理位置,
getLocation: function() {
const that = this
uni.getLocation({
type: 'gcj02',
altitude: true,
success(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
const QQMapWX = new qqmapsdk({
//填写自己申请的Key
key: 'XJ6BZ-FDYK4-3ETUM-XWJNJ-VQUVS-GQBYJ'
});
// 解析地址
QQMapWX.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success: (res) => {
//定位成功
console.log("当前位置", res.result.address);
that.address = res.result.address
that.$emit("change", that.index, that.address)
},
fail: function(res) {
console.log(res);
uni.showToast({
title: res.message,
duration: 2000,
icon: "none",
})
},
})
}
})
},
// 用户授权
getAuthorize: function() {
const that = this
uni.authorize({
scope: 'scope.userLocation',
success(res) {
that.getLocation()
},
// 授权失败
fail(err) {
uni.showModal({
title: '提示',
showCancel: false,
confirmText: '确认授权',
success() {
uni.openSetting({
success(res) {
console.log(res)
},
fail(err) {
console.log(err)
}
})
}
})
}
})
}
}
}
</script>
<style>
.gi-location-content {
display: flex;
flex-direction: row;
align-items: center;
margin: 22rpx;
}
</style>
<template>
<view>
<gi-title :isMust="isMust" :title="title"></gi-title>
<view class="item-content" @click="toSelcet">
<view class="item-text">
<text v-for="(item,index) in realValue" :key="index">
{{item.name}}
</text>
</view>
<image src="../../static/right-arrow-ic.png" style="width: 40rpx;height: 60rpx;"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
index: {
type: Number,
default: -1
},
title: {
type: String,
default: "多级选择"
},
isMust: {
type: Boolean,
default: false
},
config: {
type: Object,
default () {
return {}
}
},
realValue: {
type: Array,
default () {
return []
}
},
item: {
type: Object,
default () {
return {}
}
}
},
created() {
if (this.config.show_default_value == 1) {
let before = uni.getStorageSync(this.item.content_id)
this.realValue = JSON.parse(before)
}
},
methods: {
toSelcet: function() {
uni.navigateTo({
url: `../../pages/multi-level-select-page/multi-level-select-page?index=${this.index}&url=${this.config.data_origin_url}&options=${this.config.cascadeOptions}&content_id=${this.item.content_id}`
})
}
}
}
</script>
<style>
.item-content {
display: flex;
padding: 32rpx 22rpx;
flex-direction: row;
align-items: center;
}
.item-text {
flex: 1;
display: flex;
flex-direction: row;
flex-wrap: wrap;
font-size: 32rpx;
color: #333333;
}
</style>
<template>
<view class="gi-note-parent">
<image :src="item.control_cfg.content_img" style="width: 100%;height: 200rpx;"
v-if="item.control_cfg.note_value_type==2"></image>
<text v-else>{{item.control_cfg.content}}</text>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
value: {
type: String,
default: "注释说明"
},
image: {
type: String,
default: ""
},
note_value_type: {
type: Number,
default: 1
},
item: {
type: Object,
default () {
return {}
}
}
},
methods: {
}
}
</script>
<style>
.gi-note-parent {
display: flex;
flex-direction: row;
padding: 32rpx;
background-color: #F5F5F5;
color: #666666;
font-size: 28rpx;
}
</style>
<!-- 数字框
保留小数位数和是否增添-->
<template>
<view class="gi-number-input-parent">
<view class="gi-number-input-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
<image src="../../static/add-ic.png" class="image-add" v-if="isArray" @click="addItem"></image>
</view>
<view style="display: flex;flex-direction: column;">
<view class="gi-number-input-item" v-for="(item,index) in values" :key="index" :index="index">
<view style="display: flex;flex-direction: row;">
<input :placeholder="placeText" placeholder-style="gi-number-input-placeholder" class="gi-number-input" @blur="inputFinish"
@focus="getFocus" :id="index" type="digit" :value="item" auto-blur="true" @input="inputValue" />
<image src="../../static/close-ic.png" class="image-add" v-if="isArray" @click="deleteItem(index)"></image>
</view>
<view class="line-grey" style="margin-top: 20rpx;"></view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
placeText: "请输入",
values: [""],
cfg: {},
isTrues: [true],
num: 0,
isArray: false,
};
},
props: {
title: {
type: String,
default: "标题"
},
index: {
type: Number,
default: -1
},
isMust: {
type: Boolean,
default: true
},
config: {
type: Object,
default () {
return {}
}
},
realValue: {
type: Array,
default () {
return [""]
}
},
isCopy: {
type: String,
default: "0"
}
},
created: function() {
this.cfg = this.config
if (this.realValue && this.realValue.length > 0) {
this.values = this.realValue
}
//校验
this.num = parseInt(this.config.float_num)
this.placeText = `请输入数字(保留${this.num}位小数)`
//是否数组
this.isArray = this.isCopy ? this.isCopy == '1' : this.config.is_copy == "1"
},
methods: {
getFocus: function(e) {
console.log("获取焦点", e);
},
addItem() {
this.values.push("")
this.isTrues.push(true)
console.log(this.values);
},
deleteItem(index) {
console.log(index);
this.values.splice(index, 1)
this.isTrues.splice(index, 1)
console.log(this.values);
this.$emit("inputChange", this.index, this.values)
},
inputValue: function(e) {
console.log(e);
let indexId = parseInt(e.target.id)
let value = e.detail.value
if (this.num == 0) {
if (value.indexOf('.') != -1) {
value = value.substring(0, value.length - 1)
return value
}
}
if (value && value.indexOf('.') != -1) {
let arr = value.split('.')
if (arr.length == 2) {
if (arr[1].length > this.num) {
value = `${arr[0]}.${arr[1].substring(0,this.num)}`
uni.showToast({
title: `最多输入${this.num}位小数`,
icon: 'none'
})
}
} else if (arr.length >= 2) {
uni.showToast({
title: `最多输入${this.num}位小数`,
icon: 'none'
})
if (arr[1].length > this.num) {
value = `${arr[0]}.${arr[1].substring(0,this.num)}`
} else {
value = `${arr[0]}.${arr[1]}`
}
}
}
return value
},
inputFinish: function(e) {
console.log(e);
let value = e.detail.value
let indexId = e.target.id
if (value && value.indexOf('.') != -1) {
let arr = value.split('.')
if (arr.length == 2) {
if (arr[1].length > this.num) {
value = `${arr[0]}.${arr[1].substring(0,this.num)}`
}
} else if (arr.length >= 2) {
if (arr[1].length > this.num) {
value = `${arr[0]}.${arr[1].substring(0,this.num)}`
} else {
value = `${arr[0]}.${arr[1]}`
}
}
}
this.$set(this.values, indexId, value)
this.$emit("inputChange", this.index, this.values)
}
}
}
</script>
<style>
.gi-number-input-parent {
display: flex;
flex-direction: column;
background-color: #FFF;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.gi-number-input-title {
display: flex;
align-items: center;
flex-direction: row;
}
.gi-number-input-placeholder {
font-size: 30rpx;
color: #999999;
}
.gi-number-input-item {
margin-top: 32rpx;
padding-left: 22rpx;
color: #333333;
display: flex;
flex-direction: column;
}
.gi-number-input {
font-size: 32rpx;
flex: 1;
color: #333333;
}
.gi-number-input-text {
margin-top: 32rpx;
font-size: 32rpx;
flex: 1;
color: #333333;
}
</style>
<!-- 扫码控件
类型:人员码 条形码
是否允许增添-->
<template>
<view class="gi-scan-parent">
<view class="gi-input-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
<image src="../../static/add-ic.png" class="image-add" v-if="isArray" @click="addItem"></image>
</view>
<view v-for="(item,index) in values" :key="index" class="gi-scan-item">
<view style="display: flex;flex-direction: row;align-items: center;">
<image src="../../static/icon_scan.png" style="width: 40rpx;height: 40rpx;" @click="scan(index)"></image>
<view class="text-black-normal" style="margin-left: 20rpx;flex: 1;">{{item}}</view>
<image src="../../static/close-ic.png" style="width: 40rpx;height: 40rpx;" @click="deleteItem(index)"></image>
</view>
<view class="line-grey" style="margin-top: 20rpx;"></view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
values: [],
type: 1 //1人员扫码 2条码
};
},
props: {
title: {
type: String,
default: "标题"
},
index: {
type: Number,
default: -1
},
isMust: {
type: Boolean,
default: true
},
config: {
type: Object,
default () {
return {}
}
}
},
methods: {
addItem: function() {
this.values.push("")
},
deleteItem: function(index) {
console.log(index);
this.values.splice(index, 1)
console.log(this.values);
this.$emit("scanChange", this.index, this.values)
},
scan: function(index) {
let that = this
uni.scanCode({
success: (res) => {
console.log(res.result);
if (that.type == 1) {
let userId = res.result
that.scanInfo(index, userId)
} else {
that.values[index] = res.result
this.$emit("scanChange", that.index, that.values)
}
},
fail: (error) => {
uni.showToast({
title: "二维码识别失败",
icon: 'none'
})
}
})
},
scanInfo(userId, index) {
this.$http.consoleGet({
url: "/api/v1/user/user/get_detail",
data: {
"user_id": userId
},
header: {
"access_token": uni.getStorageSync("access_token"),
"Content-Type": "application/x-www-form-urlencoded"
}
}).then((res) => {
console.log(res.data.data);
let info = {}
this.values[index] = info
this.$emit("dataChange", this.scanItemList)
})
},
}
}
</script>
<style>
.gi-scan-item {
display: flex;
flex-direction: column;
padding-left: 22rpx;
margin-top: 32rpx;
}
</style>
<template>
<view class="gi-search-parent">
<input :placeholder="'请输入'+placeholder" v-model="value" style="flex: 1;" />
<image src="../../static/search-icon.png" style="width: 40rpx;height: 40rpx;" @click="search"></image>
</view>
</template>
<script>
export default {
name: "gi-search",
data() {
return {
value: ""
};
},
props: {
placeholder: {
type: String,
default: "请输入"
},
index: {
type: Number,
default: -1
},
val: {
type: String,
default: ""
}
},
created: function() {
this.value = this.val
},
methods: {
search: function() {
this.$emit("search", this.index, this.value)
}
}
}
</script>
<style>
.gi-search-parent {
display: flex;
flex-direction: row;
align-items: center;
border: 2rpx solid #c0c4cc;
margin: 16rpx 64rpx 16rpx 40rpx;
padding: 24rpx 32rpx;
border-radius: 5rpx;
}
</style>
<template>
<view class="gi-select-user-parent">
<gi-title :isMust="isMust" :title="title"></gi-title>
<view class="item-content" @click="toSelcet">
<view class="item-text">
<text v-for="(item,index) in realValue" :key="index">
{{item.user_name}},
</text>
</view>
<image src="../../static/right-arrow-ic.png" style="width: 20rpx;height: 30rpx;"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
index: {
type: Number,
default: -1
},
title: {
type: String,
default: "人员选择"
},
isMust: {
type: Boolean,
default: false
},
config: {
type: Object,
default () {
return {}
}
},
realValue: {
type: Array,
default () {
return []
}
},
projectId: {
type: String,
default: ""
},
selectPost: {
type: Array,
default () {
return []
}
}
},
created() {
console.log(this.projectId);
},
methods: {
toSelcet: function() {
uni.navigateTo({
url: `../select-user-page/select-user-page?selected=${JSON.stringify(this.realValue)}&type=0&project_id=${this.projectId}&index=${this.index}&user_way=${this.config.user_way}&selectPost=${JSON.stringify(this.selectPost)}`
})
}
}
}
</script>
<style>
.gi-select-user-parent {
display: flex;
flex-direction: column;
background-color: #FFF;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.item-content {
display: flex;
padding: 32rpx 22rpx;
flex-direction: row;
align-items: center;
}
.item-text {
flex: 1;
display: flex;
flex-direction: row;
flex-wrap: wrap;
font-size: 32rpx;
color: #333333;
}
</style>
<template>
<view class="gi-sign-parent">
<view class="gi-title" style="margin-bottom: 32rpx;">
<text class="star" v-if="item.validate_type==1">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{item.content_name}}</text>
<text class="text-blue-normal" @click="toSign" v-if="isEdit">开始签名</text>
</view>
<image :src="signUrl" style="height: 400rpx;width: 100%;" v-if="signUrl!=''"></image>
<gi-input-modal :showModal="showModal" @cancel="cancel" @sure="sure" :type="'password'"></gi-input-modal>
</view>
</template>
<script>
export default {
name: "gi-sign",
data() {
return {
content: "您还未设置签名,请前往【我的】进行签名设置",
showModal: false,
signUrl: ""
};
},
props: {
item: {
type: Object,
default () {
return {}
}
},
index: {
type: Number,
default: -1
},
isEdit: {
type: Boolean,
default: true
}
},
created: function() {
this.signUrl = this.item.real_value
},
methods: {
getSign: function(password) {
this.$http.consoleGet({
url: "/api/v1/system/p_user_system/get_cur_sign",
data: {
"sign_pwd": password
},
header: {
"access_token": this.getToken()
}
}).then((res) => {
let result = res.data
console.log("签名信息:", result);
if (result.code == 0) {
if (result.data.is_sign == 0) { //未设置签名
this.noSign()
} else {
this.signUrl = result.data.sign_url
this.$emit("signChange", this.index, this.signUrl)
}
} else if (result.code == 33201) { //已设置签名需要密码
this.showModal = true
} else {
uni.showToast({
title: result.msg,
icon: 'none'
})
}
})
},
toSign: function() {
this.getSign("")
},
noSign: function() {
uni.showModal({
title: "签名",
content: this.content,
cancelText: "取消",
confirmText: "去设置",
showCancel: true,
confirmColor: '#1890FF',
success: res => {
if (res.confirm) {
uni.navigateTo({
url: "../../pages/sign-edit-page/sign-edit-page"
})
}
}
})
},
cancel: function() {
this.showModal = false
},
sure: function(e) {
this.showModal = false
this.getSign(e)
}
}
}
</script>
<style>
.gi-sign-parent {
display: flex;
background-color: #FFFFFF;
flex-direction: column;
flex-wrap: wrap;
padding: 32rpx 32rpx 0rpx 0rpx;
}
</style>
<template>
<view style="padding: 10rpx 20rpx;background-color: #FFFFFF;">
<gi-title title="签到二维码"></gi-title>
<image src="../../static/qrcode-ic.png" style="width: 96rpx;height: 96rpx;margin-top: 10px;"
@click="showQrcode">
</image>
<view style="display: flex;flex-direction: column;" v-if="record_id!=''">
<view style="margin-top: 10px;">签到人员</view>
<view style="display: flex;flex-direction: row;flex-wrap: wrap;">
<view v-for="(item,index) in users" :key="index">
<view class="sign-user-style">
{{item.value}}
</view>
</view>
</view>
</view>
<view class="model-view" :style="showModal?'':'display:none;'">
<view class="model-out-box">
<view class="text-black-normal">{{curTitle}}</view>
<view class="model-content">
<canvas canvas-id="qrcode" style="margin: 40rpx;"></canvas>
</view>
<view style="display: flex;flex-direction: row;width: 100%;">
<view class="btn-dialog-grey" @click="cancel">取消</view>
<view class="btn-dialog-blue" @click="saveQrcode">保存到本地</view>
</view>
</view>
</view>
</view>
</template>
<script>
import uQRCode from "../../common/Sansnn-uQRCode/uqrcode.js"
export default {
name: "gi-signin",
props: {
record_id: {
type: String,
default: ""
},
users: {
type: Array,
default () {
return [{
"value": "张三五"
}, {
"value": "李四六"
}]
}
}
},
data() {
return {
showModal: false,
};
},
methods: {
showQrcode(index) {
if (this.record_id == "") {
this.$toast.showToast("请先提交表单生成二维码")
return
}
this.showModal = true
this.$nextTick(function() {
this.cancvsQrcode(this.record_id)
})
},
cancvsQrcode(text) {
uQRCode.make({
canvasId: 'qrcode',
componentInstance: this,
text: text,
size: 160,
margin: 10,
backgroundColor: '#ffffff',
foregroundColor: '#000000',
fileType: 'jpg',
correctLevel: uQRCode.errorCorrectLevel.H,
success: res => {
console.log(res)
this.qrcodeSrc = res
},
fail: error => {
console.log(error)
}
})
},
cancel() {
this.curTitle = ""
this.curIndex = -1
this.showModal = false
},
saveQrcode() {
// #ifndef H5
this.save(this.qrcodeSrc)
// #endif
// #ifdef H5
let _t = this;
uni.downloadFile({
url: this.qrcodeSrc,
success: (res) => {
if (res.statusCode === 200) {
let file = res.tempFilePath;
_t.save(file)
}
}
});
// #endif
},
save(url) {
let _this = this;
console.log(url);
uni.saveImageToPhotosAlbum({
filePath: url,
success: () => {
uni.hideLoading();
uni.showToast({
title: "图片已保存到相册"
});
},
fail: () => {
uni.hideLoading();
uni.showToast({
title: "图片保存失败"
});
}
});
}
}
}
</script>
<style>
.model-view {
position: fixed;
top: 0;
z-index: 1;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
background-color: rgba(0, 0, 0, 0.4);
}
.model-out-box {
width: 600rpx;
height: 600rpx;
background-color: #FFFFFF;
border-radius: 20rpx;
margin-top: 45%;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 32rpx 0 0 0;
align-items: center;
}
.model-content {
width: 400rpx;
height: 400rpx;
border-radius: 10rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
}
.btn-dialog-grey {
display: flex;
flex: 1;
height: 100rpx;
font-size: 32rpx;
color: #333333;
align-items: center;
border-top: 2rpx solid rgba(0, 0, 0, 0.1);
border-right: 2rpx solid rgba(0, 0, 0, 0.1);
justify-content: center;
}
.btn-dialog-blue {
display: flex;
flex: 1;
height: 100rpx;
font-size: 32rpx;
color: #1890FF;
border-top: 2rpx solid rgba(0, 0, 0, 0.1);
align-items: center;
justify-content: center;
}
.sign-user-style {
width: 160rpx;
height: 40px;
border: 1px solid #E5E5E5;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
margin: 10px;
}
</style>
<template>
<view>
<!-- 图片上传 -->
<gi-upload v-if="item.control_type==22&&item.control_cfg.up_type!=5" :title="item.content_name"
:isMust="item.validate_type==1" :index="index" :config="item.control_cfg" @change="fileChange"
:realValue="item.real_value">
</gi-upload>
<gi-record v-if="item.control_type==22&&item.control_cfg.up_type==5" :title="item.content_name"
:isMust="item.validate_type==1" :index="index" :config="item.control_cfg" @change="audioChange"
:realValue="item.real_value" @addAudio="addAudio" :state="recordSate"></gi-record>
<!-- 时间选择控件 -->
<gi-time-select v-if="item.control_type==19" :title="item.content_name" :isMust="item.validate_type==1"
:index="index" :config="item.control_cfg" @change="timeChange" :realValue="item.real_value">
</gi-time-select>
<!-- 下拉控件 -->
<gi-select v-if="item.control_type==21" :title="item.content_name" :isMust="item.validate_type==1"
:project_id="projectId" :index="index" :config="item.control_cfg" @change="selectChange"
:selected="item.real_value">
</gi-select>
</view>
</template>
<script>
export default {
name: "gi-solder-business",
data() {
return {
};
},
props: {
item: {
type: Object,
default () {
return {}
}
},
index: {
type: Number,
default: -1
}
}
}
</script>
<style>
</style>
<!-- 多行文本
与单行的不同之处 少一个是否校验字段-->
<template>
<view class="gi-textarea-parent">
<view class="gi-textarea-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
<image src="../../static/add-ic.png" class="image-add" v-if="isArray" @click="addItem"></image>
</view>
<view style="display: flex;flex-direction: column;" v-if="cfg.value_type==1">
<view class="gi-textarea-item" v-for="(item,index) in values" :key="index" :index="index">
<view style="display: flex;flex-direction: row;">
<textarea :placeholder="placeText" placeholder-style="gi-textarea-placeholder" class="gi-textarea" @blur="inputFinish"
:id="index" :type="inputType" :value="item" auto-blur="true" @input="inputValue" />
<image src="../../static/close-ic.png" class="image-add" v-if="isArray" @click="deleteItem(index)"></image>
</view>
<view :class="[isTrues[index]?'line-grey':'line-red']" style="margin-top: 20rpx;"></view>
</view>
</view>
<view class="gi-textarea-text" style="padding-left: 22rpx;" v-else>{{cfg.textVal}}</view>
</view>
</template>
<script>
export default {
data() {
return {
placeText: "请输入",
values: [""],
cfg: {},
isTrues: [true],
maxlength: 255,
minLength: 0,
isArray: false,
inputType: 'text'
};
},
props: {
title: {
type: String,
default: "标题"
},
index: {
type: Number,
default: -1
},
isMust: {
type: Boolean,
default: true
},
config: {
type: Object,
default () {
return {}
}
},
vals: {
type: Array,
default () {
return [""]
}
},
isCopy: {
type: String,
default: "0"
}
},
created: function() {
this.cfg = this.config
if(this.vals&&this.vals.length>0){
this.values=this.vals
for (var i = 0; i < this.vals.length; i++) {
this.isTrues.push(true)
}
}
//校验
this.validType = this.config.content_valid_type
if (this.validType == 'phone') {
this.placeText = "请输入手机号"
} else if (this.validType == 'id_card') {
this.placeText = "请输入身份证号"
}
//字符长度
this.minLength = parseInt(this.config.min)
this.maxlength = parseInt(this.config.max)
//是否数组
this.isArray = this.isCopy ? this.isCopy == '1' : this.config.is_copy == "1"
},
methods: {
addItem:function() {
this.values.push("")
this.isTrues.push(true)
console.log(this.values);
},
deleteItem:function(index) {
console.log(index);
this.values.splice(index, 1)
this.isTrues.splice(index, 1)
console.log(this.values);
this.$emit("inputChange", this.index, this.values)
},
inputValue:function(e){
let value = e.detail.value
let indexId = e.target.id
if (value.length >= this.minLength && value.length <= this.maxlength) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else if (value.length < this.minLength) {
this.$set(this.isTrues, indexId, false)
uni.showToast({
title: `请输入${this.minLength}${this.maxlength}内容`,
icon: 'none'
})
this.$emit("inputChange", this.index, this.values)
} else if (value.length > this.maxlength) {
value = value.substring(0, this.maxlength)
}
return value
},
inputFinish:function(e) {
console.log(e);
let value = e.detail.value
let indexId = e.target.id
//校验类型
if (value.length >= this.minLength && value.length <= this.maxlength) {
this.$set(this.isTrues, indexId, true)
this.$set(this.values, indexId, e.detail.value)
this.$emit("inputChange", this.index, this.values)
} else {
this.$set(this.isTrues, indexId, false)
uni.showToast({
title: `请输入${this.minLength}${this.maxlength}内容`,
icon: 'none'
})
this.$emit("inputChange", this.index, this.values)
}
}
}
}
</script>
<style>
.gi-textarea-parent {
display: flex;
flex-direction: column;
background-color: #FFF;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.gi-textarea-title {
display: flex;
align-items: center;
flex-direction: row;
}
.gi-textarea-placeholder {
font-size: 30rpx;
color: #999999;
}
.gi-textarea-item {
margin-top: 32rpx;
padding-left: 22rpx;
color: #333333;
display: flex;
flex-direction: column;
}
.gi-textarea {
font-size: 32rpx;
flex: 1;
color: #333333;
}
.gi-textarea-text {
margin-top: 32rpx;
font-size: 32rpx;
flex: 1;
color: #333333;
}
</style>
<!-- 时间选择框
是否有跨度
时间类型,例如:1年月,2年月日,3年月日时分,4年月日时分秒,5时分秒-->
<template>
<view class="gi-time-select-parent">
<view class="gi-input-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
</view>
<view class="gi-select-time" v-if="cfg.date_type==2">
<view style="flex: 1;display: flex;align-items: center;justify-content: center;font-size: 28rpx;"
@click="selectStartTime">{{startTime}}</view>
<view style="width: 40rpx;height: 2rpx;background-color: #BFBFBF;"></view>
<view
style="flex: 1;margin-left: 20rpx;display: flex;align-items: center;justify-content: center;font-size: 28rpx;"
@click="selectEndTime">{{endTime}}</view>
</view>
<view class="gi-select-time" v-else>
<view style="flex: 1;">{{selectTime}}</view>
<view style="color: #1890FF;" @click="selectTimeShow">请选择时间</view>
</view>
<e-picker-plus ref="picker" @confirm="confirm" :startRule="startRule" :endRule="endRule" :mode="mode" />
</view>
</template>
<script>
export default {
data() {
return {
values: [],
startTime: "开始时间",
endTime: "结束时间",
selectTime: "",
startRule: "",
endRule: "",
timeType: 3,
mode: "YMD",
cfg: {},
isCurrentTime: false
};
},
created: function() {
this.cfg = this.config
let dateFmt = this.config.date_fmt
if (dateFmt == 1) {
this.mode = "YM"
} else if (dateFmt == 2) {
this.mode = "YMD"
} else if (dateFmt == 3) {
this.mode = "YMDhm"
} else if (dateFmt == 4) {
this.mode = "YMDhms"
} else if (dateFmt == 5) {
this.mode = "hms"
}
this.initTime(dateFmt)
if (this.cfg.date_type == 2) {
if (this.realValue && this.realValue.length == 2) {
this.startTime = this.realValue[0]
this.endTime = this.realValue[1]
}
} else if (this.cfg.date_type == 1) {
if (this.realValue && this.realValue.length == 1) {
this.selectTime = this.realValue[0]
}
}
},
props: {
title: {
type: String,
default: "标题"
},
config: {
type: Object,
default () {
return {}
}
},
isMust: {
type: Boolean,
default: false
},
index: {
type: Number,
default: -1
},
realValue: {
type: Array,
default () {
return []
}
}
},
methods: {
initTime: function(dateFmt) {
this.isCurrentTime = this.cfg.is_current_time == 1
if (this.isCurrentTime) {
this.startTime = this.getCurrentTime(dateFmt)
this.endTime = this.getCurrentTime(dateFmt)
this.selectTime = this.getCurrentTime(dateFmt)
if (this.cfg.date_type == 2) {
this.values.push(this.startTime)
this.values.push(this.endTime)
} else if (this.cfg.date_type == 1) {
this.values.push(this.selectTime)
}
this.$emit("change", this.index, this.values)
}
},
getCurrentTime: function(mode) {
var date = new Date()
let year = date.getFullYear()
let month = date.getMonth() + 1
month = month < 10 ? "0" + month : month
let day = date.getDate()
day = day < 10 ? "0" + day : day
let hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours()
let minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()
let second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()
if (mode == 1) {
return `${year}-${month}`
} else if (mode == 2) {
return `${year}-${month}-${day}`
} else if (mode == 3) {
return `${year}-${month}-${day} ${hour}:${minute}`
} else if (mode == 4) {
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
} else if (mode == 5) {
return `${hour}:${minute}:${second}`
} else {
return ""
}
},
selectTimeShow() {
this.timeType = 3
this.$refs.picker.show()
},
selectStartTime() {
this.timeType = 1
this.$refs.picker.show()
},
selectEndTime() {
this.timeType = 2
this.$refs.picker.show()
},
compairTime(time1, time2) {
let start = new Date(time1)
let end = new Date(time2)
return start.getTime() > end.getTime()
},
confirm(e) {
if (this.timeType == 1) {
if (this.endTime !== "结束时间") {
if (this.compairTime(e.result, this.endTime)) {
this.startTime = this.endTime
uni.showToast({
title: "开始时间不能大于结束时间",
icon: 'none'
})
} else {
this.startTime = e.result
}
} else {
this.startTime = e.result
}
} else if (this.timeType == 2) {
if (this.startTime !== "开始时间") {
if (this.compairTime(this.startTime, e.result)) {
this.endTime = this.startTime
uni.showToast({
title: "结束时间不能小于开始时间",
icon: 'none'
})
} else {
this.endTime = e.result
}
} else {
this.endTime = e.result
}
} else if (this.timeType == 3) {
this.selectTime = e.result
}
console.log(this.selectTime);
this.values = []
if (this.config.date_type == 2) {
if (this.startTime != "开始时间" && this.endTime != "结束时间") {
this.values.push(this.startTime)
this.values.push(this.endTime)
}
} else {
if (this.selectTime != "请选择时间") {
this.values.push(this.selectTime)
}
}
console.log(this.values);
this.$emit("change", this.index, this.values)
},
}
}
</script>
<style>
.gi-time-select-parent {
display: flex;
flex-direction: column;
background-color: #FFF;
padding: 32rpx 32rpx 0rpx 10rpx;
}
.gi-select-time {
display: flex;
flex-direction: row;
align-items: center;
padding: 32rpx 0 20rpx 22rpx;
}
</style>
<template>
<view class="gi-title">
<text class="star" v-if="isMust">*</text>
<text class="text-black-normal" style="margin-left: 10rpx;flex: 1;">{{title}}</text>
</view>
</template>
<script>
export default {
data() {
return {
};
},
props: {
isMust: {
type: Boolean,
default: false
},
title: {
type: String,
default: "标题"
}
}
}
</script>
<style>
</style>
<template>
<view style="padding: 32rpx;">
<view style="display: flex;flex-direction: row;">
<view class="weather-left">
<text class="text-white">上午</text>
<text class="text-yellow">{{amWeather.temp||26}}</text>
<view class="weather-item">
<image src="../../static/weather-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">天气</text>
<text class="text-white">{{amWeather.weather}}</text>
</view>
<view class="weather-item">
<image src="../../static/wind-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">风向</text>
<text class="text-white">{{amWeather.winddirect}}</text>
</view>
<view class="weather-item">
<image src="../../static/wind2-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">风力</text>
<text class="text-white">{{amWeather.windpower}}</text>
</view>
</view>
<view class="weather-right">
<text class="text-white">下午</text>
<text class="text-yellow">{{pmWeather.temp||26}}</text>
<view class="weather-item">
<image src="../../static/weather-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">天气</text>
<text class="text-white">{{pmWeather.weather}}</text>
</view>
<view class="weather-item">
<image src="../../static/wind-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">风向</text>
<text class="text-white">{{pmWeather.winddirect}}</text>
</view>
<view class="weather-item">
<image src="../../static/wind2-ic.png" class="weather-image"></image>
<text class="text-white" style="flex: 1;margin-left: 20rpx;">风力</text>
<text class="text-white">{{pmWeather.windpower}}</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: "gi-weather",
data() {
return {
amWeather: {},
pmWeather: {},
weather: {}
};
},
props: {
index: {
type: Number,
default: -1
},
real_value: {
type: Array,
default () {
return []
}
}
},
created: function() {
if (this.real_value && this.real_value.length > 0) {
this.amWeather = this.real_value[0].am
this.pmWeather = this.real_value[0].pm
} else {
this.getWeather()
}
},
methods: {
getWeather: function() {
this.$http.get({
url: "/api/v1/weather/get_weather",
header: {
access_token: this.getToken()
}
}).then((res) => {
let result = res.data
console.log("天气", result);
let hourWeather = result.data.result.hourly
this.weather = result.data.result
let hour = this.getCurrentHour()
if (hour < 12) {
this.amWeather = hourWeather[hour - 1]
this.pmWeather = hourWeather[13]
this.amWeather.temp = this.weather.temp
} else {
this.amWeather = hourWeather[10]
this.pmWeather = hourWeather[hour - 1]
this.pmWeather.temp = this.weather.temp
}
this.amWeather.winddirect = this.weather.winddirect
this.pmWeather.winddirect = this.weather.winddirect
this.amWeather.windpower = this.weather.windpower
this.pmWeather.windpower = this.weather.windpower
let values = [{
"am": this.amWeather,
"pm": this.pmWeather
}]
this.$emit("change", this.index, values)
})
},
getCurrentHour: function() {
let date = new Date()
let hour = date.getHours()
console.log("当前小时:", hour);
return hour
}
}
}
</script>
<style>
.weather-left {
display: flex;
flex: 1;
flex-direction: column;
background-color: #08143A;
border-radius: 10rpx;
padding: 20rpx;
}
.weather-right {
display: flex;
flex: 1;
flex-direction: column;
margin-left: 20rpx;
background-color: #1890FF;
border-radius: 10rpx;
padding: 20rpx;
}
.text-white {
font-size: 28rpx;
color: #FFFFFF;
}
.text-yellow {
font-size: 64rpx;
color: #FFAD0B;
}
.weather-image {
width: 40rpx;
height: 40rpx;
}
.weather-item {
display: flex;
flex-direction: row;
margin-top: 10rpx;
align-items: center;
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment