| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355 |
- <template>
- <view :style="[mainStyle]">
- <view v-if="allShow">
- <!--pages/detail/detail.wxml-->
- <view class="banner">
- <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
- duration="1000">
- <block v-for="(item, index) in product.images" :key="index">
- <swiper-item autoplay="true">
- <image :src="item + '?x-oss-process=style/w750-auto'" mode="aspectFit"></image>
- </swiper-item>
- </block>
- </swiper>
- <view class="dots dflex">
- <block v-for="(item, index) in product.images" :key="index">
- <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
- @tap="dotEvent"></view>
- </block>
- </view>
- </view>
- <view class="info bgfff">
- <view class="infos dflex">
- <view class="price dflex">
- ¥<text>{{product.salePrice?product.salePrice:'0'}}</text>
- <text class="origin"
- v-if="product.salePrice == product.actualPrice && product.marketPrice > 0&&product.salePrice<product.marketPrice">¥{{product.marketPrice}}</text>
- </view>
- <view class=" sellStock" v-if="product.sellStock>0">销量:<text>{{product.sellStock}}</text></view>
- <view class="share" @tap="showShare">
- <image src="/static/pages/images/fxico.png"></image>分享
- </view>
- </view>
- <view class="huiyuan" @tap="govip" v-if="show_membership_price==1&&product.membersPrice!=null">
- <!-- &&product.membersPrice<product.salePrice -->
- <view class="ddflex huiyuanjia">
- <view class="ddflex">
- <!-- <image src="/product/static/product/image/huiyuanjia.png" class="huiyuanimg"></image> -->
- {{userInfo.level && userInfo.level != 'LV0' ? userInfo.level : '会员价'}}
- <text
- class="hymoney">¥{{product.actualPrice < product.salePrice ? product.actualPrice : product.membersPrice}}</text>
- 立省¥{{product.jianMoney?product.jianMoney:'0'}}
- </view>
- <view class="d-open" v-if="!userInfo.level">立即开通</view>
- <image src="/product/static/product/image/govip.png" class="govipimg" v-else></image>
- </view>
- </view>
- <view class="title">
- <image src="/static/pages/images/jishida.png" class="tag"
- v-if="product.isJs&&merchant.type!=5&& about.timely_close != 1">
- </image>
- <image src="/product/static/product/image/overseasPurchase.png" class="tag"
- v-if="product.isOtc===5">
- </image>
- <text class="yushou"
- v-if="product.estimatedDeliveryTimeStr">预售</text>{{product.title?product.title:''}}
- </view>
- <view class="protext">
- {{product.brandName ? product.brandName : ''}} {{product.brief ? product.brief : ''}}
- </view>
- <view class="guarantee dflex" v-if="guarantee.length>0">
- <view class="cont dflex">
- <view v-for="(item, index) in guarantee" :key="index" class="dflex li">
- <image src="/product/static/product/image/guarantee.png"></image>{{item}}
- </view>
- </view>
- </view>
- <!-- isOtc 0 默认 1 处方药 2 非处方药 3 医疗器械 4 食品类 5 海外购 -->
- <block v-if="product.isOtc!=5">
- <block v-if="is_open_shop == 1 && ascription">
- <view class="xiaodian dflex malr20"
- v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0) || product.serviceShopRate">
- <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
- <view class="shouyi flex"
- v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0)">
- <text>预计分销收益</text>
- <view v-if="product.isMeCommission == 0"><text>¥</text>{{product.oneCommission}}</view>
- <view v-else><text>¥</text>{{product.twoCommission}}</view>
- </view>
- <view class="shouyi flex" v-if="product.serviceShopRate">
- <text>预计小店服务费</text>
- <view><text>¥</text>{{product.serviceShopRate}}</view>
- </view>
- <view class="dflex" v-if="product.isJoinShop">
- <view class="fenxiang" @tap="showShare">分享推广</view>
- <navigator :url="url" hover-class="none" class="goShop">去小店</navigator>
- </view>
- <view class="addshop" @tap="addShop" v-else>添加到小店</view>
- </view>
- </block>
- <block v-else>
- <view class="xiaodian dflex malr20"
- v-if="((product.isMeCommission != 1 || product.isMeCommission != '1') && product.oneCommission>0) || ((product.isMeCommission == 1 || product.isMeCommission == '1') && product.twoCommission>0)">
- <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
- <view class="shouyi flex">
- <text>预计分销收益</text>
- <view v-if="product.isMeCommission == 0"><text>¥</text>{{product.oneCommission}}</view>
- <view v-else><text>¥</text>{{product.twoCommission}}</view>
- </view>
- <navigator url="/promote/apply/apply" hover-class="none" class="fenxiang"
- v-if="isDistriUser != 2">我要推广</navigator>
- <view class="fenxiang" @tap="showShare" v-else>分享推广</view>
- </view>
- </block>
- </block>
- </view>
- <view class="detinfo mt20 bgfff">
- <view class="item dflex" v-if="couponList&&couponList.length>0">
- <label>优惠券</label>
- <view class="quan flex dflex" @click="jumpUrl('/product/coupon/coupon?productId=' + query.id)">
- <view class="flex dflex coupon-list">
- <text v-for="(item,index) in couponList" :key="index"
- v-if="index < 3">{{item.couponTitle}}</text>
- </view>
- <view class="ling dflex">领券<image src="/static/pages/images/more3.png"></image>
- </view>
- </view>
- </view>
- <view class="item pro-sel dflex" v-if="product.propertiesList && product.propertiesList.length > 0"
- @click="product.stock > 0 ? addShopCart() : ''">
- <label>已选</label>
- <view class="flex">{{product.properties}}</view>
- <image src="/static/pages/images/more.png" class="mrico"></image>
- </view>
- <view class="item pro-time dflex" v-if="product.estimatedDeliveryTimeStr">
- <label>预计发货时间</label>
- <view class="flex">{{product.estimatedDeliveryTimeStr}} 前发货</view>
- </view>
- <view class="item dflex">
- <label>配送至</label>
- <view class="flex" @tap="toAddress">
- <view class="address">{{address.address?address.address:''}}{{address.house?address.house:''}}
- </view>
- <view class="huo" v-if="tabe&&tabe.length>0">
- <!-- <text>现货</text> -->
- <text v-for="(item, index) in tabe" :key="index" v-if="tabe.length>0">{{item}}</text>
- <!-- 现在下单,预计2小时后送达 -->
- </view>
- </view>
- <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
- </view>
- <view class="item dflex" v-if="merchant.isDefault!=1">
- <label>当前门店</label>
- <view class="flex" @tap="updateShop">
- <view class="address">{{merchant.title}}</view>
- </view>
- <image src="/static/pages/images/more2.png" class="more" @tap="updateShop"></image>
- </view>
- <navigator :url="'/product/supplier/supplier?id=' + product.supplierModel.id" hover-class="none"
- class="item det-sup dflex" v-if="about.is_show_supplier == 1 && product.supplierModel">
- <label>供应商</label>
- <view class="flex">
- <view class="dflex">
- <view class="sup-name flex tover">{{product.supplierModel.name}}</view>
- <image src="/static/pages/images/more.png" class="mrico"></image>
- </view>
- <view class="sup-bri tover" v-if="product.supplierModel.businessScope">
- 主营范围:{{product.supplierModel.businessScope}}</view>
- </view>
- </navigator>
- </view>
- <!-- 商品详情等页面 -->
- <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="product.id" :form="form"
- @scoreTab="scoreTab" @showTab="showTab" v-if="product.id" @freshen="freshenFun" @getForm="getForm">
- </product-footer>
- <v-share :hide-toast="hideShare" :product="product" :code-url="codeUrl" @onFather="click"></v-share>
- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
- <view class="bot fixed bgfff dflex" :style="'padding-bottom: ' + (bottomBlankHeight + 20) + 'rpx'">
- <view class="btnfot">
- <view class="botbtn" @click="goHome()">
- <image src="/static/pages/images/sy.png"></image>首页
- </view>
- <view class="botbtn" @tap="jumpCart('pages/cart/cart')">
- <image src="/static/pages/images/gwc.png"></image>购物车<text class="message"
- v-if="product.count > 0">{{product.count}}</text>
- </view>
- <view class="botbtn" @tap="clickCollect">
- <image src="/static/pages/images/shoucang_h.png" v-if="product.isCollect"></image>
- <image src="/static/pages/images/shoucang.png" v-else></image>收藏
- </view>
- </view>
- <view class="btnbuy">
- <view
- :class="['addcart',product.stock >= 1 && product.state == 1&&product.salePrice>0 ? '' : 'gray']"
- @tap="product.stock >= 1 && product.state == 1&&product.salePrice>0 ? addShopCart() : ''">加入购物车
- </view>
- <view class="gmbtn mbglinear" @tap="atOnceBuy"
- v-if="product.stock >= 1 && product.state == 1&&product.salePrice>0">
- {{product.isOtc==1 ?'预约下单': '立即购买'}}
- </view>
- <view class="gmbtn mbggray" v-if="(product.stock < 1)&&load">已售罄</view>
- <block v-else>
- <view class="gmbtn mbggray" v-if="(product.state != 1||!product.salePrice)&&load">已下架</view>
- </block>
- <view class="gmbtn mbggray" v-if="product.stock < 1 && product.state == 1&&product.salePrice>0">立即购买
- </view>
- </view>
- </view>
- <view class="xiajia" v-if="product.stock < 1">您来晚了,商品已售罄</view>
- <block v-else>
- <view class="xiajia" v-if="(product.state !=1 ||!product.salePrice) &&load">您来晚了,商品已经下架</view>
- </block>
- <!-- 商品规格 -->
- <block v-if="isShow">
- <product-popup :product="popup" :order-type="1" :is-cart="isCart" :is-timely="product.isTimely"
- :merchant="merchant" :merchant-id="merchantId" @hidePopup="hidePopup"
- @addCartSuccess="addCartSuccess" :index="index" :shopId="query.shopId" @freshen="changeFreshen"
- @getPor="getPor">
- </product-popup>
- </block>
- <!-- 返回顶部 -->
- <button open-type="contact" class="side-contact">
- <image src="/static/pages/images/kfico1.png"></image>客服
- </button>
- <view class="contact_index" @tap="goTop">
- <image src="/static/pages/images/backtop.png"></image>顶部
- </view>
- <!-- 添加到小店成功 -->
- <view class="mask" :hidden="isHide" @tap="hidePop"></view>
- <view class="suc" :hidden="isHide">
- <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
- <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
- <text>快去我的小店看看吧</text>
- <view class="shopcc dflex">
- <view class="shop" @tap="showShare">分享推广</view>
- <navigator :url="url" hover-class="none" class="shop">我的小店</navigator>
- </view>
- <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
- </view>
- <block v-if="isActive">
- <product-acitvity @hideActive="hideActive"></product-acitvity>
- </block>
- <block v-if="isPopupLogin">
- <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
- </block>
- <!-- 订单购买轮播 -->
- <view :class="(marqueeOrderItem ? 'roll-notice ' : '') + 'dflex'" v-if="marqueeOrderItem">
- <image :src="marqueeOrderItem.avatar"></image>
- <view class="flex">{{ marqueeOrderItem.time }} 购买了{{ marqueeOrderItem.productName }}</view>
- </view>
- <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate"
- @closeUpdate="closeUpdate"></update-userinfo>
- <privacy :is-update="true" @getLocations="initLocation"></privacy>
- </view>
- <!-- #ifdef H5 -->
- <wx-share ref="wxshare" />
- <!-- #endif -->
- </view>
- </template>
- <script>
- const app = getApp();
- const req = require("../../utils/request.js");
- const utils = require("../../utils/util.js");
- var QQMapWX = require("../../utils/qqmap.js");
- const route = require("../../utils/route");
- const api = require("../../utils/api.js");
- import productFooter from "../../components/product-footer/index";
- import productPopup from "../../components/product-popup/index";
- import vShare from "../../components/share/share";
- import productAcitvity from "../../components/product-activity/index";
- import productLogin from "../../components/product-login/index";
- import h5util from "../../utils/h5util";
- const actionsdk = require('../../action_sdk/actionsdk-1.0.0.js');
- export default {
- data() {
- return {
- picUrlss: req.public.picUrls,
- mainStyle: app.globalData.mainStyle,
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- swiperCurrent: 0,
- bannerUrls: [],
- isShow: false,
- pro: {},
- isCart: false,
- timer: [],
- hideShare: true,
- codeUrl: '',
- form: {
- page: 1,
- limit: 10
- },
- contentList: [{
- pic: "/static/pages/images/bar.png",
- name: '好风依旧',
- time: '4秒前'
- }, {
- pic: "/static/pages/images/bar.png",
- name: '杨鑫',
- time: '20秒前'
- }, {
- pic: "/static/pages/images/bar.png",
- name: '杨鑫',
- time: '5秒前'
- }],
- isNotice: false,
- hideShop: true,
- //隐藏添加到小店
- isHide: true,
- //添加小店成功弹窗
- url: '/mine/shop/shop',
- freshen: true,
- //是否更新页面
- isActive: false,
- current: "",
- query: "",
- merchantId: "",
- merchant: "",
- userInfo: "",
- ascription: false, //是否开启小店
- guarantee: "",
- show_membership_price: "",
- Is_Store_Price_Stock: "",
- is_open_shop: "",
- is_open_comments: "",
- shopId: "",
- params: "",
- product: "",
- nodes: "",
- imgs: [],
- tabe: "",
- load: false,
- address: {},
- index: "",
- popup: "",
- tabIndex: "",
- switch: true,
- about: {},
- allShow: false,
- isDistriUser: 0, // 判断用户是否是分销员 2为分销员
- isPopupLogin: false,
- marqueeOrderItemIndex: 0,
- marqueeOrderItem: '',
- isShowTime: false,
- couponList: [],
- isVideoScene: false, //立即购买是否需要登录
- isShowUpdate: false, //是否显示更新信息弹窗
- isUpdateInfo: false, //更新用户信息
- isUpdateMobile: false, //绑定手机号
- };
- },
- components: {
- productFooter,
- productPopup,
- vShare,
- productAcitvity,
- productLogin
- },
- onLoad: async function(options) {
- let that = this;
- // console.log(options);
- this.query = options;
- this.setData({
- query: options
- });
- if (options.scene) {
- this.scene = options.scene;
- this.merchantId = options.merchantId;
- }
- if (options.merchantId) {
- that.setData({
- merchantId: options.merchantId
- });
- }
- if (options.userMerchantId) {
- req.setStorage('user_merchantId', options.userMerchantId)
- }
- if (options.isShare || options.isShareTimeline) {
- req.setStorage('pidCode', options.userId);
- let params = {
- userId: options.userId,
- merchantId: options.merchantId ? options.merchantId : '',
- }
- await this.bindUser(params);
- } else {
- }
- return false
- if (options.hideShop) {
- this.setData({
- hideShop: false
- });
- } // if (options.merchantId && options.merchantId != 'undefined') {
- // req.getRequest('/api/merchant/detail', { id: options.merchantId }, data => {
- // req.setStorage("MERCHANT", data)
- // that.setData({ merchant: data })
- // console.log(data, "执行+++++++++++++++++++++")
- // })
- // } else {
- // let merchant = req.getStorage('MERCHANT');
- // this.setData({ merchant: merchant });
- // }
- // else{
- // // req.getRequest('/api/merchant/getMerchantList',{}, res => {
- // // res = res.filter(it=>it.isDefault==1)
- // // req.setStorage('MERCHANT', res[0]);
- // // this.data.merchant=res[0]
- // // that.setData({merchant:res[0]})
- // // console.log(this.data.merchant)
- // // })
- // let merchant=req.getStorage('MERCHANT')
- // that.setData({merchant:merchant})
- // }
- this.isShop()
- setInterval(() => {
- this.setData({
- isNotice: true
- });
- }, 10000);
- setTimeout(() => {
- actionsdk.initAction();
- }, 2000)
- },
- async onShow() {
- if (req.getStorage('isVideoScene') && (req.getStorage('scene') == 1176 || req.getStorage('scene') ==
- 1177 || req.getStorage('scene') == 1195)) {
- this.isVideoScene = true
- }
- if (this.freshen) {
- let that = this;
- await this.loadCodeParams();
- if (that.scene) {
- that.bindUser(that.params);
- }
- this.getGuarantee().then(data => {
- // console.log("debug1", data);
- if (this.switch) {
- this.getMerchant()
- }
- })
- await this.getProductCoupon()
- // if (this.switch) {
- // this.getMerchant()
- // }
- await this.browsRecound(this.query.id);
- }
- this.getBuyOrderMarquee(!this.isShowTime);
- },
- onShareAppMessage: async function(options) {
- var content = await this.onShareMessage(options);
- return content;
- },
- onReachBottom() {
- if (this.is_open_comments == 1 && this.tabIndex == 2) {
- this.form.page++;
- this.setData({
- ['form.page']: this.form.page
- });
- // this.selectComponent("#list").loadScore(this.current);
- // console.log(this.form, "++++++++++++++++")
- this.$refs.list.loadScore(this.current, this.form);
- }
- },
- onReady() {
- // #ifdef H5
- var that = this;
- //初始化分享内容
- setTimeout(async function() {
- var shareContent = await that.onShareMessage();
- if (shareContent) {
- shareContent.path = window.location.origin + shareContent.path;
- }
- that.$refs.wxshare.init(shareContent);
- }, 4 * 1000);
- // #endif
- },
- methods: {
- initLocation() {
- this.getMerchant();
- },
- goHome() {
- h5util.jumpIndex('/pages/tabBar/index?channel=home')
- // app.globalData.openHome();
- },
- async onShareMessage(options) {
- let merchantId = '';
- let path = '';
- let isSolution = '';
- isSolution = req.env[req.env.NODE_ENV].isSolution;
- let userInfo = req.getStorage('userInfo');
- let shopId = '';
- if (isSolution) {
- path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + req.getStorage(
- 'userInfo').id;
- } else {
- path = '/product/detail/detail?id=' + this.query.id
- // console.log(!req.getStorage('userInfo').id);
- if (!userInfo.id) {} else {
- path += '&userId=' + userInfo.id;
- }
- // console.log(this.query.merchantId);
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- path += '&merchantId=' + req.getStorage('MERCHANT').id;
- merchantId = req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- path += '&shopId=' + req.getStorage('smallShop').id;
- shopId = req.getStorage('smallShop').id;
- merchantId = req.getStorage('smallShop').merchantDTO.id;
- }
- }
- if (userInfo.merchantId) {
- path += '&userMerchantId=' + userInfo.merchantId;
- }
- }
- route.share(1, userInfo.id, path, merchantId, shopId, 1, this.query.id);
-
- path = this.SHARE_BEHAVIOR_FN({path:path,sendShare:false}).path
- console.log('---share path----',path)
- return {
- title: this.product.title,
- imageUrl: this.product.pic,
- path: path
- };
- },
- getBuyOrderMarquee(isToTime) {
- console.log('getBuyOrderMarquee数据获取>>>>>>');
- req.getRequest('/api/product/buyDynamic', {}, data => {
- this.isShowTime = true;
- this.buyOrderMarqueeList = data;
- if (isToTime) {
- if (this.buyOrderMarqueeList && this.buyOrderMarqueeList.length > 0) {
- this.marqueeOrderItem = this.buyOrderMarqueeList[this.marqueeOrderItemIndex];
- this.marqueeOrderItemIndex++;
- this.getMarqueeOrderItem();
- }
- }
- });
- },
- // 首页轮播最新购买记录
- getMarqueeOrderItem() {
- var tha = this;
- setTimeout(function() {
- // console.log('数据tha.marqueeOrderItemIndex>>>>', tha.marqueeOrderItemIndex);
- tha.marqueeOrderItem = tha.buyOrderMarqueeList[tha.marqueeOrderItemIndex];
- if (tha.marqueeOrderItemIndex >= tha.buyOrderMarqueeList.length - 1) {
- tha.marqueeOrderItemIndex = 0;
- } else {
- tha.marqueeOrderItemIndex++;
- }
- tha.getMarqueeOrderItem();
- }, 5000);
- },
- bindUser(par) {
- let userInfo = req.getStorage('userInfo');
- if (!userInfo) {
- req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
- // uni.login({
- // success(res) {
- // let params = {
- // code: res.code,
- // }
- // if(par.userId){
- // params.parentId = par.userId;
- // }
- // if(par.merchantId || par.shopId){
- // params.merchantId = par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
- // }
- // return new Promise((resolve, reject) => {
- // req.postRequest('/api/v2/login', params, data => {
- // resolve();
- // });
- // })
- // }
- // });
- // this.isPopupLogin = true;
- }
- },
- click(e) {
- // console.log(e,"7899")
- this.hideShare = e
- },
- getMerchant() {
- let that = this;
- api.getMerchant(this.query, req, data => {
- that.loadDefaultAddress();
- console.log('门店信息==', data)
- if (data == 1) {
- if (that.about.Many_Store == 1) api.locationShow()
- else {
- that.getuserInfo(data);
- if (req.getStorage('defaultMerchant')) {
- that.merchant = req.getStorage('defaultMerchant');
- that.query.merchantId = that.merchant.id
- } else {
- api.defaultMerchant(req, that.query, defaultRes => {
- that.merchant = defaultRes;
- that.query.merchantId = defaultRes.id
- });
- }
- that.loadProudct(that.query);
- }
- } else {
- that.getuserInfo(data);
- if (req.getStorage('userInfo') && that.merchant.id != data.id) {
- if (data.type == 5) {
- that.query.merchantId = data.merchantDTO.id
- that.query.shopId = data.id
- } else {
- that.query.merchantId = data.id
- }
- this.loadProudct(this.query);
- let pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- // console.log(prevPage, '++++++++++++++++++')
- if (prevPage) {
- prevPage.$vm.setData({
- freshen: true
- });
- }
- } else {
- this.loadProudct(this.query);
- }
- that.merchant = data
- }
- })
- },
- async showShare() {
- let shareD = await this.onShareMessage()
- h5util.jumpShare({
- title:shareD.title,
- imageUrl:shareD.imageUrl,
- path:shareD.path,
- shareType:2,
- id:this.product.id,
- merchantId:this.query.merchantId,
- sendBehaviorObj:{
- BIND_TYPE : this.BIND_TYPE,
- BIND_ID : this.BIND_ID,
- USER_ID : this.USER_ID,
- SHARE_USER_ID : this.SHARE_USER_ID,
- PARENT_CODE : this.PARENT_CODE,
- CURRENT_CODE : this.CURRENT_CODE
- }
- })
- },
- /**
- * 轮播切换
- */
- swiperChange({
- detail
- }) {
- if (this.current == 0 && this.swiperCurrent > 1) {
- //卡死时,重置current为正确索引
- this.setData({
- current: this.swiperCurrent
- });
- } else {
- //正常轮转时,记录正确页码索引
- this.setData({
- swiperCurrent: detail.current
- });
- }
- },
- dotEvent(e) {
- this.setData({
- current: e.currentTarget.dataset.current
- });
- },
- // 获取用户信息
- getuserInfo(data) {
- let that = this;
- let userInfo = req.getStorage('userInfo');
- // console.log(data, userInfo);
- if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
- 0) {
- if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
- let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' +
- userInfo.listShopBase[0].id;
- that.ascription = true;
- that.url = url
- }
- console.log('that.userInfo==' + that.userInfo)
- }
- },
- // 获取品质保证
- getGuarantee() {
- return new Promise((data, rej) => {
- req.getRequest('/api/config', {}, res => {
- req.setStorage('configRes', JSON.stringify(res))
- this.about = res
- data(res)
- if (!this.query.merchantId || this.merchant && this.merchant.isDefault == 1) {
- // 切割;拿到数组,然后在过滤掉空值
- if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
- this.setData({
- guarantee: res.b2c_service_guarantee.split(";").filter(it => {
- return it = it && it.trim();
- })
- });
- }
- } else {
- if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
- this.setData({
- guarantee: res.o2o_service_guarantee.split(";").filter(it => {
- return it = it && it.trim();
- })
- });
- }
- }
- if (res.show_membership_price) {
- this.setData({
- show_membership_price: res.show_membership_price
- });
- }
- if (res.Is_Store_Price_Stock) {
- this.setData({
- Is_Store_Price_Stock: res.Is_Store_Price_Stock
- });
- }
- if (res.is_open_shop) {
- this.setData({
- is_open_shop: res.is_open_shop
- });
- }
- if (res.is_open_comments) {
- this.setData({
- is_open_comments: res.is_open_comments
- });
- }
- });
- })
- },
- browsRecound(id) {
- let from = {
- bindId: id,
- type: 1,
- page: '/product/detail/detail?id=' + id
- };
- if (this.query.isShare) {
- from.shareType = 1;
- from.page = '/product/detail/detail?id=' + this.query.id + '&isShare=' + true;
- if (!this.query.userId) {} else {
- from.page += '&userId=' + this.query.userId;
- }
- if (!this.query.merchantId) {} else {
- from.merchantId = this.query.merchantId;
- }
- if (!this.query.shopId) {} else {
- from.shopId = this.query.shopId;
- }
- if (!this.query.userId) {} else {
- from.uid = this.query.userId;
- }
- }
- if (this.query.isShareTimeline) {
- from.shareType = 2;
- from.page = '/product/detail/detail?id=' + this.query.id + '&isShareTimeline=' + true;
- if (!this.query.userId) {} else {
- from.page += '&userId=' + this.query.userId;
- }
- if (!this.query.merchantId) {} else {
- from.merchantId = this.query.merchantId;
- }
- if (!this.query.shopId) {} else {
- from.shopId = this.query.shopId;
- }
- if (!this.query.userId) {} else {
- from.uid = this.query.userId;
- }
- }
- return new Promise((resolve, reject) => {
- req.postRequest('/api/browse', from, data => {
- resolve()
- })
- })
- },
- async govip() {
- if (await req.isAuthFn(true)) {
- uni.navigateTo({
- url: '/mine/vip/vip'
- });
- }
- },
- loadCodeParams() {
- let _ts = this;
- return new Promise((resolve, reject) => {
- let form = {
- scene: _ts.scene?_ts.scene:_ts.query.x_code_id
- };
- if (!_ts.scene && !_ts.query.x_code_id) {
- resolve();
- return false;
- } // if (_ts.merchantId) {
- // console.log("解析出来有门店")
- // form.merchantId = _ts.merchantId
- // }
- req.getRequest('/api/code/params', form, data => {
- if(_ts.options.x_code_id){
- let res = JSON.parse(data.scene)
- for(let key in res){
- this.query[key] = res[key]
- }
- resolve();
- }else{
- // console.log("====================================================================================" + data.merchantId)
- // this.data.query.id = data.scene;
- let res = JSON.parse(data.scene)
- let params = {}
- res.map(it => {
- if (res.poid) {
- _ts.query.id = res.poid
- params.id = res.poid
- }
- if (res.mid) {
- _ts.query.merchantId = res.mid
- params.merchantId = res.mid
- }
- if (res.umid) {
- req.setStorage('user_merchantId', umid)
- }
- })
- // console.log(res);
- // this.query.id = res[0];
- // this.query.merchantId = res[1];
- // this.query.shopId = res[2]; // this.query.id = res[0];
- // this.query.merchantId = res[1];
- // this.query.shopId = res[2];
- req.setStorage('appId', res.appId);
- req.setStorage('pidCode', data.userId);
- this.setData({
- params: params
- });
- resolve();
- }
- });
- });
- },
- loadProudct(query) {
- let that = this;
- that.getMy();
- that.setData({
- bannerUrls: [],
- product: '',
- nodes: ''
- });
- // console.log(query.merchantId);
- let form = {
- id: query.id
- };
- if (query.merchantId) form.merchantId = query.merchantId;
- let isShowLoading = false;
- this.allShow = false
- if (!isShowLoading) {
- req.loadIng('加载中');
- isShowLoading = true;
- }
- let userInfo = req.getStorage('userInfo');
- if (userInfo.listShopBase && userInfo.listShopBase.length > 0) {
- form.shopId = userInfo.listShopBase[0].id;
- }
- req.getRequest('/api/product/detail', form, async data => {
- //富文本图片放大
- var nodes = data.detail;
- let shareD = await this.onShareMessage()
- that.postShareMessage(shareD.title,shareD.imageUrl,shareD.path,{
- BIND_TYPE : this.BIND_TYPE,
- BIND_ID : this.BIND_ID,
- USER_ID : this.USER_ID,
- SHARE_USER_ID : this.SHARE_USER_ID,
- PARENT_CODE : this.PARENT_CODE,
- CURRENT_CODE : this.CURRENT_CODE
- })
- // console.log(nodes)
- // if (nodes) {
- // if (nodes.indexOf("src") >= 0) {
- // //正则匹配所有图片路径
- // var imgs = [];
- // nodes = nodes.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
- // imgs.push(capture);
- // that.setData({
- // imgs: imgs
- // });
- // return '';
- // });
- // }
- // }
- if (data.isOtc == 5) {
- uni.setNavigationBarTitle({
- title: '海外购'
- });
- }
- // console.log(this
- // .Is_Store_Price_Stock); // if (data.stock <= 0 && this.data.Is_Store_Price_Stock == 1) {
- // req.msgConfirm("该门店产品库存不足,请切换其他门店购买", success => {
- // this.updateShop(1)
- // // this.query.merchantId=this.data.merchantId
- // }, cancel => { })
- // }
- let tabe = [];
- let propertiesList = []
- if (data.propertiesList && data.propertiesList.length > 0) {
- data.propertiesList.map(it => {
- propertiesList.push(it.value);
- })
- }
- data.properties = propertiesList.join(' / ')
- if (data.deliverWay != null) {
- let arr = ['自提', '邮寄', '同城配送',
- '自主配送', '自动发货', '手动发货'
- ]; // console.log(data.deliverWay.split(','),JSON.parse(data.deliverWay));
- let deliverWay = JSON.parse(data.deliverWay);
- deliverWay.forEach(it => {
- tabe.push(arr[it - 1]);
- });
- if (deliverWay.indexOf(3) != -1) data.isJs = true;
- }
- // console.log(tabe, data);
- that.setData({
- bannerUrls: data.images,
- product: data,
- nodes: nodes,
- tabe: tabe,
- load: true,
- allShow: true
- });
- if (isShowLoading) {
- uni.hideLoading();
- isShowLoading = false;
- }
- if (data.membersPrice && data.actualPrice < data.salePrice) {
- let jian = parseFloat(data.salePrice - data.actualPrice).toFixed(2);
- this.setData({
- ['product.jianMoney']: jian
- });
- }
- if (data.membersPrice && data.membersPrice < data.salePrice) {
- let jian = parseFloat(data.salePrice - data.membersPrice).toFixed(2);
- this.setData({
- ['product.jianMoney']: jian
- });
- } // if (data.detail) {
- // this.setData({ detail: data.detail.replace(/\<img/gi, '<img class="rich-img"') })
- // }
- // that.getCodeUrl();
- });
- },
- getMy() {
- let that = this;
- let userInfo = req.getStorage('userInfo');
- if (!userInfo || userInfo == null) return false;
- req.getRequest('/api/user/my', {}, data => {
- that.userInfo = data;
- that.isDistriUser = data.isDistriUser;
- });
- },
- getCodeUrl() {
- let that = this;
- let scene = {
- poid: that.product.id
- }
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- scene.mid = req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- scene.sid = req.getStorage('smallShop').id;
- }
- }
- if (req.getStorage('userInfo').merchantId) {
- scene.umid = req.getStorage('userInfo').merchantId;
- }
- if (req.getStorage('appId')) scene.appId = req.getStorage('appId');
- console.log('获取小程序码==', scene); //获取小程序码
- if (this.parentCode) {
- scene.parentCode = this.parentCode
- }
- const params = {
- page: 'product/detail/detail',
- scene: JSON.stringify(scene)
- };
- req.getRequest('/api/program/codev', params, url => {
- that.setData({
- codeUrl: url
- });
- });
- },
- loadDefaultAddress() {
- if (req.isAuth()) {
- req.g('/api/address/default', data => {
- if (data) this.setData({
- address: data
- });
- else {
- if (this.about.Many_Store == 1) this.pointLocation();
- }
- }, true);
- } else {
- if (this.about.Many_Store == 1) this.pointLocation();
- }
- },
- pointLocation() {
- //定位当前位置
- let _ts = this;
- QQMapWX.initMap(req.public.mapLBSKEY);
- req.getLocation(res => {
- QQMapWX.reverseGeocoder(res, data => {
- _ts.setData({
- ['address.address']: data.address
- });
- });
- });
- },
- toAddress() {
- this.changeFreshen()
- // h5util.jumpUrlExternal({url:'/mine/address/address'})
- app.globalData.openPage('mine/address/address');
- },
- atOnceBuy() {
- // console.log(this.merchantId);
- if (this.isVideoScene && !req.getStorage('userInfo')) {
- this.bindUser()
- return false;
- }
- // #ifdef MP-WEIXIN
- if (!this.getUpdate()) return false;
- // #endif
- if (!this.query.merchantId) this.setData({
- index: 'index'
- });
- this.setData({
- isShow: true,
- isCart: false,
- popup: this.product
- });
- },
- onActive() {
- this.setData({
- isActive: true
- });
- },
- addShopCart() {
- if (this.isVideoScene && !req.getStorage('userInfo')) {
- this.bindUser()
- return false;
- }
- // #ifdef MP-WEIXIN
- if (!this.getUpdate()) return false;
- // #endif
- if (!this.query.merchantId) this.setData({
- index: 'index'
- });
- this.setData({
- isShow: true,
- isCart: true,
- popup: this.product
- });
- },
- hidePopup() {
- this.setData({
- isShow: false
- });
- },
- changeFreshen() {
- this.freshen = false;
- },
- hidePopupLogin(data) {
- this.isPopupLogin = false;
- },
- hideActive() {
- this.setData({
- isActive: false
- });
- },
- addCartSuccess(event) {
- this.setData({
- 'product.count': parseInt(this.product.count) + parseInt(event.detail.quantity),
- isShow: false
- });
- },
- async clickCollect() {
- let _ts = this;
- if (await req.isAuthFn(true)) {
- req.postRequest('/api/collect', {
- bindId: this.product.id,
- type: 1
- }, data => {
- _ts.setData({
- 'product.isCollect': !_ts.product.isCollect
- });
- });
- }
- },
- goTop: function(e) {
- // 一键回到顶部
- if (uni.pageScrollTo) {
- uni.pageScrollTo({
- scrollTop: 0
- });
- } else {
- uni.showModal({
- title: '提示',
- content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
- });
- }
- },
- onShareTimeline() {
- let merchantId = '';
- let path = 'id=' + this.query.id + '&isShareTimeline=' + true + '&appId=' + req.getStorage('appId');
- let userInfo = req.getStorage('userInfo');
- if (!userInfo.id) {} else {
- path += '&userId=' + userInfo.id;
- }
- // console.log(this.query.merchantId);
- let shopId = '';
- if (!this.query.merchantId) {
- // console.log(123, path);
- } else {
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- path += '&merchantId=' + req.getStorage('MERCHANT').id;
- merchantId = req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- path += '&shopId=' + req.getStorage('smallShop').id;
- shopId = req.getStorage('smallShop').id;
- merchantId = req.getStorage('smallShop').merchantDTO.id;
- }
- }
- }
- if (userInfo.merchantId) {
- path += '&userMerchantId=' + userInfo.merchantId;
- }
- let url = '/product/detail/detail?' + path;
- route.share(2, userInfo.id, url, merchantId, shopId, 1, this.query.id);
- // console.log(path, url);
-
- path = this.SHARE_BEHAVIOR_FN({path:path,sendShare:false}).path
-
- return {
- title: this.product.title,
- query: path,
- imageUrl: this.product.images[0]
- };
- },
- // 选择服务门店
- updateShop(type) {
- if (req.getStorage('user_merchantId')) return false
- let url = '/merchant/nearby/nearby?isChoose=true';
- if (type == 1) {
- url += '&type=' + type;
- }
- if (this.about.User_Limit_Store == 1) {
- } else {
- // h5util.jumpUrlExternal({url:url})
- uni.navigateTo({
- url:url
- })
- }
- },
- onHide() {
- this.setData({
- load: false
- })
- },
- // 是否开启小店
- isShop() {
- if (req.getStorage('distribution')) {
- let dist = req.getStorage('distribution')
- this.setData({
- distr: dist
- })
- console.log(dist)
- if (dist.distributionSmallShopOpen == 1) {
- req.postRequest('/api/shopBase/isOpenShop', {}, data => {
- this.setData({
- isshop: data
- })
- console.log(data)
- })
- }
- }
- },
- addShop() {
- //添加到小店
- req.postRequest('/api/shopProduct/save', {
- productId: this.product.id,
- type: 1
- }, data => {
- // console.log(data);
- this.setData({
- isHide: false
- });
- this.product.isJoinShop = true;
- });
- },
- hidePop() {
- //添加到小店
- this.setData({
- isHide: true
- });
- },
- showTab: function(e) {
- this.setData({
- tabIndex: e.detail
- });
- },
- scoreTab: function(e) {
- this.form.page = 0;
- this.setData({
- current: e.detail,
- ['form.page']: 1
- });
- },
- freshenFun: function(e) {
- this.setData({
- freshen: e.detail
- });
- },
- getForm: function(e) {
- // console.log(e.detail,"qqqqq")
- this.form.page = e.detail
- },
- getPor: function(e) {
- // console.log(e.detail, "qqqqq")
- this.popup = e.detail
- this.product = e.detail
- },
- getProductCoupon() {
- let form = {
- page: 1,
- limit: 3,
- productId: this.query.id
- }
- return new Promise((resolve, reject) => {
- req.getRequest('/api/coupon/listV2', form, data => {
- this.couponList = data;
- resolve();
- })
- })
- },
- jumpUrl(url) {
- this.changeFreshen()
- // h5util.jumpUrlExternal({url:url})
- uni.navigateTo({
- url: url
- })
- },
- getUpdate() {
- let userInfos = req.getStorage('userInfo');
- if (!userInfos.mobile) {
- console.log('没有手机号')
- this.isShowUpdate = true;
- this.isUpdateMobile = true;
- req.setStorage('isShowUpdateMobile', true)
- return false;
- }
- if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf(
- '用户') > -1) {
- console.log('没有昵称')
- this.isShowUpdate = true;
- this.isUpdateInfo = true;
- req.setStorage('isShowUpdateInfo', true)
- return false;
- }
- return true;
- },
- closeUpdate() {
- this.isShowUpdate = false
- this.isUpdateInfo = false;
- this.isUpdateMobile = false;
- },
- jumpCart(url) {
- if (req.getStorage('cartTab')) {
- app.globalData.reLaunchTo(url);
- // h5util.jumpUrlExternal({url:url})
- } else {
- app.globalData.openPage(url)
- // h5util.jumpUrlExternal({url:url})
- }
- }
- }
- };
- </script>
- <style>
- @import "./detail.css";
- </style>
|