Browse Source

no message

feature/v1.6
xpz2018 4 years ago
parent
commit
88ad99ec6e
7 changed files with 162 additions and 9 deletions
  1. 1
      app.json
  2. 139
      client/formate.wxs
  3. 2
      client/home/index.wxml
  4. 2
      client/workbench/index.wxml
  5. 18
      pages/login/index.js
  6. 2
      pages/login/index.wxml
  7. 7
      pages/process/index/index.js

1
app.json

@ -77,5 +77,6 @@
"usingComponents": {
"cu-custom": "/colorui/components/cu-custom"
},
"workers": "workers",
"sitemapLocation": "sitemap.json"
}

139
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
}

2
client/home/index.wxml

@ -1,4 +1,4 @@
<wxs module="formate" src="../../formate.wxs"></wxs>
<wxs module="formate" src="../formate.wxs"></wxs>
<cu-custom bgColor="bg-white" isBack="{{false}}">
<view slot="content" style="color:black;font-size:18px">我的</view>
</cu-custom>

2
client/workbench/index.wxml

@ -1,5 +1,5 @@
<!--pages/process/index.wxml-->
<wxs module="formate" src="../../formate.wxs"></wxs>
<wxs module="formate" src="../formate.wxs"></wxs>
<cu-custom bgColor="bg-white">
<view slot="content" style="color:black;font-size:36rpx">工作台</view>
</cu-custom>

18
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)

2
pages/login/index.wxml

@ -12,7 +12,7 @@
<view class="text-df" style="padding:20rpx 0rpx" wx:elif="{{metaData.qrPage == '/page/index/shenqing'}}">
<text class="text-df">现邀请您成为<text class="text-bold text-blue">{{metaData.factoryName}}</text>的员工</text>
</view>
<view class="text-df" style="padding:20rpx 0rpx" wx:elif="{{metaData.qrPage == 'page/inde/ztbsaas/yaoqing'}}">
<view class="text-df" style="padding:20rpx 0rpx" wx:elif="{{metaData.qrPage == '/page/index/ztbsaas/yaoqing'}}">
<text class="text-df">现邀请您成为<text class="text-bold text-blue">{{metaData.name}}</text>的管理员</text>
</view>
<view class="text-df" style="padding:20rpx 0rpx" wx:elif="{{metaData.qrPage == '/page/index/register'}}">

7
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

Loading…
Cancel
Save