detail.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // pointExchange/pages/detail/detail.js
  2. var util = require("../../../utils/util.js")
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. appAssetsUrl:app.appAssetsUrl,
  10. bottomLeft: app.bottomLeft,
  11. options:{},
  12. detail:{},
  13. isApply: false
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.setData({
  20. options,
  21. isApply:!!options.isApply
  22. })
  23. this.loadData();
  24. },
  25. loadData: function() {
  26. let _this = this;
  27. wx.showLoading({
  28. title: '努力加载中...',
  29. })
  30. app._post_form('product/info', "", _this.data.options, function(res) {
  31. if (res.code === 0) {
  32. _this.setData({
  33. detail: res.data
  34. })
  35. }
  36. })
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面隐藏
  45. */
  46. onHide: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面卸载
  50. */
  51. onUnload: function () {
  52. },
  53. /**
  54. * 页面相关事件处理函数--监听用户下拉动作
  55. */
  56. onPullDownRefresh: function () {
  57. },
  58. /**
  59. * 页面上拉触底事件的处理函数
  60. */
  61. onReachBottom: function () {
  62. },
  63. /**
  64. * 用户点击右上角分享
  65. */
  66. onShareAppMessage: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady: function() {
  72. //获得popup组件
  73. this.popup = this.selectComponent("#popup");
  74. this.popup2 = this.selectComponent("#popup2");
  75. this.popup3 = this.selectComponent("#popup3");
  76. },
  77. showPopup(e) {
  78. this[e.currentTarget.dataset.name].showPopup();
  79. },
  80. //取消事件
  81. _error(e) {
  82. this[e.currentTarget.dataset.name].hidePopup();
  83. },
  84. //卡券兑换商品
  85. useCoupon(e) {
  86. this._error(e);
  87. let that = this;
  88. wx.showLoading({
  89. title: '提交中...',
  90. })
  91. app._post_form('product/exchange', "", {
  92. pId: that.data.detail.id,
  93. stuId: util.getUserId()
  94. }, function(res) {
  95. if (res.code === 0) {
  96. that.popup2.hidePopup();
  97. }
  98. })
  99. },
  100. toPointExchangeByMe(){
  101. wx.navigateTo({
  102. url:'/pointExchange/pages/my/my'
  103. })
  104. },
  105. })