// packageA/mycomponent/goodsComponent/priceTitleRepertorySales/priceTitleRepertorySales.js var app = getApp(); Component({ /** * 组件的属性列表 */ properties: { plugin: { type: Object, }, isRent: { type: null, }, favorite: { type: null, }, activityid: { type: null, }, prop_goods_info: { type: null, }, isBuy: { type: null, }, isBegTime: { type: null, }, goodsType: { type: null, }, // enterAt提示选择入住时间 enterAt: { type: null, }, gooddatas: { type: null, }, fromStock:{ type: null, } }, pageLifetimes: { // 组件所在页面的生命周期函数 show: function () { //72554 if (this.data.goodsType == "hotelGoods") { this.hotelGetData(this.data.prop_goods_info); } }, }, observers: { "prop_goods_info,goodsType": function (info, type) { if (type == "hotelGoods") { this.hotelGetData(info); } }, 'gooddatas,goodsType,plugin': function (data, type, object) { if (data) { //* 限时购,宣传语显示 let goodsInfo = data.get_goods; if (goodsInfo) { goodsInfo['with_slogan'] = Boolean(goodsInfo.has_one_goods_advertising && goodsInfo.has_one_goods_advertising.is_open == 1); if (goodsInfo['with_slogan']) { data.get_goods['slogan'] = goodsInfo.has_one_goods_advertising.copywriting; } if (goodsInfo.member_discount) { if (app._isTextEmpty(goodsInfo.member_discount.discount)) { this.setData({ openVip: 1, }); } else { this.setData({ openVip: goodsInfo.member_discount.discount, }); } } if (goodsInfo.available_coupon) { this.setData({ available_coupon: goodsInfo.available_coupon || [], }); } } if (type != 'hotelGoods' && type != 'group_goods' && type != 'grabGroup' && type != 'retailGood') { this.init(this.data.gooddatas); } if (type == 'retailGood') { this.setData({ goodsInfo: data }); } else { if (type != 'grabGroup') { let otherGet = ['group_goods', 'groupwork']; this.setData({ goodsInfo: otherGet.includes(type) ? data.goods_info : data.get_goods }); } } } if (object) { this.setData({ goods_plugin: object, }); this.setIsLove(); } } }, lifetimes: { attached(e) { let language = wx.getStorageSync("langIndex"); this.setData({ language: language.en, }); }, ready() { if (Number(this.data.goodsInfo.market_price) == 0) { this.data.goodsInfo.notMarket_price = 0; } else { this.data.goodsInfo.notMarket_price = 1; } let price_text = wx.getStorageSync("yz_basic_info").lang.goods && wx.getStorageSync("yz_basic_info").lang.goods.price ? wx.getStorageSync("yz_basic_info").lang.goods.price : "现价"; let market_price_text = wx.getStorageSync("yz_basic_info").lang.goods && wx.getStorageSync("yz_basic_info").lang.goods.market_price ? wx.getStorageSync("yz_basic_info").lang.goods.market_price : "原价"; const value = wx.getStorageSync("integral"); this.setData({ integral: value || '积分', getMarketPrice: market_price_text, getprice: price_text, goods_plugin: this.data.plugin, goodsInfo: this.data.goodsInfo }); } }, /** * 组件的初始数据 */ data: { goods_plugin: {}, isGoodsLove: false, language: "", is_o2o: false, goodsInfo: [], // 是否开启好物圈插件 wechatcircle_open: 0, wx_video_link: 0, //视频号扩展插件 getMarketPrice: "", getprice: "", integral: "积分", showmoreTitle: false, openVip: 2, available_coupon: [], //优惠券 riseFansPopup:false, //让利涨粉弹窗 riseFansQrCode:'' }, /** * 组件的方法列表 */ methods: { init(data) { if (!app._isTextEmpty(data.plugin)) { if (data.plugin.wechatcircle_open && data.plugin.wechatcircle_open == 1) { this.setData({ wechatcircle_open: 1, }); } } if (data.plugin && data.plugin.wx_video_link) { this.setData({ wx_video_link: data.plugin.wx_video_link, }); } }, setTitleState(e) { this.setData({ showmoreTitle: !this.data.showmoreTitle }); }, goAdvtState() { if (this.data.goodsInfo.has_one_goods_advertising.min_link) { wx.navigateTo({ url: this.data.goodsInfo.has_one_goods_advertising.min_link }); } }, gotoMemberGradeList(e) { let tag = e.currentTarget.dataset.flag; if (tag == "1") { wx.navigateTo({ url: "/packageB/member/MemberGradeList/MemberGradeList", }); } }, //是否有爱心值 setIsLove() { if (this.data.goods_plugin.goods_love) { let love_cash = Number(this.data.goodsInfo.price) - Number(this.data.goods_plugin.goods_love.amountOfMoney); this.setData({ isGoodsLove: true, goods_love_cash: Number(love_cash.toString().match(/^\d+(?:\.\d{0,2})?/)), goods_love_deduction: this.data.goods_plugin.goods_love.amountOfCoin, goods_love_name: this.data.goods_plugin.goods_love.name, }); } else { this.setData({ isGoodsLove: false, }); } }, gotoCoupon() { if (this.data.goodsType == 'hotelGoods') { console.log(this.data.goods_info.hotel_id); wx.navigateTo({ url: "/packageC/hotel/hotelCoupon/hotelCoupon?id=" + this.data.goods_info.hotel_id, }); return; } wx.navigateTo({ url: "/packageD/coupon/coupon_store", }); }, postShow() { this.triggerEvent("tapPostShow"); }, openShare() { this.triggerEvent("tapOpenShare"); }, onFavorite() { this.triggerEvent("onFavorite"); }, // 酒店 callhotelphone() { wx.makePhoneCall({ phoneNumber: this.data.hotel_info.hotel_mobile, }); }, hotelGetData(info) { if (this.data.enterAt) console.log(info.get_goods, info.get_hotel_info); let goods_info = { ...info.get_goods, ...info.get_hotel_info.goods, }; if (!this.data.enterAt) { wx.showModal({ title: "提示", content: "选择入住酒店的时间?", success(data) { if (data.confirm) { if (info.get_hotel_info.goods.hotel_id) { wx.navigateTo({ url: "/packageC/hotel/HotelHome/HotelHome" + "?id=" + info.get_hotel_info.goods.hotel_id, }); } console.log("用户点击确定"); } else if (data.cancel) { console.log("用户点击取消"); } }, }); } this.setData({ goods_info: goods_info, hotel_info: info.get_hotel_info.hotel, isGoods: true, }); }, setRiseFansPop(){ this.setData({ riseFansPopup:!this.data.riseFansPopup }) }, //获取让利涨粉二维码 getFriendQrCode(){ if(this.data.riseFansQrCode!=''){ this.setRiseFansPop(); return; } let urlStr = app.getNetAddresss("plugin.discount-harvest-fans.frontend.controller.AddFriends.getFriendQrCode"); app._getNetWork({ url: urlStr, data:{goods_id:this.data.goodsInfo.id}, success: (resdata) => { var res = resdata.data; if (res.result != 1) { return app.tips(res.msg);; } this.setData({ riseFansPopup:true, riseFansQrCode:res.data.qr_code }) } }); }, }, });