seckillDetails.vue 31 KB

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