Commit 9005e0d1 by hank

首页点击loading

parent 575ae6c1
export const FETCH_TIME_OUT = 5000
export const BASE_URL = 'https://server.bdideal.com'
export const WEBVIEW_URL = 'https://visual.bdideal.com'
// export const BASE_URL = 'https://dev-server.bdideal.com'
// export const WEBVIEW_URL = 'https://dev-visual.bdideal.com'
// export const BASE_URL = 'https://server.bdideal.com'
// export const WEBVIEW_URL = 'https://visual.bdideal.com'
export const BASE_URL = 'https://dev-server.bdideal.com'
export const WEBVIEW_URL = 'https://dev-visual.bdideal.com'
// export const WEBVIEW_URL = 'http://127.0.0.1:8080'
/** 蓝牙的服务 uuid */
......
......@@ -50,6 +50,39 @@ export function concatParam(data: any): string {
.join('&')
}
export function formatTime(date) {
const just = 1000 * 60 * 3
const minute = 1000 * 60
const hour = 1000 * 60 * 60
const day = hour * 24
const month = day * 30
const year = day * 365
console.log(typeof date)
if (typeof date === 'string') {
date = date.replace('-', '/')
}
let times = new Date(date).getTime()
const now = new Date().getTime()
const value = now - times
console.log(times, now, value, just, 0 <= value && value <= just)
if (0 <= value && value <= just) {
return '刚刚'
} else if (just < value && value < hour) {
return Math.trunc(value / minute) + '分钟前'
} else if (hour < value && value < day) {
return Math.trunc(value / hour) + '小时前'
} else if (day < value && value < month) {
return Math.trunc(value / day) + '天前'
} else if (month < value && value < year) {
return Math.trunc(value / month) + '月前'
} else if (year < value) {
return Math.trunc(value / year) + '年前'
} else {
return '未来'
}
}
export const MyStorage = {
async getItem({ key }) {
if (process.env.TARO_ENV === 'rn') {
......
......@@ -3,7 +3,7 @@ import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { ITempItem } from '@/reducers/counter'
import { View, Text, Image } from '@tarojs/components'
import { formatTime } from '@/common/utils'
import './index.scss'
import api from '@/api/index'
......@@ -25,14 +25,25 @@ class TempItem extends Component {
this.isload = true
if (filmId) {
Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail?filmId=${filmId}` })
this.isload = false
// Taro.navigateTo({ url: `/pages/home/device/my_film/index` })
} else {
api.tempalte.getTempalteFilmCount(templateId).then(res => {
Taro.showLoading({
title: '加载中',
mask: true
})
api.tempalte
.getTempalteFilmCount(templateId)
.then(res => {
if (res.data === 0) {
Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail?templateId=${templateId}` })
} else {
Taro.navigateTo({ url: `/pages/home/tempaltes/detail?templateId=${templateId}` })
}
Taro.hideLoading()
})
.catch(() => {
Taro.hideLoading()
})
}
} else {
......@@ -49,6 +60,7 @@ class TempItem extends Component {
templateUrl: url,
filmName,
equipmentCount,
updateTime,
templateShow,
filmCount,
templateEnvironment
......@@ -64,7 +76,9 @@ class TempItem extends Component {
src={url.split(',')[0]}
/>
<View className="temp-name-container">
<Text className="temp-name">{templateName || filmName}</Text>
<Text className="temp-name">
{templateName || filmName + (' 创建于' + formatTime(updateTime))}
</Text>
{templateName !== undefined ? <Text className="temp-film-count">{filmCount}</Text> : null}
</View>
{/* {equipmentCount !== undefined ? (
......
......@@ -9,6 +9,7 @@ export interface ITempItem {
equipmentCount?: number
filmCount?: number
templateShow?: string
updateTime?: string
templateEnvironment?: string
clickItem?: () => void
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment