groupDetail.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. <template>
  2. <view v-if="allShow">
  3. <!--pages/groupDetail/groupDetail.wxml-->
  4. <view class="banner">
  5. <swiper class="swiper" @change="swiperChange" :current="current" autoplay="true" circular="true"
  6. duration="1000">
  7. <block v-for="(item, index) in bannerUrls" :key="index">
  8. <swiper-item autoplay="true">
  9. <image :src="item + '?x-oss-process=style/w750-auto'" mode="aspectFit"></image>
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. <view class="dots dflex">
  14. <block v-for="(item, index) in bannerUrls" :key="index">
  15. <view :class="'dot ' + (index == swiperCurrent ? ' active' : '')" :data-current="index"
  16. @tap="dotEvent"></view>
  17. </block>
  18. </view>
  19. </view>
  20. <!-- <view class="notification_bar" wx:if="{{isNotice}}">
  21. <swiper class="swiper_container" vertical="true" autoplay="true" circular="false" duration="1000" interval="5000" easing-function="easeInOutCubic" class="bar_box dflex">
  22. <swiper-item class="bar_con dflex" wx:for="{{contentList}}" wx:key="item">
  23. <view class="bar dflex">
  24. <image class="bar_left" src="{{item.pic}}" />
  25. <text class="bar_text">最新订单来自</text>
  26. <text class="bar_text">{{item.name}},</text>
  27. <text class="bar_text">{{item.time}}</text>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. </view> -->
  32. <view class="group">
  33. <image :src="picUrlss+'ptbg.png'" class="ptbg"></image>
  34. <view class="groups dflex">
  35. <view class="left">
  36. <view class="price">¥<text>{{act.money}}</text><text class="origin"
  37. v-if="item.marketPrice!=0&&item.marketPrice>item.money">¥{{pro.marketPrice}}</text></view>
  38. <view class="pin">{{act.person?act.person:'0'}}人已拼</view>
  39. </view>
  40. <view class="right">
  41. <image src="/static/pages/images/tuan.png" class="tuan"></image>
  42. <view class="endtime dflex">
  43. <view>{{act.start ? '距结束' : '距开始'}}还剩</view>
  44. <block v-if="timer[0] !==0"><text>{{timer[0]}}</text>天</block>
  45. <text>{{timer[1]}}</text>:
  46. <text>{{timer[2]}}</text>:
  47. <text>{{timer[3]}}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="info bgfff">
  53. <view class="infos dflex">
  54. <view class="title flex">{{pro.title}}</view>
  55. <view class="share" @tap="showShare">
  56. <image src="/static/pages/images/fxico.png"></image>分享
  57. </view>
  58. </view>
  59. <view class="guarantee dflex" v-if="guarantee.length>0">
  60. <view class="cont dflex">
  61. <view v-for="(item, index) in guarantee" :key="index" class="dflex li">
  62. <image src="/product/static/product/image/guarantee.png"></image>{{item}}
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="detinfo mt20 bgfff">
  68. <!-- isOtc 0 默认 1 处方药 2 非处方药 3 医疗器械 4 食品类 5 海外购 -->
  69. <block v-if="act.isOtc!=5">
  70. <block v-if="is_open_shop == 1 && ascription">
  71. <view class="xiaodian dflex malr20"
  72. v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0) || act.serviceShopRate">
  73. <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
  74. <view class="shouyi flex"
  75. v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
  76. <text>分销收益</text>
  77. <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
  78. <view v-else><text>¥</text>{{act.twoCommission}}</view>
  79. </view>
  80. <view class="shouyi flex" v-if="act.serviceShopRate">
  81. <text>小店服务费</text>
  82. <view><text>¥</text>{{act.serviceShopRate}}</view>
  83. </view>
  84. <view class="dflex" v-if="act.isJoinShop">
  85. <view class="fenxiang" @tap="showShare">分享推广</view>
  86. <navigator :url="url" hover-class="none" class="goShop">去小店</navigator>
  87. </view>
  88. <view class="addshop" @tap="addShop" v-else>添加到小店</view>
  89. </view>
  90. </block>
  91. <block v-else>
  92. <view class="xiaodian dflex malr20"
  93. v-if="((act.isMeCommission != 1 || act.isMeCommission != '1') && act.oneCommission>0) || ((act.isMeCommission == 1 || act.isMeCommission == '1') && act.twoCommission>0)">
  94. <image :src="picUrlss+'xdbg1.png'" class="xdbg"></image>
  95. <view class="shouyi flex">
  96. <text>分销收益</text>
  97. <view v-if="act.isMeCommission == 0"><text>¥</text>{{act.oneCommission}}</view>
  98. <view v-else><text>¥</text>{{act.twoCommission}}</view>
  99. </view>
  100. <navigator url="/promote/apply/apply" hover-class="none" class="fenxiang"
  101. v-if="isDistriUser != 2">我要推广</navigator>
  102. <view class="fenxiang" @tap="showShare" v-else>分享推广</view>
  103. </view>
  104. </block>
  105. </block>
  106. <!-- <view class="item dflex">
  107. <label>优惠券</label>
  108. <view class="quan flex dflex">
  109. <view class="flex dflex">
  110. <text>满500减50</text>
  111. <text>满200减10</text>
  112. </view>
  113. <view class="ling dflex">领券<image src="/pages/images/more3.png"></image>
  114. </view>
  115. </view>
  116. </view> -->
  117. <view class="item dflex">
  118. <label>配送至</label>
  119. <view class="flex" @tap="toAddress">
  120. <view class="address">{{address.address?address.address:''}}{{address.house?address.house:''}}
  121. </view>
  122. <view class="huo" v-if="pro.isTimely == 1"><text>现货</text>,现在下单,预计2小时后送达</view>
  123. </view>
  124. <image src="/static/pages/images/more2.png" class="more" @tap="toAddress"></image>
  125. </view>
  126. <view class="item dflex">
  127. <label>提货门店</label>
  128. <view class="flex" @tap="toMerchant">
  129. <view class="address">{{merchant.title}}</view>
  130. </view>
  131. </view>
  132. </view>
  133. <!-- 商品详情等页面 -->
  134. <product-footer ref="list" id="list" :detail="nodes" :imgs="imgs" :proId="pro.id" :form="form" v-if="pro.id"
  135. @showTab="showTab" @scoreTab="scoreTab" @freshen="freshenFun">
  136. </product-footer>
  137. <v-share :hide-toast="hideShare" :product="pro" :code-url="codeUrl" a-type="1" @onFather="click"></v-share>
  138. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 140) + 'rpx'"></view>
  139. <view class="bot fixed bgfff dflex" :style="'padding-bottom: ' + (bottomBlankHeight + 20) + 'rpx'">
  140. <button open-type="contact" class="botbtn">
  141. <image src="/static/pages/images/kfico.png"></image>在线客服
  142. </button>
  143. <view class="botbtn" @tap="jumpCart('pages/cart/cart')">
  144. <image src="/static/pages/images/gwc.png"></image>购物车<text class="message"
  145. v-if="pro.count > 0">{{pro.count}}</text>
  146. </view>
  147. <view class="botbtn" @tap="clickCollect">
  148. <image src="/static/pages/images/shoucang_h.png" v-if="pro.isCollect"></image>
  149. <image src="/static/pages/images/shoucang.png" v-else></image>收藏
  150. </view>
  151. <!-- <view class="addcart">加入购物车</view> -->
  152. <block v-if="!activityEnd">
  153. <view :class="['addcart',act.start? '' : 'gray']" @tap="act.start ? addShopCart() : ''">加入购物车
  154. </view>
  155. <view class="gmbtn mbglinear" @tap="atOnceBuy" v-if="act.start">{{pro.isOtc==1 ?'预约下单': '立即购买'}}</view>
  156. <block v-else>
  157. <view class="gmbtnyuyue mbglinear" @tap="cancelActivityRemind" v-if="isRemind">取消提醒</view>
  158. <view class="gmbtnyuyue mbglinear" @tap="addActivityRemind" v-else>开团提醒</view>
  159. </block>
  160. </block>
  161. <block v-else>
  162. <view class="gmbtnyuyue mbggray">活动不存在</view>
  163. </block>
  164. </view>
  165. <!-- 商品规格 -->
  166. <block v-if="isShow">
  167. <product-popup :product="popup" :activityId="act.id" :maxBuy="act.maxBuy" :order-type="2"
  168. @hidePopup="hidePopup" :merchant="merchant" :merchant-id="query.merchantId" :shopId="query.shopId"
  169. :isCart="isCart" @addCartSuccess="addCartSuccess" :actId="act.actId" @getPor="getPor">
  170. </product-popup>
  171. </block>
  172. <view class="contact_index" @tap="goTop">
  173. <image src="/static/pages/images/backtop.png"></image>顶部
  174. </view>
  175. <!-- 添加到小店成功 -->
  176. <view class="mask" :hidden="isHide" @tap="hidePop"></view>
  177. <view class="suc" :hidden="isHide">
  178. <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
  179. <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
  180. <text>快去我的小店看看吧</text>
  181. <view class="shopcc dflex">
  182. <view class="shop" @tap="showShare">分享推广</view>
  183. <navigator :url="url" hover-class="none" class="shop">我的小店</navigator>
  184. </view>
  185. <!-- <view class="share-btn dflex">
  186. <button class="wxfriend dflex" open-type="share">
  187. <image src="/static/pages/images/wechat.png"></image>
  188. 微信好友
  189. </button>
  190. <view class="wxposter dflex" @tap="generatePoster">
  191. <image src="/static/pages/images/poster.png"></image>
  192. 生成海报
  193. </view>
  194. </view> -->
  195. <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
  196. </view>
  197. <block v-if="isPopupLogin">
  198. <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
  199. </block>
  200. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate"
  201. @closeUpdate="closeUpdate"></update-userinfo>
  202. <privacy :is-update="true" @getLocations="initLocation"></privacy>
  203. <!-- #ifdef H5 -->
  204. <wx-share ref="wxshare" />
  205. <!-- #endif -->
  206. </view>
  207. </template>
  208. <script>
  209. const app = getApp();
  210. const req = require("../../utils/request.js");
  211. const utils = require("../../utils/util.js");
  212. var QQMapWX = require("../../utils/qqmap.js");
  213. const requsetmessage = require("../../utils/requestmessage.js");
  214. const route = require("../../utils/route");
  215. const api = require("../../utils/api");
  216. import productPopup from "../../components/product-popup/index";
  217. import vShare from "../../components/share/share";
  218. import productLogin from "../../components/product-login/index";
  219. export default {
  220. data() {
  221. return {
  222. picUrlss: req.public.picUrls,
  223. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  224. swiperCurrent: 0,
  225. bannerUrls: [],
  226. isShow: false,
  227. pro: {},
  228. timer: [],
  229. isRemind: false,
  230. hideShare: true,
  231. codeUrl: '',
  232. contentList: [{
  233. pic: "/static/pages/images/bar.png",
  234. name: '好风依旧',
  235. time: '4秒前'
  236. }, {
  237. pic: "/static/pages/images/bar.png",
  238. name: '杨鑫',
  239. time: '20秒前'
  240. }, {
  241. pic: "/static/pages/images/bar.png",
  242. name: '杨鑫',
  243. time: '5秒前'
  244. }],
  245. isNotice: false,
  246. hideShop: true,
  247. //隐藏添加到小店
  248. isHide: true,
  249. //添加小店成功弹窗
  250. form: {
  251. page: 1,
  252. limit: 10
  253. },
  254. freshen: true //是否更新页面
  255. ,
  256. current: "",
  257. query: "",
  258. merchant: "",
  259. merchantId: "",
  260. shopId: "",
  261. imgs: "",
  262. activityEnd: false,
  263. act: "",
  264. address: {},
  265. popup: {},
  266. tabIndex: "",
  267. guarantee: "",
  268. is_open_comments: "",
  269. nodes: "",
  270. switch: true,
  271. about: {},
  272. allShow: false,
  273. isCart: false,
  274. url: '',
  275. is_open_shop: '', //商户是否开启分销
  276. ascription: false, //是否开启小店
  277. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  278. isPopupLogin: false,
  279. isShowUpdate: false, //是否显示更新信息弹窗
  280. isUpdateInfo: false, //更新用户信息
  281. isUpdateMobile: false, //绑定手机号
  282. };
  283. },
  284. components: {
  285. productPopup,
  286. vShare,
  287. productLogin
  288. },
  289. props: {},
  290. onLoad: async function(options) {
  291. if (options.appId) req.setStorage('appId', options.appId);
  292. let tmplIds = [];
  293. this.query = options;
  294. if (options.scene) {
  295. this.scene = options.scene;
  296. }
  297. if (options.isShare) {
  298. this.query.id = options.id;
  299. this.query.acid = options.acid;
  300. req.setStorage('pidCode', options.userId);
  301. req.setStorage('pidCode', options.userId);
  302. let params = {
  303. userId: options.userId,
  304. merchantId: options.merchantId ? options.merchantId : '',
  305. }
  306. await this.bindUser(params);
  307. } else {
  308. await req.silenceLogin();
  309. }
  310. if (options.hideShop) {
  311. // console.log(options.hideShop);
  312. this.setData({
  313. hideShop: this.query.hideShop
  314. });
  315. } else {
  316. this.setData({
  317. hideShop: 'true'
  318. });
  319. }
  320. // console.log(this.hideShop);
  321. console.info(options);
  322. setInterval(() => {
  323. this.setData({
  324. isNotice: true
  325. });
  326. }, 10000);
  327. },
  328. onShow: async function() {
  329. let that = this
  330. if (this.freshen) {
  331. await this.loadCodeParams();
  332. if (that.scene) {
  333. await that.bindUser(that.params);
  334. }
  335. this.getGuarantee().then(data => {
  336. if (this.switch) {
  337. that.getMerchant();
  338. }
  339. })
  340. this.browsRecound(this.query.id); // let merchant = req.getStorage('MERCHANT');
  341. }
  342. },
  343. onUnload() {
  344. if (this.timer) clearInterval(this.timer);
  345. },
  346. onShareAppMessage: function() {
  347. return this.onShareMessage();
  348. // console.log('产品详情', this.data.product);
  349. // return {
  350. // title: this.data.pro.title,
  351. // imageUrl: this.data.pro.pic,
  352. // path: '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid + '&isShare=' + true + '&userId=' + req.getStorage('userInfo').id+'&merchantId='+this.data.query.merchantId
  353. // }
  354. },
  355. onReachBottom() {
  356. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  357. this.form.page++;
  358. this.setData({
  359. ['form.page']: this.form.page
  360. });
  361. // this.selectComponent("#list").loadScore(this.current);
  362. this.$refs.list.loadScore(this.current);
  363. }
  364. },
  365. onReady() {
  366. // #ifdef H5
  367. var that = this;
  368. //初始化分享内容
  369. setTimeout(function() {
  370. var shareContent = that.onShareMessage();
  371. if (shareContent) {
  372. shareContent.path = window.location.origin + shareContent.path;
  373. }
  374. console.log('分享内容》》》》》', shareContent);
  375. that.$refs.wxshare.init(shareContent);
  376. }, 4 * 1000);
  377. // #endif
  378. },
  379. methods: {
  380. initLocation() {
  381. this.getMerchant();
  382. },
  383. onShareMessage() {
  384. let merchantId = '';
  385. let path = '';
  386. let isSolution = '';
  387. // #ifndef H5
  388. isSolution = req.env[req.env.NODE_ENV].isSolution;
  389. // #endif
  390. // #ifdef H5
  391. isSolution = false;
  392. // #endif
  393. let userInfo = req.getStorage('userInfo');
  394. let shopId = '';
  395. if (isSolution) {
  396. path = '/share/home/index?appId=' + req.getStorage('appId') + '&userId=' + userInfo.id;
  397. } else {
  398. path = '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
  399. '&isShare=' + true + '&appId=' + req.getStorage('appId');
  400. // console.log(!req.getStorage('userInfo').id);
  401. if (!userInfo.id) {} else {
  402. path += '&userId=' + userInfo.id;
  403. }
  404. // console.log(this.query.merchantId);
  405. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  406. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  407. merchantId = req.getStorage('MERCHANT').id;
  408. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  409. path += '&shopId=' + req.getStorage('smallShop').id;
  410. shopId = req.getStorage('smallShop').id;
  411. merchantId = req.getStorage('smallShop').merchantDTO.id;
  412. }
  413. }
  414. }
  415. route.share(1, userInfo.id, path, merchantId, shopId, 5, this.query.acid + '_' + this
  416. .query.id);
  417. return {
  418. title: this.pro.title,
  419. imageUrl: this.pro.pic,
  420. path: path
  421. };
  422. },
  423. getMerchant() {
  424. let that = this;
  425. api.getMerchant(this.query, req, data => {
  426. that.loadDefaultAddress();
  427. if (data == 1) {
  428. if (that.about.Many_Store == 1) api.locationShow()
  429. else {
  430. that.getuserInfos(data);
  431. if (req.getStorage('defaultMerchant')) {
  432. that.merchant = req.getStorage('defaultMerchant');
  433. that.query.merchantId = that.merchant.id
  434. } else {
  435. api.defaultMerchant(req, that.query, defaultRes => {
  436. that.merchant = defaultRes;
  437. that.query.merchantId = defaultRes.id
  438. });
  439. }
  440. that.loadProudct(that.query);
  441. }
  442. } else {
  443. that.getuserInfos(data);
  444. if (data.type == 5) {
  445. that.query.merchantId = data.merchantDTO.id
  446. that.query.shopId = data.id
  447. } else {
  448. that.query.merchantId = data.id
  449. }
  450. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  451. this.loadProudct();
  452. let pages = getCurrentPages();
  453. var prevPage = pages[pages.length - 2];
  454. if (prevPage) {
  455. prevPage.$vm.setData({
  456. freshen: true
  457. });
  458. }
  459. } else {
  460. this.loadProudct();
  461. }
  462. that.merchant = data
  463. }
  464. })
  465. },
  466. bindUser(par) {
  467. let userInfo = req.getStorage('userInfo');
  468. if (!userInfo) {
  469. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  470. }
  471. },
  472. click(e) {
  473. // console.log(e)
  474. this.hideShare = e
  475. },
  476. showShare() {
  477. // #ifndef H5
  478. req.isLogin().then(success => {
  479. if (success) {
  480. this.getCodeUrl()
  481. this.setData({
  482. hideShare: false
  483. });
  484. }
  485. });
  486. // #endif
  487. },
  488. /**
  489. * 轮播切换
  490. */
  491. swiperChange({
  492. detail
  493. }) {
  494. if (this.current == 0 && this.swiperCurrent > 1) {
  495. //卡死时,重置current为正确索引
  496. this.setData({
  497. current: this.swiperCurrent
  498. });
  499. } else {
  500. //正常轮转时,记录正确页码索引
  501. this.setData({
  502. swiperCurrent: detail.current
  503. });
  504. }
  505. },
  506. dotEvent(e) {
  507. this.setData({
  508. current: e.currentTarget.dataset.current
  509. });
  510. },
  511. browsRecound(id) {
  512. let from = {
  513. bindId: id,
  514. type: 5,
  515. page: '/product/groupDetail/groupDetail' + id + '&acid=' + this.query.acid
  516. };
  517. if (this.query.isShare) {
  518. from.shareType = 1;
  519. from.page = '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
  520. '&isShare=' +
  521. true;
  522. if (!this.query.userId) {} else {
  523. from.page += '&userId=' + this.query.userId;
  524. }
  525. if (!this.query.merchantId) {} else {
  526. from.merchantId = this.query.merchantId;
  527. }
  528. if (!this.query.shopId) {} else {
  529. from.shopId = this.query.shopId;
  530. }
  531. if (!this.query.userId) {} else {
  532. from.uid = this.query.userId;
  533. }
  534. }
  535. if (this.query.isShareTimeline) {
  536. from.shareType = 2;
  537. from.page = '/product/groupDetail/groupDetail?id=' + this.query.id + '&acid=' + this.query.acid +
  538. '&isShareTimeline=' + true;
  539. if (!this.query.userId) {} else {
  540. from.page += '&userId=' + this.query.userId;
  541. }
  542. if (!this.query.merchantId) {} else {
  543. from.merchantId = this.query.merchantId;
  544. }
  545. if (!this.query.shopId) {} else {
  546. from.shopId = this.query.shopId;
  547. }
  548. if (!this.query.userId) {} else {
  549. from.uid = this.query.userId;
  550. }
  551. }
  552. req.postRequest('/api/browse', from, data => {});
  553. },
  554. addShopCart() {
  555. // 加入购物车
  556. if (!this.act.start) return req.msg('活动还未开始');
  557. if (this.act.end) return req.msg('活动已结束');
  558. if (!this.getUpdate()) return false;
  559. this.setData({
  560. isShow: true,
  561. isCart: true,
  562. popup: {
  563. id: this.pro.id,
  564. pic: this.pro.pic,
  565. title: this.pro.title,
  566. salePrice: this.act.money,
  567. paramsId: this.pro.paramsId,
  568. stock: this.pro.stock,
  569. marketPrice: this.pro.marketPrice,
  570. skuId: this.pro.skuId
  571. }
  572. });
  573. },
  574. loadCodeParams() {
  575. let _ts = this;
  576. return new Promise((resolve, reject) => {
  577. if (!_ts.scene) {
  578. resolve();
  579. return false;
  580. }
  581. req.getRequest('/api/code/params', {
  582. scene: _ts.scene
  583. }, data => {
  584. if (data) {
  585. let res = data.scene.split('_')
  586. res.map(it => {
  587. if (it.indexOf('poid') > -1) {
  588. _ts.query.id = it.split('=')[1]
  589. }
  590. if (it.indexOf('acid') > -1) {
  591. _ts.query.acid = it.split('=')[1]
  592. }
  593. if (it.indexOf('mid') > -1) {
  594. _ts.query.merchantId = it.split('=')[1]
  595. }
  596. if (it.indexOf('sid') > -1) {
  597. _ts.query.shopId = it.split('=')[1]
  598. }
  599. })
  600. req.setStorage('pidCode', data.userId);
  601. req.setStorage('appId', res[res.length - 1]);
  602. }
  603. resolve();
  604. });
  605. });
  606. },
  607. getCodeUrl() {
  608. let that = this; //获取小程序码
  609. const query = this.query;
  610. let scene = 'poid=' + that.pro.id + '_acid=' + query.acid;
  611. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  612. scene += '_mid=' + req.getStorage('MERCHANT').id;
  613. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  614. scene += '_sid=' + req.getStorage('smallShop').id;
  615. }
  616. }
  617. if (req.getStorage('appId')) scene += '_' + req.getStorage('appId');
  618. // console.log(scene); //获取小程序码
  619. const params = {
  620. page: 'product/groupDetail/groupDetail',
  621. scene: scene
  622. };
  623. // console.log('ma--', params);
  624. req.getRequest('/api/program/codev', params, url => {
  625. that.setData({
  626. codeUrl: url
  627. });
  628. });
  629. },
  630. async loadProudct() {
  631. let that = this;
  632. await that.loadActivity();
  633. const query = that.query;
  634. req.getRequest('/api/product/detail', {
  635. id: query.id
  636. }, data => {
  637. //富文本图片放大
  638. this.nodes = data.detail;
  639. that.setData({
  640. bannerUrls: data.images,
  641. pro: data,
  642. 'pro.salePrice': this.act.money,
  643. // 'pro.stock': this.act.quantity,
  644. 'pro.stock': this.act.quantity - this.act.payQuantity,
  645. 'pro.payQuantity': this.act.payQuantity,
  646. 'pro.maxBuy': this.act.maxBuy
  647. });
  648. });
  649. },
  650. loadActivity() {
  651. const query = this.query;
  652. return new Promise((resolve, reject) => {
  653. let isShowLoading = false;
  654. if (!isShowLoading) {
  655. req.loadIng('加载中');
  656. isShowLoading = true;
  657. }
  658. let from = {
  659. id: query.acid
  660. }
  661. if (!this.query.merchantId) {} else {
  662. from.merchantId = this.query.merchantId
  663. }
  664. let userInfo = req.getStorage('userInfo');
  665. if (userInfo.listShopBase && userInfo.listShopBase.length > 0) {
  666. from.shopId = userInfo.listShopBase[0].id;
  667. }
  668. req.getRequest('/api/activity/detail', from, data => {
  669. this.getMy();
  670. if (!data || data == 2001) {
  671. this.setData({
  672. activityEnd: true
  673. });
  674. return false;
  675. } else {
  676. // console.log(data);
  677. this.setData({
  678. act: data,
  679. isRemind: data.remindId,
  680. allShow: true
  681. });
  682. if (isShowLoading) {
  683. uni.hideLoading();
  684. isShowLoading = false;
  685. }
  686. this.initTimer(data);
  687. }
  688. resolve();
  689. });
  690. });
  691. },
  692. // 获取用户信息
  693. getuserInfos(data) {
  694. let userInfo = req.getStorage('userInfo');
  695. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  696. 0) {
  697. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  698. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' +
  699. userInfo.listShopBase[0].id;
  700. this.url = url;
  701. this.ascription = true;
  702. }
  703. }
  704. },
  705. getMy() {
  706. let that = this;
  707. let userInfo = req.getStorage('userInfo');
  708. if (!userInfo || userInfo == null) return false;
  709. req.getRequest('/api/user/my', {}, data => {
  710. that.isDistriUser = data.isDistriUser;
  711. });
  712. },
  713. initTimer(group) {
  714. //计时器
  715. let _ts = this;
  716. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  717. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  718. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  719. if (!group.start) endTime = startTime;
  720. let times = parseInt((endTime - nowTime) / 1000);
  721. // console.log(times / 60 / 60);
  722. this.timer = setInterval(() => {
  723. times--;
  724. if (times <= 0) {
  725. //重新加载列表
  726. _ts.setData({
  727. 'act.end': true
  728. });
  729. return false;
  730. }
  731. let n = utils.formatDayTimes(times);
  732. _ts.setData({
  733. timer: n.split(/:|天/g)
  734. });
  735. }, 1000);
  736. },
  737. loadDefaultAddress() {
  738. if (req.isAuth()) {
  739. req.g('/api/address/default', data => {
  740. if (data) {
  741. this.setData({
  742. address: data
  743. });
  744. } else {
  745. if (this.about.Many_Store == 1) this.pointLocation();
  746. }
  747. }, true);
  748. } else {
  749. if (this.about.Many_Store == 1) this.pointLocation();
  750. }
  751. },
  752. toAddress() {
  753. app.globalData.openPage('mine/address/address');
  754. },
  755. toMerchant() {
  756. if (this.about.User_Limit_Store == 1) {
  757. } else {
  758. app.globalData.openPage('merchant/nearby/nearby?isChoose=true');
  759. }
  760. },
  761. pointLocation() {
  762. //定位当前位置
  763. let _ts = this;
  764. QQMapWX.initMap(req.public.mapLBSKEY);
  765. req.getLocation(res => {
  766. QQMapWX.reverseGeocoder(res, data => {
  767. _ts.setData({
  768. 'address.address': data.address
  769. });
  770. });
  771. });
  772. },
  773. atOnceBuy() {
  774. //立即购买
  775. if (!this.act.start) return req.msg('活动还未开始');
  776. if (this.act.end) return req.msg('活动已结束');
  777. if (!this.getUpdate()) return false;
  778. this.setData({
  779. isShow: true,
  780. isCart: false,
  781. popup: {
  782. id: this.pro.id,
  783. pic: this.pro.pic,
  784. title: this.pro.title,
  785. salePrice: this.act.money,
  786. paramsId: this.pro.paramsId,
  787. stock: this.pro.stock,
  788. marketPrice: this.pro.marketPrice,
  789. skuId: this.pro.skuId
  790. }
  791. });
  792. },
  793. addCartSuccess(event) {
  794. this.setData({
  795. 'pro.count': parseInt(this.pro.count) + parseInt(event.detail.quantity),
  796. isShow: false
  797. });
  798. },
  799. addActivityRemind() {
  800. req.postRequest('/api/activity/remind', {
  801. activityId: this.act.id
  802. }, res => {
  803. // 订阅调用
  804. requsetmessage.remind();
  805. req.msg('订阅提醒成功');
  806. this.setData({
  807. isRemind: true
  808. });
  809. });
  810. },
  811. cancelActivityRemind(event) {
  812. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  813. } else {
  814. req.postRequest('/api/activity/cancel/remind', {
  815. id: this.act.id
  816. }, res => {
  817. req.msg('取消提醒成功');
  818. this.setData({
  819. isRemind: false
  820. });
  821. });
  822. }
  823. },
  824. hidePopup() {
  825. this.setData({
  826. isShow: false
  827. });
  828. },
  829. hidePopupLogin(data) {
  830. this.isPopupLogin = false;
  831. },
  832. clickCollect() {
  833. let _ts = this;
  834. req.postRequest('/api/collect', {
  835. bindId: this.pro.id,
  836. type: 1
  837. }, data => {
  838. _ts.setData({
  839. 'pro.isCollect': !_ts.pro.isCollect
  840. });
  841. });
  842. },
  843. goTop: function(e) {
  844. // 一键回到顶部
  845. if (uni.pageScrollTo) {
  846. uni.pageScrollTo({
  847. scrollTop: 0
  848. });
  849. } else {
  850. uni.showModal({
  851. title: '提示',
  852. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  853. });
  854. }
  855. },
  856. onShareTimeline() {
  857. let merchantId = '';
  858. let path = 'id=' + this.query.id + '&acid=' + this.query.acid + '&isShareTimeline=' + true + '&appId=' +
  859. req.getStorage('appId');
  860. if (!req.getStorage('userInfo').id) {} else {
  861. path += '&userId=' + req.getStorage('userInfo').id;
  862. }
  863. let shopId = '';
  864. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  865. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  866. merchantId = req.getStorage('MERCHANT').id;
  867. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  868. path += '&shopId=' + req.getStorage('smallShop').id;
  869. shopId = req.getStorage('smallShop').id;
  870. merchantId = req.getStorage('smallShop').merchantDTO.id;
  871. }
  872. }
  873. let url = '/product/groupDetail/groupDetail?' + path;
  874. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 5, this.query.acid + '_' + this
  875. .query.id);
  876. return {
  877. title: this.pro.title,
  878. query: path,
  879. imageUrl: this.pro.pic
  880. }; // return {
  881. // title: this.data.pro.title,
  882. // imageUrl: this.data.pro.pic
  883. // }
  884. },
  885. addShop() {
  886. //添加到小店
  887. req.postRequest('/api/shopProduct/save', {
  888. productId: this.query.acid,
  889. type: 2
  890. }, data => {
  891. this.act.isJoinShop = true;
  892. this.isHide = false;
  893. });
  894. },
  895. hidePop() {
  896. //添加到小店
  897. this.setData({
  898. isHide: true
  899. });
  900. },
  901. showTab: function(e) {
  902. this.setData({
  903. tabIndex: e.detail
  904. });
  905. },
  906. scoreTab: function(e) {
  907. this.form.page = 0;
  908. this.setData({
  909. current: e.detail,
  910. ['form.page']: 1
  911. });
  912. },
  913. freshenFun: function(e) {
  914. this.setData({
  915. freshen: e.detail
  916. });
  917. },
  918. getPor: function(e) {
  919. // console.log(e.detail, "qqqqq")
  920. this.popup = e.detail
  921. this.act.id = e.detail.actId
  922. },
  923. // 获取品种保证
  924. getGuarantee() {
  925. return new Promise((data, rej) => {
  926. req.getRequest('/api/config', {}, res => {
  927. req.setStorage('configRes', JSON.stringify(res))
  928. this.about = res
  929. data(res)
  930. if (this.merchant && this.merchant.isDefault == 1) {
  931. // 切割;拿到数组,然后在过滤掉空值
  932. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  933. this.setData({
  934. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  935. return it = it && it.trim();
  936. })
  937. });
  938. }
  939. } else {
  940. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  941. this.setData({
  942. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  943. return it = it && it.trim();
  944. })
  945. });
  946. }
  947. } // if(res.Is_Store_Price_Stock){
  948. // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
  949. // }
  950. if (res.is_open_shop) {
  951. this.is_open_shop = res.is_open_shop;
  952. }
  953. if (res.is_open_comments) {
  954. this.setData({
  955. is_open_comments: res.is_open_comments
  956. });
  957. } // 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 })
  958. });
  959. })
  960. },
  961. getUpdate() {
  962. let userInfos = req.getStorage('userInfo');
  963. if (!userInfos.mobile) {
  964. console.log('没有手机号')
  965. this.isShowUpdate = true;
  966. this.isUpdateMobile = true;
  967. req.setStorage('isShowUpdateMobile', true)
  968. return false;
  969. }
  970. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf(
  971. '用户') > -1) {
  972. console.log('没有昵称')
  973. this.isShowUpdate = true;
  974. this.isUpdateInfo = true;
  975. req.setStorage('isShowUpdateInfo', true)
  976. return false;
  977. }
  978. return true;
  979. },
  980. closeUpdate() {
  981. this.isShowUpdate = false
  982. this.isUpdateInfo = false;
  983. this.isUpdateMobile = false;
  984. },
  985. jumpCart(url) {
  986. if (req.getStorage('cartTab')) {
  987. app.globalData.reLaunchTo(url);
  988. } else {
  989. app.globalData.openPage(url)
  990. }
  991. }
  992. }
  993. };
  994. </script>
  995. <style>
  996. @import "./groupDetail.css";
  997. </style>