details.js 2.2 KB

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