couponDetail.js 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { couponDetail } from '../../api/other';
  2. Page({
  3. data: {
  4. codeType: 'qr',
  5. status:0,
  6. id:'',
  7. couponInfo:{}
  8. },
  9. goPage(){
  10. wx.switchTab({
  11. url: '/pages/store/store'
  12. })
  13. },
  14. onLoad(options) {
  15. this.setData({
  16. status:options.status,
  17. id:options.id
  18. })
  19. },
  20. onReady(){
  21. this.getcouponDetail();
  22. },
  23. async getcouponDetail(){
  24. const res = await couponDetail(this.data.id);
  25. if(res.code == 200){
  26. let item = {
  27. ...res.data,
  28. verify_status_text:res.data.verify_status == 0?'未核销':res.data.verify_status == 1?'已核销':'已过期'
  29. }
  30. this.setData({
  31. couponInfo:item
  32. })
  33. }else{
  34. wx.showToast({
  35. title: res.message || '请求失败',
  36. icon: 'none',
  37. duration: 2000
  38. });
  39. }
  40. console.log(res)
  41. },
  42. toggleCode() {
  43. this.setData({
  44. codeType: this.data.codeType === 'qr' ? 'bar' : 'qr'
  45. });
  46. }
  47. })