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.

214 lines
5.3 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. date: "", //默认起始时间
  11. date2: "", //默认结束时间
  12. list: [],
  13. typeList: [{
  14. name: '微信支付',
  15. value: 1
  16. }],
  17. statusList: [{
  18. name: '交易成功',
  19. value: 1
  20. }],
  21. showNocontent: true,
  22. todayDate: null,
  23. amount: "",
  24. total: "",
  25. page: 1,
  26. pageNum: 1,
  27. type: "",
  28. },
  29. bindDateChange(e) {
  30. let that = this;
  31. that.setData({
  32. date: e.detail.value + " 00:00:00",
  33. })
  34. console.log(that.data.date)
  35. },
  36. bindDateChange2(e) {
  37. let that = this;
  38. that.setData({
  39. date2: e.detail.value + " 23:59:59",
  40. })
  41. console.log(that.data.date2)
  42. },
  43. onShow: function () {
  44. let that = this;
  45. that.setData({
  46. date: '选择开始日期',
  47. date2: '选择结束日期',
  48. });
  49. },
  50. onLoad(option) {
  51. console.log(option, 'option');
  52. this.setData({
  53. type: option.type
  54. })
  55. if (option.type == "transaction") {
  56. wx.setNavigationBarTitle({
  57. title: '核销记录',
  58. })
  59. } else if (option.type == "record") {
  60. wx.setNavigationBarTitle({
  61. title: '收银记录',
  62. })
  63. } else if (option.type == "pos") {
  64. wx.setNavigationBarTitle({
  65. title: '交易流水',
  66. })
  67. }
  68. },
  69. search: function () {
  70. let that = this;
  71. let startdate = that.data.date;
  72. let enddate = that.data.date2;
  73. console.log(startdate, enddate);
  74. if (startdate == "选择开始日期" || enddate == "选择结束日期") {
  75. wx.showToast({
  76. title: '请选择起止时间!',
  77. icon: "none"
  78. })
  79. return
  80. }
  81. that.setData({
  82. pageNum: 1
  83. })
  84. this.getList()
  85. this.getSum()
  86. },
  87. getList() {
  88. const that = this
  89. const pageNum = that.data.pageNum
  90. const type = that.data.type
  91. const data = {
  92. pageNum,
  93. pageSize: 20,
  94. startDate: that.data.date,
  95. endDate: that.data.date2,
  96. phone: type == "pos" ? wx.getStorageSync("linkPhone") : undefined,
  97. createBegin: type == "pos" ? that.data.date : undefined,
  98. createEnd: type == "pos" ? that.data.date2 : undefined,
  99. }
  100. // const url = type == "transaction"
  101. // ? config.api.couponOrderListVerifiedV2
  102. // : config.api.micropayListMicroPayV2
  103. let url = ''
  104. if (type == "transaction") {
  105. url = config.api.couponOrderListVerifiedV2
  106. } else if (type == "record"){
  107. url = config.api.micropayListMicroPayV2
  108. } else if (type == "pos") {
  109. url = config.api.oneMerchantOrderlist
  110. }
  111. Http.get({
  112. url,
  113. data
  114. })
  115. .then(res => {
  116. wx.hideLoading()
  117. console.log(res, 'res');
  118. if (type == "pos") {
  119. if (res.data.list) {
  120. that.setData({
  121. list: res.data.list,
  122. })
  123. that.setData({
  124. showNocontent: false
  125. })
  126. }
  127. return
  128. }
  129. if (res.data.list && res.data.list.list && res.data.list.list.length > 0) {
  130. that.setData({
  131. showNocontent: false
  132. })
  133. res.data && res.data.list.list.map(file => {
  134. file.expiredTime = format.formatTime(file.expiredTime, 'yyyy-MM-dddd hh:mm:ss')
  135. file.createDate = format.formatTime(file.createDate, 'yyyy-MM-dddd hh:mm:ss')
  136. file.updateDate = format.formatTime(file.updateDate, 'yyyy-MM-dddd hh:mm:ss')
  137. file.ids = file.id.slice(0, 4) + `******` + file.id.slice(14)
  138. if (type == "record") {
  139. that.data.typeList.map((item01) => {
  140. if (file.type == item01.value) {
  141. file.type = item01.name
  142. }
  143. })
  144. that.data.statusList.map((item01) => {
  145. if (file.orderStatus == item01.value) {
  146. file.orderStatus = item01.name
  147. }
  148. })
  149. }
  150. })
  151. }
  152. if (pageNum == 1) {
  153. that.setData({
  154. list: res.data.list.list,
  155. // amount: res.data.amount / 100
  156. })
  157. } else if (pageNum > 1) {
  158. const list = that.data.list
  159. // let amount = that.data.amount + res.data.amount
  160. res.data.list.list.forEach(item => {
  161. list.push(item)
  162. })
  163. that.setData({
  164. list,
  165. // amount
  166. })
  167. }
  168. }).catch(err => {
  169. console.log(err, 'err');
  170. })
  171. },
  172. getSum() {
  173. const that = this
  174. const type = that.data.type
  175. const url = type == "transaction"
  176. ? config.api.couponOrderSumVerified
  177. : config.api.micropaySumMicroPay
  178. const data = {
  179. startDate: that.data.date,
  180. endDate: that.data.date2
  181. }
  182. Http.get({
  183. url,
  184. data
  185. })
  186. .then(res => {
  187. console.log(res, 'res');
  188. that.setData({
  189. amount: res.data.amount / 100,
  190. total: res.data.total
  191. })
  192. }).catch(err => {
  193. console.log(err, 'err');
  194. })
  195. },
  196. onReachBottom: function () {
  197. wx.showLoading({
  198. title: '玩命加载中',
  199. })
  200. let pageNum = this.data.pageNum + 1
  201. this.setData({
  202. pageNum
  203. })
  204. this.getList()
  205. },
  206. })