car.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. carInfo: {},
  7. // tab
  8. active: 0,
  9. // 是否可以领取积分
  10. disabled: false,
  11. // 用户信息
  12. userInfo: {}
  13. },
  14. //事件处理函数
  15. receiveBtn: function () {
  16. let user = this.data.userInfo;
  17. wx.request({
  18. url: app.globalData.publicUrl + '/api/htyd/carShow/check',
  19. method: "get",
  20. data: {
  21. id: user._id
  22. },
  23. success: (res) => {
  24. if (res.data.errcode === 0) {
  25. wx.request({
  26. url: app.globalData.publicUrl + '/api/htyd/carShow/getShow',
  27. method: "get",
  28. data: {
  29. id: user._id
  30. },
  31. success: (arr) => {
  32. if (arr.data.errcode === 0) {
  33. wx.showToast({
  34. title: '领取积分成功',
  35. icon: 'success',
  36. duration: 2000
  37. })
  38. }
  39. }
  40. })
  41. } else {
  42. wx.showToast({
  43. title: '条件不足',
  44. icon: 'error',
  45. duration: 2000
  46. })
  47. }
  48. }
  49. })
  50. },
  51. onLoad: function () {
  52. // 用户信息
  53. let data = app.globalData.userInfo;
  54. if (data) this.setData({ userInfo: data })
  55. // 查询信息
  56. wx.request({
  57. url: app.globalData.publicUrl + '/api/htyd/config/car',
  58. method: "get",
  59. data: {},
  60. success: (res) => {
  61. this.setData({ carInfo: res.data.data })
  62. }
  63. })
  64. },
  65. })