seckillDetails.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  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="picUrlss+'msbg.png'" class="ptbg" v-if="act.start"></image>
  34. <image :src="picUrlss+'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="picUrlss+'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="picUrlss+'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="picUrlss+'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. <button open-type="contact" class="botbtn">
  166. <image src="/static/pages/images/kfico.png"></image>在线客服
  167. </button>
  168. <view class="botbtn" @tap="jumpCart('pages/cart/cart')">
  169. <image src="/static/pages/images/gwc.png"></image>购物车<text class="message"
  170. v-if="pro.count > 0">{{pro.count}}</text>
  171. </view>
  172. <block v-if="!activityEnd">
  173. <block v-if="act.start">
  174. <!-- <view class="addcart flot" bindtap="addShopCart">加入购物车</view> -->
  175. <view :class="['addcart',act.start? '' : 'gray']" @tap="act.start ? addShopCart() : ''">加入购物车
  176. </view>
  177. <view class="gmbtn mbglinear flot" @tap="atOnceBuy">{{pro.isOtc==1 ?'预约下单': '立即购买'}}</view>
  178. </block>
  179. <!--
  180. <view class="addcart {{pro.state == 1 ? '' : 'gray'}}" bindtap="addShopCart">加入购物车</view>
  181. <view class="gmbtn mbglinear" bindtap="atOnceBuy" wx:if="{{act.start}}">立即购买</view> -->
  182. <view v-else>
  183. <!-- <view class="addcart flot" bindtap="addShopCart">加入购物车</view> -->
  184. <view class="gmbtn1 flot" @tap="cancelActivityRemind" v-if="isRemind">
  185. <icon class="ico">
  186. <image src="/activity/static/activity/images/rednaozhong.png" class="background"></image>
  187. </icon>
  188. <text class="txt">取消提醒</text>
  189. </view>
  190. <view class="gmbtnyuyue mbggreen flot" @tap="addActivityRemind" v-else>
  191. <icon class="ico">
  192. <image src="/activity/static/activity/images/clock2.png" class="background"></image>
  193. </icon>
  194. <text class="txt">预约提醒</text>
  195. </view>
  196. </view>
  197. </block>
  198. <block v-else>
  199. <view class="gmbtnyuyue mbggray">活动不存在</view>
  200. </block>
  201. </view>
  202. <!-- 商品规格 -->
  203. <block v-if="isShow">
  204. <product-popup :product="popup" :activityId="act.id" :is-cart="isCart" @hidePopup="hidePopup"
  205. @add-cart-success="addCartSuccess" :order-type="orderType" :merchant="merchant" :actId="act.actId"
  206. :merchant-id="query.merchantId" :shop-id="query.shopId" @getPor="getPor"></product-popup>
  207. </block>
  208. <view class="contact_index" @tap="goTop">
  209. <image src="/static/pages/images/backtop.png"></image>顶部
  210. </view>
  211. <!-- 添加到小店成功 -->
  212. <view class="mask" :hidden="isHide" @tap="hidePop"></view>
  213. <view class="suc" :hidden="isHide">
  214. <image :src="picUrlss + 'tjcg1.png'" class="tjcg1"></image>
  215. <image :src="picUrlss+'tjcg.png'" class="tjcg"></image>
  216. <text>快去我的小店看看吧</text>
  217. <view class="shopcc dflex">
  218. <view class="shop" @tap="showShare">分享推广</view>
  219. <navigator :url="url" hover-class="none" class="shop" >我的小店</navigator>
  220. </view>
  221. <!-- <view class="share-btn dflex">
  222. <button class="wxfriend dflex" open-type="share">
  223. <image src="/static/pages/images/wechat.png"></image>
  224. 微信好友
  225. </button>
  226. <view class="wxposter dflex" @tap="generatePoster">
  227. <image src="/static/pages/images/poster.png"></image>
  228. 生成海报
  229. </view>
  230. </view> -->
  231. <image src="/static/pages/images/close2.png" class="suc-close" @tap="hidePop"></image>
  232. </view>
  233. <block v-if="isPopupLogin">
  234. <product-login :about="about" @hidePopupLogin="hidePopupLogin"></product-login>
  235. </block>
  236. <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate"></update-userinfo>
  237. <privacy :is-update="true" @getLocations="initLocation"></privacy>
  238. <!-- #ifdef H5 -->
  239. <wx-share ref="wxshare" />
  240. <!-- #endif -->
  241. </view>
  242. </template>
  243. <script>
  244. const app = getApp();
  245. const req = require("../../utils/request.js");
  246. const utils = require("../../utils/util.js");
  247. var QQMapWX = require("../../utils/qqmap.js");
  248. const requsetmessage = require("../../utils/requestmessage.js");
  249. const route = require("../../utils/route");
  250. const api = require("../../utils/api");
  251. import productPopup from "../../components/product-popup/index";
  252. import vShare from "../../components/share/share";
  253. import productLogin from "../../components/product-login/index";
  254. export default {
  255. data() {
  256. return {
  257. picUrlss: req.public.picUrls,
  258. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  259. swiperCurrent: 0,
  260. bannerUrls: [],
  261. isShow: false,
  262. pro: {},
  263. timer: [],
  264. orderType: '',
  265. isRemind: false,
  266. hideShare: true,
  267. isCart: false,
  268. codeUrl: '',
  269. hideShop: true,
  270. //隐藏添加到小店
  271. isHide: true,
  272. //添加小店成功弹窗
  273. url: '/mine/shop/shop?userId=' + req.getStorage('userInfo').id,
  274. contentList: [{
  275. pic: "/static/pages/images/bar.png",
  276. name: '好风依旧',
  277. time: '4秒前'
  278. }, {
  279. pic: "/static/pages/images/bar.png",
  280. name: '杨鑫',
  281. time: '20秒前'
  282. }, {
  283. pic: "/static/pages/images/bar.png",
  284. name: '杨鑫',
  285. time: '5秒前'
  286. }],
  287. isNotice: false,
  288. form: {
  289. page: 1,
  290. limit: 10
  291. },
  292. freshen: true //是否更新页面
  293. ,
  294. current: "",
  295. query: "",
  296. merchant: "",
  297. merchantId: "",
  298. shopId: "",
  299. imgs: "",
  300. activityEnd: false,
  301. act: "",
  302. address: {},
  303. popup: {},
  304. params: "",
  305. tabIndex: "",
  306. guarantee: "",
  307. is_open_comments: "",
  308. nodes: "",
  309. switch: true,
  310. about: {},
  311. allShow: false,
  312. url:'',
  313. is_open_shop: '',//商户是否开启分销
  314. ascription: false,//是否开启小店
  315. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  316. isPopupLogin: false,
  317. isShowUpdate: false,//是否显示更新信息弹窗
  318. isUpdateInfo: false,//更新用户信息
  319. isUpdateMobile: false,//绑定手机号
  320. };
  321. },
  322. components: {
  323. productPopup,
  324. vShare,
  325. productLogin
  326. },
  327. props: {},
  328. onLoad: async function(options) {
  329. console.log('秒杀详情==' + JSON.stringify(options));
  330. if(options.appId) req.setStorage('appId',options.appId);
  331. this.query = options;
  332. this.setData({
  333. query: options
  334. });
  335. if (options.scene) {
  336. this.scene = options.scene;
  337. }
  338. if (options.isShare) {
  339. this.query.id = options.id;
  340. this.query.acid = options.acid;
  341. req.setStorage('pidCode', options.userId);
  342. let params = {
  343. userId: options.userId,
  344. merchantId: options.merchantId ? options.merchantId : '',
  345. }
  346. await this.bindUser(params);
  347. }else{
  348. await req.silenceLogin();
  349. }
  350. if (options.hideShop) {
  351. // console.log(options.hideShop);
  352. this.setData({
  353. hideShop: false
  354. });
  355. }
  356. // console.log(this.hideShop);
  357. // console.log(options);
  358. setInterval(() => {
  359. this.setData({
  360. isNotice: true
  361. });
  362. }, 10000); // this.isShop()
  363. },
  364. onShow: async function() {
  365. console.log("7899")
  366. let that = this
  367. if (this.freshen) {
  368. console.log("rty")
  369. if (that.scene) {
  370. await this.loadCodeParams();
  371. }
  372. if(that.scene){
  373. await that.bindUser(that.query);
  374. }
  375. // this.getMerchant();
  376. this.getGuarantee().then(data => {
  377. // console.log(data)
  378. if (this.switch) {
  379. that.getMerchant();
  380. }
  381. })
  382. await this.browsRecound(this.query.id);
  383. }
  384. },
  385. onUnload() {
  386. if (this.timer) clearInterval(this.timer);
  387. },
  388. onShareAppMessage: function() {
  389. return this.onShareMessage();
  390. },
  391. onUnload: function() {},
  392. onReachBottom() {
  393. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  394. this.form.page++;
  395. this.setData({
  396. ['form.page']: this.form.page
  397. });
  398. // this.selectComponent("#list").loadScore(this.current);
  399. this.$refs.list.loadScore(this.current);
  400. }
  401. },
  402. onReady() {
  403. // #ifdef H5
  404. var that = this;
  405. //初始化分享内容
  406. setTimeout(function() {
  407. var shareContent = that.onShareMessage();
  408. if (shareContent) {
  409. shareContent.path = window.location.origin + shareContent.path;
  410. }
  411. console.log('分享内容》》》》》', shareContent);
  412. that.$refs.wxshare.init(shareContent);
  413. }, 4 * 1000);
  414. // #endif
  415. },
  416. methods: {
  417. initLocation(){
  418. this.getMerchant();
  419. },
  420. onShareMessage(){
  421. let merchantId = '';
  422. let path = '';
  423. let isSolution = '';
  424. // #ifndef H5
  425. isSolution = req.env[req.env.NODE_ENV].isSolution;
  426. // #endif
  427. // #ifdef H5
  428. isSolution = false;
  429. // #endif
  430. let userInfo = req.getStorage('userInfo');
  431. let shopId = '';
  432. if(isSolution){
  433. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  434. }else{
  435. path = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query.acid +
  436. '&isShare=' + true+ '&appId=' + req.getStorage('appId');
  437. // console.log(!req.getStorage('userInfo').id);
  438. if (!userInfo.id) {} else {
  439. path += '&userId=' + userInfo.id;
  440. }
  441. // console.log(this.query.merchantId);
  442. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  443. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  444. merchantId = req.getStorage('MERCHANT').id;
  445. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  446. path += '&shopId=' + req.getStorage('smallShop').id;
  447. shopId = req.getStorage('smallShop').id;
  448. merchantId = req.getStorage('smallShop').merchantDTO.id;
  449. }
  450. }
  451. }
  452. // console.log(path)
  453. route.share(1, userInfo.id, path, merchantId, shopId, 6, this.query.acid + '_' + this.query.id);
  454. return {
  455. title: this.pro.title,
  456. imageUrl: this.pro.pic,
  457. path: path
  458. };
  459. },
  460. getMerchant(){
  461. let that = this;
  462. api.getMerchant(this.query, req, data => {
  463. that.loadDefaultAddress();
  464. if (data == 1) {
  465. if(that.about.Many_Store == 1) api.locationShow()
  466. else{
  467. that.getuserInfos(data);
  468. if(req.getStorage('defaultMerchant')) {
  469. that.merchant = req.getStorage('defaultMerchant');
  470. that.query.merchantId = that.merchant.id
  471. }else{
  472. api.defaultMerchant(req, that.query, defaultRes=>{
  473. that.merchant = defaultRes;
  474. that.query.merchantId = defaultRes.id
  475. });
  476. }
  477. that.loadProudct(that.query);
  478. }
  479. } else {
  480. that.getuserInfos(data);
  481. if (data.type == 5) {
  482. that.query.merchantId = data.merchantDTO.id
  483. that.query.shopId = data.id
  484. } else {
  485. that.query.merchantId = data.id
  486. }
  487. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  488. this.loadProudct();
  489. let pages = getCurrentPages();
  490. var prevPage = pages[pages.length - 2];
  491. if (prevPage) {
  492. prevPage.$vm.setData({
  493. freshen: true
  494. });
  495. }
  496. } else {
  497. this.loadProudct();
  498. }
  499. that.merchant = data
  500. }
  501. })
  502. },
  503. bindUser(par){
  504. let userInfo = req.getStorage('userInfo');
  505. if(!userInfo){
  506. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  507. // uni.login({
  508. // success(res) {
  509. // let params = {
  510. // code: res.code,
  511. // parentId: par.userId,
  512. // merchantId: par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
  513. // }
  514. // return new Promise((resolve,reject)=>{
  515. // req.postRequest('/api/v2/login', params, data => {
  516. // resolve();
  517. // });
  518. // })
  519. // }
  520. // });
  521. // this.isPopupLogin = true;
  522. }
  523. },
  524. click(e) {
  525. // console.log(e)
  526. this.hideShare = e
  527. },
  528. showShare() {
  529. // #ifndef H5
  530. req.isLogin().then(success => {
  531. if (success) {
  532. this.getCodeUrl()
  533. this.setData({
  534. hideShare: false
  535. });
  536. }
  537. });
  538. // #endif
  539. },
  540. /**
  541. * 轮播切换
  542. */
  543. swiperChange({
  544. detail
  545. }) {
  546. if (this.current == 0 && this.swiperCurrent > 1) {
  547. //卡死时,重置current为正确索引
  548. this.setData({
  549. current: this.swiperCurrent
  550. });
  551. } else {
  552. //正常轮转时,记录正确页码索引
  553. this.setData({
  554. swiperCurrent: detail.current
  555. });
  556. }
  557. },
  558. dotEvent(e) {
  559. this.setData({
  560. current: e.currentTarget.dataset.current
  561. });
  562. },
  563. browsRecound(id) {
  564. let from = {
  565. bindId: id,
  566. type: 6,
  567. page: '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query.acid
  568. };
  569. if (this.query.isShare) {
  570. from.shareType = 1;
  571. from.page = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query
  572. .acid + '&isShare=' + true;
  573. if (!this.query.userId) {} else {
  574. from.page += '&userId=' + this.query.userId;
  575. }
  576. if (!this.query.merchantId) {} else {
  577. from.merchantId = this.query.merchantId;
  578. }
  579. if (!this.query.shopId) {} else {
  580. from.shopId = this.query.shopId;
  581. }
  582. if (!this.query.userId) {} else {
  583. from.uid = this.query.userId;
  584. }
  585. }
  586. if (this.query.isShareTimeline) {
  587. from.shareType = 2;
  588. from.page = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query
  589. .acid + '&isShareTimeline=' + true;
  590. if (!this.query.userId) {} else {
  591. from.page += '&userId=' + this.query.userId;
  592. }
  593. if (!this.query.merchantId) {} else {
  594. from.merchantId = this.query.merchantId;
  595. }
  596. if (!this.query.shopId) {} else {
  597. from.shopId = this.query.shopId;
  598. }
  599. if (!this.query.userId) {} else {
  600. from.uid = this.query.userId;
  601. }
  602. }
  603. return new Promise((reject,resolve)=>{
  604. req.postRequest('/api/browse', from, data => {resolve()});
  605. })
  606. },
  607. loadCodeParams() {
  608. let _ts = this;
  609. return new Promise((resolve, reject) => {
  610. if (!_ts.scene) {
  611. resolve();
  612. return false;
  613. }
  614. req.getRequest('/api/code/params', {
  615. scene: _ts.scene
  616. }, data => {
  617. if (data) {
  618. let res = data.scene.split('_');
  619. res.map(it=>{
  620. if(it.indexOf('poid')>-1){
  621. _ts.query.id = it.split('=')[1]
  622. }
  623. if(it.indexOf('acid')>-1){
  624. _ts.query.acid = it.split('=')[1]
  625. }
  626. if(it.indexOf('mid')>-1){
  627. _ts.query.merchantId = it.split('=')[1]
  628. }
  629. if(it.indexOf('sid')>-1){
  630. _ts.query.shopId = it.split('=')[1]
  631. }
  632. })
  633. _ts.query.userId = data.userId;
  634. req.setStorage('pidCode', data.userId);
  635. req.setStorage('appId',res[res.length-1]);
  636. }
  637. resolve();
  638. });
  639. });
  640. },
  641. getCodeUrl() {
  642. let that = this; //获取小程序码
  643. const query = this.query;
  644. let scene = 'poid='+that.pro.id + '_acid=' + query.acid;
  645. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  646. scene += '_mid=' + req.getStorage('MERCHANT').id;
  647. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  648. scene += '_sid=' + req.getStorage('smallShop').id;
  649. }
  650. }
  651. if(req.getStorage('appId')) scene += '_'+ req.getStorage('appId');
  652. // console.log(scene); //获取小程序码
  653. const params = {
  654. page: 'activity/seckillDetails/seckillDetails',
  655. scene: scene
  656. };
  657. // console.log('ma--', params);
  658. req.getRequest('/api/program/codev', params, url => {
  659. that.setData({
  660. codeUrl: url
  661. });
  662. });
  663. },
  664. async loadProudct() {
  665. let that = this;
  666. await that.loadActivity();
  667. const query = that.query;
  668. let isShowLoading = false;
  669. if (!isShowLoading) {
  670. req.loadIng('加载中');
  671. isShowLoading = true;
  672. }
  673. req.getRequest('/api/product/detail', {
  674. id: query.id
  675. }, data => {
  676. //富文本图片放大
  677. that.nodes = data.detail;
  678. let propertiesList = []
  679. if (data.propertiesList && data.propertiesList.length > 0) {
  680. data.propertiesList.map(it => {
  681. propertiesList.push(it.value);
  682. })
  683. }
  684. data.properties = propertiesList.join(' / ')
  685. that.setData({
  686. bannerUrls: data.images,
  687. pro: data,
  688. 'pro.salePrice': this.act.money,
  689. // 'pro.stock': this.act.quantity,
  690. 'pro.stock': this.act.quantity - this.act.payQuantity,
  691. 'pro.payQuantity': this.act.payQuantity,
  692. 'pro.maxBuy': this.act.maxBuy,
  693. allShow: true
  694. });
  695. if (isShowLoading) {
  696. uni.hideLoading();
  697. isShowLoading = false;
  698. // this.freshen = false
  699. }
  700. // console.log(this.pro);
  701. // that.getCodeUrl();
  702. });
  703. },
  704. loadActivity() {
  705. const query = this.query;
  706. return new Promise((resolve, reject) => {
  707. let from = {
  708. id: query.acid
  709. }
  710. // console.log(this.query.merchantId)
  711. if (this.query.merchantId) {
  712. from.merchantId = this.query.merchantId
  713. }
  714. let userInfo = req.getStorage('userInfo');
  715. if(userInfo.listShopBase && userInfo.listShopBase.length >0 ){
  716. from.shopId = userInfo.listShopBase[0].id;
  717. }
  718. req.getRequest('/api/activity/detail', from, data => {
  719. // console.log(data);
  720. this.getMy();
  721. if (data.type == 1) {
  722. this.setData({
  723. orderType: 2
  724. });
  725. }
  726. if (data.type == 2) {
  727. this.setData({
  728. orderType: 3
  729. });
  730. }
  731. if (data.type == 4) {
  732. this.setData({
  733. orderType: 6
  734. });
  735. }
  736. if (data.type == 5) {
  737. this.setData({
  738. orderType: 7
  739. });
  740. }
  741. if (!data || data == 2001) {
  742. this.setData({
  743. activityEnd: true
  744. });
  745. return false;
  746. } else {
  747. this.setData({
  748. act: data,
  749. isRemind: data.remindId
  750. });
  751. this.initTimer(data);
  752. }
  753. resolve();
  754. });
  755. });
  756. },
  757. // 获取用户信息
  758. getuserInfos(data) {
  759. let userInfo = req.getStorage('userInfo');
  760. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  761. 0) {
  762. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  763. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' + userInfo.listShopBase[0].id;
  764. this.url = url;
  765. this.ascription = true;
  766. }
  767. }
  768. },
  769. getMy() {
  770. let that = this;
  771. let userInfo = req.getStorage('userInfo');
  772. if(!userInfo || userInfo == null) return false;
  773. req.getRequest('/api/user/my', {}, data => {
  774. that.isDistriUser = data.isDistriUser;
  775. });
  776. },
  777. initTimer(group) {
  778. //计时器
  779. let _ts = this;
  780. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  781. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  782. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  783. if (!group.start) endTime = startTime;
  784. let times = parseInt((endTime - nowTime) / 1000);
  785. // console.log(times / 60 / 60);
  786. this.timer = setInterval(() => {
  787. times--;
  788. if (times <= 0) {
  789. //重新加载列表
  790. _ts.setData({
  791. 'act.end': true
  792. });
  793. return false;
  794. }
  795. let n = utils.formatDayTimes(times);
  796. _ts.setData({
  797. timer: n.split(/:|天/g)
  798. });
  799. }, 1000);
  800. },
  801. loadDefaultAddress() {
  802. if (req.isAuth()) {
  803. req.g('/api/address/default', data => {
  804. if (data) this.setData({
  805. address: data
  806. });
  807. else if(this.about.Many_Store == 1) this.pointLocation();
  808. }, true);
  809. } else {
  810. if(this.about.Many_Store == 1) this.pointLocation();
  811. }
  812. },
  813. toAddress() {
  814. app.globalData.openPage('mine/address/address');
  815. },
  816. toMerchant() {
  817. if (this.about.User_Limit_Store == 1) {
  818. } else {
  819. app.globalData.openPage('merchant/nearby/nearby?isChoose=true');
  820. }
  821. },
  822. toactive() {
  823. app.globalData.openPage('merchant/nearby/nearby');
  824. },
  825. pointLocation() {
  826. //定位当前位置
  827. let _ts = this;
  828. QQMapWX.initMap(req.public.mapLBSKEY);
  829. req.getLocation(res => {
  830. QQMapWX.reverseGeocoder(res, data => {
  831. _ts.setData({
  832. ['address.address']: data.address
  833. });
  834. });
  835. });
  836. },
  837. addShopCart() {
  838. // 加入购物车
  839. if (!this.act.start) return req.msg('活动还未开始');
  840. if (this.act.payQuantity >= this.act.quantity) return req.msg('活动产品已售罄');
  841. if (this.act.end) return req.msg('活动已结束');
  842. if(!this.getUpdate()) return false;
  843. this.setData({
  844. isShow: true,
  845. isCart: true,
  846. popup: {
  847. id: this.pro.id,
  848. pic: this.pro.pic,
  849. title: this.pro.title,
  850. salePrice: this.act.money,
  851. stock: this.pro.stock,
  852. paramsId: this.pro.paramsId,
  853. marketPrice: this.pro.marketPrice,
  854. skuId: this.pro.skuId
  855. }
  856. });
  857. },
  858. atOnceBuy() {
  859. //立即购买
  860. if (!this.act.start) return req.msg('活动还未开始');
  861. if (this.act.payQuantity >= this.act.quantity) return req.msg('活动产品已售罄');
  862. if (this.act.end) return req.msg('活动已结束');
  863. if(!this.getUpdate()) return false;
  864. // this.setData({ isShow: true, isCart: false, popup: this.data.product });
  865. this.setData({
  866. isShow: true,
  867. isCart: false,
  868. popup: {
  869. id: this.pro.id,
  870. pic: this.pro.pic,
  871. title: this.pro.title,
  872. salePrice: this.act.money,
  873. stock: this.pro.stock,
  874. paramsId: this.pro.paramsId,
  875. marketPrice: this.pro.marketPrice,
  876. skuId: this.pro.skuId
  877. }
  878. });
  879. },
  880. addActivityRemind() {
  881. // 订阅调用
  882. req.postRequest('/api/activity/remind', {
  883. activityId: this.act.id
  884. }, res => {
  885. requsetmessage.remind();
  886. req.msg('预约成功');
  887. this.setData({
  888. isRemind: true
  889. });
  890. });
  891. },
  892. addCartSuccess(event) {
  893. this.setData({
  894. 'pro.count': parseInt(this.pro.count) + parseInt(event.detail.quantity),
  895. isShow: false
  896. });
  897. },
  898. cancelActivityRemind(event) {
  899. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  900. } else {
  901. req.postRequest('/api/activity/cancel/remind', {
  902. id: this.act.id
  903. }, res => {
  904. req.msg('取消预约成功');
  905. this.setData({
  906. isRemind: false
  907. });
  908. });
  909. }
  910. },
  911. hidePopup() {
  912. this.setData({
  913. isShow: false
  914. });
  915. },
  916. hidePopupLogin(data) {
  917. this.isPopupLogin = false;
  918. },
  919. clickCollect() {
  920. let _ts = this;
  921. req.postRequest('/api/collect', {
  922. bindId: this.pro.id,
  923. type: 1
  924. }, data => {
  925. _ts.setData({
  926. 'pro.isCollect': !_ts.pro.isCollect
  927. });
  928. });
  929. },
  930. goTop: function(e) {
  931. // 一键回到顶部
  932. if (uni.pageScrollTo) {
  933. uni.pageScrollTo({
  934. scrollTop: 0
  935. });
  936. } else {
  937. uni.showModal({
  938. title: '提示',
  939. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  940. });
  941. }
  942. },
  943. getPor: function(e) {
  944. // console.log(e.detail, "qqqqq")
  945. this.popup = e.detail
  946. this.act.id = e.detail.actId
  947. },
  948. onShareTimeline() {
  949. let merchantId = '';
  950. let path = 'id=' + this.query.id + '&acid=' + this.query.acid + '&isShareTimeline=' + true+'&appId='+req.getStorage('appId');
  951. if (!req.getStorage('userInfo').id) {} else {
  952. path += '&userId=' + req.getStorage('userInfo').id;
  953. }
  954. // console.log(this.merchantId);
  955. let shopId = '';
  956. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  957. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  958. merchantId = req.getStorage('MERCHANT').id;
  959. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  960. path += '&shopId=' + req.getStorage('smallShop').id;
  961. shopId = req.getStorage('smallShop').id;
  962. merchantId = req.getStorage('smallShop').merchantDTO.id;
  963. }
  964. }
  965. let url = '/activity/seckillDetails/seckillDetails?' + path;
  966. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 6, this.query.acid + '_' + this
  967. .query.id);
  968. return {
  969. title: this.pro.title,
  970. query: path,
  971. imageUrl: this.pro.pic
  972. };
  973. },
  974. showTab: function(e) {
  975. this.setData({
  976. tabIndex: e.detail
  977. });
  978. },
  979. scoreTab: function(e) {
  980. this.form.page = 0;
  981. this.setData({
  982. current: e.detail,
  983. ['form.page']: 1
  984. });
  985. },
  986. freshenFun: function(e) {
  987. this.setData({
  988. freshen: e.detail
  989. });
  990. },
  991. // 获取品种保证
  992. getGuarantee() {
  993. return new Promise((data, rej) => {
  994. req.getRequest('/api/config', {}, res => {
  995. req.setStorage("configRes", JSON.stringify(res))
  996. this.about = res
  997. data(res)
  998. if (this.merchant && this.merchant.isDefault == 1 || this.query.acid) {
  999. // 切割;拿到数组,然后在过滤掉空值
  1000. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  1001. this.setData({
  1002. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  1003. return it = it && it.trim();
  1004. })
  1005. });
  1006. }
  1007. } else {
  1008. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  1009. this.setData({
  1010. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  1011. return it = it && it.trim();
  1012. })
  1013. });
  1014. }
  1015. } // if(res.Is_Store_Price_Stock){
  1016. // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
  1017. // }
  1018. if (res.is_open_shop) {
  1019. this.is_open_shop = res.is_open_shop;
  1020. }
  1021. if (res.is_open_comments) {
  1022. this.setData({
  1023. is_open_comments: res.is_open_comments
  1024. });
  1025. } // 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 })
  1026. });
  1027. })
  1028. },
  1029. // 是否开启小店
  1030. isShop() {
  1031. if (req.getStorage('distribution')) {
  1032. dist = req.getStorage('distribution')
  1033. this.setData({
  1034. distr: dist
  1035. })
  1036. console.log(dist)
  1037. if (dist.distributionSmallShopOpen == 1) {
  1038. req.postRequest('/api/shopBase/isOpenShop', {}, data => {
  1039. this.setData({
  1040. isshop: data
  1041. })
  1042. console.log(data)
  1043. })
  1044. }
  1045. }
  1046. },
  1047. addShop() { //添加到小店
  1048. req.postRequest('/api/shopProduct/save', {
  1049. productId: this.act.id,
  1050. type: 3
  1051. }, data => {
  1052. this.act.isJoinShop = true;
  1053. this.isHide = false;
  1054. })
  1055. },
  1056. hidePop() { //添加到小店
  1057. this.setData({
  1058. isHide: true
  1059. })
  1060. },
  1061. getUpdate() {
  1062. let userInfos = req.getStorage('userInfo');
  1063. if(!userInfos.mobile){
  1064. console.log('没有手机号')
  1065. this.isShowUpdate = true;
  1066. this.isUpdateMobile = true;
  1067. req.setStorage('isShowUpdateMobile',true)
  1068. return false;
  1069. }
  1070. if (!userInfos.avatar || userInfos.avatar.indexOf('thirdwx.qlogo') > -1 || userInfos.nickName.indexOf('用户') > -1 ) {
  1071. console.log('没有昵称')
  1072. this.isShowUpdate = true;
  1073. this.isUpdateInfo = true;
  1074. req.setStorage('isShowUpdateInfo',true)
  1075. return false;
  1076. }
  1077. return true;
  1078. },
  1079. closeUpdate(){
  1080. this.isShowUpdate = false
  1081. this.isUpdateInfo = false;
  1082. this.isUpdateMobile = false;
  1083. },
  1084. jumpCart(url){
  1085. if(req.getStorage('cartTab')){
  1086. app.globalData.reLaunchTo(url);
  1087. }else{
  1088. app.globalData.openPage(url)
  1089. }
  1090. }
  1091. }
  1092. };
  1093. </script>
  1094. <style>
  1095. @import "./seckillDetails.css";
  1096. </style>