diff --git a/app.json b/app.json index 1c2fbc7..5feb4cc 100644 --- a/app.json +++ b/app.json @@ -77,5 +77,6 @@ "usingComponents": { "cu-custom": "/colorui/components/cu-custom" }, + "workers": "workers", "sitemapLocation": "sitemap.json" } diff --git a/client/formate.wxs b/client/formate.wxs new file mode 100644 index 0000000..934e432 --- /dev/null +++ b/client/formate.wxs @@ -0,0 +1,139 @@ +function isEmpty(val) { + return typeof val === 'undefined' || val === '' || val === null +} + +function formatTime(time) { + if (isEmpty(time)) { + return '' + } + var minute = 60 * 1000 + var just = 3 * 60 * 1000 + var onehour = 60 * 60 * 1000 + var oneday = 24 * 60 * 60 * 1000 + time = time.replace(getRegExp('/\s/g', 'g'), '') + var datetime = getDate(time.trim()) + var gap = getDate().getTime() - datetime.getTime() + + if (gap > oneday) { + return time.substring(0, 10) + } else if (gap > onehour) { + return parseInt(gap / onehour) + '小时前' + } else if (gap > onehour) { + return parseInt(gap / onehour) + '小时前' + } else if (gap > just) { + return parseInt(gap / minute) + '分钟前' + } else { + return '刚刚更新' + } +} + +function formateDate(datetime) { + if (isEmpty(datetime)) { + return '' + } + var date = getDate(datetime.trim()) + var today = getDate() + var dayCode = 24 * 60 * 60 * 1000 + var week = '' + if (date.getTime() === today.getTime()) { + week = '(今天)' + } else if (date.getTime() === today.getTime() + dayCode) { + week = '(明天)' + } else if (date.getTime() === today.getTime() - dayCode) { + week = '(昨天)' + } else if (date.getTime() === today.getTime() + dayCode * 2) { + week = '(后天)' + } else { + week = ['(周日)', '(周一)', '(周二)', '(周三)', '(周四)', '(周五)', '(周六)'][date.getDay()] + } + if (isEmpty(week)) { + week = '' + } + return datetime + week +} + +function formateAmount(amount, fix) { + if (isEmpty(amount)) { + return '' + } + if(!fix){ + fix = 3 + } + return Number(amount).toFixed(fix) +} + +function formateWeight(weight) { + return (parseFloat(weight) / 1000).toFixed(1) +} + +function formatePrice(weight) { + return (parseFloat(weight) * 1000).toFixed(0) +} + +function maxWeight(fweight, sweight) { + if(fweight && sweight){ + if(fweight > sweight){ + return fweight + } + return sweight + } + if(sweight){ + return sweight + } + return '- -' +} + +function minWeight(fweight, sweight) { + if(fweight && sweight){ + if(fweight < sweight){ + return fweight + } + return sweight + } + if(fweight){ + return fweight + } + return '- -' +} + +function numberFormat (value) { + if (value || value == 0) { + return Number(value).toFixed(2) + } + return '' +} + +function substring(str, start, end){ + if(str){ + return str.substring(start, end) + } + return '' +} + +function formateDrice (value) { + if (value || value == 0) { + return (parseFloat(value) * 1000).toFixed(0) + } + return '- -' +} + +function formateDescripe (value) { + if (typeof(value) == 'number') { + return value + '%' + } + return '- -' +} + +module.exports = { + numberFormat: numberFormat, + formateAmount: formateAmount, + formatePrice: formatePrice, + formateWeight: formateWeight, + formatTime: formatTime, + formateDate: formateDate, + maxWeight: maxWeight, + minWeight: minWeight, + substring: substring, + formateDescripe: formateDescripe, + formateDrice: formateDrice +} \ No newline at end of file diff --git a/client/home/index.wxml b/client/home/index.wxml index ae1181d..ef7266c 100644 --- a/client/home/index.wxml +++ b/client/home/index.wxml @@ -1,4 +1,4 @@ - + 我的 diff --git a/client/workbench/index.wxml b/client/workbench/index.wxml index b9baed7..1d62515 100644 --- a/client/workbench/index.wxml +++ b/client/workbench/index.wxml @@ -1,5 +1,5 @@ - + 工作台 diff --git a/pages/login/index.js b/pages/login/index.js index 401c315..9b1c0f5 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -97,9 +97,18 @@ Page({ if(factoryId){ app.userInfo.factoryId = factoryId } else { - const enterpriseInfo = app.userInfo.enterpriseInfos[app.userInfo.enterpriseInfos.length - 1] - if(enterpriseInfo.factoryInfos && enterpriseInfo.factoryInfos.length){ - factoryId = enterpriseInfo.factoryInfos[enterpriseInfo.factoryInfos.length - 1].factoryId + for (let mIndex = app.userInfo.enterpriseInfos.length - 1; mIndex >= 0; mIndex--) { + if(factoryId){ + break + } + const element = app.userInfo.enterpriseInfos[mIndex] + for (let nIndex = element.factoryInfos.length - 1; nIndex >= 0; nIndex--) { + const item = element.factoryInfos[nIndex] + if(item.factoryId){ + factoryId = item.factoryId + break + } + } } app.userInfo.factoryId = factoryId } @@ -385,9 +394,8 @@ Page({ return } this.setData({loging: true}) - if(this.data.metaData.qrPage == 'page/inde/ztbsaas/yaoqing'){ + if(this.data.metaData.qrPage == '/page/index/ztbsaas/yaoqing'){ // 绑定企业主账号 - // var param = {joiningEnterprisePublicInvitationId: this.data.metaData.enterpriseId, userName: this.data.metaData.userName} bindAccount(this.data.metaData).then(result => { this.data.metaData = null this.fetchUserInfo(app.globalData.token) diff --git a/pages/login/index.wxml b/pages/login/index.wxml index 195ed0a..a274a13 100644 --- a/pages/login/index.wxml +++ b/pages/login/index.wxml @@ -12,7 +12,7 @@ 现邀请您成为{{metaData.factoryName}}的员工 - + 现邀请您成为{{metaData.name}}的管理员 diff --git a/pages/process/index/index.js b/pages/process/index/index.js index d55940b..88c46ff 100644 --- a/pages/process/index/index.js +++ b/pages/process/index/index.js @@ -1,8 +1,8 @@ // pages/index/index.js -import Dialog from '../../../components/dialog/dialog' import { getStatisticsInfo } from "../../../api/saas" import util from '../../../utils/util' const event = require('../../../utils/event') +// const worker = wx.createWorker('/workers/process.js') const app = getApp() Component({ @@ -79,6 +79,11 @@ Component({ } else { this.setData({userInfo: app.userInfo, height, minDate, maxDate, vdate, vdateString }) } + // worker.postMessage({ x : 10, y : 2 }) + // worker.onMessage(function(res){ + // console.log('这是主线程打印的') + // console.log(res) + // }) wx.hideLoading() } this.data.firstShow = true