seckillDetails.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  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="/static/pages/images/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. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  252. swiperCurrent: 0,
  253. bannerUrls: [],
  254. isShow: false,
  255. pro: {},
  256. timer: [],
  257. orderType: '',
  258. isRemind: false,
  259. hideShare: true,
  260. isCart: false,
  261. codeUrl: '',
  262. hideShop: true,
  263. //隐藏添加到小店
  264. isHide: true,
  265. //添加小店成功弹窗
  266. url: '/mine/shop/shop?userId=' + req.getStorage('userInfo').id,
  267. contentList: [{
  268. pic: "/static/pages/images/bar.png",
  269. name: '好风依旧',
  270. time: '4秒前'
  271. }, {
  272. pic: "/static/pages/images/bar.png",
  273. name: '杨鑫',
  274. time: '20秒前'
  275. }, {
  276. pic: "/static/pages/images/bar.png",
  277. name: '杨鑫',
  278. time: '5秒前'
  279. }],
  280. isNotice: false,
  281. form: {
  282. page: 1,
  283. limit: 10
  284. },
  285. freshen: true //是否更新页面
  286. ,
  287. current: "",
  288. query: "",
  289. merchant: "",
  290. merchantId: "",
  291. shopId: "",
  292. imgs: "",
  293. activityEnd: false,
  294. act: "",
  295. address: {},
  296. popup: {},
  297. params: "",
  298. tabIndex: "",
  299. guarantee: "",
  300. is_open_comments: "",
  301. nodes: "",
  302. switch: true,
  303. about: {},
  304. allShow: false,
  305. url:'',
  306. is_open_shop: '',//商户是否开启分销
  307. ascription: false,//是否开启小店
  308. isDistriUser: 0, // 判断用户是否是分销员 2为分销员
  309. isPopupLogin: false
  310. };
  311. },
  312. components: {
  313. productFooter,
  314. productPopup,
  315. vShare,
  316. productLogin
  317. },
  318. props: {},
  319. onLoad: function(options) {
  320. console.log('秒杀详情==' + JSON.stringify(options));
  321. this.query = options;
  322. this.setData({
  323. query: options
  324. });
  325. if (options.scene) {
  326. this.scene = options.scene;
  327. }
  328. if (options.isShare) {
  329. this.query.id = options.id;
  330. this.query.acid = options.acid;
  331. req.setStorage('pidCode', options.userId);
  332. let params = {
  333. userId: options.userId,
  334. merchantId: options.merchantId ? options.merchantId : '',
  335. }
  336. this.bindUser(params);
  337. }
  338. if (options.hideShop) {
  339. // console.log(options.hideShop);
  340. this.setData({
  341. hideShop: false
  342. });
  343. }
  344. // console.log(this.hideShop);
  345. // console.log(options);
  346. setInterval(() => {
  347. this.setData({
  348. isNotice: true
  349. });
  350. }, 10000); // this.isShop()
  351. },
  352. onShow: async function() {
  353. console.log("7899")
  354. let that = this
  355. if (this.freshen) {
  356. console.log("rty")
  357. if (that.scene) {
  358. await this.loadCodeParams();
  359. }
  360. if(that.scene){
  361. await that.bindUser(that.query);
  362. }
  363. // this.getMerchant();
  364. this.getGuarantee().then(data => {
  365. // console.log(data)
  366. if (this.switch) {
  367. api.getMerchant(this.query, req, data => {
  368. // console.log(data)
  369. that.loadDefaultAddress();
  370. if (data == 1) {
  371. api.locationShow()
  372. } else {
  373. that.getuserInfos(data);
  374. if (data.type == 5) {
  375. that.query.merchantId = data.merchantDTO.id
  376. that.query.shopId = data.id
  377. } else {
  378. that.query.merchantId = data.id
  379. }
  380. if (req.getStorage('userInfo') && that.merchant.id != data.id) {
  381. console.log(1, that.merchant, data)
  382. let pages = getCurrentPages();
  383. var prevPage = pages[pages.length - 2];
  384. if (prevPage) {
  385. prevPage.$vm.setData({
  386. freshen: true
  387. });
  388. }
  389. } else {
  390. console.log(2, this.freshen, this.switch)
  391. // this.loadProudct();
  392. }
  393. this.loadProudct();
  394. that.merchant = data
  395. }
  396. })
  397. }
  398. })
  399. await this.browsRecound(this.query.id);
  400. }
  401. },
  402. onUnload() {
  403. if (this.timer) clearInterval(this.timer);
  404. },
  405. onShareAppMessage: function() {
  406. let merchantId = '';
  407. let path = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query.acid +
  408. '&isShare=' + true;
  409. // console.log(!req.getStorage('userInfo').id);
  410. if (!req.getStorage('userInfo').id) {} else {
  411. path += '&userId=' + req.getStorage('userInfo').id;
  412. }
  413. // console.log(this.query.merchantId);
  414. let shopId = '';
  415. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  416. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  417. merchantId = req.getStorage('MERCHANT').id;
  418. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  419. path += '&shopId=' + req.getStorage('smallShop').id;
  420. shopId = req.getStorage('smallShop').id;
  421. merchantId = req.getStorage('smallShop').merchantDTO.id;
  422. }
  423. }
  424. // console.log(path)
  425. route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 6, this.query.acid + '_' + this
  426. .query.id);
  427. return {
  428. title: this.pro.title,
  429. imageUrl: this.pro.pic,
  430. path: path
  431. };
  432. },
  433. onUnload: function() {},
  434. onReachBottom() {
  435. if (this.is_open_comments == 1 && this.tabIndex == 2) {
  436. this.form.page++;
  437. this.setData({
  438. ['form.page']: this.form.page
  439. });
  440. // this.selectComponent("#list").loadScore(this.current);
  441. this.$refs.list.loadScore(this.current);
  442. }
  443. },
  444. methods: {
  445. bindUser(par){
  446. let userInfo = req.getStorage('userInfo');
  447. if(!userInfo){
  448. // uni.login({
  449. // success(res) {
  450. // let params = {
  451. // code: res.code,
  452. // parentId: par.userId,
  453. // merchantId: par.merchantId ? par.merchantId : par.shopId ? par.shopId : ''
  454. // }
  455. // return new Promise((resolve,reject)=>{
  456. // req.postRequest('/api/v2/login', params, data => {
  457. // resolve();
  458. // });
  459. // })
  460. // }
  461. // });
  462. // this.isPopupLogin = true;
  463. req.silenceLogin(par.userId, par.merchantId ? par.merchantId : par.shopId ? par.shopId : '');
  464. }
  465. },
  466. click(e) {
  467. // console.log(e)
  468. this.hideShare = e
  469. },
  470. showShare() {
  471. // #ifndef H5
  472. req.isLogin().then(success => {
  473. if (success) {
  474. this.getCodeUrl()
  475. this.setData({
  476. hideShare: false
  477. });
  478. }
  479. });
  480. // #endif
  481. },
  482. /**
  483. * 轮播切换
  484. */
  485. swiperChange({
  486. detail
  487. }) {
  488. if (this.current == 0 && this.swiperCurrent > 1) {
  489. //卡死时,重置current为正确索引
  490. this.setData({
  491. current: this.swiperCurrent
  492. });
  493. } else {
  494. //正常轮转时,记录正确页码索引
  495. this.setData({
  496. swiperCurrent: detail.current
  497. });
  498. }
  499. },
  500. dotEvent(e) {
  501. this.setData({
  502. current: e.currentTarget.dataset.current
  503. });
  504. },
  505. browsRecound(id) {
  506. let from = {
  507. bindId: id,
  508. type: 6,
  509. page: '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query.acid
  510. };
  511. if (this.query.isShare) {
  512. from.shareType = 1;
  513. from.page = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query
  514. .acid + '&isShare=' + true;
  515. if (!this.query.userId) {} else {
  516. from.page += '&userId=' + this.query.userId;
  517. }
  518. if (!this.query.merchantId) {} else {
  519. from.merchantId = this.query.merchantId;
  520. }
  521. if (!this.query.shopId) {} else {
  522. from.shopId = this.query.shopId;
  523. }
  524. if (!this.query.userId) {} else {
  525. from.uid = this.query.userId;
  526. }
  527. }
  528. if (this.query.isShareTimeline) {
  529. from.shareType = 2;
  530. from.page = '/activity/seckillDetails/seckillDetails?id=' + this.query.id + '&acid=' + this.query
  531. .acid + '&isShareTimeline=' + true;
  532. if (!this.query.userId) {} else {
  533. from.page += '&userId=' + this.query.userId;
  534. }
  535. if (!this.query.merchantId) {} else {
  536. from.merchantId = this.query.merchantId;
  537. }
  538. if (!this.query.shopId) {} else {
  539. from.shopId = this.query.shopId;
  540. }
  541. if (!this.query.userId) {} else {
  542. from.uid = this.query.userId;
  543. }
  544. }
  545. return new Promise((resolve,reject)=>{
  546. req.postRequest('/api/browse', from, data => {resolve()});
  547. })
  548. },
  549. loadCodeParams() {
  550. let _ts = this;
  551. return new Promise((resolve, reject) => {
  552. if (!_ts.scene) {
  553. resolve();
  554. return false;
  555. }
  556. req.getRequest('/api/code/params', {
  557. scene: _ts.scene
  558. }, data => {
  559. if (data) {
  560. _ts.query.id = data.scene.split('_')[0];
  561. _ts.query.acid = data.scene.split('_')[1];
  562. _ts.query.merchantId = data.scene.split('_')[2];
  563. _ts.query.shopId = data.scene.split('_')[3];
  564. _ts.query.userId = data.userId;
  565. req.setStorage('pidCode', data.userId);
  566. }
  567. resolve();
  568. });
  569. });
  570. },
  571. getCodeUrl() {
  572. let that = this; //获取小程序码
  573. const query = this.query;
  574. let scene = that.pro.id + '_' + query.acid;
  575. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  576. scene += '_' + req.getStorage('MERCHANT').id;
  577. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  578. scene += '_' + req.getStorage('smallShop').id;
  579. }
  580. }
  581. // console.log(scene); //获取小程序码
  582. const params = {
  583. page: 'activity/seckillDetails/seckillDetails',
  584. scene: scene
  585. };
  586. // console.log('ma--', params);
  587. req.getRequest('/api/program/codev', params, url => {
  588. that.setData({
  589. codeUrl: url
  590. });
  591. });
  592. },
  593. async loadProudct() {
  594. let that = this;
  595. await that.loadActivity();
  596. const query = that.query;
  597. let isShowLoading = false;
  598. if (!isShowLoading) {
  599. req.loadIng('加载中');
  600. isShowLoading = true;
  601. }
  602. req.getRequest('/api/product/detail', {
  603. id: query.id
  604. }, data => {
  605. //富文本图片放大
  606. that.nodes = data.detail;
  607. let propertiesList = []
  608. if (data.propertiesList && data.propertiesList.length > 0) {
  609. data.propertiesList.map(it => {
  610. propertiesList.push(it.value);
  611. })
  612. }
  613. data.properties = propertiesList.join(' / ')
  614. that.setData({
  615. bannerUrls: data.images,
  616. pro: data,
  617. 'pro.salePrice': this.act.money,
  618. // 'pro.stock': this.act.quantity,
  619. 'pro.stock': this.act.quantity - this.act.payQuantity,
  620. 'pro.payQuantity': this.act.payQuantity,
  621. 'pro.maxBuy': this.act.maxBuy,
  622. allShow: true
  623. });
  624. if (isShowLoading) {
  625. uni.hideLoading();
  626. isShowLoading = false;
  627. // this.freshen = false
  628. }
  629. // console.log(this.pro);
  630. // that.getCodeUrl();
  631. });
  632. },
  633. loadActivity() {
  634. const query = this.query;
  635. return new Promise((resolve, reject) => {
  636. let from = {
  637. id: query.acid
  638. }
  639. // console.log(this.query.merchantId)
  640. if (this.query.merchantId) {
  641. from.merchantId = this.query.merchantId
  642. }
  643. let userInfo = req.getStorage('userInfo');
  644. if(userInfo.listShopBase && userInfo.listShopBase.length >0 ){
  645. from.shopId = userInfo.listShopBase[0].id;
  646. }
  647. req.getRequest('/api/activity/detail', from, data => {
  648. // console.log(data);
  649. this.getMy();
  650. if (data.type == 1) {
  651. this.setData({
  652. orderType: 2
  653. });
  654. }
  655. if (data.type == 2) {
  656. this.setData({
  657. orderType: 3
  658. });
  659. }
  660. if (data.type == 4) {
  661. this.setData({
  662. orderType: 6
  663. });
  664. }
  665. if (data.type == 5) {
  666. this.setData({
  667. orderType: 7
  668. });
  669. }
  670. if (!data || data == 2001) {
  671. this.setData({
  672. activityEnd: true
  673. });
  674. return false;
  675. } else {
  676. this.setData({
  677. act: data,
  678. isRemind: data.remindId
  679. });
  680. this.initTimer(data);
  681. }
  682. resolve();
  683. });
  684. });
  685. },
  686. // 获取用户信息
  687. getuserInfos(data) {
  688. let userInfo = req.getStorage('userInfo');
  689. if (userInfo && userInfo.listShopBase && userInfo.listShopBase != null && userInfo.listShopBase.length >
  690. 0) {
  691. if (userInfo.listShopBase[0].merchant_id == data.id && data.type != 5) {
  692. let url = '/mine/shop/shop?merchantId=' + userInfo.listShopBase[0].merchant_id + '&shopId=' + userInfo.listShopBase[0].id;
  693. this.url = url;
  694. this.ascription = true;
  695. }
  696. }
  697. },
  698. getMy() {
  699. let that = this;
  700. let userInfo = req.getStorage('userInfo');
  701. if(!userInfo || userInfo == null) return false;
  702. req.getRequest('/api/user/my', {}, data => {
  703. that.isDistriUser = data.isDistriUser;
  704. });
  705. },
  706. initTimer(group) {
  707. //计时器
  708. let _ts = this;
  709. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  710. let startTime = new Date(group.startTime.replace(/-/g, '/')).getTime();
  711. let endTime = new Date(group.endTime.replace(/-/g, '/')).getTime();
  712. if (!group.start) endTime = startTime;
  713. let times = parseInt((endTime - nowTime) / 1000);
  714. // console.log(times / 60 / 60);
  715. this.timer = setInterval(() => {
  716. times--;
  717. if (times <= 0) {
  718. //重新加载列表
  719. _ts.setData({
  720. 'act.end': true
  721. });
  722. return false;
  723. }
  724. let n = utils.formatDayTimes(times);
  725. _ts.setData({
  726. timer: n.split(/:|天/g)
  727. });
  728. }, 1000);
  729. },
  730. loadDefaultAddress() {
  731. if (req.isAuth()) {
  732. req.g('/api/address/default', data => {
  733. if (data) this.setData({
  734. address: data
  735. });
  736. else this.pointLocation();
  737. }, true);
  738. } else {
  739. this.pointLocation();
  740. }
  741. },
  742. toAddress() {
  743. app.globalData.openPage('mine/address/address');
  744. },
  745. toMerchant() {
  746. if (this.about.User_Limit_Store == 1) {
  747. } else {
  748. app.globalData.openPage('pages/nearby/nearby?isChoose=true');
  749. }
  750. },
  751. toactive() {
  752. app.globalData.openPage('pages/nearby/nearby');
  753. },
  754. pointLocation() {
  755. //定位当前位置
  756. let _ts = this;
  757. QQMapWX.initMap();
  758. req.getLocation(res => {
  759. QQMapWX.reverseGeocoder(res, data => {
  760. _ts.setData({
  761. ['address.address']: data.address
  762. });
  763. });
  764. });
  765. },
  766. addShopCart() {
  767. // 加入购物车
  768. if (!this.act.start) return req.msg('活动还未开始');
  769. if (this.act.payQuantity >= this.act.quantity) return req.msg('活动产品已售罄');
  770. if (this.act.end) return req.msg(
  771. '活动已结束');
  772. this.setData({
  773. isShow: true,
  774. isCart: true,
  775. popup: {
  776. id: this.pro.id,
  777. pic: this.pro.pic,
  778. title: this.pro.title,
  779. salePrice: this.act.money,
  780. stock: this.pro.stock,
  781. paramsId: this.pro.paramsId,
  782. marketPrice: this.pro.marketPrice,
  783. skuId: this.pro.skuId
  784. }
  785. });
  786. },
  787. atOnceBuy() {
  788. //立即购买
  789. if (!this.act.start) return req.msg('活动还未开始');
  790. if (this.act.payQuantity >= this.act.quantity) return req.msg('活动产品已售罄');
  791. if (this.act.end) return req.msg(
  792. '活动已结束');
  793. // this.setData({ isShow: true, isCart: false, popup: this.data.product });
  794. this.setData({
  795. isShow: true,
  796. isCart: false,
  797. popup: {
  798. id: this.pro.id,
  799. pic: this.pro.pic,
  800. title: this.pro.title,
  801. salePrice: this.act.money,
  802. stock: this.pro.stock,
  803. paramsId: this.pro.paramsId,
  804. marketPrice: this.pro.marketPrice,
  805. skuId: this.pro.skuId
  806. }
  807. });
  808. },
  809. addActivityRemind() {
  810. // 订阅调用
  811. req.postRequest('/api/activity/remind', {
  812. activityId: this.act.id
  813. }, res => {
  814. requsetmessage.remind();
  815. req.msg('预约成功');
  816. this.setData({
  817. isRemind: true
  818. });
  819. });
  820. },
  821. addCartSuccess(event) {
  822. this.setData({
  823. 'pro.count': parseInt(this.pro.count) + parseInt(event.detail.quantity),
  824. isShow: false
  825. });
  826. },
  827. cancelActivityRemind(event) {
  828. if (req.header.appId == 'ZQ1VK5oc17I387E') {
  829. } else {
  830. req.postRequest('/api/activity/cancel/remind', {
  831. id: this.act.id
  832. }, res => {
  833. req.msg('取消预约成功');
  834. this.setData({
  835. isRemind: false
  836. });
  837. });
  838. }
  839. },
  840. hidePopup() {
  841. this.setData({
  842. isShow: false
  843. });
  844. },
  845. hidePopupLogin(data) {
  846. this.isPopupLogin = false;
  847. },
  848. clickCollect() {
  849. let _ts = this;
  850. req.postRequest('/api/collect', {
  851. bindId: this.pro.id,
  852. type: 1
  853. }, data => {
  854. _ts.setData({
  855. 'pro.isCollect': !_ts.pro.isCollect
  856. });
  857. });
  858. },
  859. goTop: function(e) {
  860. // 一键回到顶部
  861. if (uni.pageScrollTo) {
  862. uni.pageScrollTo({
  863. scrollTop: 0
  864. });
  865. } else {
  866. uni.showModal({
  867. title: '提示',
  868. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  869. });
  870. }
  871. },
  872. getPor: function(e) {
  873. // console.log(e.detail, "qqqqq")
  874. this.popup = e.detail
  875. this.act.id = e.detail.actId
  876. },
  877. onShareTimeline() {
  878. let merchantId = '';
  879. let path = 'id=' + this.query.id + '&acid=' + this.query.acid + '&isShareTimeline=' + true;
  880. if (!req.getStorage('userInfo').id) {} else {
  881. path += '&userId=' + req.getStorage('userInfo').id;
  882. }
  883. // console.log(this.merchantId);
  884. let shopId = '';
  885. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  886. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  887. merchantId = req.getStorage('MERCHANT').id;
  888. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  889. path += '&shopId=' + req.getStorage('smallShop').id;
  890. shopId = req.getStorage('smallShop').id;
  891. merchantId = req.getStorage('smallShop').merchantDTO.id;
  892. }
  893. }
  894. let url = '/activity/seckillDetails/seckillDetails?' + path;
  895. route.share(2, req.getStorage('userInfo').id, url, merchantId, shopId, 6, this.query.acid + '_' + this
  896. .query.id);
  897. return {
  898. title: this.pro.title,
  899. query: path,
  900. imageUrl: this.pro.pic
  901. };
  902. },
  903. showTab: function(e) {
  904. this.setData({
  905. tabIndex: e.detail
  906. });
  907. },
  908. scoreTab: function(e) {
  909. this.form.page = 0;
  910. this.setData({
  911. current: e.detail,
  912. ['form.page']: 1
  913. });
  914. },
  915. freshenFun: function(e) {
  916. this.setData({
  917. freshen: e.detail
  918. });
  919. },
  920. // 获取品种保证
  921. getGuarantee() {
  922. return new Promise((data, rej) => {
  923. req.getRequest('/api/config', {}, res => {
  924. req.setStorage("configRes", JSON.stringify(res))
  925. this.about = res
  926. data(res)
  927. if (this.merchant && this.merchant.isDefault == 1 || this.query.acid) {
  928. // 切割;拿到数组,然后在过滤掉空值
  929. if (res.b2c_service_guarantee && res.b2c_service_guarantee != null) {
  930. this.setData({
  931. guarantee: res.b2c_service_guarantee.split(";").filter(it => {
  932. return it = it && it.trim();
  933. })
  934. });
  935. }
  936. } else {
  937. if (res.o2o_service_guarantee && res.b2c_service_guarantee != null) {
  938. this.setData({
  939. guarantee: res.o2o_service_guarantee.split(";").filter(it => {
  940. return it = it && it.trim();
  941. })
  942. });
  943. }
  944. } // if(res.Is_Store_Price_Stock){
  945. // this.setData({Is_Store_Price_Stock:res.Is_Store_Price_Stock})
  946. // }
  947. if (res.is_open_shop) {
  948. this.is_open_shop = res.is_open_shop;
  949. }
  950. if (res.is_open_comments) {
  951. this.setData({
  952. is_open_comments: res.is_open_comments
  953. });
  954. } // 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 })
  955. });
  956. })
  957. },
  958. // 是否开启小店
  959. isShop() {
  960. if (req.getStorage('distribution')) {
  961. dist = req.getStorage('distribution')
  962. this.setData({
  963. distr: dist
  964. })
  965. console.log(dist)
  966. if (dist.distributionSmallShopOpen == 1) {
  967. req.postRequest('/api/shopBase/isOpenShop', {}, data => {
  968. this.setData({
  969. isshop: data
  970. })
  971. console.log(data)
  972. })
  973. }
  974. }
  975. },
  976. addShop() { //添加到小店
  977. req.postRequest('/api/shopProduct/save', {
  978. productId: this.act.id,
  979. type: 3
  980. }, data => {
  981. this.act.isJoinShop = true;
  982. this.isHide = false;
  983. })
  984. },
  985. hidePop() { //添加到小店
  986. this.setData({
  987. isHide: true
  988. })
  989. },
  990. }
  991. };
  992. </script>
  993. <style>
  994. @import "./seckillDetails.css";
  995. </style>