Browse Source

upload

dev_czc
HolyKnightIX 2 years ago
parent
commit
0565c24f13
15 changed files with 721 additions and 126 deletions
  1. +3
    -1
      app.json
  2. +25
    -13
      config/config.js
  3. +4
    -4
      ext.json
  4. +107
    -0
      pages/Appointment/appointment.js
  5. +8
    -0
      pages/Appointment/appointment.json
  6. +50
    -0
      pages/Appointment/appointment.ttml
  7. +157
    -0
      pages/Appointment/appointment.ttss
  8. +117
    -0
      pages/appointDetail/appointDetail.js
  9. +8
    -0
      pages/appointDetail/appointDetail.json
  10. +18
    -0
      pages/appointDetail/appointDetail.ttml
  11. +32
    -0
      pages/appointDetail/appointDetail.ttss
  12. +2
    -2
      pages/main/main.js
  13. +81
    -82
      pages/marktingsettlement/marktingsettlement.js
  14. +27
    -0
      project.private.config.json
  15. +82
    -24
      utils/util.js

+ 3
- 1
app.json View File

@@ -21,7 +21,9 @@
"pages/exchange/index",
"pages/creditOperate/index",
"pages/goHtml/goHtml",
"pages/orderUrl/orderUrl"
"pages/orderUrl/orderUrl",
"pages/Appointment/appointment",
"pages/appointDetail/appointDetail"
],
"window": {
"backgroundTextStyle": "light",


+ 25
- 13
config/config.js View File

@@ -5,14 +5,14 @@ let url = extConfig.attr.configUrl;
var apiPrefix = url + '/B';

let config = {
apiPrefix:apiPrefix,
apiPrefix: apiPrefix,
api: {

// 获取进件 页面地址
findTt: "/api/merchant/getTtReceiverUrl",
/**
* 接口用途:login
*/
* 接口用途:login
*/
login: '/api/user/login',
/**
* B端用户详情
@@ -118,13 +118,25 @@ let config = {
*/
getMicroPayAmountOnDate: '/api/micropay/getMicroPayAmountOnDate',
/**
* 首页账单列表
*/
* 首页账单列表
*/
listBillOweAndWaitPay: "/api/bill/listBillOweAndWaitPay",
/**
* 账单
*/
listBill: "/api/bill/listBill",
/**
* 预约列表
*/
appointmentList: "/api/wxCouponOrderReservation/list",
/**
* 预约详情
*/
appointDetail: "/api/wxCouponOrderReservation/detail",
/**
* 预约确认
*/
appointConfirm: "/api/wxCouponOrderReservation/updateStatus",
/**
* 获得openId
*/
@@ -210,8 +222,8 @@ let config = {
*/
getCreditList: "/api/credit/list",
/**
* 查询账户信息
*/
* 查询账户信息
*/
findAccountById: "/api/merchant/findAccountById",
/**
* 更新收款账户信息
@@ -306,12 +318,12 @@ let config = {
*/
addbatch: "/api/wxCouponChannel/addbatch",
/**
* B端发卷-下架
*/
* B端发卷-下架
*/
soldOut: "/api/wxCouponChannel/update",
/**
* B端发卷-作废
*/
* B端发卷-作废
*/
cancellation: "/api/coupon/update",
/**
* B端发卷-查询审批历史记录
@@ -332,7 +344,7 @@ let config = {
/**
* 导出订单记录
*/
exportUrl: "/api/couponOrder/getVerifiedExportUrl",
exportUrl: "/api/couponOrder/getVerifiedExportUrl",

},
weapp: {
@@ -345,6 +357,6 @@ let config = {
for (var key in config.api) {
config.api[key] = apiPrefix + config.api[key];
}
console.log(config,"config");
console.log(config, "config");

module.exports = config;

+ 4
- 4
ext.json View File

@@ -2,10 +2,10 @@
"ext": {
"attr": {
"configUrl": "https://btest.malls.iformall.com",
"datatowerurl": "https://mobile.malls.iformall.com"
"datatowerurl": "https://mobiletest.malls.iformall.com"
},
"name": "富茂券券集团商户端",
"weappId": "tt60d3166effed27cc01",
"name": "富茂家政商户端",
"weappId": "tt80b0f60d1f8c7bda01",
"appVersion": "Btest.5.1.0"
},
"debug": false,
@@ -29,7 +29,7 @@
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#52A0FD"
},
"extAppid": "tt60d3166effed27cc01",
"extAppid": "tt80b0f60d1f8c7bda01",
"extEnable": true,
"permission": {
"scope.userLocation": {


+ 107
- 0
pages/Appointment/appointment.js View File

@@ -0,0 +1,107 @@
// c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\Appointment\appointment\appointment.js
const config = require('../../config/config.js')
const Http = require('../../utils/http.js')
const HttpBasics = require('../../utils/HttpBasics.js')
const util = require('../../utils/util')
var app = getApp()
Page({
data: {
currentID: "",
pickedTime: "",
startTime: "开始时间",
endTime: "结束时间",
pageNum: 1,
status: 0,
list: []
},

onLoad(options) {
this.getList()
},

getList(status, startTime, endTime) {
const that = this
const data = {
pageNum: this.data.pageNum,
pageSize: 20,
}

if (startTime && endTime) {
data.serchStartDate = startTime
data.serchEndDate = endTime
}

if (status) {
data.status = status
}

HttpBasics.get({
url: config.api.appointmentList,
data
})
.then(res => {
console.log(res, 'res');
res.data.list.forEach(item => {
const appointStart = util.timestampToTime(item.startDate, 'YYYY-MM-DD hh:mm:ss')
const appointEnd = util.timestampToTime(item.endDate, 'hh:mm:ss')
item.appointTime = appointStart + ' - ' + appointEnd
})
that.setData({
list: res.data.list,
})
}).catch(err => {
console.log(err, 'err');
})
},

setNav(e) {
const id = e.currentTarget.dataset.id
this.setData({
currentID: id == this.data.currentID ? '' : id
})

console.log(this.data.currentID, 'currentID');
},

setType(e) {
const type = e.currentTarget.dataset.type * 1
this.setData({
currentID: '',
})
this.getList(type)
},

setStartTime(e) {
console.log(e.detail.value, 'e');
this.setData({
startTime: e.detail.value
})
},

setEndTime(e) {
console.log(e.detail.value, 'e');
this.setData({
endTime: e.detail.value
})
},

search() {
if (this.data.startTime == '开始时间' || this.data.endTime == '结束时间') {
return
}
const startTime = this.data.startTime + " 00:00:00"
const endTime = this.data.endTime + " 23:59:59"
this.getList(false, startTime, endTime)
},

goDetail(e) {
const id = e.currentTarget.dataset.id
tt.navigateTo({
url: `/pages/appointDetail/appointDetail?id=${id}`,
});
},

onShow() {
this.getList()
}
})

+ 8
- 0
pages/Appointment/appointment.json View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "预约管理",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#52A0FD",
"usingComponents": {}
}

+ 50
- 0
pages/Appointment/appointment.ttml View File

@@ -0,0 +1,50 @@
<view>
<view class="nav">
<view class="{{ currentID == 1 ? 'currentItem' : 'item' }}" bindtap="setNav" data-id="1">
<text>类型</text>
<image mode="widthFix" src="../../assets/images/arrow.png"></image>
</view>
<view class="{{ currentID == 2 ? 'currentItem' : 'item' }}" bindtap="setNav" data-id="2">
<text>日期</text>
<image mode="widthFix" src="../../assets/images/arrow.png">
</image>
</view>
</view>

<view class="{{ currentID == 1 ? 'type active' : 'type' }}">
<view class="item" bindtap="setType" data-type="">全部</view>
<view class="item" bindtap="setType" data-type="0">未确认</view>
<view class="item" bindtap="setType" data-type="5">已确认</view>
<view class="item" bindtap="setType" data-type="8">已完成</view>
</view>

<view tt:if="{{ currentID == 2 }}" class="pickedTime">
<picker class="picker" mode="date" bindchange="setStartTime">{{ startTime }}</picker> 至 <picker class="picker"
mode="date" bindchange="setEndTime">{{ endTime }}</picker>
<button class="search" type="primary" bindtap="search">查询</button>
</view>

<view class="{{ currentID != 1 ? 'list active' : 'list' }}">
<view tt:if="{{ list.length > 0 }}" class="item" tt:for="{{ list }}">
<view class="head">
<view>订单编号:{{ item.couponOrderId }}</view>
<view tt:if="{{ item.status == 0 }}" class="notice noAppoint">未确认</view>
<view tt:if="{{ item.status == 3 }}" class="notice refund">已退款</view>
<view tt:if="{{ item.status == 5 }}" class="notice confirm">已确认</view>
<view tt:if="{{ item.status == 8 }}" class="notice complete">已完成</view>
</view>
<view class="body">
<view class="items">商品名称:{{ item.couponTitle }}</view>
<view class="items">用户手机号码:{{ item.userPhone }}</view>
<view class="items">服务预约时间:</view>
<view class="items">{{ item.appointTime }}</view>
</view>
<view class="footer">
<button type="primary" bindtap="goDetail" data-id="{{ item.id }}">详情</button>
</view>
</view>
<view tt:if="{{ list.length == 0 }}" class="itemXX">
暂无记录
</view>
</view>
</view>

+ 157
- 0
pages/Appointment/appointment.ttss View File

@@ -0,0 +1,157 @@
.nav {
display: flex;
justify-content: space-between;
padding: 20rpx 150rpx;
background-color: #f7f7f7;
}

.nav .item image {
position: relative;
bottom: 5rpx;
width: 30rpx;
margin-left: 20rpx;
}

.nav .currentItem {
color: #52a0fd;
}

.nav .currentItem image {
position: relative;
bottom: 5rpx;
width: 30rpx;
margin-left: 20rpx;
transform: rotate(180deg);
transition: all 0.3s;
}

.type {
text-align: center;
padding: 40rpx;
transform: translateY(-150%);
opacity: 0;
transition: all 0.3s;
background-color: #ffffff86;
z-index: 99;
}

.type.active {
transform: translateY(0);
opacity: 1;
}

.type .item {
color: #ffffff;
background-color: #52a0fd;
border-radius: 5rpx;
padding: 10rpx 0;
margin-bottom: 40rpx;
}

.type .item.center {
margin: 30rpx 0;
}

.pickedTime {
position: relative;
bottom: 480rpx;
text-align: center;
}

.pickedTime .picker {
display: inline-block;
background-color: #529ffd86;
padding: 10rpx;
border-radius: 10rpx;
color: #ffffff;
}

.pickedTime .search {
display: inline-block;
width: 120rpx;
height: 60rpx;
line-height: 60rpx;
padding: 5rpx;
margin-left: 40rpx;
}

.list {
position: relative;
bottom: 480rpx;
margin-top: 20rpx;
z-index: -1;
}

.list.active {
z-index: 1;
}

.list .item {
width: 90%;
border: 1px solid #ffffff93;
margin: auto;
overflow: hidden;
background-color: #0000000a;
border-radius: 20rpx;
margin-bottom: 30rpx;
}

.list .itemXX {
text-align: center;
}

.list .item .head {
position: relative;
padding: 20rpx;
font-size: 30rpx;
border-bottom: 1px solid #ffffff93;
}

.notice {
position: absolute;
width: 250rpx;
text-align: center;
top: 28rpx;
right: -80rpx;
transform: rotate(45deg);
font-size: 35rpx;
}

.notice.noAppoint {
color: red;
background-color: #ffcc66;
}

.notice.confirm {
color: #ffffff;
background-color: #ffcc66;
}

.notice.refund {
color: #ffffff;
background-color: #ff0000;
}

.notice.complete {
color: #ffffff;
background-color: #19be27;
}

.list .item .body {
padding: 20rpx 20rpx;
border-bottom: 1px solid #ffffff93;
}

.list .item .body .items {
margin-bottom: 10rpx;
}


.list .item .footer {
margin: 25rpx 0;
padding: 0 170rpx;
}

.list .item .footer button {
background-color: #52a0fd;
}

+ 117
- 0
pages/appointDetail/appointDetail.js View File

@@ -0,0 +1,117 @@
// c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\appointDetail\appointDetail.js
const config = require('../../config/config.js')
const Http = require('../../utils/http.js')
const HttpBasics = require('../../utils/HttpBasics.js')
const util = require('../../utils/util')
var app = getApp()

Page({
data: {
id: "",
detail: null
},

onLoad(options) {
console.log(options, 'options');
if (options.id) {
this.setData({
id: options.id
})
this.getDetail(options.id)
}
},

getDetail(id) {
const that = this
const data = {
id
}
HttpBasics.get({
url: config.api.appointDetail,
data
})
.then(res => {
console.log(res, 'res');
const appointStart = util.timestampToTime(res.data.startDate, 'YYYY-MM-DD hh:mm:ss')
const appointEnd = util.timestampToTime(res.data.endDate, 'hh:mm:ss')
res.data.appointTime = appointStart + ' - ' + appointEnd
that.setData({
detail: res.data
})
}).catch(err => {
console.log(err, 'err');
})
},

back() {
tt.navigateBack();
},

cancel() {
const that = this
tt.showModal({
title: "提示",
content: "是否与用户取得联系并取消预约?",
showCancel: true,
confirmText: "确认取消",
confirmColor: "#52a0fd",
cancelText: "返回",
success(res) {
if (res.confirm) {
that.goChange(that.data.id, 0)
}
if (res.cancel) {
return
}
}
});
},

confirm() {
const that = this
tt.showModal({
title: "提示",
content: "是否与用户取得联系并完成预约?",
showCancel: true,
confirmText: "确认完成",
confirmColor: "#52a0fd",
cancelText: "关闭",
success(res) {
if (res.confirm) {
that.goChange(that.data.id, 5)
}
if (res.cancel) {
return
}
}
});
},

goChange(id, status) {
const data = {
id,
status
}
HttpBasics.post({
url: config.api.appointConfirm,
data
})
.then(res => {
console.log(res, 'res');
tt.showToast({
title: status == 5 ? '确认成功!' : '取消成功!',
icon: "success",
duration: 2000
});
setTimeout(() => {
tt.navigateBack();
}, 2000);
}).catch(err => {
console.log(err, 'err');
tt.showToast({
title: err.message,
icon: "none"
});
})
}
})

+ 8
- 0
pages/appointDetail/appointDetail.json View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "预约详情",
"enablePullDownRefresh": true,
"backgroundTextStyle": "dark",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#52A0FD",
"usingComponents": {}
}

+ 18
- 0
pages/appointDetail/appointDetail.ttml View File

@@ -0,0 +1,18 @@
<!-- c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\appointDetail\appointDetail.ttml -->
<view>
<view class="card">
<view class="item">订单编号:{{ detail.couponOrderId }}</view>
<view class="item">商品名称:{{ detail.couponTitle }}</view>
<view class="item">服务预约时间:{{ detail.appointTime }}</view>
<view class="item">服务预约地址:{{ detail.userAddress }}</view>
<view class="item">用户手机号码:{{ detail.userPhone }}</view>
<view class="item">备注:{{ detail.describeStr }}</view>
</view>
<view class="btns">
<button class="back" bindtap="back">返回</button>
<block tt:if="{{ detail.status != 8 }}">
<button tt:if="{{ detail.status == 0 }}" class="confirm" bindtap="confirm">确认预约</button>
<button tt:if="{{ detail.status == 5 }}" class="confirm" bindtap="cancel">取消预约</button>
</block>
</view>
</view>

+ 32
- 0
pages/appointDetail/appointDetail.ttss View File

@@ -0,0 +1,32 @@
/* c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttb\pages\appointDetail\appointDetail.ttss */
.card {
width: 95%;
border: 1px solid #00000063;
margin: 40rpx auto;
padding: 20rpx;
border-radius: 15rpx;
box-sizing: border-box;
}

.card .item {
margin-bottom: 20rpx;
}

.btns {
position: fixed;
width: 95%;
left: 50%;
bottom: 130rpx;
transform: translateX(-50%);
padding: 0 80rpx;
box-sizing: border-box;
}

.btns .back {
margin-bottom: 40rpx;
}

.btns .confirm {
color: #ffffff;
background-color: #52a0fd;
}

+ 2
- 2
pages/main/main.js View File

@@ -288,7 +288,7 @@ Page({
// id: 8
// }
{
text: '预约服务',
text: '服务预约',
icon: 'iconfont icon-lingquanzhongxin',
id: 9
},
@@ -520,7 +520,7 @@ Page({
})
} else if (id == 9) { //服务预约
tt.navigateTo({
url: '/pages/marktingsettlement/marktingsettlement',
url: '/pages/Appointment/appointment',
})
}
},


+ 81
- 82
pages/marktingsettlement/marktingsettlement.js View File

@@ -15,25 +15,25 @@ Page({
flagdate: null,
list: [],
tabTxt: [{
title: '全部',
idss: 0
},
{
title: '日期',
idss: 1
},
{
title: '类型',
idss: 2
},
{
title: '状态',
idss: 3
},
{
title: '来源',
idss: 4
}
title: '全部',
idss: 0
},
{
title: '日期',
idss: 1
},
{
title: '类型',
idss: 2
},
{
title: '状态',
idss: 3
},
{
title: '来源',
idss: 4
}
],
showList: null,
loading: "",
@@ -43,37 +43,36 @@ Page({
hasMore: false, //加载更多按钮
moreTxt: '点击加载更多',
dataNull: true,
status:'',
type:'',
source:'',
status: '',
type: '',
source: '',
date: "",
date2: "",
idss: 0,
subsidy:'',
subsidy: '',
pageNum: 1, //第几页
height: null,
billtypes: [{
name: '自主结算',
billTypeValue: 1,
id: 1
},
{
name: '微信分账',
billTypeValue: 2,
id: 2
}
name: '自主结算',
billTypeValue: 1,
id: 1
},
{
name: '微信分账',
billTypeValue: 2,
id: 2
}
],
statustypes: [
{
name: '未结算',
status: 0,
id: 0
},
{
name: '已结算',
status: 1,
id: 1
}
statustypes: [{
name: '未结算',
status: 0,
id: 0
},
{
name: '已结算',
status: 1,
id: 1
}
],
//结算来源
auditWayOptions: [
@@ -132,7 +131,7 @@ Page({
idss: e.target.dataset.idss || e.currentTarget.dataset.idss,
pageNum: 1
})
if (e.currentTarget.dataset.idss===0){
if (e.currentTarget.dataset.idss === 0) {
this.setData({
source: '',
type: '',
@@ -144,14 +143,14 @@ Page({
this.getTotleData()
}
var data = [true, true, true, true, true],
index = e.currentTarget.dataset.index;
index = e.currentTarget.dataset.index;
data[index] = !that.data.tab[index];
that.setData({
tab: data
})
},
bindDateChange1: function (e) {
if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()){
if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) {
tt.showToast({
title: '抱歉,开始日期不能大于结束日期',
icon: 'none',
@@ -178,19 +177,19 @@ Page({
date2: e.detail.value
})
},
search(e){
search(e) {
console.log(e.currentTarget.dataset.ids)
let type = e.currentTarget.dataset.ids;
if(type==0){
if (type == 0) {
this.setData({
source:'',
type:'',
status:'',
date:'',
date2:''
source: '',
type: '',
status: '',
date: '',
date2: ''
})
} else if(type == 1){
if(!this.data.date){
} else if (type == 1) {
if (!this.data.date) {
tt.showToast({
title: '抱歉请选择开始日期',
icon: 'none',
@@ -198,7 +197,7 @@ Page({
mask: false
});
return;
} else if (!this.data.date2){
} else if (!this.data.date2) {
tt.showToast({
title: '抱歉请选择结束日期',
icon: 'none',
@@ -209,7 +208,7 @@ Page({
}
} else if (type == 2) {
this.setData({
type:e.currentTarget.dataset.id
type: e.currentTarget.dataset.id
})
} else if (type == 3) {
console.log(e.currentTarget.dataset.id)
@@ -259,22 +258,22 @@ Page({
})
console.log(arr, 888888888888)
},
getTotleData(){
getTotleData() {
let _this = this;
Http.get({
url: config.api.getSubsidySummary,
data: {
startdate: this.data.date?this.data.date + " 00:00:00":'',
enddate: this.data.date2?this.data.date2 + " 23:59:59":'',
source: this.data.source,
type: this.data.type,
status: this.data.status
}
})
url: config.api.getSubsidySummary,
data: {
startdate: this.data.date ? this.data.date + " 00:00:00" : '',
enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
source: this.data.source,
type: this.data.type,
status: this.data.status
}
})
.then(res => {
console.log(res,777)
console.log(res, 777)
_this.setData({
subsidy: Number(Number(res.data.subsidy)/100).toFixed(2)
subsidy: Number(Number(res.data.subsidy) / 100).toFixed(2)
})
tt.stopPullDownRefresh();
})
@@ -291,17 +290,17 @@ Page({
getList: function (page) {
let _this = this;
Http.get({
url: config.api.getSubsidyList,
data: {
pageNum: page,
pageSize: 10,
startdate: this.data.date ? this.data.date + " 00:00:00" : '',
enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
source: this.data.source,
type: this.data.type,
status: this.data.status
}
})
url: config.api.getSubsidyList,
data: {
pageNum: page,
pageSize: 10,
startdate: this.data.date ? this.data.date + " 00:00:00" : '',
enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
source: this.data.source,
type: this.data.type,
status: this.data.status
}
})
.then(res => {
tt.stopPullDownRefresh();
let data = res.data.list;
@@ -316,7 +315,7 @@ Page({
item.createDate01 = util.formatTime(item.createDate, 'yyyy-MM-dddd hh:mm:ss')
item.sourceStr = this.data.auditWayOptions.filter(e => e.value == item.source).length > 0 ? this.data.auditWayOptions.filter(e => e.value == item.source)[0].name : '';
item.typeStr = this.data.billtypes.filter(e => e.id == item.type).length > 0 ? this.data.billtypes.filter(e => e.id == item.type)[0].name : '';
item.statusStr = item.status===0?'未结算' : "已结算";
item.statusStr = item.status === 0 ? '未结算' : "已结算";
allBillList.map((item02, index02) => {
if (item02.id == item.id) {
haveIf = true;
@@ -326,7 +325,7 @@ Page({
allBillList.push(item)
}
})
console.log(allBillList,444)
console.log(allBillList, 444)
if (res.data.pages <= page) {
_this.setData({
allBillList,


+ 27
- 0
project.private.config.json View File

@@ -0,0 +1,27 @@
{
"condition": {
"miniprogram": {
"current": -1,
"list": [
{
"id": 1687232092199,
"name": "pages/Appointment/appointment",
"pathName": "pages/Appointment/appointment",
"query": "",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
},
{
"id": 1687252858255,
"name": "pages/appointDetail/appointDetail",
"pathName": "pages/appointDetail/appointDetail",
"query": "id=831011125579538432",
"scene": "990001",
"launchFrom": "scan",
"location": "qr_code"
}
]
}
}
}

+ 82
- 24
utils/util.js View File

@@ -8,10 +8,11 @@ function convertUTCTimeToLocalTime(UTCDateString) {
if (!UTCDateString) {
return '-';
}
function formatFunc(str) { //格式化显示

function formatFunc(str) { //格式化显示
return str > 9 ? str : '0' + str
}
var date2 = new Date(UTCDateString); //这步是关键
var date2 = new Date(UTCDateString); //这步是关键
var year = date2.getFullYear();
var mon = formatFunc(date2.getMonth() + 1);
var day = formatFunc(date2.getDate());
@@ -20,7 +21,7 @@ function convertUTCTimeToLocalTime(UTCDateString) {
hour = hour >= 24 ? hour - 24 : hour;
hour = formatFunc(hour);
var min = formatFunc(date2.getMinutes());
var dateStr = ' ' + hour + ':' + min ;
var dateStr = ' ' + hour + ':' + min;
return dateStr;
}

@@ -29,15 +30,15 @@ function convertUTCTimeToLocalTime(UTCDateString) {
// return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
// }

function moodsText(Num){//人气值处理 Num人气值 返回字符串 处理到万位
function moodsText(Num) { //人气值处理 Num人气值 返回字符串 处理到万位
let sing = ""
if(Num>10000){
sing = (Num/10000).toFixed(2)+"w"
}else{
sing =Num
}
return sing
if (Num > 10000) {
sing = (Num / 10000).toFixed(2) + "w"
} else {
sing = Num
}
return sing
}

const formatTime = (date, fmt) => {
@@ -69,9 +70,9 @@ const formatTime = (date, fmt) => {
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length == 1
? o[k]
: ("00" + o[k]).substr(("" + o[k]).length)
RegExp.$1.length == 1 ?
o[k] :
("00" + o[k]).substr(("" + o[k]).length)
);
return fmt;
} catch (error) {
@@ -97,6 +98,61 @@ function barc(id, code, width, height) {
);
}

/**
* @description 根据时间戳获取时间
* @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位);若不传,则返回:“无时间戳”
* @param {*} format 选传,string类型,提供以下时间格式:YYYY-MM-DD hh:mm:ss、YYYY/MM/DD hh:mm:ss、YYYY.MM.DD hh:mm:ss、YYYY MM DD hh:mm:ss、YYYY年MM月DD日 hh:mm:ss、YYYY-MM-DD、YYYY/MM/DD、YYYY.MM.DD、YYYY MM DD、YYYY年MM月DD日、hh:mm:ss、hh:mm;若不传,则默认为:YYYY-MM-DD
* @returns 根据要求的时间格式
* @version V 1.0, Created by YWQ, 2022.10.20
*/
function timestampToTime(timestamp, format) {
if (!timestamp) return false
//时间戳为10位需*1000,时间戳为13位不需乘1000
const length = timestamp ? timestamp.length : ''

if (length <= 10) {
var date = new Date(timestamp * 1000)
} else {
var date = new Date(timestamp)
}


let Y = String(date.getFullYear())
let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
// return Y + M + D + h + m + s
if (format == "YYYY-MM-DD hh:mm:ss") {
return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
} else if (format == "YYYY/MM/DD hh:mm:ss") {
return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
} else if (format == "YYYY.MM.DD hh:mm:ss") {
return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
} else if (format == "YYYY MM DD hh:mm:ss") {
return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
} else if (format == "YYYY年MM月DD日 hh:mm:ss") {
return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
} else if (format == "YYYY-MM-DD") {
return Y + "-" + M + "-" + D
} else if (format == "YYYY/MM/DD") {
return Y + "/" + M + "/" + D
} else if (format == "YYYY.MM.DD") {
return Y + "." + M + "." + D
} else if (format == "YYYY MM DD") {
return Y + " " + M + " " + D
} else if (format == "YYYY年MM月DD日") {
return Y + "年" + M + "月" + D + "日"
} else if (format == "hh:mm:ss") {
return h + ":" + m + ":" + s
} else if (format == "hh:mm") {
return h + ":" + m
} else {
return Y + "-" + M + "-" + D
}
}

function qrc(id, code, width, height) {
qrcode.api.draw(code, {
ctx: tt.createCanvasContext(id),
@@ -137,20 +193,20 @@ function timechuo(startTime) {
var minute = Math.floor(runTime / 60);
var runTime = runTime % 60;
var second = runTime;
if (day && !year && !month){
if (day && !year && !month) {
return (day + '天' + hour + "小时" + minute + "分钟")
} else if (month && !year){
return ((month*30+day) +'天' + hour + "小时" + minute + "分钟")
} else if (month && !year) {
return ((month * 30 + day) + '天' + hour + "小时" + minute + "分钟")
} else if (year) {
return ((year*365 + month*30+ day) + '天' + hour + "小时" + minute + "分钟")
}else{
return ((year * 365 + month * 30 + day) + '天' + hour + "小时" + minute + "分钟")
} else {
return (hour + "小时" + minute + "分钟")
}
}


//计算时间差
function timecha(endTime,startTime) {
function timecha(endTime, startTime) {
var s1 = new Date(endTime.replace(/-/g, "/"));
var s2 = new Date(startTime.replace(/-/g, "/"));
var runTime = parseInt((s1.getTime() - s2.getTime()) / 1000);
@@ -165,8 +221,9 @@ function timecha(endTime,startTime) {
var minute = Math.floor(runTime / 60);
var runTime = runTime % 60;
var second = runTime;
return (month+"月"+day+"天"+hour+"小时"+minute+"分钟")
return (month + "月" + day + "天" + hour + "小时" + minute + "分钟")
}

function isJSON(str) {
if (typeof str == 'string') {
console.log("string")
@@ -202,6 +259,7 @@ module.exports = {
// fmtDate: fmtDate,
timechuo: timechuo,
timecha: timecha,
moodsText:moodsText,
convertUTCTimeToLocalTime: convertUTCTimeToLocalTime
};
moodsText: moodsText,
convertUTCTimeToLocalTime: convertUTCTimeToLocalTime,
timestampToTime: timestampToTime
};

Loading…
Cancel
Save