| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206 |
- <template>
- <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.imageList" :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.imageList" :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.minSalePrice}}<block v-if="product.maxSalePrice>product.minSalePrice">-{{product.maxSalePrice}}</block></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="dflex huiyuanjia">
- <view class="dflex">
-
- <!-- <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="merge">
- <view class="m-tit">套餐内容</view>
- <view class="m-list">
- <view class="li ddflex" v-for="(item,index) in product.nodeList" :key="index" v-if="index < nodeIndex" @click="jumpUrl('/product/detail/detail?id=' + item.product.id)">
- <image :src="item.product.pic" mode="aspectFill"></image>
- <view class="fflex">
- <view class="m-pro-tit">{{item.product.title}}</view>
- <view class="m-pro-specs" v-if="item.productSku.properties&&item.productSku.properties!='DEFAULT_SKU'">规格<text v-for="(it,idx) in JSON.parse(item.productSku.properties)" :key="idx">{{it.value}}</text></view>
- <view class="m-pro-opt ddflex">
- <view class="m-pro-price">¥<text>{{item.productSku.salePrice}}</text></view>
- <view class="m-pro-count">×{{item.quantity}}</view>
- </view>
- </view>
- </view>
- </view>
- <view :class="'colle ddflex' + (isCollapse?' active':'')" v-if="product.nodeList.length > 3" @click="collapse">{{isCollapse?'收起':'查看'}}更多<image src="../../static/pages/images/bico.png"></image></view>
- </view>
- <view class="detinfo mt20 bgfff">
- <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>
- <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" :is-merge="1"
- @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">
- <navigator class="botbtn" open-type="reLaunch" url="/pages/index/index" hover-class="none">
- <image src="/static/pages/images/sy.png"></image>首页
- </navigator>
- </view>
- <view class="btnbuy">
- <view class="gmbtn mbglinear fflex" @tap="atOnceBuy" v-if="product.quantity >= 1 && product.state == 1">
- 马上抢
- </view>
- <view class="gmbtn mbggray fflex" v-if="(product.quantity < 1)&&load">已售罄</view>
- <block v-else>
- <view class="gmbtn mbggray fflex" v-if="(product.state != 1)&&load">已下架</view>
- </block>
- <view class="gmbtn mbggray fflex" v-if="product.quantity < 1 && product.state == 1">马上抢
- </view>
- </view>
- </view>
- <view class="xiajia" v-if="product.quantity < 1">您来晚了,商品已售罄</view>
- <block v-else>
- <view class="xiajia" v-if="(product.state !=1) &&load">您来晚了,商品已经下架</view>
- </block>
- <!-- 商品规格 -->
- <block v-if="isShow">
- <product-popup :product="popup" :order-type="991" :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>
- <!-- 返回顶部 -->
- <contact-button img-url="/static/pages/images/kfico1.png" class-name="side-contact" button-text="客服"></contact-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></privacy>
- <!-- #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 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";
- export default {
- data() {
- return {
- picUrlss: req.public.picUrls,
- 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,//绑定手机号
- nodeIndex: 3,
- isCollapse: false,
- isShowUpdate: false,//是否显示更新信息弹窗
- isUpdateInfo: false,//更新用户信息
- isUpdateMobile: false,//绑定手机号
- };
- },
- components: {
- productPopup,
- vShare,
- productAcitvity,
- productLogin
- },
- props: {},
- onLoad: async function(options) {
- if(options.appId) req.setStorage('appId',options.appId);
- 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.isShare || options.isShareTimeline) {
- req.setStorage('pidCode', options.userId);
- let params = {
- userId: options.userId,
- merchantId: options.merchantId ? options.merchantId : '',
- }
- await this.bindUser(params);
- }else{
- await req.silenceLogin();
- }
-
- 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);
- },
- onShow: async function() {
- 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) {
- await 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() {
- // console.log(options);
- return this.onShareMessage();
- },
- 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(function() {
- var shareContent = that.onShareMessage();
- if (shareContent) {
- shareContent.path = window.location.origin + shareContent.path;
- }
- console.log('分享内容》》》》》', shareContent);
- that.$refs.wxshare.init(shareContent);
- }, 4 * 1000);
- // #endif
- },
-
- methods: {
- onShareMessage(){
- let merchantId = '';
- let path = '';
- let isSolution = '';
- // #ifndef H5
- isSolution = req.env[req.env.NODE_ENV].isSolution;
- // #endif
- // #ifdef H5
- isSolution = false;
- // #endif
- let userInfo = req.getStorage('userInfo');
- let shopId = '';
- if(isSolution){
- path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
- }else{
- path = '/product/mergeDetail/detail?id=' + this.query.id + '&isShare=' + true + '&appId=' + req.getStorage('appId');
- if (!userInfo.id) {} else {
- path += '&userId=' + userInfo.id;
- }
- 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;
- }
- }
- }
- route.share(1, userInfo.id, path, merchantId, shopId, 1, this.query.id);
- return {
- title: this.product.title,
- imageUrl: this.product.pic,
- path: path
- };
- },
-
- collapse(){
- if(this.isCollapse){
- this.nodeIndex = 3;
- }else{
- this.nodeIndex = this.product.nodeList.length;
- }
- this.isCollapse = !this.isCollapse
- },
- 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) {
- // 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;
- req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
- }
- },
- click(e) {
- // console.log(e,"7899")
- this.hideShare = e
- },
- getMerchant() {
- let that = this;
- api.getMerchant(this.query, req, data => {
- that.loadDefaultAddress();
- 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, _ts.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
- }
- })
- },
- showShare() {
- // console.log(11111,this.hideShare)
- // #ifdef H5
- this.setData({
- hideShare: false
- });
- // #endif
- // #ifndef H5
- req.isLogin().then(success => {
- // console.log(success)
- if (success) {
- this.getCodeUrl()
- this.setData({
- hideShare: false
- });
- // console.log(this.hideShare)
- }
- });
- // #endif
- },
- /**
- * 轮播切换
- */
- 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/mergeDetail/detail?id=' + id
- };
- if (this.query.isShare) {
- from.shareType = 1;
- from.page = '/product/mergeDetail/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/mergeDetail/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()});
- })
- },
- govip() {
- uni.navigateTo({
- url: '/mine/vip/vip'
- });
- },
- loadProudct(query) {
- let that = this;
- that.getMy();
- that.setData({
- bannerUrls: [],
- product: '',
- nodes: ''
- });
- // console.log(query.merchantId);
- let form = {
- id: query.id
- };
- let isShowLoading = false;
- this.allShow = false
- if (!isShowLoading) {
- req.loadIng('加载中');
- isShowLoading = true;
- }
- req.getRequest('/api/v3/merge/detail', form, data => {
- //富文本图片放大
- var nodes = data.text;
- data.priceList.map(it=>{
- it.active = false;
- return it;
- })
- that.setData({
- bannerUrls: data.imageList,
- product: data,
- nodes: nodes,
- 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;
- });
- },
- loadCodeParams() {
- let _ts = this;
-
- return new Promise((resolve, reject) => {
- let form = {
- scene: _ts.scene
- };
- if (!_ts.scene) {
- resolve();
- return false;
- } // if (_ts.merchantId) {
- // console.log("解析出来有门店")
- // form.merchantId = _ts.merchantId
- // }
-
-
- req.getRequest('/api/code/params', form, data => {
- // console.log("====================================================================================" + data.merchantId)
- // this.data.query.id = data.scene;
- let res = data.scene.split('_');
- let params = {
- userId: data.userId
- }
- res.map(it=>{
- if(it.indexOf('poid')>-1){
- _ts.query.id = it.split('=')[1]
- params.id = it.split('=')[1]
- }
- if(it.indexOf('mid')>-1){
- _ts.query.merchantId = it.split('=')[1]
- params.merchantId = it.split('=')[1]
- }
- if(it.indexOf('sid')>-1){
- _ts.query.shopId = it.split('=')[1]
- params.shopId = it.split('=')[1]
- }
- })
- req.setStorage('pidCode', data.userId);
- req.setStorage('appId',res[res.length-1]);
- this.setData({
- params: params
- });
- resolve();
- });
- });
- },
- 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('appId')) scene += '_'+ req.getStorage('appId');
- // console.log(scene); //获取小程序码
- const params = {
- page: 'product/mergeDetail/detail',
- scene: 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() {
- app.globalData.openPage('mine/address/address');
- },
- atOnceBuy() {
- // console.log(this.merchantId);
- if(this.isVideoScene && !req.getStorage('userInfo')){
- this.bindUser()
- return false;
- }
- if(!this.getUpdate()) return false;
- 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;
- }
- if(!this.getUpdate()) return false;
- 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
- });
- },
- clickCollect() {
- let _ts = this;
- 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');
- if (!req.getStorage('userInfo').id) {} else {
- path += '&userId=' + req.getStorage('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;
- }
- }
- }
- let url = '/product/mergeDetail/detail?' + path;
- route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 1, this.query.id);
- // console.log(path, url);
- return {
- title: this.product.title,
- query: path,
- imageUrl: this.product.images[0]
- };
- },
- // 选择服务门店
- updateShop(type) {
- let url = 'merchant/nearby/nearby?isChoose=true';
- if (type == 1) {
- url += '&type=' + type;
- }
- if (this.about.User_Limit_Store == 1) {
- } else {
- app.globalData.openPage(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){
- 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;
- },
- }
- };
- </script>
- <style>
- @import "./detail.css";
- </style>
|