couponDetail.js 1019 B

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