exchangeRecord.js 7.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. list: [],
  6. page: 1,
  7. image: '',
  8. sn: '',
  9. },
  10. onLoad() {
  11. that = this;
  12. dd.setNavigationBar({ title: "兑换记录" });
  13. this.getData();
  14. },
  15. openDetail(e) {
  16. var id = e.target.dataset.item.id;
  17. dd.navigateTo({
  18. url: '../prizeDetail/prizeDetail?id=' + id + '&is=1'
  19. })
  20. },
  21. showText(e) {
  22. if (e.target.dataset.item) {
  23. var id = e.target.dataset.item.id;
  24. app.$get('api/shop/exchange/qrcode', { id: id, employee_id: app.globalData.userData.id }).then((res) => {
  25. this.setData({
  26. image: app.globalData.baseUrl + res.data.data,
  27. sn: e.target.dataset.item.sn
  28. })
  29. })
  30. }
  31. this.setData({
  32. isBh: !this.data.isBh,
  33. })
  34. },
  35. handleCopy() {
  36. dd.setClipboard({
  37. text: this.data.sn,
  38. })
  39. app.globalData.showToast("已复制");
  40. },
  41. //上啦加载
  42. onScrollToLower() {
  43. if (!that.data.isData) {
  44. this.setData({ page: ++that.data.page })
  45. this.getData(true);
  46. }
  47. },
  48. getData(is) {
  49. var data = {
  50. page: this.data.page,
  51. page_size: 20,
  52. export: 0,
  53. self_only: 1,
  54. }
  55. app.$get('api/shop/exchange/list', data).then((res) => {
  56. var data = res.data.data.list;
  57. // var data = [{ "id": 12, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Rbyz1GyicvA=", "status": 2, "goods_id": 2, "cancel_remark": "我不行要了", "remark": "", "complete_time": 1638945904, "create_time": "1638753880", "update_time": "1638945904", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 11, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Q/LSNQ5ifE4=", "status": 2, "goods_id": 2, "cancel_remark": "请问请问", "remark": "", "complete_time": 1638945970, "create_time": "1638753877", "update_time": "1638945970", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 10, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "ta4pqZiK+Us=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950372, "create_time": "1638753875", "update_time": "1638950372", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 9, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Mqoj3ep8bhw=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950372, "create_time": "1638753872", "update_time": "1638950372", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 8, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "sZCbBbLnP8w=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638753869", "update_time": "1638950410", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 7, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "INQTFWQ8y24=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638753866", "update_time": "1638950410", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 6, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "z3/Wklt2268=", "status": 2, "goods_id": 2, "cancel_remark": "不想要", "remark": "", "complete_time": 1638514879, "create_time": "1638514822", "update_time": "1638514879", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 5, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "Fxq1K/GC+pY=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638514772", "update_time": "1638950410", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 4, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "No0/drUMdlQ=", "status": 0, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 0, "create_time": "1638514623", "update_time": "1638514623", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 3, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "aZ6VskccUEk=", "status": 0, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 0, "create_time": "1638514513", "update_time": "1638514513", "delete_time": null, "goods_image": null, "goods_desc": null, "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }]
  58. data.map(item => {
  59. item.date = this.timestampToTime(item.create_time)
  60. })
  61. var list = that.data.list;
  62. if (is) {
  63. if (data.length < 20) {
  64. this.setData({
  65. list: list.concat(data),
  66. isData: true
  67. })
  68. } else {
  69. this.setData({
  70. list: list.concat(data)
  71. })
  72. }
  73. } else {
  74. this.setData({
  75. list: data,
  76. isData: false
  77. })
  78. }
  79. })
  80. },
  81. timestampToTime(timestamp) {
  82. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  83. var Y = date.getFullYear() + '-';
  84. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  85. var D = date.getDate() + ' ';
  86. var h = date.getHours() + ':';
  87. var m = date.getMinutes() + ':';
  88. var s = date.getSeconds();
  89. return Y + M + D + h + m + s;
  90. },
  91. });