details.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
  23. this.setData({
  24. webViewUrl
  25. })
  26. this.getDatas(options.goods_id)
  27. },
  28. getDatas(goods_id) {
  29. var self = this
  30. getReq({
  31. act: 'goods_common',
  32. op: 'index',
  33. goods_id
  34. }, function (res) {
  35. if (res.code == 200) {
  36. let getOneSummary = res.datas.summary.filter((item, index) => {
  37. return item.goods_id == goods_id
  38. })
  39. console.log('---')
  40. console.log(getOneSummary[0])
  41. self.setData({
  42. datas: res.datas,
  43. getOneSummary: getOneSummary[0],
  44. imgUrls: res.datas.common_info.images
  45. })
  46. }
  47. })
  48. },
  49. toWebView() {
  50. let webViewUrl = encodeURIComponent(this.data.webViewUrl)
  51. wx.navigateTo({
  52. url: `/pages/webView/webView?url=${webViewUrl}`
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面初次渲染完成
  57. */
  58. onReady: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面显示
  62. */
  63. onShow: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面隐藏
  67. */
  68. onHide: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面卸载
  72. */
  73. onUnload: function () {
  74. },
  75. /**
  76. * 页面相关事件处理函数--监听用户下拉动作
  77. */
  78. onPullDownRefresh: function () {
  79. },
  80. /**
  81. * 页面上拉触底事件的处理函数
  82. */
  83. onReachBottom: function () {
  84. },
  85. /**
  86. * 用户点击右上角分享
  87. */
  88. onShareAppMessage: function () {
  89. }
  90. })