groupDetail.vue 28 KB

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