promotion-card.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/promotion-card/promotion-card.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. url: app.globalData.url,
  9. code:'',
  10. userinfo: app.globalData
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. var that = this;
  17. var header = {
  18. 'content-type': 'application/x-www-form-urlencoded',
  19. };
  20. wx.request({
  21. url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
  22. method: 'POST',
  23. header: header,
  24. success: function (res) {
  25. console.log(res)
  26. if (res.data.code == 200) {
  27. that.setData({
  28. userinfo: res.data.data
  29. })
  30. } else {
  31. that.setData({
  32. userinfo: []
  33. })
  34. }
  35. }
  36. });
  37. that.getCode();
  38. },
  39. getCode:function(){
  40. var header = {
  41. 'content-type': 'application/x-www-form-urlencoded',
  42. };
  43. var that = this;
  44. wx.request({
  45. url: app.globalData.url + '/routine/auth_api/get_code?uid=' + app.globalData.uid,
  46. method: 'get',
  47. header: header,
  48. success: function (res) {
  49. if (res.data.code == 200) {
  50. that.setData({
  51. code: res.data.msg
  52. })
  53. } else {
  54. wx.showToast({
  55. title: res.data.msg,
  56. icon: 'none',
  57. duration: 0
  58. })
  59. that.setData({
  60. code: ''
  61. })
  62. }
  63. }
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面隐藏
  78. */
  79. onHide: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {
  85. },
  86. /**
  87. * 页面相关事件处理函数--监听用户下拉动作
  88. */
  89. onPullDownRefresh: function () {
  90. },
  91. /**
  92. * 页面上拉触底事件的处理函数
  93. */
  94. onReachBottom: function () {
  95. },
  96. /**
  97. * 用户点击右上角分享
  98. */
  99. onShareAppMessage: function () {
  100. }
  101. })