const app = getApp() var util = require('../../utils/util.js'); var api = require('../../utils/service-api.js'); var comReq = require('../../utils/common-request.js'); var shopcart = require('../../utils/shopcart.js'); Page({ data: { userInfo: '', //用户信息 stardata: [1, 2, 3, 4, 5], interval: 2000, duration: 1000, imgUrls: [], imagetext: ['商品介绍', '规格与包装'], currentTabsIndex: 0, checkCollect: true, goodsInfo: {}, adverList: '', adverLists: '', normspopup: false, currentIndex: 0, id: '', num: 1, whetherSpecification: false, //是否选择规格 specification: '', //规格 specificationId: '', //规格id specificationPrice: '', //规格价格 price: '', //价格 originalPrice: '', //划线价 normsList: [], couponList: [], activity:[],//满减活动 evaluateList: [], // 评论列表 evaluateNum: 0, // 评论数量 currentIndexs: 0, currentIndex: 0, hidden: false, limit: 10, offset: 0, inform: true, hidden: true, shareShow: false, cartProductId: "", //商品id title: "", //商品名 imgSrc: "", //商品图片 isShare: 0, qrcode:false, }, onLoad: function(options) { var _this = this; //debugger; var goodsId = options.id; var shopId = options.shopId; if (goodsId == undefined || goodsId == null) { const scene = decodeURIComponent(options.scene); console.log("scene", scene) var params=scene.split(","); goodsId = params[1]; shopId = params[0]; app.shopInfo = { id: shopId}; //获取门店信息 util.request({ api: api.yuyue.findShopInfoById + "/" + shopId, callback: function (data) { app.shopInfo = data.rows[0]; }, checkLogin:true, }); } if (goodsId == undefined || goodsId == null) { wx.showModal({ title: '提示', content: '产品信息加载失败', showCancel: false }) } _this.showGoods(goodsId); _this.setData({ id: goodsId, }); // 判断是否从通知跳进来 if (options.isShare == 1) { this.setData({ isShare: options.isShare }) } }, onShow(options) { }, // 回到首页 goBack() { wx.switchTab({ url: '../index/index' }) }, goIndex() { wx.reLaunch({ url: '/pages/index/index' }) }, //转发 onShareAppMessage(res) { var title = this.data.goodsInfo.title; var shopCoupon=this.data.goodsInfo.shopCoupon; if (shopCoupon){ title = title +" - "+ shopCoupon.cname; } var index = this.data.index var id = this.data.id; if (res.from === "button") {} return { title: title, imageUrl: this.data.imgUrls[0].imgPath, path: "pages/service/details?id=" + id + "&shopId="+app.shopInfo.id+"&isShare=" + 1, success(res) { }, fail(res) { } } }, // 咨询药师 consult(e) { this.setData({ telShow: true }) }, // 分享 share(e) { this.setData({ shareShow: true, popupShow: true }) }, //跳转到购物车 goCart(e) { wx.switchTab({ url: '../shopCar/shopCar', }) }, // 图文选项卡 onTabsItemEvent(e) { var index = e.currentTarget.dataset.index; // console.log(index) this.setData({ currentTabsIndex: index }) }, // 收藏 collect() { var _this = this; var id = _this.data.id; util.request("POST", "/wxapi/Collection/saveCollection", { "collProductid": id }, function(data) { if (data.status == 200) { _this.setData({ checkCollect: true }) } }, false); }, // 取消收藏 cancel() { var _this = this; var id = _this.data.id; console.log(id) util.request("POST", "/wxapi/Collection/deleteByProductId/" + id, {}, function(data) { console.log(data.rows) if (data.status == 200) { _this.setData({ checkCollect: false }) } }, false); }, // 查询商品详情 showGoods: function(id) { var _this = this; util.request({ api: "/wxapi/ShopProduct/getProductById/"+app.shopInfo.id+"/" + id, callback:function(data){ if (data.rows[0].mobileDetails != null) { data.rows[0].mobileDetails = data.rows[0].mobileDetails.replace(/