special.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // pages/special/special.js
  2. const getReq = require('./../../config.js').getReq;
  3. import recordSource from '../../utils/recordSource';
  4. let app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. special_datas: {},
  11. summery: [],
  12. special_id:0,
  13. fromSource: '',
  14. firstLoad: true
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. let title = options.title ? options.title : "熊猫美妆";
  21. let special_id = options.special_id;
  22. wx.setNavigationBarTitle({
  23. title: title
  24. })
  25. let fromSource = recordSource(app, `act=special&op=index&special_id=${special_id}&curpage=1&page=10&client_type=mini`)
  26. this.setData({
  27. special_id,
  28. title,
  29. fromSource: app.globalData.fromSource
  30. });
  31. var self = this;
  32. getReq({
  33. act: 'special',
  34. op: 'index',
  35. special_id,
  36. page: 10,
  37. curpage: 1,
  38. from: fromSource
  39. }, function (res) {
  40. if (res.code == 200) {
  41. console.log('special:', res);
  42. self.setData({
  43. special_datas: res.datas,
  44. summery: res.datas.summary,
  45. firstLoad: false
  46. });
  47. }
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () {
  59. if(!this.data.firstLoad) {
  60. app.setFromSource(this.data.fromSource)
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面卸载
  70. */
  71. onUnload: function () {
  72. },
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh: function () {
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. let special_id = this.data.special_id;
  88. let title = this.data.title;
  89. return {
  90. title: `熊猫美妆为您推荐:${title}`,
  91. path: `/pages/special/special?title=${title}&special_id=${special_id}`
  92. }
  93. }
  94. })