微信小程序时间两侧拖拉

2023-10-23 19:32

本文主要是介绍微信小程序时间两侧拖拉,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果:

在这里插入图片描述

wxs文件:

var taskFr = {getTask: function (time) {time = time+480;var d, h, m, h = (time / 60 % 24).toFixed(0);m = (time  % 60).toFixed(0);if(m>=0 &&m<10){m='0'+m}var timeStr =  h + ":" + m return timeStr}
}module.exports = {getTask: taskFr.getTask
}

xml文件:

<view class="history"><view id="the-id" class="content" wx:for="{{historyList}}" wx:for-index="idx" wx:for-item="itemName" wx:key="idx"><view class="history-detail"><mp-cell bindtap="godetail" data-index="{{itemName.code}}" link hover url="/pages/panel/myEquipment/devicecontrol/devicehistory/historydetail/historydetail"value="消毒时间:{{itemName.startTime}}"><image slot="icon" src="/assets/images/时间.svg"style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image></mp-cell><view class="line"></view><mp-cell hover value="消毒响应:{{itemName.status==1?'成功':'消毒失败'}}"><image slot="icon" src="/assets/images/响应.svg"style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image></mp-cell><view class="line"></view><mp-cell hover value="消毒结束时间:{{itemName.endTime}}"><image slot="icon" url="../index" src="/assets/images/结束时间.svg"style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image></mp-cell><view class="line"></view><mp-cell hover value="指令编号:{{itemName.code}}"><image slot="icon" src="/assets/images/编号.svg"style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image></mp-cell><view class="line"></view></view></view><view class="more"  bindtap="moreHistory">点击加载更多</view>
</view>

wxss文件:

.line {border: 1rpx dotted lightgray;height: 1rpx;width: 100%;
}
.history {background-color: #fcfaf9;
}
.history-detail {background-color: white;margin-bottom: 100rpx;
}
.more {/* position: fixed; *//* position: absolute; *//* bottom: 20rpx; */margin-top: 20px;text-align: center;height: 60rpx;
}

js文件:

