C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

203 righe
5.5 KiB

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