productGroup.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <view class="container">
  3. <!-- 轮播图 -->
  4. <top-swiper :imgList="imgList"></top-swiper>
  5. <!-- 拼团倒计时 -->
  6. <group-time :goodsObjact="goodsObjact" :key='goodsObjact.product_price' :seckillObj="seckillObj"></group-time>
  7. <!-- 拼团标题 -->
  8. <group-content :goodsObjact="goodsObjact"></group-content>
  9. <!-- 拼团到货时间及优惠 -->
  10. <discounts :mark='goodsObjact.mark' :Info="goodsObjact.info" @clickCoupon="Getcoupon" :showCoupon='false'></discounts>
  11. <!-- 规格信息 -->
  12. <!-- <fresh-detail :goodsObjact="goodsObjact"></fresh-detail> -->
  13. <!-- <view class="uni-padding-wrap pinklistbox" v-if="pinkTlist.length > 0">
  14. <view class="pinklist">
  15. <view v-for="(ls, ind) in showlist">
  16. <view class="flex pinklist_list">
  17. <view class="pink_img"><image :src="ls.avatar"></image></view>
  18. <view class="pink_name">{{ ls.nickname }}</view>
  19. <view class="pink_tpl">
  20. <view class="pink_people">
  21. 还差
  22. <text>{{ ls.count }}</text>
  23. 人拼团
  24. </view>
  25. </view>
  26. <view class="pint" @click="groupBooking(ls.id)">
  27. 去拼团
  28. <text class="iconfont iconenter"></text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="More" @click="clickMore" v-if="more">查看更多</view>
  34. </view> -->
  35. <view class="ping-plan">
  36. <view class="participate-7 flex-between-center">
  37. <view class="participate-7-1">
  38. <text class="word" v-if="pink_type == 1">AA团</text>
  39. <text class="word" v-else>达人团</text>
  40. <text>玩法</text>
  41. </view>
  42. <view class="participate-7-1" @click="ToRule()">
  43. <text class="word1">详细规则</text>
  44. <image src="../../static/img/img74.png"></image>
  45. </view>
  46. </view>
  47. <view class="participate-8 flex-between-center">
  48. <view class="participate-8-1">
  49. <image class="img1" src="https://shicai.liuniu946.com/img/img76.png"></image>
  50. <view class="word-1">开团/参团</view>
  51. <view class="word-2">拼团享低价</view>
  52. </view>
  53. <image src="https://shicai.liuniu946.com/img/img75.png"></image>
  54. <view class="participate-8-1">
  55. <image class="img2" src="https://shicai.liuniu946.com/img/img77.png"></image>
  56. <view class="word-1">邀请邻里参团</view>
  57. <view class="word-2">分享优惠多</view>
  58. </view>
  59. <image src="https://shicai.liuniu946.com/img/img75.png"></image>
  60. <view class="participate-8-1">
  61. <image class="img3" src="https://shicai.liuniu946.com/img/img78.png"></image>
  62. <view class="word-1">人满发货</view>
  63. <view class="word-2">人不满退款</view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 大家都在拼 达人团显示 -->
  68. <now-list v-if="pink_type == 2" :recommendedlist="recommendedlist"></now-list>
  69. <!-- 图文详情 -->
  70. <content-text :description="description"></content-text>
  71. <!-- 底部高度撑开 -->
  72. <view class="contentBottomHeight"></view>
  73. <!-- 底部操作菜单 -->
  74. <view v-if="show == false">
  75. <view v-if="goodsObjact.pink_type == 'AA团'">
  76. <group-bottom :peoplePrize='goodsObjact.people_prize' @buy="openPinkT" :seckillObj="seckillObj"></group-bottom>
  77. </view>
  78. </view>
  79. <!-- 返回按钮 -->
  80. <return-button></return-button>
  81. </view>
  82. </template>
  83. <script>
  84. import { nowPinkLst } from '@/api/order.js';
  85. import {
  86. goodsDetail,
  87. cartAdd,
  88. collectAdd,
  89. collectDel,
  90. seckillGoods,
  91. groupGoods
  92. } from '@/api/product.js';
  93. import {
  94. mapState
  95. } from 'vuex';
  96. import store from '@/store/index.js';
  97. import {
  98. saveUrl
  99. } from '@/utils/loginUtils.js';
  100. import {
  101. timeComputed
  102. } from '@/utils/rocessor.js';
  103. // #ifdef H5
  104. import {
  105. weixindata
  106. } from '@/utils/wxAuthorized';
  107. // #endif
  108. // 头部轮播图
  109. import topSwiper from './common/topSwiper.vue';
  110. // 拼团倒计时
  111. import groupTime from './common/groupTime.vue';
  112. // 拼团标题
  113. import groupContent from './common/groupContent.vue';
  114. // 拼团到货时间及优惠
  115. import discounts from './common/discounts.vue';
  116. // 规格信息
  117. import freshDetail from './common/freshDetail.vue';
  118. // 图文详情
  119. import contentText from './common/contentText.vue';
  120. // 底部按钮
  121. import groupBottom from './common/groupBottom.vue';
  122. // 返回按钮
  123. import returnButton from '@/pages/return/returnButton.vue';
  124. // 大家还在拼
  125. import NowList from '../groupBooking/common/nowList.vue';
  126. export default {
  127. components: {
  128. topSwiper,
  129. groupTime,
  130. groupContent,
  131. discounts,
  132. freshDetail,
  133. contentText,
  134. groupBottom,
  135. returnButton,
  136. NowList
  137. },
  138. data() {
  139. return {
  140. reply: '', //评论
  141. list: '', //商品详情的数据
  142. type: 1, //默认支付方式add为
  143. goodsNumber: 1, //购买数量
  144. goodsid: '', //商品id
  145. description: '', //商品描述
  146. goodsObjact: {}, //保存商品数据
  147. //图片循环
  148. imgList: [],
  149. // 对比对象
  150. actionPrice: 0, //默认选中商品价格
  151. actionImage: '', //默认选中图片
  152. good_list: '', //猜你喜欢列表
  153. goodsNumberMax: 0, //最大可购买数量
  154. // 倒计时数据保存
  155. seckillObj: {
  156. stopTime: 0, //结束时间
  157. stop: false, //是否结束
  158. stopTimeH: 0, //小时
  159. stopTimeM: 0, //分钟
  160. stopTimeS: 0, //秒钟
  161. stopTimeD: 0, //天
  162. upTime: 0 //更新组件内部组件用
  163. },
  164. // 拼团数据保存
  165. pink: {
  166. id: '', //拼团编号
  167. uid: '', //用户编号
  168. people: '', //拼团人数
  169. price: '', //拼团价格
  170. stop_time: '', //拼团结束时间
  171. nickname: '', //团长昵称
  172. avatar: '', //团长头像
  173. count: '', //拼团剩余人数
  174. h: '', //时
  175. i: '', //分
  176. s: '' //秒
  177. },
  178. userInfo: '',
  179. pinkTlist: '', //拼团数据
  180. more: true, //查看更多按钮
  181. showlist: [],
  182. pink_type: 1, //拼团类别
  183. show: false, // 是否显示底部按钮
  184. recommendedlist:[], // 大家都在拼
  185. };
  186. },
  187. filters: {
  188. parseIntTo(percent) {
  189. percent = +percent * 100;
  190. if (percent % 1 === 0) {
  191. return percent;
  192. } else {
  193. percent = percent.toFixed(1);
  194. return percent;
  195. }
  196. }
  197. },
  198. async onLoad(options) {
  199. let obj = this;
  200. obj.userInfo = uni.getStorageSync('userInfo');
  201. //保存商品id
  202. this.goodsid = options.id;
  203. if (options.show) {
  204. this.show = options.show;
  205. }
  206. console.log(this.show, 5656)
  207. // 判断有无人邀请
  208. if (options.spread) {
  209. // 存储邀请人
  210. uni.setStorageSync('spread', options.spread);
  211. }
  212. saveUrl();
  213. // 家在数据
  214. this.groupGoods();
  215. return;
  216. // 注册邀请信息
  217. // #ifdef H5
  218. let bool = uni.getStorageSync('weichatBrowser') || '';
  219. if (bool) {
  220. weixindata();
  221. }
  222. // #endif
  223. },
  224. computed: {
  225. ...mapState(['weichatObj', 'baseURL', 'urlFile'])
  226. },
  227. // 分享
  228. // onShareAppMessage(options) {
  229. // // 设置菜单中的转发按钮触发转发事件时的转发内容
  230. // let pages = getCurrentPages(); //获取加载的页面
  231. // let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  232. // let url = currentPage.route; //当前页面url
  233. // let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  234. // let shareObj = {
  235. // title: this.goodsObjact.title + ' 价格:' + this.goodsObjact.price, // 默认是小程序的名称(可以写slogan等)
  236. // path: url + '?id=' + item.id + '&spread=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
  237. // imageUrl: this.goodsObjact.image,
  238. // success: function(res) {
  239. // // 转发成功之后的回调
  240. // if (res.errMsg == 'shareAppMessage:ok') {}
  241. // },
  242. // fail: function() {
  243. // // 转发失败之后的回调
  244. // if (res.errMsg == 'shareAppMessage:fail cancel') {
  245. // // 用户取消转发
  246. // } else if (res.errMsg == 'shareAppMessage:fail') {
  247. // // 转发失败,其中 detail message 为详细失败信息
  248. // }
  249. // }
  250. // };
  251. // return shareObj;
  252. // },
  253. methods: {
  254. // 跳转详细规则
  255. ToRule() {
  256. if( this.pink_type == 1 ) {
  257. // AA团
  258. uni.navigateTo({
  259. url: '/pages/rule/AArule'
  260. })
  261. } else {
  262. // 达人团
  263. uni.navigateTo({
  264. url: '/pages/rule/DaRrule'
  265. })
  266. }
  267. },
  268. // 去开团
  269. ToKaiTuan(item) {
  270. let id = item.id;
  271. uni.navigateTo({
  272. url: '/pages/product/productGroup?id=' + id
  273. });
  274. },
  275. // 跳转页面
  276. navTo(url) {
  277. uni.navigateTo({
  278. url
  279. });
  280. },
  281. // 查看更多
  282. clickMore() {
  283. this.showlist = this.pinkTlist;
  284. console.log(this.showlist, 22);
  285. this.more = false;
  286. },
  287. //去拼团
  288. groupBooking(item) {
  289. uni.navigateTo({
  290. url: '/pages/groupBooking/groupdetails?id=' + item
  291. });
  292. },
  293. // 获取拼团商品详情
  294. groupGoods() {
  295. let obj = this;
  296. // 大家还在拼
  297. nowPinkLst({}).then(({data}) => {
  298. this.recommendedlist = data;
  299. })
  300. groupGoods({}, this.goodsid).then(function({
  301. data
  302. }) {
  303. let goods = data.storeInfo;
  304. obj.goodsObjact = goods;
  305. console.log(obj.goodsObjact, 88)
  306. if (obj.goodsObjact.description != null) {
  307. obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
  308. }
  309. obj.imgList = goods.images; //保存轮播图
  310. obj.actionPrice = goods.price; //保存默认选中商品价格
  311. obj.actionImage = goods.image_base; //保存默认选中商品图片
  312. obj.goodsNumberMax = 1; //保存默认选中最大可购买商品数量
  313. if (obj.goodsObjact.pink_type == 'AA团') {
  314. obj.pink_type = 1;
  315. } else {
  316. obj.pink_type = 2;
  317. }
  318. obj.pinkTlist = data.pink;
  319. obj.showlist = obj.pinkTlist.slice(0, 2);
  320. if (obj.pinkTlist.length <= 2) {
  321. obj.more = false;
  322. }
  323. // 保存结束时间
  324. obj.seckillObj.stopTime = goods.stop_time * 1000;
  325. // 获取当前时间
  326. let acitonTime = new Date();
  327. // 判断当前时间是否大于结束时间
  328. if (acitonTime.getTime() > obj.seckillObj.stopTime) {
  329. // 当前秒杀时间已经结束
  330. obj.seckillObj.stop = true;
  331. } else {
  332. // 计算倒计时
  333. let time = timeComputed(obj.seckillObj.stopTime)
  334. // 倒计时数据保存
  335. obj.seckillObj = {
  336. stopTime: goods.stop_time * 1000, //结束时间
  337. stop: false, //是否结束
  338. stopTimeD: time.day, //天
  339. stopTimeH: time.hours, //小时
  340. stopTimeM: time.minutes, //分钟
  341. stopTimeS: time.seconds, //秒钟
  342. upTime: (new Date()).getTime()
  343. }
  344. }
  345. });
  346. },
  347. // 立即购买
  348. // buy(item) {
  349. // let obj = this;
  350. // obj.type = item;
  351. // // 创建传值对象
  352. // let data = {
  353. // cartNum: obj.goodsNumber, //商品数量
  354. // new: 1, //商品是否新增加到购物车1为不加入0为加入
  355. // combinationId: obj.goodsid,
  356. // productId: obj.goodsObjact.product_id
  357. // };
  358. // cartAdd(data)
  359. // .then(function(e) {
  360. // let da = e.data;
  361. // if (obj.type == 1) {
  362. // // 跳转到支付页
  363. // uni.navigateTo({
  364. // url: '/pages/order/createOrderKai?id=' + da.cartId+'&goodsType=2'
  365. // });
  366. // }
  367. // })
  368. // .catch(e => {
  369. // console.log(e);
  370. // });
  371. // },
  372. // 一键开团
  373. openPinkT() {
  374. uni.navigateTo({
  375. url: '/pages/product/groupdetails?id=' + this.goodsid
  376. })
  377. },
  378. // 阻止触发上级事件
  379. stopPrevent() {}
  380. }
  381. };
  382. </script>
  383. <style lang="scss">
  384. //默认商品底部高度
  385. .goodsBottom {
  386. height: 160rpx;
  387. }
  388. page {
  389. background: #f0f0f0;
  390. }
  391. //秒杀、拼团底部高度
  392. .contentBottomHeight {
  393. height: 110rpx;
  394. // background-color: #FFFFFF;
  395. }
  396. //默认商品底部高度
  397. .goodsBottom {
  398. height: 160rpx;
  399. }
  400. /deep/ .iconenter {
  401. font-size: $font-base + 2rpx;
  402. color: #888;
  403. }
  404. /deep/ .con_image {
  405. width: 130rpx;
  406. height: 130rpx;
  407. display: inline-block;
  408. padding: 15rpx;
  409. image {
  410. width: 100%;
  411. height: 100%;
  412. }
  413. }
  414. /* 商品详情中限制图片大小 */
  415. /deep/ .rich-img {
  416. width: 100% !important;
  417. height: auto;
  418. }
  419. .pinklistbox {
  420. background: #ffffff;
  421. margin-top: 25rpx;
  422. overflow: hidden;
  423. }
  424. .pink_num {
  425. background: -webkit-linear-gradient(left, #fdf5f6, #fbebf6);
  426. padding: 15rpx 25rpx;
  427. font-size: 26rpx;
  428. color: #dd524d;
  429. }
  430. .pint {
  431. background: -webkit-linear-gradient(left, #ff1f4f, #ff0409);
  432. padding: 10rpx 25rpx;
  433. color: #ffffff;
  434. font-size: 24rpx;
  435. border-radius: 25rpx;
  436. .iconenter {
  437. font-size: 15px;
  438. color: #ffffff;
  439. }
  440. }
  441. .pinklist {
  442. padding: 0rpx 25rpx;
  443. padding-top: 45rpx !important;
  444. }
  445. .pinklist_list {
  446. margin-bottom: 10rpx;
  447. }
  448. .pink_img {
  449. width: 100rpx;
  450. height: 100rpx;
  451. image {
  452. width: 100%;
  453. height: 100%;
  454. border-radius: 100%;
  455. }
  456. }
  457. .pink_people {
  458. font-size: 28rpx;
  459. text {
  460. color: #dd524d;
  461. }
  462. }
  463. .pink_time {
  464. font-size: 26rpx;
  465. color: #909399;
  466. }
  467. .pink_name {
  468. width: 200rpx;
  469. overflow: hidden;
  470. white-space: nowrap;
  471. text-overflow: ellipsis;
  472. padding-left: 10rpx;
  473. // background: #FC2A3F;
  474. // height: 50rpx;
  475. }
  476. .More {
  477. width: 100%;
  478. line-height: 2;
  479. background-color: #fc2a3f;
  480. font-size: $font-lg;
  481. margin: 0 auto;
  482. text-align: center;
  483. color: #ffffff;
  484. // border-radius: 50rpx;
  485. }
  486. .ping-plan {
  487. background-color: #FFFFFF;
  488. padding: 25rpx 35rpx;
  489. border-top: 15rpx solid #F3F3F4;
  490. border-bottom: 15rpx solid #F3F3F4;
  491. }
  492. .participate-7 {
  493. color: #000000;
  494. font-size: 29rpx;
  495. font-weight: 500;
  496. padding-bottom: 25rpx;
  497. .participate-7-1 {
  498. .word {
  499. color: #ff0a1a;
  500. }
  501. .word1 {
  502. font-size: 25rpx;
  503. color: #989aa0;
  504. }
  505. image {
  506. width: 10rpx;
  507. height: 20rpx;
  508. margin-left: 15rpx;
  509. }
  510. }
  511. }
  512. //左右顶格加上下居中
  513. .flex-between-center {
  514. display: flex;
  515. justify-content: space-between;
  516. align-items: center;
  517. }
  518. .participate-8 {
  519. image {
  520. width: 26rpx;
  521. height: 12rpx;
  522. }
  523. .participate-8-1 {
  524. text-align: center;
  525. .img1 {
  526. width: 43rpx;
  527. height: 50rpx;
  528. }
  529. .img2 {
  530. width: 43rpx;
  531. height: 42rpx;
  532. }
  533. .img3 {
  534. width: 60rpx;
  535. height: 46rpx;
  536. }
  537. .word-1 {
  538. font-size: 23rpx;
  539. color: #000000;
  540. line-height: 34rpx;
  541. }
  542. .word-2 {
  543. font-size: 21rpx;
  544. color: #91949B;
  545. line-height: 34rpx;
  546. }
  547. }
  548. }
  549. </style>