// pages/panel/myEquipment/devicecontrol/devicehistory/devicehistory.js
const util = require('./../../../../../utils/util')
import {requst_disinfection_history
} from './../../../../api/index'
Page({/*** 页面的初始数据*/data: {//每页显示的行数:pagesize: 2,//页码(从1开始):page: 1,//用于标识是否还有更多的状态state: 1,//用于数组的追加和暂存allList: [],//用于渲染页面的数组historyList: [],},//自定义函数//点击后保留当前id的机器数据再进入下个页面godetail:function (event) {var index=event.currentTarget.dataset['index'];wx.setStorageSync('historyid', index)// wx.setStorageSync('name', 'jello')// wx.navigateTo({//   url: '/pages/panel/myEquipment/devicecontrol/devicecontroal'//点击后跳转// })},//日期转换函数getTime: function (time) {time *= 1;let date = new Date(time);let y = date.getFullYear(); // 年let MM = date.getMonth() + 1; // 月MM = MM < 10 ? ('0' + MM) : MM;let d = date.getDate(); // 日d = d < 10 ? ('0' + d) : d;let h = date.getHours(); // 时h = h < 10 ? ('0' + h) : h;let m = date.getMinutes(); // 分m = m < 10 ? ('0' + m) : m;let s = date.getSeconds(); // 秒s = s < 10 ? ('0' + s) : s;return y + '年' + MM + '月' + d + '日' + h + ':' + m + ':' + s;},//获取消毒列表getHistory(pagesize, page) {var that = this;requst_disinfection_history({pagesize,page}).then((e) => {if (res.data.length < 1) {that.setData({state: 0})} else if (res.data.length < that.data.pagesize) {that.setData({state: 0})}e.forEach(res => {console.log(res.startTime);res.startTime = that.getTime(res.startTime);res.endTime = that.getTime(res.endTime);that.data.allList.push(res)})that.setData({historyList: that.data.allList})console.log(that.data.historyList);}).catch((err) => {console.log(err);})},moreHistory() {this.setData({page: this.data.page + 1});this.getHistory(this.data.pagesize, this.data.page);},/*** 生命周期函数--监听页面加载*/onLoad: function (options) {var that = thiswx.setNavigationBarTitle({title: '历史消毒记录'});//页面初始化this.getHistory(this.data.pagesize, this.data.page);//模拟请求数据util.httpFake('disinfection-history', 'get', {}, function (e) {console.log(e);e.forEach(res => {console.log(res.startTime);res.startTime = that.getTime(res.startTime);res.endTime = that.getTime(res.endTime);that.data.allList.push(res)})that.setData({historyList: that.data.allList})console.log(that.data.historyList);});},/*** 生命周期函数--监听页面初次渲染完成*/onReady: function () {},/*** 生命周期函数--监听页面显示*/onShow: function () {},/*** 生命周期函数--监听页面隐藏*/onHide: function () {},/*** 生命周期函数--监听页面卸载*/onUnload: function () {},/*** 页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh: function () {},/*** 页面上拉触底事件的处理函数*/onReachBottom: function () {},/*** 用户点击右上角分享*/onShareAppMessage: function () {}
})

这篇关于微信小程序时间两侧拖拉的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/270010

相关文章

C++ 函数 strftime 和时间格式示例详解

《C++函数strftime和时间格式示例详解》strftime是C/C++标准库中用于格式化日期和时间的函数,定义在ctime头文件中,它将tm结构体中的时间信息转换为指定格式的字符串,是处理... 目录C++ 函数 strftipythonme 详解一、函数原型二、功能描述三、格式字符串说明四、返回值五

从基础到进阶详解Pandas时间数据处理指南

《从基础到进阶详解Pandas时间数据处理指南》Pandas构建了完整的时间数据处理生态,核心由四个基础类构成,Timestamp,DatetimeIndex,Period和Timedelta,下面我... 目录1. 时间数据类型与基础操作1.1 核心时间对象体系1.2 时间数据生成技巧2. 时间索引与数据

Python基于微信OCR引擎实现高效图片文字识别

《Python基于微信OCR引擎实现高效图片文字识别》这篇文章主要为大家详细介绍了一款基于微信OCR引擎的图片文字识别桌面应用开发全过程,可以实现从图片拖拽识别到文字提取,感兴趣的小伙伴可以跟随小编一... 目录一、项目概述1.1 开发背景1.2 技术选型1.3 核心优势二、功能详解2.1 核心功能模块2.

python编写朋克风格的天气查询程序

《python编写朋克风格的天气查询程序》这篇文章主要为大家详细介绍了一个基于Python的桌面应用程序,使用了tkinter库来创建图形用户界面并通过requests库调用Open-MeteoAPI... 目录工具介绍工具使用说明python脚本内容如何运行脚本工具介绍这个天气查询工具是一个基于 Pyt

Ubuntu设置程序开机自启动的操作步骤

《Ubuntu设置程序开机自启动的操作步骤》在部署程序到边缘端时,我们总希望可以通电即启动我们写好的程序,本篇博客用以记录如何在ubuntu开机执行某条命令或者某个可执行程序,需要的朋友可以参考下... 目录1、概述2、图形界面设置3、设置为Systemd服务1、概述测试环境:Ubuntu22.04 带图

Python程序打包exe,单文件和多文件方式

《Python程序打包exe,单文件和多文件方式》:本文主要介绍Python程序打包exe,单文件和多文件方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录python 脚本打成exe文件安装Pyinstaller准备一个ico图标打包方式一(适用于文件较少的程

Python程序的文件头部声明小结

《Python程序的文件头部声明小结》在Python文件的顶部声明编码通常是必须的,尤其是在处理非ASCII字符时,下面就来介绍一下两种头部文件声明,具有一定的参考价值,感兴趣的可以了解一下... 目录一、# coding=utf-8二、#!/usr/bin/env python三、运行Python程序四、

如何基于Python开发一个微信自动化工具

《如何基于Python开发一个微信自动化工具》在当今数字化办公场景中,自动化工具已成为提升工作效率的利器,本文将深入剖析一个基于Python的微信自动化工具开发全过程,有需要的小伙伴可以了解下... 目录概述功能全景1. 核心功能模块2. 特色功能效果展示1. 主界面概览2. 定时任务配置3. 操作日志演示

利用Python实现时间序列动量策略

《利用Python实现时间序列动量策略》时间序列动量策略作为量化交易领域中最为持久且被深入研究的策略类型之一,其核心理念相对简明:对于显示上升趋势的资产建立多头头寸,对于呈现下降趋势的资产建立空头头寸... 目录引言传统策略面临的风险管理挑战波动率调整机制:实现风险标准化策略实施的技术细节波动率调整的战略价

Redis迷你版微信抢红包实战

《Redis迷你版微信抢红包实战》本文主要介绍了Redis迷你版微信抢红包实战... 目录1 思路分析1.1hCckRX 流程1.2 注意点①拆红包:二倍均值算法②发红包:list③抢红包&记录:hset2 代码实现2.1 拆红包splitRedPacket2.2 发红包sendRedPacket2.3 抢