C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

showList.js 5.1 KiB

il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 2 ans
il y a 1 an
il y a 2 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const navigationBarHeight = (getApp().statusBarHeight + 40) + 'px'
  2. let config = require("../../../config/config.js");
  3. let Http = require("../../../utils/HttpBasics");
  4. const util = require("../../../utils/util");
  5. let app = getApp();
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. navigationBarHeight,
  13. carPayOrderList: [],
  14. pageNum: '1'
  15. },
  16. getList(pageNum) {
  17. const that = this
  18. Http.get({
  19. url: config.api.carPayOrderList + `?pageNum=${pageNum}&pageSize=10`,
  20. }).then(res => {
  21. console.log(res, 'res');
  22. res.data.list.forEach(item => {
  23. item.payTime = this.timestampToTime(item.payTime, 'YYYY-MM-DD hh:mm:ss')
  24. item.createTime = this.timestampToTime(item.createTime, 'YYYY-MM-DD hh:mm:ss')
  25. item.updateTime = this.timestampToTime(item.updateTime, 'YYYY-MM-DD hh:mm:ss')
  26. })
  27. if (pageNum == 1) {
  28. const tempArr = res.data.list
  29. tempArr.forEach(item => {
  30. item.payAmount = this.getPayNumber(item.payAmount)
  31. })
  32. that.setData({
  33. carPayOrderList: res.data.list
  34. })
  35. } else {
  36. const tempArr = that.data.carPayOrderList
  37. res.data.list.forEach(item => {
  38. item.payAmount = this.getPayNumber(item.payAmount)
  39. tempArr.push(item)
  40. })
  41. that.setData({
  42. carPayOrderList: tempArr
  43. })
  44. }
  45. }).catch(err => {
  46. })
  47. },
  48. getPayNumber(num) {
  49. return (num / 100).toFixed(2) + "元"
  50. },
  51. goDetial(e) {
  52. const item = JSON.stringify(e.currentTarget.dataset.item)
  53. wx.navigateTo({
  54. url: `/pages/passCar/showDetail/showDetail?item=${item}`,
  55. })
  56. },
  57. /**
  58. * @description 根据时间戳获取时间
  59. * @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位)
  60. * @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日;若不传,则默认为:YYYY-MM-DD
  61. * @returns 根据要求的时间格式
  62. * @version V 1.0, Created by YWQ, 2022.10.20
  63. */
  64. timestampToTime(timestamp, format) {
  65. //时间戳为10位需*1000,时间戳为13位不需乘1000
  66. const length = timestamp.length
  67. if (length <= 10) {
  68. var date = new Date(timestamp * 1000)
  69. } else {
  70. var date = new Date(timestamp)
  71. }
  72. let Y = String(date.getFullYear())
  73. let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  74. let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
  75. let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
  76. let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
  77. let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
  78. // return Y + M + D + h + m + s
  79. if (format == "YYYY-MM-DD hh:mm:ss") {
  80. return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
  81. } else if (format == "YYYY/MM/DD hh:mm:ss") {
  82. return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
  83. } else if (format == "YYYY.MM.DD hh:mm:ss") {
  84. return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
  85. } else if (format == "YYYY MM DD hh:mm:ss") {
  86. return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
  87. } else if (format == "YYYY年MM月DD日 hh:mm:ss") {
  88. return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
  89. } else if (format == "YYYY-MM-DD") {
  90. return Y + "-" + M + "-" + D
  91. } else if (format == "YYYY/MM/DD") {
  92. return Y + "/" + M + "/" + D
  93. } else if (format == "YYYY.MM.DD") {
  94. return Y + "." + M + "." + D
  95. } else if (format == "YYYY MM DD") {
  96. return Y + " " + M + " " + D
  97. } else if (format == "YYYY年MM月DD日") {
  98. return Y + "年" + M + "月" + D + "日"
  99. } else {
  100. return Y + "-" + M + "-" + D
  101. }
  102. },
  103. /**
  104. * 生命周期函数--监听页面加载
  105. */
  106. onLoad(options) {
  107. Http.get({
  108. url: config.api.checkPhoneStatus,
  109. data: {}
  110. }).then(res => {
  111. this.getList(this.data.pageNum)
  112. }).catch(err => {
  113. wx.navigateTo({
  114. url: `/pages/getphoneInfo/index?path=passCarList`,
  115. })
  116. })
  117. },
  118. /**
  119. * 生命周期函数--监听页面初次渲染完成
  120. */
  121. onReady() {
  122. },
  123. /**
  124. * 生命周期函数--监听页面显示
  125. */
  126. onShow() {
  127. },
  128. /**
  129. * 生命周期函数--监听页面隐藏
  130. */
  131. onHide() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面卸载
  135. */
  136. onUnload() {
  137. },
  138. /**
  139. * 页面相关事件处理函数--监听用户下拉动作
  140. */
  141. onPullDownRefresh() {
  142. this.getList(this.data.pageNum);
  143. wx.stopPullDownRefresh();
  144. },
  145. /**
  146. * 页面上拉触底事件的处理函数
  147. */
  148. onReachBottom() {
  149. const that = this;
  150. that.data.pageNum++;
  151. that.setData({
  152. pageNum: that.data.pageNum
  153. });
  154. that.getList(that.data.pageNum);
  155. },
  156. /**
  157. * 用户点击右上角分享
  158. */
  159. onShareAppMessage() {
  160. }
  161. })