give.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const util = require('../../../utils/util.js')
  2. const app = getApp()
  3. Page({
  4. data: {
  5. info: {},
  6. phone: '',
  7. id: ''
  8. },
  9. onLoad: function (options) {
  10. this.setData({ id: options.id })
  11. this.getInfo()
  12. },
  13. inputChange(e) {
  14. this.setData({ phone: e.detail.value })
  15. },
  16. getInfo() {//现金券领取详情
  17. let that = this;
  18. util.ajax({
  19. func: "v2/voucher/receiveStatus",
  20. data: { "id": that.data.id },
  21. load: false
  22. }, function (res) {
  23. if (res.code == 0) {
  24. that.setData({ info: res.data })
  25. } else {
  26. util.showTips(res.reason);
  27. }
  28. });
  29. },
  30. submit() {//成长卡领取
  31. let that = this;
  32. if (util.isPhone(this.data.phone)) {
  33. util.showTips("请输入正确的手机号");
  34. return false
  35. }
  36. util.ajax({
  37. func: "v2/voucher/receive",
  38. data: { "phone": that.data.phone, "id": that.data.id },
  39. }, function (res) {
  40. if (res.code == 0) {
  41. wx.navigateTo({
  42. url: '/pages/account/safe/result?status=' + res.data.status + '&vid=' + res.data.vid + '&articleType=' + that.data.info.articleType
  43. })
  44. } else {
  45. util.showTips(res.reason);
  46. }
  47. });
  48. },
  49. seeCard() {
  50. if (app.globalData.userInfo) {
  51. wx.navigateTo({
  52. url: '/pages/account/safe/index'
  53. })
  54. } else {
  55. // 静默登录
  56. util.silentLogin().then(res => {
  57. wx.navigateTo({
  58. url: '/pages/account/safe/index'
  59. })
  60. })
  61. }
  62. }
  63. })