抖音b端
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.

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