prizeDetail.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. detail: {},
  6. id: '',
  7. is: true,//是否是发放员进来
  8. disabled: false,
  9. sn:'',
  10. image:''
  11. },
  12. onLoad(e) {
  13. that = this;
  14. dd.setNavigationBar({ title: "奖品兑换详情" });
  15. if (e.id) {
  16. this.setData({ id: e.id })
  17. }
  18. if (e.is) {
  19. this.setData({ is: false })
  20. }
  21. },
  22. showImg(e) {
  23. var url = e.target.dataset.url
  24. dd.previewImage({
  25. current: 0,
  26. urls:[url]
  27. });
  28. },
  29. onShow() {
  30. if (app.globalData.userData) {
  31. that.getData();
  32. } else {
  33. app.login(app.globalData.corpId, function (is) {
  34. if (is) {
  35. that.getData();
  36. } else {
  37. dd.reLaunch({
  38. url: '../../noJurisdiction/noJurisdiction'
  39. })
  40. }
  41. }, function () { })
  42. }
  43. },
  44. openText() {
  45. this.setData({ disabled: true });
  46. app.$post("api/shop/exchange/deal", { id: this.data.id }).then((res) => {
  47. app.globalData.showToast("已发放");
  48. setTimeout(() => {
  49. this.setData({ disabled: false });
  50. this.getData()
  51. }, 1000);
  52. }).catch(err => {
  53. this.setData({ disabled: false });
  54. })
  55. },
  56. showText() {
  57. app.$get('api/shop/exchange/qrcode', { id: this.data.id, employee_id: app.globalData.userData.id }).then((res) => {
  58. this.setData({
  59. image: app.globalData.baseUrl + res.data.data,
  60. })
  61. })
  62. this.setData({
  63. isBh: !this.data.isBh,
  64. })
  65. },
  66. showText2() {
  67. this.setData({
  68. isBh: !this.data.isBh,
  69. })
  70. },
  71. handleCopy() {
  72. dd.setClipboard({
  73. text: this.data.detail.sn,
  74. })
  75. app.globalData.showToast("已复制");
  76. },
  77. getData() {
  78. app.$get('api/shop/exchange/detail', { id: this.data.id }).then((res) => {
  79. let data = res.data.data;
  80. data.date = this.timestampToTime(data.create_time)
  81. data.date2 = this.timestampToTime(data.complete_time)
  82. this.setData({ detail: res.data.data })
  83. })
  84. },
  85. timestampToTime(timestamp) {
  86. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  87. var Y = date.getFullYear() + '-';
  88. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  89. var D = date.getDate() + ' ';
  90. var h = date.getHours() + ':';
  91. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() ) + ':';
  92. var s = date.getSeconds();
  93. return Y + M + D + h + m + s;
  94. },
  95. });