Commit 4c2eba07 by 前端

fixed

1 parent 82113ebb
...@@ -68,7 +68,7 @@ class ActivityApi { ...@@ -68,7 +68,7 @@ class ActivityApi {
// 获取我的访客数据 // 获取我的访客数据
getActivityVisitorList(data) { getActivityVisitorList(data) {
return api.post({ return api.post({
method: `scrm.api.shopmall.customer.visitor.records`, method: `${path}.user.activity.visitor.list`,
...data, ...data,
}); });
} }
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
"name": "packageOutput", "name": "packageOutput",
"pages": [ "pages": [
"pages/shareWebview/shareWebview", "pages/shareWebview/shareWebview",
"pages/warReport/warReport",
"pages/visitor/visitor", "pages/visitor/visitor",
"pages/monthReport/monthReport", "pages/monthReport/monthReport",
"pages/crowdDetail/crowdDetail" "pages/crowdDetail/crowdDetail"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
// 配置预发布的小程序aapId // 配置预发布的小程序aapId
export const preReleaseAppId = '55555' export const preReleaseAppId = 'wx96c8f2a3e76907cb'
// 小程序id // 小程序id
export const appId = 'wxc50d04ae5aa9984a' export const appId = 'wxc50d04ae5aa9984a'
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
.up-box { .up-box {
position: absolute; position: absolute;
width: 108rpx; width: 128rpx;
background: #FFFFFF; background: #FFFFFF;
box-shadow: 0 0 18rpx 0 #3a596a1c; box-shadow: 0 0 18rpx 0 #3a596a1c;
border-radius: 8rpx; border-radius: 8rpx;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
padding: 24rpx; padding: 24rpx;
margin: 0rpx 16rpx; margin: 0rpx 16rpx;
border-radius: 32rpx; border-radius: 32rpx;
background: #F4F8FE;
.output-title { .output-title {
font-weight: 600; font-weight: 600;
font-size: 32rpx; font-size: 32rpx;
......
...@@ -57,9 +57,12 @@ Component({ ...@@ -57,9 +57,12 @@ Component({
jumpReport(e) { jumpReport(e) {
let { item } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
if (item.activityStatus == 1) return wx.$api.showToast('当前活动尚未开始') if (item.activityStatus == 1) return wx.$api.showToast('当前活动尚未开始')
if(item.activityStatus == 2)
wx.navigateTo({ wx.navigateTo({
url: `/packagesList/packageOutput/pages/shareWebview/shareWebview?url=${encodeURIComponent(item.reportUrl)}`, url: `/packagesList/packageOutput/pages/shareWebview/shareWebview?url=${encodeURIComponent(item.reportUrl)}`,
}); });
else
wx.$router.go('/packagesList/packageOutput/pages/warReport/warReport', item)
}, },
// 跳转 // 跳转
jump(e) { jump(e) {
...@@ -72,7 +75,7 @@ Component({ ...@@ -72,7 +75,7 @@ Component({
}, },
// 价格格式化 // 价格格式化
priceFormat(num, point = 2) { priceFormat(num, point = 2) {
let numStr = num.toString().split('.')[0] let numStr = (num/100).toString().split('.')[0]
if (numStr.length < 6) { // 判断数字有多长,如果小于6,,表示10万以内的数字,让其直接显示 if (numStr.length < 6) { // 判断数字有多长,如果小于6,,表示10万以内的数字,让其直接显示
return numStr; return numStr;
} else if (numStr.length >= 6 && numStr.length <= 8) { // 如果数字大于6位,小于8位,让其数字后面加单位万 } else if (numStr.length >= 6 && numStr.length <= 8) { // 如果数字大于6位,小于8位,让其数字后面加单位万
......
...@@ -15,7 +15,8 @@ Page({ ...@@ -15,7 +15,8 @@ Page({
outputValue: [{ outputValue: [{
label: '今日产值/元', label: '今日产值/元',
name: 'realAmountToday', name: 'realAmountToday',
unit: '¥' unit: '¥',
multiple: 0.01,
}, { }, {
label: '今日订单/单', label: '今日订单/单',
name: 'orderCountToday', name: 'orderCountToday',
...@@ -27,7 +28,8 @@ Page({ ...@@ -27,7 +28,8 @@ Page({
}, { }, {
label: '累计产值/元', label: '累计产值/元',
name: 'realAmount', name: 'realAmount',
unit: '¥' unit: '¥',
multiple: 0.01,
}, { }, {
label: '累计订单/单', label: '累计订单/单',
name: 'orderCount', name: 'orderCount',
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</view> </view>
<view class="output-value"> <view class="output-value">
<view class="output-item" wx:for="{{outputValue}}" wx:key="index"> <view class="output-item" wx:for="{{outputValue}}" wx:key="index">
<view class="output-num"><text>{{item.unit}}</text>{{outputData[item.name] || 0}}</view> <view class="output-num"><text>{{item.unit}}</text>{{outputData[item.name]*(item.multiple || 1) || 0}}</view>
<view class="output-label">{{item.label}}</view> <view class="output-label">{{item.label}}</view>
</view> </view>
</view> </view>
......
...@@ -4,119 +4,119 @@ import index_const from "~/packagesList/outDetail/index_const" ...@@ -4,119 +4,119 @@ import index_const from "~/packagesList/outDetail/index_const"
import { commentTime } from '~/utils/format' import { commentTime } from '~/utils/format'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list: [], list: [],
allNum: 0, allNum: 0,
todayNum: 0, todayNum: 0,
activityTypList: index_const.data.activityTypList, activityTypList: index_const.data.activityTypList,
IMG_URL: IMG_URL_STORE, IMG_URL:IMG_URL_STORE,
isPravite: false isPravite:false
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
}, },
onRoute(options) { onRoute(options) {
let { activityId, visitCount, visitCountToday } = options let activityId = options.activityId
ActivityApi.getActivityVisitorList({ ActivityApi.getActivityVisitorList({
activityId activityId,
}).then(res => { staffFlag:true
console.log(res) }).then(res => {
res.list && res.list.forEach(val => { res.visitorList && res.visitorList.forEach(val => {
val.lastVisitFormatTime = commentTime(new Date(val.lastBrowseDate).getTime()) val.lastVisitFormatTime = commentTime(val.lastVisitDate)
// if (!val.customerPhone && val.guestId) { if(!val.customerPhone&&val.guestId){
// val.gId = (val.guestId.split('_')).pop() || '' val.gId = (val.guestId.split('_')).pop() || ''
// }
})
this.setData({
allNum: visitCount,
todayNum: visitCountToday,
list: res.list
})
})
},
toCopyName(e) {
const { name } = e.currentTarget.dataset
if (name) {
wx.setClipboardData({
data: name
})
} }
}, })
this.setData({
// 打电话 allNum: res.visitorTotal,
callPhone(e) { todayNum: res.todayTotal,
let { mobile } = e.currentTarget.dataset list: res.visitorList
wx.makePhoneCall({ })
phoneNumber: mobile.toString() })
}) },
}, toCopyName(e){
// 复制微信号 const {name} = e.currentTarget.dataset
copyWechart(e) { if(name){
let { wechartno } = e.currentTarget.dataset wx.setClipboardData({
wx.setClipboardData({ data: name
data: wechartno.toString(), })
success(res) { }
wx.showToast({ },
title: '微信号已复制',
icon: "none" // 打电话
}) callPhone(e) {
} let { mobile } = e.currentTarget.dataset
wx.makePhoneCall({
phoneNumber: mobile.toString()
})
},
// 复制微信号
copyWechart(e) {
let { wechartno } = e.currentTarget.dataset
wx.setClipboardData({
data: wechartno.toString(),
success (res) {
wx.showToast({
title: '微信号已复制',
icon: "none"
}) })
}, }
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() { onReady() {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide() { onHide() {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload() { onUnload() {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom() { onReachBottom() {
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() { onShareAppMessage() {
} }
}) })
\ No newline at end of file \ No newline at end of file
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
</view> </view>
<view class="content"> <view class="content">
<view class="title"> <view class="title">
<view>总访客<text> · {{allNum||0}}</text></view> <view>总访客<text> · {{allNum}}</text></view>
<view>今日访客<text> · {{todayNum||0}}</text></view> <view>今日访客<text> · {{todayNum}}</text></view>
</view> </view>
<view class="list-box"> <view class="list-box">
<block wx:if="{{!isPravite}}"> <block wx:if="{{!isPravite}}">
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
<view class="list-item {{item.orderStatus == 0 ? '' : 'orderde'}}"> <view class="list-item {{item.orderStatus == 0 ? '' : 'orderde'}}">
<view class="top"> <view class="top">
<view class="top-left"> <view class="top-left">
<image webp src="{{item.customerAvatar ? item.customerAvatar : '{{IMG_URL}}store-assistant/default_avatar.png'}}"></image> <image webp src="{{item.customerImageUrl ? item.customerImageUrl : '{{IMG_URL}}store-assistant/default_avatar.png'}}"></image>
<view class="name-mobile"> <view class="name-mobile">
<view class="name"> <view class="name">
{{item.customerName || ""}} {{item.customerNickName || ""}}
<glsx-image wx:if="{{item.customerName&&item.customerName!='未知访客'}}" data-name="{{item.customerName}}" bind:tap="toCopyName" class="copy" src="store-assistant/copy_name.png"></glsx-image> <glsx-image wx:if="{{item.customerNickName&&item.customerNickName!='未知访客'}}" data-name="{{item.customerNickName}}" bind:tap="toCopyName" class="copy" src="store-assistant/copy_name.png"></glsx-image>
<!-- <text class="order-statue {{item.orderStatus == 0 ? '' : 'green'}}">{{item.orderStatus == 0 ? '未下单' : '已下单'}}</text> --> <!-- <text class="order-statue {{item.orderStatus == 0 ? '' : 'green'}}">{{item.orderStatus == 0 ? '未下单' : '已下单'}}</text> -->
</view> </view>
<view class="mobile" wx:if="{{item.mobile}}"> <view class="mobile" wx:if="{{item.customerPhone}}">
{{item.mobile}} {{item.customerPhone}}
<text class="order-statue {{item.orderStatus == 0 ? '' : 'green'}}">{{item.orderStatus == 0 ? '未下单' : '已下单'}}</text> <text class="order-statue {{item.orderStatus == 0 ? '' : 'green'}}">{{item.orderStatus == 0 ? '未下单' : '已下单'}}</text>
</view> </view>
<view class="mobile" wx:else> <view class="mobile" wx:else>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</view> </view>
</view> </view>
<view class="top-right"> <view class="top-right">
<glsx-image class="btn_icon" wx:if="{{item.mobile}}" webp src="store-assistant/activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{item.mobile}}"></glsx-image> <glsx-image class="btn_icon" wx:if="{{item.customerPhone}}" webp src="store-assistant/activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{item.customerPhone}}"></glsx-image>
<glsx-image class="btn_icon" wx:if="{{item.userWechartNo}}" webp src="store-assistant/activity_order_wechart_icon.png" bind:tap="copyWechart" data-wechartno="{{item.userWechartNo}}"></glsx-image> <glsx-image class="btn_icon" wx:if="{{item.userWechartNo}}" webp src="store-assistant/activity_order_wechart_icon.png" bind:tap="copyWechart" data-wechartno="{{item.userWechartNo}}"></glsx-image>
</view> </view>
</view> </view>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<!-- <text>{{activityTypList[0]}}</text> --> <!-- <text>{{activityTypList[0]}}</text> -->
</view> </view>
<view class="footprint"> <view class="footprint">
<text>浏览 {{item.browseCount}} 次</text> <text>浏览 {{item.visitCount}} 次</text>
<text>{{item.lastVisitFormatTime}} 访问过</text> <text>{{item.lastVisitFormatTime}} 访问过</text>
</view> </view>
</view> </view>
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
<view class="list-item {{item.visitStatus==1?'orderde':''}}"> <view class="list-item {{item.visitStatus==1?'orderde':''}}">
<view class="top"> <view class="top">
<view class="top-left"> <view class="top-left">
<image webp src="{{item.customerAvatar ? item.customerAvatar : '{{IMG_URL}}store-assistant/default_avatar.png'}}"></image> <image webp src="{{item.customerImageUrl ? item.customerImageUrl : '{{IMG_URL}}store-assistant/default_avatar.png'}}"></image>
<view class="name-mobile"> <view class="name-mobile">
<view style="padding-top:8rpx" class="name"> <view style="padding-top:8rpx" class="name">
{{item.customerName || "未知访客"}} {{item.customerNickName || "未知访客"}}
<glsx-image wx:if="{{item.customerName&&item.customerName!='未知访客'}}" bind:tap="toCopyName" class="copy" src="store-assistant/copy_name.png"></glsx-image> <glsx-image wx:if="{{item.customerNickName&&item.customerNickName!='未知访客'}}" bind:tap="toCopyName" class="copy" src="store-assistant/copy_name.png"></glsx-image>
</view> </view>
</view> </view>
</view> </view>
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
{{item.taskName || ''}} {{item.taskName || ''}}
</view> </view>
<view class="footprint"> <view class="footprint">
<text>浏览 {{item.browseCount}}次</text> <text>浏览 {{item.visitCount}}次</text>
<text>{{item.lastVisitFormatTime}} 访问过</text> <text>{{item.lastVisitFormatTime}} 访问过</text>
</view> </view>
</view> </view>
......
// packageActivity/pages/warReport/warReport.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onRoute(e) {
console.log(e)
this.setData({
infoData: e
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "活动战报"
}
\ No newline at end of file \ No newline at end of file
/* packageActivity/pages/warReport/warReport.wxss */
.content{
width: 100%;
min-height: 100vh;
display: flex;
flex-flow: column;
background: #fff;
align-items: center;
.time-box{
width: 100%;
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
text-align: center;
color: #1B233D;
}
.no-data{
display: flex;
flex-flow: column;
margin-top: 328rpx;
.no_data_image{
width: 400rpx;
height: 400rpx;
}
.text{
font-size: 28rpx;
color: #7A8299;
text-align: center;
}
}
}
\ No newline at end of file \ No newline at end of file
<!--packageActivity/pages/warReport/warReport.wxml-->
<view class="content">
<block wx:if="{{infoData.reportUrl}}">
<view class="time-box">最近更新于 {{infoData.reportCreatedDate}}</view>
<image src="{{infoData.reportUrl}}" mode="widthFix"></image>
</block>
<view wx:else class="no-data">
<glsx-image class="no_data_image" webp src="store-assistant/no_warReport_data.png"></glsx-image>
<view class="text">活动战报未生成,请耐心等待</view>
</view>
</view>
...@@ -218,8 +218,8 @@ Component({ ...@@ -218,8 +218,8 @@ Component({
// 跳转咨询页面 // 跳转咨询页面
goConsult() { goConsult() {
wx.openCustomerServiceChat({ wx.openCustomerServiceChat({
extInfo: { url: "https://work.weixin.qq.com/kfid/kfcfbc84ad072f27636" }, extInfo: { url: "https://work.weixin.qq.com/kfid/kfcf7b721472201345e" },
corpId: "wx51bda2e574d24a91", corpId: "ww047bdc0f1e76cc13",
complete: (r) => { complete: (r) => {
console.log(r); console.log(r);
}, },
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</view> --> </view> -->
<view class="layout" id="layout" style="top:{{navHeight}}px; height: calc(100vh - 150rpx)"> <view class="layout" id="layout" style="top:{{navHeight}}px; height: calc(100vh - 150rpx)">
<!-- 背景图 --> <!-- 背景图 -->
<view class="bg-box" style="height:{{368 + navHeight * 2}}rpx;top:-{{navHeight}}px"> <view class="bg-box" style="height:{{368 + navHeight * 2}}rpx;top:-{{navHeight+16}}px">
<view class="bg"> <view class="bg">
<glsx-image webp src="store-assistant/index_bg.webp"></glsx-image> <glsx-image webp src="store-assistant/index_bg.webp"></glsx-image>
</view> </view>
......
/** 根据时间回显时间格式 */ /** 根据时间回显时间格式 */
export function timeAgo(dateTimeStamp) { export function timeAgo(dateTimeStamp) {
let result = '刚刚' let result = '刚刚'
let minute = 1000 * 60 let minute = 1000 * 60
let hour = minute * 60 let hour = minute * 60
let day = hour * 24 let day = hour * 24
let now = new Date().getTime() //获取当前时间毫秒 let now = new Date().getTime() //获取当前时间毫秒
let diffValue = now - dateTimeStamp //时间差 let diffValue = now - dateTimeStamp //时间差
let todayValue = new Date() let todayValue = new Date()
todayValue.setHours(0) todayValue.setHours(0)
todayValue.setMinutes(0) todayValue.setMinutes(0)
todayValue.setSeconds(0) todayValue.setSeconds(0)
todayValue.setMilliseconds(0) todayValue.setMilliseconds(0)
let todayTimeStamp = todayValue.getTime() //获取当天零时毫秒 let todayTimeStamp = todayValue.getTime() //获取当天零时毫秒
if (diffValue < 0) { if (diffValue < 0) {
return result return result
} }
let diffTodayValue = todayTimeStamp - dateTimeStamp let diffTodayValue = todayTimeStamp - dateTimeStamp
//计算时间差的分,时,天,周,月 //计算时间差的分,时,天,周,月
let minC = diffValue / minute let minC = diffValue / minute
let hourC = diffValue / hour let hourC = diffValue / hour
let dayC = diffTodayValue / day let dayC = diffTodayValue / day
if (diffTodayValue > 0) { if (diffTodayValue > 0) {
if (dayC >= 2) { if (dayC >= 2) {
return new Date(dateTimeStamp).format('MM月dd日 hh:mm:ss') return new Date(dateTimeStamp).format('MM月dd日 hh:mm:ss')
}
if (dayC >= 1 && dayC < 2) {
return '前天' + new Date(dateTimeStamp).format(' hh:mm:ss')
}
return '昨天' + new Date(dateTimeStamp).format(' hh:mm:ss')
}
if (hourC >= 1 && hourC <= 23) {
return parseInt(hourC) + '小时前'
}
if (minC >= 1 && minC <= 59) {
return parseInt(minC) + '分钟前'
} }
if (dayC >= 1 && dayC < 2) { if (diffValue >= 0 && diffValue <= minute) {
return '前天' + new Date(dateTimeStamp).format(' hh:mm:ss') return '刚刚'
} }
return '昨天' + new Date(dateTimeStamp).format(' hh:mm:ss') return new Date(dateTimeStamp).format('MM月dd日 hh:mm:ss')
}
if (hourC >= 1 && hourC <= 23) {
return parseInt(hourC) + '小时前'
}
if (minC >= 1 && minC <= 59) {
return parseInt(minC) + '分钟前'
}
if (diffValue >= 0 && diffValue <= minute) {
return '刚刚'
}
return new Date(dateTimeStamp).format('MM月dd日 hh:mm:ss')
} }
//用来判断评论时间 //用来判断评论时间
export function commentTime(dateTimeStamp) { export function commentTime(dateTimeStamp) {
var result var result
let time = dateTimeStamp let time = dateTimeStamp
let nowTime = new Date().getTime() let nowTime = new Date().getTime()
let timeDifference = nowTime - time let timeDifference = nowTime - time
let minTime = 60000 let minTime = 60000
let hourTime = minTime * 60 let hourTime = minTime * 60
let dayTime = hourTime * 24 let dayTime = hourTime * 24
let weektTime = dayTime * 7 let weektTime = dayTime * 7
let monthTime = dayTime * 30 let monthTime = dayTime * 30
let yearTime = dayTime * 365 let yearTime = dayTime * 365
if (Math.floor(timeDifference / yearTime) >= 1) { if (Math.floor(timeDifference / yearTime) >= 1) {
result = Math.floor(timeDifference / yearTime) + '年前' result = Math.floor(timeDifference / yearTime) + '年前'
} else if (Math.floor(timeDifference / monthTime) >= 1) { } else if (Math.floor(timeDifference / monthTime) >= 1) {
result = Math.floor(timeDifference / monthTime) + '月前' result = Math.floor(timeDifference / monthTime) + '月前'
} else if (Math.floor(timeDifference / weektTime) >= 1) { } else if (Math.floor(timeDifference / weektTime) >= 1) {
result = Math.floor(timeDifference / weektTime) + '周前' result = Math.floor(timeDifference / weektTime) + '周前'
} else if (Math.floor(timeDifference / dayTime) >= 1) { } else if (Math.floor(timeDifference / dayTime) >= 1) {
result = Math.floor(timeDifference / dayTime) + '天前' result = Math.floor(timeDifference / dayTime) + '天前'
} else if (Math.floor(timeDifference / hourTime) >= 1) { } else if (Math.floor(timeDifference / hourTime) >= 1) {
result = Math.floor(timeDifference / hourTime) + '小时前' result = Math.floor(timeDifference / hourTime) + '小时前'
} else if (Math.floor(timeDifference / minTime) >= 1) { } else if (Math.floor(timeDifference / minTime) >= 1) {
result = Math.floor(timeDifference / minTime) + '分钟前' result = Math.floor(timeDifference / minTime) + '分钟前'
if (Math.floor(timeDifference / minTime) <= 5) { if (Math.floor(timeDifference / minTime) <= 5) {
//五分钟内就是刚刚 //五分钟内就是刚刚
result = '刚刚' result = '刚刚'
}
} }
} return result
return result
} }
/**IOS时间兼容 */ /**IOS时间兼容 */
export function iosTimeFormat(time) { export function iosTimeFormat(time) {
return time.replace(/\-/g, '/') return time.replace(/\-/g, '/')
} }
/**获取时间段总时长 */ /**获取时间段总时长 */
export function getScopeTime(inputTime, curTime) { export function getScopeTime(inputTime, curTime) {
let obj = { let obj = {
text: '-', text: '-',
day: 0, day: 0,
isDanger: false isDanger: false
} }
if (!inputTime || arguments.length === 0) return obj if (!inputTime || arguments.length === 0) return obj
let time = curTime / 1000 - inputTime / 1000 let time = curTime / 1000 - inputTime / 1000
if (time < 60) { if (time < 60) {
let s = parseInt(time) let s = parseInt(time)
obj.text = `00:00:${s}` obj.text = `00:00:${s}`
} else if (time < 3600) { } else if (time < 3600) {
let m = parseInt(time / 60) let m = parseInt(time / 60)
let s = parseInt(time % 60) let s = parseInt(time % 60)
m = m < 10 ? `0${m}` : m m = m < 10 ? `0${m}` : m
s = s < 10 ? `0${s}` : s s = s < 10 ? `0${s}` : s
obj.text = `00:${m}:${s}` obj.text = `00:${m}:${s}`
} else if (time < 86400) { } else if (time < 86400) {
let h = parseInt(time / 3600) let h = parseInt(time / 3600)
let min = time - h * 3600 let min = time - h * 3600
let m = parseInt(min / 60) let m = parseInt(min / 60)
let s = parseInt(time % 60) let s = parseInt(time % 60)
m = m < 10 ? `0${m}` : m m = m < 10 ? `0${m}` : m
s = s < 10 ? `0${s}` : s s = s < 10 ? `0${s}` : s
obj.text = `${h}:${m}:${s}` obj.text = `${h}:${m}:${s}`
} else if (time > 86400) { } else if (time > 86400) {
let day = parseInt(time / 86400) let day = parseInt(time / 86400)
let hour = time - day * 86400 let hour = time - day * 86400
let h = parseInt(hour / 3600) let h = parseInt(hour / 3600)
let min = hour - h * 3600 let min = hour - h * 3600
let m = parseInt(min / 60) let m = parseInt(min / 60)
let s = parseInt(time % 60) let s = parseInt(time % 60)
h = h < 10 ? `0${h}` : h h = h < 10 ? `0${h}` : h
m = m < 10 ? `0${m}` : m m = m < 10 ? `0${m}` : m
s = s < 10 ? `0${s}` : s s = s < 10 ? `0${s}` : s
if (day > 7 || (day == 7 && h > 0)) obj.isDanger = false if (day > 7 || (day == 7 && h > 0)) obj.isDanger = false
obj.day = day obj.day = day
obj.text = `${day}天${h}:${m}:${s}` obj.text = `${day}天${h}:${m}:${s}`
} }
return obj.text return obj.text
} }
export function getNowMonth() { export function getNowMonth() {
var date = new Date() var date = new Date()
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() + 1 var month = date.getMonth() + 1
month = month > 9 ? month : '0' + month month = month > 9 ? month : '0' + month
var nowMonth = year + '-' + month var nowMonth = year + '-' + month
return nowMonth return nowMonth
} }
/**num:要转换的数值,fixed:精确几位小数 */ /**num:要转换的数值,fixed:精确几位小数 */
export function decimal(num, fixed = 2) { export function decimal(num, fixed = 2) {
const pow = Math.pow(10, fixed) const pow = Math.pow(10, fixed)
return Number(Math.round(num * pow) / pow) return Number(Math.round(num * pow) / pow)
} }
/**分转元 */ /**分转元 */
export function centsToyuan(price) { export function centsToyuan(price) {
// console.log(decimal) // console.log(decimal)
return decimal(price / 100, 2).toFixed(2) return decimal(price / 100, 2).toFixed(2)
} }
/**设置价格 */ /**设置价格 */
export function setPrice(price) { export function setPrice(price) {
let [num, decimal] = price.toString().split('.') let [num, decimal] = price.toString().split('.')
if (!decimal) decimal = '00' if (!decimal) decimal = '00'
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}` return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') + `.${decimal}`
} }
/**精确加减 */
export function accAdd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.toString().split(".")[1].length;
}
catch (e) {
r1 = 0;
}
try {
r2 = arg2.toString().split(".")[1].length;
}
catch (e) {
r2 = 0;
}
m = Math.pow(10, Math.max(r1, r2));
return (arg1 * m + arg2 * m) / m;
}
/**
* 乘法函数,用来得到精确的乘法结果
* 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
* 调用:accMul(arg1,arg2)
* 返回值:arg1乘以 arg2的精确结果
**/
export const accMul = (arg1, arg2) => {
if (isNaN(arg1)) {
arg1 = 0;
}
if (isNaN(arg2)) {
arg2 = 0;
}
arg1 = Number(arg1);
arg2 = Number(arg2);
var m = 0,
s1 = arg1.toString(),
s2 = arg2.toString();
try {
m += s1.split(".")[1].length;
} catch (e) { }
try {
m += s2.split(".")[1].length;
} catch (e) { }
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
};
export function deleteSecond(time) { export function deleteSecond(time) {
console.log(time) console.log(time)
if (!time.length) return '' if (!time.length) return ''
time = time.split(' ') time = time.split(' ')
let moth = time[0].split('-') let moth = time[0].split('-')
let hour = time[1].split(':') let hour = time[1].split(':')
moth.shift() moth.shift()
hour = hour.slice(0, -1) hour = hour.slice(0, -1)
moth = moth.join('-') moth = moth.join('-')
hour = hour.join(':') hour = hour.join(':')
return `${moth} ${hour}` return `${moth} ${hour}`
} }
...@@ -21,7 +21,7 @@ const systemInfo = wx.getSystemInfoSync() ...@@ -21,7 +21,7 @@ const systemInfo = wx.getSystemInfoSync()
const manual = false const manual = false
const release = false const release = false
let index = 1 let index = 2
// 判断小程序环境 // 判断小程序环境
// develop:开发版(正常开发工具,测试时) // develop:开发版(正常开发工具,测试时)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!