抖音b端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

134 rindas
3.9 KiB

  1. const config = require('../../config/config.js')
  2. const Common = require('../../common/common.js')
  3. const format = require('../../utils/util.js')
  4. var app = getApp()
  5. Page({
  6. data: {
  7. val: '请输入券码',
  8. couponOrderId: null,
  9. couponOrderDetail: null,
  10. statusImg: '',
  11. statusText: '',
  12. flag: false,
  13. detail: '',
  14. remark: '',
  15. contentType: 0,
  16. },
  17. rule() {
  18. tt.navigateTo({
  19. url: `/pages/main/rule/rule?detail=${this.data.couponOrderDetail.detail}&remark=${this.data.couponOrderDetail.remark}&contentType=${this.data.contentType}`
  20. })
  21. },
  22. onLoad(options) {
  23. if (tt.getStorageSync("couponOrderId")) {
  24. this.setData({
  25. couponOrderId: tt.getStorageSync("couponOrderId"),
  26. couponTenantId: tt.getStorageSync("couponTenantId")
  27. })
  28. this.detailInfo(tt.getStorageSync("couponOrderId"), tt.getStorageSync("couponTenantId"))
  29. }
  30. },
  31. detailInfo(couponOrderId, couponTenantId) {
  32. var that = this;
  33. Common.getCouponOrderDetail(couponOrderId, couponTenantId)
  34. .then(res => {
  35. console.log(res, "res123")
  36. if (res.code == 200) {
  37. this.setData({
  38. contentType: res.data.contentType ? res.data.contentType : 0
  39. })
  40. console.log(this.data.contentType)
  41. if (res.data.contentType != undefined && res.data.contentType == 1) {
  42. Common.getHtml(couponOrderId).then(res => {
  43. if (res.data.html && res.data.html != '') {
  44. app.globalData.curHtml = decodeURI(res.data.html);
  45. }
  46. })
  47. }
  48. res.data.createDate = format.formatTime(res.data.createDate, 'yyyy-MM-dddd hh:mm:ss')
  49. res.data.expiredTime = format.formatTime(res.data.expiredTime, 'yyyy-MM-dddd hh:mm:ss')
  50. switch (res.data.couponOrderStatus) {
  51. case 0:
  52. //待使用
  53. that.setData({
  54. statusText: '未核销',
  55. flag: true
  56. })
  57. break;
  58. case 1:
  59. //已核销
  60. that.setData({
  61. statusImg: '/static/images/use.png',
  62. statusText: '已核销',
  63. flag: false
  64. })
  65. break;
  66. case 2:
  67. that.setData({
  68. statusImg: '/static/images/beOverdue.png',
  69. statusText: '已过期',
  70. flag: false
  71. })
  72. //已过期
  73. break;
  74. case 3:
  75. that.setData({
  76. statusImg: '/static/images/refund.png',
  77. statusText: '已退款',
  78. flag: false
  79. })
  80. //已作废
  81. break;
  82. default:
  83. tt.showToast({
  84. title: '数据有误',
  85. image: '../../static/images/fail.png'
  86. })
  87. }
  88. console.log(res)
  89. console.log("我是请求回来的数据")
  90. that.setData({
  91. couponOrderDetail: res.data
  92. })
  93. } else {
  94. tt.reLaunch({
  95. url: 'pages/main/writeoffPage/errorPage/errorPage',
  96. })
  97. }
  98. })
  99. },
  100. user() {
  101. console.log(tt.getStorageSync("verifyRemark"))
  102. // return
  103. Common.couponOrderVerify(this.data.couponOrderId, this.data.couponTenantId, tt.getStorageSync("verifyRemark"))
  104. .then(res => {
  105. console.log(res)
  106. if (res.code == 200) {
  107. tt.redirectTo({
  108. url: '../success/success',
  109. })
  110. } else {
  111. tt.showModal({
  112. title: '抱歉',
  113. content: res.message,
  114. showCancel: false
  115. })
  116. }
  117. })
  118. .catch(error => {
  119. console.log(error)
  120. tt.showModal({
  121. title: '抱歉',
  122. content: error.message,
  123. showCancel: false
  124. })
  125. })
  126. },
  127. reBuck() {
  128. tt.switchTab({
  129. url: '/pages/main/main',
  130. })
  131. }
  132. })