myredpacket.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // pages/mine/wxml/myredpacket/myredpacket.js
  2. const app = getApp();
  3. var utils = require('../../../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. contIndex: 1,
  10. remaining: 0,
  11. getRecord: [],//领取记录
  12. usageRecord: [], //使用记录
  13. paySum: 0
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. let _this = this;
  20. _this.getData(1)
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 生命周期函数--监听页面显示
  29. */
  30. onShow: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. },
  52. //切换标签
  53. cuttab: function (e) {
  54. var _this = this;
  55. if (e.currentTarget.id === 'tab1') {
  56. _this.setData({
  57. contIndex: 1
  58. })
  59. } else if (e.currentTarget.id === 'tab2') {
  60. _this.setData({
  61. contIndex: 2
  62. })
  63. }
  64. },
  65. //获取数据
  66. getData: function (p) {
  67. let _this = this;
  68. wx.request({
  69. url: app.globalData.prodUrl + 'web-pm/wx/pm/list_redpack',
  70. data: '',
  71. header: { 'ydw-token': wx.getStorageSync('key').ydw_token},
  72. method: 'GET',
  73. dataType: 'json',
  74. responseType: 'text',
  75. success: function(data) {
  76. // console.log(data);
  77. _this.setData({
  78. getRecord: data.data.list,
  79. remaining: data.data.balance,
  80. usageRecord: data.data.list_record
  81. })
  82. },
  83. fail: function(res) {},
  84. complete: function(res) {},
  85. });
  86. }
  87. })