special.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. self.setData({
  42. special_datas: res.datas,
  43. summery: res.datas.summary,
  44. firstLoad: false
  45. });
  46. }
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. if(!this.data.firstLoad) {
  59. app.setFromSource(this.data.fromSource)
  60. }
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. let special_id = this.data.special_id;
  87. let title = this.data.title;
  88. return {
  89. title: `熊猫美妆为您推荐:${title}`,
  90. path: `/pages/special/special?title=${title}&special_id=${special_id}`
  91. }
  92. }
  93. })