// pages/info/sceneProductInfo/index.js import commonApi from "../../../utils/https/common" import util from "../../../utils/util" let app = getApp() Page({ /** * 页面的初始数据 */ data: { info:null, bookingInfo:null, bookingInfoTitle:"", safeBottom:app.globalData.safeBottom, isLike:0, comment:[], commentTotal:0, isTest:true }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(!options.id){ util.back() return; } commonApi._post("pbservice/Other/getClientConfig",{ unique_key:"wechatxcx" }).then(res=>{ let data = JSON.parse(res.data); this.setData({ isTest:data.isTest }) }) this.setData({ id:options.id }) commonApi._post("scene/detail",{ id:options.id }).then(res=>{ if(!res.data){ wx.showToast({ title: '产品已下架', icon:'none' }) setTimeout(()=>{ util.back(); },1000) return; } res.data.display_tags = (res.data.display_tags?res.data.display_tags.split(","):[]).splice(0,2); // res.data.listimg = res.data.listimg?res.data.listimg.split(","):[]; res.data.product.map(product=>{ product.sku.map(sku=>{ sku.display_tags = (sku.display_tags?sku.display_tags.split(","):[]).splice(0,2); }) }) this.setData({ info:res.data }) this.BroswerRecord() }) // 获取收藏的状态 if(wx.getStorageSync("jstrip_token")){ commonApi.user_post("scene/is_scene_collection",{ scene_id:options.id }).then(res=>{ this.setData({ isLike:res.data }) }) } commonApi._post("ask/getQuestionList",{ scene_id:options.id, page_no:1, page_num:3 }).then(res=>{ this.setData({ ask:res.data.rows }) console.log(res) }) // 获取评价列表 commonApi._post("scene/get_comment",{ scene_id:options.id }).then(res=>{ res.data.list.map(item=>{ item.rate = Number(item.rate) }) this.setData({ comment:res.data.list.splice(0,3), commentTotal:res.data.total }) console.log(res) }) }, BroswerRecord:function(){ setTimeout(()=>{ if(app.globalData.uuid){ commonApi._post('browse/browse_record',{ type:"scene", title:this.data.info.title, drive:"mini", source_id:this.data.info.id, url:"/pages/info/sceneProductInfo/index?id="+this.data.info.id, uuid:app.globalData.uuid }).then(res=>{ }) } else { this.BroswerRecord(); } },500) }, like:function(){ let id = this.data.id,isLike = Number(this.data.isLike); console.log(isLike) commonApi.user_post(isLike!=1?"scene/scene_collection":"scene/scene_cancel_collection",{ scene_id:id }).then(res=>{ if(res.code==1){ console.log(isLike) wx.showToast({ title: '操作成功', }) this.setData({ isLike:isLike==1?0:1 }) } }) }, gotolocation:function(){ let info = this.data.info; wx.openLocation({ latitude: Number(info.lat), longitude: Number(info.lon) }) }, audioGuide:function(){ wx.navigateToMiniProgram({ appId: 'wx74f380bc721a0379', path:'/pages/listen/listen' }) }, showBookingInfo:function(e){ this.setData({ bookingInfo:e.currentTarget.dataset.item.sku_model, bookingInfoTitle:e.currentTarget.dataset.item.sku_name }) }, closeMask:function(){ this.setData({ bookingInfo:null }) }, order:function(e){ app.globalData.couponInfo = null; // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; app.globalData.product = e.currentTarget.dataset; wx.navigateTo({ url: '/pages/order/scene/index', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })