Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

232 строки
7.2 KiB

  1. const config = require('../../config/config.js')
  2. const Http = require('../../utils/HttpBasics.js')
  3. const format = require('../../utils/util.js')
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. list: [],
  11. showNocontent: false,
  12. sum_real_payment1: 0,
  13. sum_real_payment2: 0,
  14. sum_real_payment3: 0,
  15. page: 1,
  16. tabIndex: 0
  17. },
  18. /**
  19. * 生命周期函数--监听页面显示
  20. */
  21. onShow() {
  22. let that = this;
  23. // 获取当前的时间
  24. let myDate = new Date();
  25. let date_value = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate();
  26. that.setData({
  27. todayDate: date_value
  28. })
  29. that.getList(1);
  30. that.payMum1();
  31. // that.payMum2();
  32. // that.payMum3();
  33. },
  34. getList(page) {
  35. let that = this;
  36. let postData = {
  37. pageNum: page,
  38. pageSize: 10,
  39. startdate: this.data.todayDate + " 00:00:00",
  40. enddate: this.data.todayDate + " 23:59:59",
  41. payType: this.data.tabIndex
  42. }
  43. Http.get({
  44. url: config.api.cardPayList,
  45. data: postData
  46. })
  47. .then(res => {
  48. res.data.list.forEach(item => {
  49. item.cardId = item.cardId.slice(0, 4) + `******` + item.cardId.slice(14)
  50. item.createDate = that.timestampToTime(item.createDate, 'YYYY-MM-DD hh:mm:ss')
  51. })
  52. if (page == 1) {
  53. that.setData({
  54. list: []
  55. })
  56. }
  57. var tmpArr = that.data.list;
  58. tmpArr.push.apply(tmpArr, res.data.list);
  59. if (res.code == 200 && tmpArr.length > 0) {
  60. tmpArr.map(file => {
  61. file.updateDate = format.formatTime(file.updateDate, 'yyyy-MM-dddd hh:mm:ss')
  62. console.log(file.updateDate)
  63. })
  64. that.setData({
  65. length: res.data.total,
  66. list: tmpArr
  67. })
  68. } else {
  69. that.setData({
  70. length: 0,
  71. showNocontent: true
  72. })
  73. }
  74. })
  75. },
  76. payMum1: function () {
  77. let that = this;
  78. let postData = {
  79. merchantId: app.globalData.merchant.merchant_id,
  80. startdate: this.data.todayDate + " 00:00:00",
  81. enddate: this.data.todayDate + " 23:59:59",
  82. payType: this.data.tabIndex
  83. };
  84. Http.get({
  85. url: config.api.payMum,
  86. data: postData
  87. })
  88. .then(res => {
  89. if (res.data.length > 0) {
  90. that.setData({
  91. sum_real_payment1: Number(res.data[0].sum_deduction_amount ? res.data[0].sum_deduction_amount : 0)
  92. })
  93. } else {
  94. that.setData({
  95. sum_real_payment1: Number(res.data.sum_deduction_amount ? res.data.sum_deduction_amount : 0)
  96. })
  97. }
  98. })
  99. .catch(err => {
  100. console.log(err)
  101. })
  102. },
  103. payMum2: function () {
  104. let that = this;
  105. let postData = {
  106. merchantId: app.globalData.merchant.merchant_id,
  107. startdate: this.data.todayDate + " 00:00:00",
  108. enddate: this.data.todayDate + " 23:59:59",
  109. payStatus: 1,
  110. payType: this.data.tabIndex
  111. };
  112. Http.get({
  113. url: config.api.payMum,
  114. data: postData
  115. })
  116. .then(res => {
  117. if (res.data.length > 0) {
  118. console.log(res.data[0].sum_real_payment, 222)
  119. that.setData({
  120. sum_real_payment2: Number(res.data[0].sum_deduction_amount ? res.data[0].sum_deduction_amount : 0)
  121. })
  122. } else {
  123. that.setData({
  124. sum_real_payment2: Number(res.data.sum_deduction_amount ? res.data.sum_deduction_amount : 0)
  125. })
  126. }
  127. })
  128. .catch(err => {
  129. console.log(err)
  130. })
  131. },
  132. payMum3: function () {
  133. let that = this;
  134. let postData = {
  135. merchantId: app.globalData.merchant.merchant_id,
  136. startdate: this.data.todayDate + " 00:00:00",
  137. enddate: this.data.todayDate + " 23:59:59",
  138. payStatus: 2,
  139. payType: this.data.tabIndex
  140. };
  141. Http.get({
  142. url: config.api.payMum,
  143. data: postData
  144. })
  145. .then(res => {
  146. if (res.data.length > 0) {
  147. that.setData({
  148. sum_real_payment3: Number(res.data[0].sum_deduction_amount ? res.data[0].sum_deduction_amount : 0)
  149. })
  150. } else {
  151. that.setData({
  152. sum_real_payment3: Number(res.data.sum_deduction_amount ? res.data.sum_deduction_amount : 0)
  153. })
  154. }
  155. })
  156. .catch(err => {
  157. console.log(err)
  158. })
  159. },
  160. // 跳转到按日期查询界面
  161. gotoDate: function () {
  162. wx.navigateTo({
  163. url: '/pages/receiveDate/receiveDate',
  164. })
  165. },
  166. /**
  167. * @description 根据时间戳获取时间
  168. * @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位);若不传,则返回:“无时间戳”
  169. * @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
  170. * @returns 根据要求的时间格式
  171. * @version V 1.0, Created by YWQ, 2022.10.20
  172. */
  173. timestampToTime(timestamp, format) {
  174. //时间戳为10位需*1000,时间戳为13位不需乘1000
  175. const length = timestamp.length
  176. if (length <= 10) {
  177. var date = new Date(timestamp * 1000)
  178. } else {
  179. var date = new Date(timestamp)
  180. }
  181. let Y = String(date.getFullYear())
  182. let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  183. let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
  184. let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
  185. let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
  186. let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
  187. // return Y + M + D + h + m + s
  188. if (format == "YYYY-MM-DD hh:mm:ss") {
  189. return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
  190. } else if (format == "YYYY/MM/DD hh:mm:ss") {
  191. return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
  192. } else if (format == "YYYY.MM.DD hh:mm:ss") {
  193. return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
  194. } else if (format == "YYYY MM DD hh:mm:ss") {
  195. return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
  196. } else if (format == "YYYY年MM月DD日 hh:mm:ss") {
  197. return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
  198. } else if (format == "YYYY-MM-DD") {
  199. return Y + "-" + M + "-" + D
  200. } else if (format == "YYYY/MM/DD") {
  201. return Y + "/" + M + "/" + D
  202. } else if (format == "YYYY.MM.DD") {
  203. return Y + "." + M + "." + D
  204. } else if (format == "YYYY MM DD") {
  205. return Y + " " + M + " " + D
  206. } else if (format == "YYYY年MM月DD日") {
  207. return Y + "年" + M + "月" + D + "日"
  208. } else {
  209. return Y + "-" + M + "-" + D
  210. }
  211. },
  212. // 更改tab栏
  213. changeTabs(e) {
  214. this.setData({
  215. list: [],
  216. tabIndex: e.target.id,
  217. })
  218. this.getList(1);
  219. this.payMum1();
  220. },
  221. //加载更多
  222. onReachBottom: function () {
  223. let that = this;
  224. that.data.page++;
  225. that.setData({
  226. page: that.data.page
  227. });
  228. that.getList(that.data.page);
  229. },
  230. })