You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
5.0 KiB

  1. const config = require('../../config/config.js')
  2. const Http = require('../../utils/HttpBasics.js')
  3. const format = require('../../utils/util.js')
  4. const util = require('../../utils/util.js')
  5. const qrCodeJS = require('../../utils/qrcode.js')
  6. var app = getApp()
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. item: {},
  13. cardSend: {},
  14. refund: {},
  15. refundFee: '',
  16. payStatus: 0 // 3退款中、4已退款
  17. },
  18. getPayMoney(e) {
  19. this.setData({
  20. refundFee: e.detail.value
  21. })
  22. },
  23. getDetail(cardSpendId) {
  24. const that = this
  25. const data = {
  26. cardSpendId: cardSpendId
  27. }
  28. Http.get({
  29. url: config.api.cardPayDetail,
  30. data
  31. }).then(res => {
  32. if (res.data.cardSend) {
  33. res.data.cardSend.createDate = that.timestampToTime(res.data.cardSend.createDate, 'YYYY-MM-DD hh:mm:ss')
  34. }
  35. if (res.data.refund) {
  36. res.data.refund.createTime = that.timestampToTime(res.data.refund.createTime, 'YYYY-MM-DD hh:mm:ss')
  37. }
  38. that.setData({
  39. cardSend: res.data.cardSend,
  40. refund: res.data.refund,
  41. })
  42. }).catch(err => {
  43. console.log(err, 'err');
  44. })
  45. },
  46. refundConfirm() {
  47. const data = {
  48. cardSpendId: this.data.item.id,
  49. refundFee: this.data.refundFee
  50. }
  51. Http.post({
  52. url: config.api.cardRefundCardOrder,
  53. data
  54. })
  55. .then(res => {
  56. wx.showToast({
  57. title: '申请成功!',
  58. icon: 'success'
  59. })
  60. setTimeout(() => {
  61. wx.navigateBack()
  62. }, 1500);
  63. }).catch(err => {
  64. console.log(err, 'err');
  65. wx.showToast({
  66. title: err.message,
  67. icon: 'none'
  68. })
  69. })
  70. },
  71. back() {
  72. wx.navigateBack()
  73. },
  74. /**
  75. * @description 根据时间戳获取时间
  76. * @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位);若不传,则返回:“无时间戳”
  77. * @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
  78. * @returns 根据要求的时间格式
  79. * @version V 1.0, Created by YWQ, 2022.10.20
  80. */
  81. timestampToTime(timestamp, format) {
  82. //时间戳为10位需*1000,时间戳为13位不需乘1000
  83. const length = timestamp.length
  84. if (length <= 10) {
  85. var date = new Date(timestamp * 1000)
  86. } else {
  87. var date = new Date(timestamp)
  88. }
  89. let Y = String(date.getFullYear())
  90. let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  91. let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
  92. let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
  93. let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
  94. let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
  95. // return Y + M + D + h + m + s
  96. if (format == "YYYY-MM-DD hh:mm:ss") {
  97. return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
  98. } else if (format == "YYYY/MM/DD hh:mm:ss") {
  99. return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
  100. } else if (format == "YYYY.MM.DD hh:mm:ss") {
  101. return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
  102. } else if (format == "YYYY MM DD hh:mm:ss") {
  103. return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
  104. } else if (format == "YYYY年MM月DD日 hh:mm:ss") {
  105. return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
  106. } else if (format == "YYYY-MM-DD") {
  107. return Y + "-" + M + "-" + D
  108. } else if (format == "YYYY/MM/DD") {
  109. return Y + "/" + M + "/" + D
  110. } else if (format == "YYYY.MM.DD") {
  111. return Y + "." + M + "." + D
  112. } else if (format == "YYYY MM DD") {
  113. return Y + " " + M + " " + D
  114. } else if (format == "YYYY年MM月DD日") {
  115. return Y + "年" + M + "月" + D + "日"
  116. } else {
  117. return Y + "-" + M + "-" + D
  118. }
  119. },
  120. /**
  121. * 生命周期函数--监听页面加载
  122. */
  123. onLoad(options) {
  124. if (options.item) {
  125. console.log(options, 'options');
  126. const item = JSON.parse(options.item)
  127. console.log(item, 'item');
  128. this.setData({
  129. item: item
  130. })
  131. this.getDetail(item.id)
  132. }
  133. },
  134. /**
  135. * 生命周期函数--监听页面初次渲染完成
  136. */
  137. onReady() {
  138. },
  139. /**
  140. * 生命周期函数--监听页面显示
  141. */
  142. onShow() {
  143. },
  144. /**
  145. * 生命周期函数--监听页面隐藏
  146. */
  147. onHide() {
  148. },
  149. /**
  150. * 生命周期函数--监听页面卸载
  151. */
  152. onUnload() {
  153. },
  154. /**
  155. * 页面相关事件处理函数--监听用户下拉动作
  156. */
  157. onPullDownRefresh() {
  158. },
  159. /**
  160. * 页面上拉触底事件的处理函数
  161. */
  162. onReachBottom() {
  163. },
  164. /**
  165. * 用户点击右上角分享
  166. */
  167. onShareAppMessage() {
  168. }
  169. })