| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982 |
- <template>
- <view v-if="allShow">
- <!--pages/groupDetail/groupDetail.wxml-->
- <view class="banner">
- <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
- duration="1000">
- <block v-for="(item, index) in bannerUrls" :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 bannerUrls" :key="index">
- <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
- @tap="dotEvent"></view>
- </block>
- </view>
- </view>
- <!-- <view class="notification_bar" wx:if="{{isNotice}}">
- <swiper class="swiper_container" vertical="true" autoplay="true" circular="false" duration="1000" interval="5000" easing-function="easeInOutCubic" class="bar_box dflex">
- <swiper-item class="bar_con dflex" wx:for="{{contentList}}" wx:key="item">
- <view class="bar dflex">
- <image class="bar_left" src="{{item.pic}}" />
- <text class="bar_text">最新订单来自</text>
- <text class="bar_text">{{item.name}},</text>
- <text class="bar_text">{{item.time}}</text>
- </view>
- </swiper-item>
- </swiper>
- </view> -->
- <view class="group">
- <image src="/static/pages/images/ptbg.png" class="ptbg"></image>
- <view class="groups dflex">
- <view class="left">
- <view class="price">¥<text>{{act.money}}</text><text class="origin"
- v-if="item.marketPrice!=0&&item.marketPrice>item.money">¥{{pro.marketPrice}}</text></view>
- <view class="pin">{{act.person?act.person:'0'}}人已拼</view>
- </view>
- <view class="right">
- <image src="/static/pages/images/tuan.png" class="tuan"></image>
- <view class="endtime dflex">
- <view>{{act.start ? '距结束' : '距开始'}}还剩</view>
- <block v-if="timer[0] !==0"><text>{{timer[0]}}</text>天</block>
- <text>{{timer[1]}}</text>:
- <text>{{timer[2]}}</text>:
- <text>{{timer[3]}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="info bgfff">
- <view class="infos dflex">
- <view class="title flex">{{pro.title}}</view>
- <view class="share" @tap="showShare">
- <image src="/static/pages/images/fxico.png"></image>分享
- </view>
- </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>
- </view>
- <view class="detinfo mt20 bgfff">
- <!-- isOtc 0 默认 1 处方药 2 非处方药 3 医疗器械 4 食品类 5 海外购 -->
- <block v-if="act.isOtc!=5">
- <block v-if="is_open_shop == 1 && ascription">
- <view class="xiaodian dflex malr20" v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0) || act.serviceShopRate">
- <image src="/static/pages/images/xdbg1.png" class="xdbg"></image>
- <view class="shouyi flex" v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
- <text>分销收益</text>
- <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
- <view v-else><text>¥</text>{{act.twoCommission}}</view>
- </view>
- <view class="shouyi flex" v-if="act.serviceShopRate">
- <text>小店服务费</text>
- <view><text>¥</text>{{act.serviceShopRate}}</view>
- </view>
- <view class="dflex" v-if="act.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="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
- <image src="/static/pages/images/xdbg1.png" class="xdbg"></image>
- <view class="shouyi flex">
- <text>分销收益</text>
- <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
- <view v-else><text>¥</text>{{act.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 class="item dflex">
- <label>优惠券</label>
- <view class="quan flex dflex">
- <view class="flex dflex">
- <text>满500减50</text>
- <text>满200减10</text>
- </view>
- <view class="ling dflex">领券<image src="/pages/images/more3.png"></image>
- </view>
- </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="pro.isTimely == 1"><text>现货</text>,现在下单,预计2小时后送达</view>
- </view>
- <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
- </view>
- <view class="item dflex">
- <label>提货门店</label>
- <view class="flex" @tap="toMerchant">
- <view class="address">{{merchant.title}}</view>
- </view>
- </view>
- </view>
- <!-- 商品详情等页面 -->
- <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="pro.id" :form="form" v-if="pro.id"
- @showTab="showTab" @scoreTab="scoreTab" @freshen="freshenFun">
- </product-footer>
- <v-share :hide-toast="hideShare" :product="pro" :code-url="codeUrl" a-type="1" @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'">
- <contact-button img-url="/static/pages/images/kfico.png" class-name="botbtn" button-text="在线客服"></contact-button>
- <navigator class="botbtn" open-type="switchTab" url="/pages/cart/cart" hover-class="none">
- <image src="/static/pages/images/gwc.png"></image>购物车<text class="message"
- v-if="pro.count > 0">{{pro.count}}</text>
- </navigator>
- <view class="botbtn" @tap="clickCollect">
- <image src="/static/pages/images/shoucang_h.png" v-if="pro.isCollect"></image>
- <image src="/static/pages/images/shoucang.png" v-else></image>收藏
- </view>
- <!-- <view class="addcart">加入购物车</view> -->
- <block v-if="!activityEnd">
- <view
- :class="['addcart',act.start? '' : 'gray']"
- @tap="act.start ? addShopCart() : ''">加入购物车
- </view>
- <view class="gmbtn mbglinear" @tap="atOnceBuy" v-if="act.start">{{pro.isOtc==1 ?'预约下单': '立即购买'}}</view>
- <block v-else>
- <view class="gmbtnyuyue mbglinear" @tap="cancelActivityRemind" v-if="isRemind">取消提醒</view>
- <view class="gmbtnyuyue mbglinear" @tap="addActivityRemind" v-else>开团提醒</view>
- </block>
- </block>
- <block v-else>
- <view class="gmbtnyuyue mbggray">活动不存在</view>
- </block>
- </view>
- <!-- 商品规格 -->
- <block v-if="isShow">
- <product-popup :product="popup" :activityId="act.id" :maxBuy="act.maxBuy" :order-type="2"
- @hidePopup="hidePopup" :merchant="merchant" :merchant-id="query.merchantId" :shopId="query.shopId"
- :isCart="isCart" @addCartSuccess="addCartSuccess" :actId="act.actId" @getPor="getPor">
- </product-popup>
- </block>
- <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="/static/pages/images/tjcg1.png" class="tjcg1"></image>
- <image src="/static/pages/images/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>
- <!-- <view class="share-btn dflex">
- <button class="wxfriend dflex" open-type="share">
- <image src="/static/pages/images/wechat.png"></image>
- 微信好友
- </button>
- <view class="wxposter dflex" @tap="generatePoster">
- <image src="/static/pages/images/poster.png"></image>
- 生成海报
- </view>
- </view> -->
- <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
- </view>
- <block v-if="isPopupLogin">
- <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
- </block>
- </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 requsetmessage = require("../../utils/requestmessage.js");
- const route = require("../../utils/route");
- const api = require("../../utils/api");
- import productFooter from "../../components/product_footer/index";
- import productPopup from "../../components/product-popup/index";
- import vShare from "../../components/share/share";
- import productLogin from "../../components/product-login/index";
- export default {
- data() {
- return {
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- swiperCurrent: 0,
- bannerUrls: [],
- isShow: false,
- pro: {},
- timer: [],
- isRemind: false,
- hideShare: true,
- codeUrl: '',
- 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,
- //添加小店成功弹窗
- form: {
- page: 1,
- limit: 10
- },
- freshen: true //是否更新页面
- ,
- current: "",
- query: "",
- merchant: "",
- merchantId: "",
- shopId: "",
- imgs: "",
- activityEnd: false,
- act: "",
- address: {},
- popup: {},
- tabIndex: "",
- guarantee: "",
- is_open_comments: "",
- nodes: "",
- switch: true,
- about: {},
- allShow: false,
- isCart: false,
- url: '',
- is_open_shop: '',//商户是否开启分销
- ascription: false,//是否开启小店
- isDistriUser: 0, // 判断用户是否是分销员 2为分销员
- isPopupLogin: false
- };
- },
- components: {
- productFooter,
- productPopup,
- vShare,
- productLogin
- },
- props: {},
- onLoad: function(options) {
- let tmplIds = [];
- this.query = options;
- if (options.scene) {
- this.scene = options.scene;
- }
- if (options.isShare) {
- this.query.id = options.id;
- this.query.acid = options.acid;
- req.setStorage('pidCode', options.userId);
- req.setStorage('pidCode', options.userId);
- let params = {
- userId: options.userId,
- merchantId: options.merchantId ? options.merchantId : '',
- }
- this.bindUser(params);
- }
- if (options.hideShop) {
- // console.log(options.hideShop);
- this.setData({
- hideShop: this.query.hideShop
- });
- } else {
- this.setData({
- hideShop: 'true'
- });
- }
- // console.log(this.hideShop);
- console.info(options);
- setInterval(() => {
- this.setData({
- isNotice: true
- });
- }, 10000);
- },
- onShow: async function() {
- let that = this
- if (this.freshen) {
- await this.loadCodeParams();
- if(that.scene){
- await that.bindUser(that.params);
- }
- this.getGuarantee().then(data => {
- if (this.switch) {
- api.getMerchant(this.query, req, data => {
- that.loadDefaultAddress();
- if (data == 1) {
- api.locationShow()
- } else {
- that.getuserInfos(data);
- if (data.type == 5) {
- that.query.merchantId = data.merchantDTO.id
- that.query.shopId = data.id
- } else {
- that.query.merchantId = data.id
- }
- if (req.getStorage('userInfo') && that.merchant.id != data.id) {
- this.loadProudct();
- let pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- if (prevPage) {
- prevPage.$vm.setData({
- freshen: true
- });
- }
- } else {
- this.loadProudct();
- }
- that.merchant = data
- }
- })
- }
- })
- this.browsRecound(this.query.id); // let merchant = req.getStorage('MERCHANT');
- }
- },
- onUnload() {
- if (this.timer) clearInterval(this.timer);
- },
- onShareAppMessage: function() {
- let merchantId = '';
- let path = '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
- '&isShare=' + true;
- // console.log(!req.getStorage('userInfo').id);
- if (!req.getStorage('userInfo').id) {} else {
- path += '&userId=' + req.getStorage('userInfo').id;
- }
- // console.log(this.query.merchantId);
- let shopId = '';
- 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, req.getStorage('userInfo').id, path, merchantId, shopId, 5, this.query.acid + '_' + this
- .query.id);
- return {
- title: this.pro.title,
- imageUrl: this.pro.pic,
- path: path
- }; // console.log('产品详情', this.data.product);
- // return {
- // title: this.data.pro.title,
- // imageUrl: this.data.pro.pic,
- // path: '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id+'&merchantId='+this.data.query.merchantId
- // }
- },
- 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);
- this.$refs.list.loadScore(this.current);
- }
- },
- methods: {
- bindUser(par){
- let userInfo = req.getStorage('userInfo');
- if(!userInfo){
- // uni.login({
- // success(res) {
- // let params = {
- // code: res.code,
- // parentId: par.userId,
- // 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)
- this.hideShare = e
- },
- showShare() {
- // #ifndef H5
- req.isLogin().then(success => {
- if (success) {
- this.getCodeUrl()
- this.setData({
- hideShare: false
- });
- }
- });
- // #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
- });
- },
- browsRecound(id) {
- let from = {
- bindId: id,
- type: 5,
- page: '/product/groupDetail/groupDetail' + id + '&acid=' + this.query.acid
- };
- if (this.query.isShare) {
- from.shareType = 1;
- from.page = '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
- '&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/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
- '&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;
- }
- }
- req.postRequest('/api/browse', from, data => {});
- },
- addShopCart() {
- // 加入购物车
- if (!this.act.start) return req.msg('活动还未开始');
- if (this.act.end) return req.msg('活动已结束');
- this.setData({
- isShow: true,
- isCart: true,
- popup: {
- id: this.pro.id,
- pic: this.pro.pic,
- title: this.pro.title,
- salePrice: this.act.money,
- paramsId: this.pro.paramsId,
- stock: this.pro.stock,
- marketPrice: this.pro.marketPrice,
- skuId: this.pro.skuId
- }
- });
- },
- loadCodeParams() {
- let _ts = this;
- return new Promise((resolve, reject) => {
- if (!_ts.scene) {
- resolve();
- return false;
- }
- req.getRequest('/api/code/params', {
- scene: _ts.scene
- }, data => {
- if (data) {
- this.query.id = data.scene.split('_')[0];
- this.query.acid = data.scene.split('_')[1];
- this.query.merchantId = data.scene.split('_')[2];
- this.query.shopId = data.scene.split('_')[3];
- req.setStorage('pidCode', data.userId);
- }
- resolve();
- });
- });
- },
- getCodeUrl() {
- let that = this; //获取小程序码
- const query = this.query;
- let scene = that.pro.id + '_' + query.acid;
- if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
- scene += '_' + req.getStorage('MERCHANT').id;
- if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
- scene += '_' + req.getStorage('smallShop').id;
- }
- }
- // console.log(scene); //获取小程序码
- const params = {
- page: 'product/groupDetail/groupDetail',
- scene: scene
- };
- // console.log('ma--', params);
- req.getRequest('/api/program/codev', params, url => {
- that.setData({
- codeUrl: url
- });
- });
- },
- async loadProudct() {
- let that = this;
- await that.loadActivity();
- const query = that.query;
- req.getRequest('/api/product/detail', {
- id: query.id
- }, data => {
- //富文本图片放大
- this.nodes = data.detail;
- that.setData({
- bannerUrls: data.images,
- pro: data,
- 'pro.salePrice': this.act.money,
- // 'pro.stock': this.act.quantity,
- 'pro.stock': this.act.quantity - this.act.payQuantity,
- 'pro.payQuantity': this.act.payQuantity,
- 'pro.maxBuy': this.act.maxBuy
- });
- });
- },
- loadActivity() {
- const query = this.query;
- return new Promise((resolve, reject) => {
- let isShowLoading = false;
- if (!isShowLoading) {
- req.loadIng('加载中');
- isShowLoading = true;
- }
- let from = {
- id: query.acid
- }
- if (!this.query.merchantId) {} else {
- from.merchantId = this.query.merchantId
- }
- let userInfo = req.getStorage('userInfo');
- if(userInfo.listShopBase && userInfo.listShopBase.length >0 ){
- from.shopId = userInfo.listShopBase[0].id;
- }
- req.getRequest('/api/activity/detail', from, data => {
- this.getMy();
- if (!data || data == 2001) {
- this.setData({
- activityEnd: true
- });
- return false;
- } else {
- // console.log(data);
- this.setData({
- act: data,
- isRemind: data.remindId,
- allShow: true
- });
- if (isShowLoading) {
- uni.hideLoading();
- isShowLoading = false;
- }
- this.initTimer(data);
- }
- resolve();
- });
- });
- },
- // 获取用户信息
- getuserInfos(data) {
- let userInfo = req.getStorage('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;
- this.url = url;
- this.ascription = true;
- }
- }
- },
- getMy() {
- let that = this;
- let userInfo = req.getStorage('userInfo');
- if(!userInfo || userInfo == null) return false;
- req.getRequest('/api/user/my', {}, data => {
- that.isDistriUser = data.isDistriUser;
- });
- },
-
- initTimer(group) {
- //计时器
- let _ts = this;
- let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
- let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
- let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
- if (!group.start) endTime = startTime;
- let times = parseInt((endTime - nowTime) / 1000);
- // console.log(times / 60 / 60);
- this.timer = setInterval(() => {
- times--;
- if (times <= 0) {
- //重新加载列表
- _ts.setData({
- 'act.end': true
- });
- return false;
- }
- let n = utils.formatDayTimes(times);
- _ts.setData({
- timer: n.split(/:|天/g)
- });
- }, 1000);
- },
- loadDefaultAddress() {
- if (req.isAuth()) {
- req.g('/api/address/default', data => {
- if (data) {
- this.setData({
- address: data
- });
- } else {
- this.pointLocation();
- }
- }, true);
- } else {
- this.pointLocation();
- }
- },
- toAddress() {
- app.globalData.openPage('mine/address/address');
- },
- toMerchant() {
- if (this.about.User_Limit_Store == 1) {
- } else {
- app.globalData.openPage('pages/nearby/nearby?isChoose=true');
- }
- },
- pointLocation() {
- //定位当前位置
- let _ts = this;
- QQMapWX.initMap();
- req.getLocation(res => {
- QQMapWX.reverseGeocoder(res, data => {
- _ts.setData({
- 'address.address': data.address
- });
- });
- });
- },
- atOnceBuy() {
- //立即购买
- if (!this.act.start) return req.msg('活动还未开始');
- if (this.act.end) return req.msg('活动已结束');
- this.setData({
- isShow: true,
- isCart: false,
- popup: {
- id: this.pro.id,
- pic: this.pro.pic,
- title: this.pro.title,
- salePrice: this.act.money,
- paramsId: this.pro.paramsId,
- stock: this.pro.stock,
- marketPrice: this.pro.marketPrice,
- skuId: this.pro.skuId
- }
- });
- },
- addCartSuccess(event) {
- this.setData({
- 'pro.count': parseInt(this.pro.count) + parseInt(event.detail.quantity),
- isShow: false
- });
- },
- addActivityRemind() {
- req.postRequest('/api/activity/remind', {
- activityId: this.act.id
- }, res => {
- // 订阅调用
- requsetmessage.remind();
- req.msg('订阅提醒成功');
- this.setData({
- isRemind: true
- });
- });
- },
- cancelActivityRemind(event) {
- if (req.header.appId == 'ZQ1VK5oc17I387E') {
- } else {
- req.postRequest('/api/activity/cancel/remind', {
- id: this.act.id
- }, res => {
- req.msg('取消提醒成功');
- this.setData({
- isRemind: false
- });
- });
- }
- },
- hidePopup() {
- this.setData({
- isShow: false
- });
- },
- hidePopupLogin(data) {
- this.isPopupLogin = false;
- },
- clickCollect() {
- let _ts = this;
- req.postRequest('/api/collect', {
- bindId: this.pro.id,
- type: 1
- }, data => {
- _ts.setData({
- 'pro.isCollect': !_ts.pro.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 + '&acid=' + this.query.acid + '&isShareTimeline=' + true;
- if (!req.getStorage('userInfo').id) {} else {
- path += '&userId=' + req.getStorage('userInfo').id;
- }
- let shopId = '';
- 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/groupDetail/groupDetail?' + path;
- route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 5, this.query.acid + '_' + this
- .query.id);
- return {
- title: this.pro.title,
- query: path,
- imageUrl: this.pro.pic
- }; // return {
- // title: this.data.pro.title,
- // imageUrl: this.data.pro.pic
- // }
- },
- addShop() {
- //添加到小店
- req.postRequest('/api/shopProduct/save', {
- productId: this.query.acid,
- type: 2
- }, data => {
- this.act.isJoinShop = true;
- this.isHide = false;
- });
- },
- 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
- });
- },
- getPor: function(e) {
- // console.log(e.detail, "qqqqq")
- this.popup = e.detail
- this.act.id=e.detail.actId
- },
- // 获取品种保证
- getGuarantee() {
- return new Promise((data, rej) => {
- req.getRequest('/api/config', {}, res => {
- req.setStorage('configRes', JSON.stringify(res))
- this.about = res
- data(res)
- if (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.Is_Store_Price_Stock){
- // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
- // }
- if (res.is_open_shop) {
- this.is_open_shop = res.is_open_shop;
- }
- if (res.is_open_comments) {
- this.setData({
- is_open_comments: res.is_open_comments
- });
- } // this.setData({ show_membership_price: res.show_membership_price, Is_Store_Price_Stock: res.Is_Store_Price_Stock, is_open_shop: res.is_open_shop })
- });
- })
- }
- }
- };
- </script>
- <style>
- @import "./groupDetail.css";
- </style>
|