list.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. const util = require("../../../utils/util");
  2. const api = require('../../../api/api.js');
  3. var app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. problems: [],
  10. hasLogin: false,
  11. bookTradeNo: ''
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. if (options.bookTradeNo) {
  18. this.setData({
  19. bookTradeNo: options.bookTradeNo
  20. })
  21. }
  22. this.getProblems();
  23. },
  24. goProblem(e) {
  25. let that=this
  26. console.info(e)
  27. //此类问题 是否已报备过
  28. util.request(api.ProblemReported, {
  29. bookTradeNo: that.data.bookTradeNo,
  30. problemId: e.currentTarget.dataset.id
  31. }).then(res => {
  32. if (res.data) {
  33. wx.showToast({
  34. title: '请勿重复报备~',
  35. duration: 2000,
  36. })
  37. } else {
  38. wx.navigateTo({
  39. url: '/pages/problem/add/problemAdd?id=' + e.currentTarget.dataset.id +
  40. '&name=' + e.currentTarget.dataset.name +
  41. '&bookTradeNo=' + that.data.bookTradeNo,
  42. })
  43. }
  44. })
  45. },
  46. getProblems() {
  47. let that = this
  48. wx.showLoading();
  49. util.request(api.ProblemProblems, {}).then(res => {
  50. wx.hideLoading();
  51. if (res.errno === 0) {
  52. that.setData({
  53. problems: res.data
  54. });
  55. }
  56. }).catch(res => {
  57. console.info(res)
  58. wx.hideLoading();
  59. })
  60. },
  61. /**
  62. * 生命周期函数--监听页面初次渲染完成
  63. */
  64. onReady: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面显示
  68. */
  69. onShow: function () {
  70. let userInfo = wx.getStorageSync('userInfo');
  71. if (userInfo) {
  72. this.setData({
  73. hasLogin: true
  74. });
  75. }
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. }
  102. })