details.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // pages/details/details.js
  2. const getReq = require('./../../config.js').getReq
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrls: [],
  9. datas: {},
  10. getOneSummary: [],
  11. webViewUrl: '',
  12. indicatorDots: true,
  13. vertical: false,
  14. autoplay: true,
  15. interval: 2000,
  16. duration: 500
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getDatas(options.goods_id)
  23. },
  24. getDatas(goods_id) {
  25. let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${goods_id}&client_type=ios`
  26. var self = this
  27. getReq({
  28. act: 'goods_common',
  29. op: 'index',
  30. goods_id
  31. }, function (res) {
  32. if (res.code == 200) {
  33. console.log(res)
  34. let getOneSummary = res.datas.summary.filter((item, index) => {
  35. return item.goods_id == goods_id
  36. })
  37. console.log('---')
  38. console.log(res.datas.common_info.attrs)
  39. console.log(getOneSummary[0])
  40. self.setData({
  41. datas: res.datas,
  42. getOneSummary: getOneSummary[0],
  43. imgUrls: res.datas.common_info.images,
  44. webViewUrl
  45. })
  46. }
  47. })
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. }
  84. })