jiangping
2024-07-29 d9a89d83c2048a964f16ca179feb2b7f21b9d33a
wechat_staff/pages/detailDis/product.js
@@ -1,7 +1,8 @@
import {
  shareContent,
  getProductInfo,
  actionDo
  actionDo,
  refreshEnjoy
} from '../../api/index'
import moment from "moment";
Page({
@@ -10,10 +11,19 @@
   */
  data: {
    bottomLift: 0,
    current: 0,
    id: '',
    info: {},
    member: {},
    showShare: false
    showShare: false,
    enjoyList: []
  },
  onShow(){
    console.log('onShow')
    refreshEnjoy(this)
  },
  onHide() {
    console.log('onHide')
  },
  /**
   * 生命周期函数--监听页面加载
@@ -34,13 +44,17 @@
      member
    })
  },
  //  组件事件
  handleEnjoy(e) {
    const info = this.data.info
    if(info.id == null ){
      return
    }
    const enjoyList = wx.getStorageSync('enjoyList') || []
    const { type, flag } = e.detail
    console.log('type', type);
    console.log('flag', flag);
    const info = this.data.info
    console.log('flag', flag);
    if(type == 'enjoy'){
      // 点击了喜欢
      const index = enjoyList.findIndex( i => i.id === info.id )
@@ -49,7 +63,7 @@
        this.setData({ info })
        enjoyList.push({
          ...info,
          joinType: 'product',
          joinType: '0',
          timestamp: new Date().getTime()
        })
      }else{
@@ -58,6 +72,7 @@
        enjoyList.splice(index, 1)
      }
      wx.setStorageSync('enjoyList', enjoyList)
      refreshEnjoy(this)
    }else{
      actionDo({
        id: info.id,
@@ -71,22 +86,27 @@
      })
    }
  },
  handleAction(e) {
    const actionType = e.currentTarget.dataset.code
  priviewBanner(e) {
    const url = e.currentTarget.dataset.url
    const {
      info
    } = this.data
    actionDo({
      actionType,
      id: this.data.info.id
    }).then(res => {
      info.isCollection = !info.isCollection
      this.setData({
        info
      })
      wx.showToast({
        title: actionType == 'collect' ? '收藏成功' : '取消收藏',
      })
    wx.previewImage({
      urls: info.bannerImgList,
      current: url
    })
  },
  bindchange(e) {
    this.setData({ current: e.detail.current })
  },
  priviewSpace(e) {
    const url = e.currentTarget.dataset.url
    const {
      info
    } = this.data
    wx.previewImage({
      urls: info.spaceList.map(i => i.spaceImg),
      current: url
    })
  },
  onShareAppMessage() {
@@ -201,6 +221,15 @@
  onHide() {
  },
  goTestPage(){
    wx.navigateTo({
      url: '/pages/webView/index',
      success: function(res) {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('data',{link:'http://crmtest.zhibang.com:8000/core/oauth/authorize/jump?timestamp=-465385833&agent_phone_number=18055151023&bindKey=mpAddIntention&sign=cdfe13abfe2727b40eee160085c80d11'} );
      }
    })
  },
  onUnload() {
  },
@@ -211,10 +240,4 @@
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
  }
})