apply.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // pages/apply/apply.js
  2. const app = getApp()
  3. const host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list:[]
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. wx.showLoading({
  16. title: '',
  17. })
  18. this.setData({
  19. openid: app.globalData.openid
  20. })
  21. this.getData();
  22. },
  23. getData:function(){
  24. wx.request({
  25. url: host+'/api/wx/signup/list',
  26. header:{
  27. openid:this.data.openid
  28. },
  29. method:'GET',
  30. success:res=>{
  31. if (res.statusCode == 403){
  32. this.save()
  33. }else{
  34. wx.hideLoading()
  35. let data=res.data.data
  36. for(let i=0;i<data.length;i++){
  37. data[i].subject_item_1 = data[i].subject_item.split('|')
  38. }
  39. this.setData({
  40. list: data
  41. })
  42. }
  43. }
  44. })
  45. },
  46. save: function () {
  47. var _this = this
  48. wx.showLoading({
  49. title: '正在登录',
  50. })
  51. wx.getStorage({
  52. key: 'userInfo',
  53. success: function (res) {
  54. console.log(res)
  55. wx.request({
  56. url: host + '/api/wx/auth',
  57. method: 'POST',
  58. data: {
  59. nickname: res.data.nickName,
  60. avatar: res.data.avatarUrl,
  61. openid: app.globalData.openid,
  62. },
  63. success: res => {
  64. wx.hideLoading()
  65. _this.getData();
  66. }
  67. })
  68. },
  69. })
  70. },
  71. pay:function(e){
  72. wx.navigateTo({
  73. url: '../pay/pay?id='+e.target.dataset.id,
  74. })
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow: function () {
  85. this.getData();
  86. },
  87. /**
  88. * 生命周期函数--监听页面隐藏
  89. */
  90. onHide: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. onUnload: function () {
  96. },
  97. /**
  98. * 页面相关事件处理函数--监听用户下拉动作
  99. */
  100. onPullDownRefresh: function () {
  101. this.getData();
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })