detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <template>
  2. <view class="box">
  3. <!-- 拼团 -->
  4. <view class="lyy-a">
  5. <view class="lyy-a-p">
  6. <view class="lyy-a-f">
  7. <view>
  8. <image :src="goods.image" class="lyy-a-tu" />
  9. </view>
  10. <view class="lyy-a-z">
  11. <view class="lyy-a-word lyy-a-word2">{{ goods.title }}</view>
  12. <view class="flex money-box">
  13. <view class="lyy-a-f lyy-a-word margin-r-20">
  14. <view class="lyy-a-word3">¥{{ goods.price }}</view>
  15. </view>
  16. <view class="lyy-a-tu2 lyy-a-f padding-c-20 border-radius-all">
  17. <view class="lyy-a-tu4 flex-shrink-false">{{ goods.people }}人拼</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="lyy-hx"></view>
  25. <!-- 第二部分 -->
  26. <view class="lyy-b padding-t-20">
  27. <view class="lyy-b-p">
  28. <view class="lyy-b-jz flex">
  29. <view class="image1">
  30. <view class="lyy-b-word">剩余时间</view>
  31. </view>
  32. </view>
  33. <view class="lyy-b-jz flex">
  34. <uni-countdowns v-if="pinkBool == 0" color="#FFFFFF" splitor-color="#901b21"
  35. background-color="#901b21" border-color="#901b21" :show-day="false" :hour="stopTime.stopTimeH"
  36. :minute="stopTime.stopTimeM" :second="stopTime.stopTimeS"></uni-countdowns>
  37. </view>
  38. <view class="lyy-b-jz flex">
  39. <span class="lyy-b-word2">{{ pinkT.people }}</span>
  40. <span class="lyy-b-word3">人成团,还差{{ peopleNub }}人</span>
  41. </view>
  42. <view class="lyy-b-jz flex">
  43. <view class="cmy-user-box">
  44. <view class="user-list">
  45. <view class="lyy-y bg-gray">
  46. <image :src="pinkT.avatar" class="user-list-img" />
  47. </view>
  48. <view class="lyy-y-word clamp">{{ pinkT.nickname }}</view>
  49. </view>
  50. <view class="user-list" v-for="(item , i) in people" :key='i'>
  51. <view class="lyy-y bg-gray">
  52. <image :src="item.avatar" class="user-list-img" />
  53. </view>
  54. <view class="lyy-y-word clamp">{{ item.nickname }}</view>
  55. </view>
  56. <view class="user-list" v-for="(l, i) in peopleNub" :key="i">
  57. <view class="lyy-y bg-gray"></view>
  58. <view class="lyy-y-word clamp">待邀请</view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="lyy-b-jz flex">
  63. <view class="lyy-b-but" v-if="status == 1 && pinkBool == 0" @click="invitation">邀请好友参团</view>
  64. <view class="lyy-b-but" v-if="status == 0&&pinkBool==0" @click="goBuy">立即加入</view>
  65. <!-- <view class="lyy-b-but" @click="goBuy">立即加入</view> -->
  66. <view class="lyy-b-but bg-gray" v-if="pinkBool == -1">拼团失败</view>
  67. <view class="lyy-b-but" v-if="pinkBool == 1">拼团成功</view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="lyy-hx"></view>
  72. <!-- 第三部分 -->
  73. <view class="lyy-c">
  74. <view class="lyy-c-p">
  75. <view class="lyy-c-word">
  76. <view>拼团规则:</view>
  77. <view>1.点击商品进入商品详情,通过拼团进入订单支付 页,用户付款成功后,按页面提示分享给好友。</view>
  78. <view>2.好友通过分享,加入拼团,完成订单支付,待达成 拼团人数后,拼团成功。</view>
  79. <view class="">
  80. {{scene}}
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
  89. import {
  90. getCombinationLisPink
  91. } from '@/api/product.js';
  92. import {
  93. groupGoods
  94. } from '@/api/product.js';
  95. import {
  96. timeComputed
  97. } from '@/utils/rocessor.js';
  98. import {
  99. mapState
  100. } from 'vuex';
  101. // 倒计时
  102. export default {
  103. // #ifdef MP
  104. onShareAppMessage: function(res) {
  105. if (res.from === 'button') {
  106. // 来自页面内分享按钮
  107. let pages = getCurrentPages();
  108. // 获取当前页面
  109. let page = pages[pages.length - 1];
  110. let path = '/' + page.route + '?';
  111. // 保存传值
  112. for (let i in page.options) {
  113. path += i + '=' + page.options[i] + '&';
  114. }
  115. // 保存邀请人
  116. path += 'spread=' + this.userInfo.uid;
  117. let data = {
  118. path: path,
  119. imageUrl: this.goods.image,
  120. title: '万水千山总是情,一起来拼行不行' //this.goods.title
  121. };
  122. return data;
  123. } else {
  124. // 来自页面内分享按钮
  125. let pages = getCurrentPages();
  126. // 获取当前页面
  127. let page = pages[pages.length - 1];
  128. let path = '/' + page.route + '?';
  129. // 保存传值
  130. for (let i in page.options) {
  131. path += i + '=' + page.options[i] + '&';
  132. }
  133. // 保存邀请人
  134. path += 'spread=' + this.userInfo.uid;
  135. let data = {
  136. path: path,
  137. imageUrl: this.goods.image,
  138. title: '万水千山总是情,一起来拼行不行' //this.goods.title
  139. };
  140. return data;
  141. }
  142. },
  143. // #endif
  144. data() {
  145. return {
  146. gp_id: 0, //拼团商品id
  147. goods: {}, //商品信息
  148. pinkT: {}, //拼团团长信息
  149. people: [], //拼团成员信息
  150. status: 0, //判断是否为团长
  151. gid: 0,
  152. user_info: {}, //当前用户信息
  153. // 倒计时
  154. stopTime: {
  155. stopTimeH: 0,
  156. stopTimeM: 0,
  157. stopTimeS: 0
  158. },
  159. pinkBool: 0, //拼团状态0为待拼团 -1为拼团失败 1为拼团成功
  160. userBool: 0, //判断用户是否已经参与拼团 0未参加 1为已参加
  161. spread: '', //默认没有邀请人
  162. userInfo: {}, //当前用户信息
  163. peopleNub: 0,
  164. scene: ''
  165. };
  166. },
  167. onLoad(option) {
  168. if (option.scene) {
  169. // this.scene = option.scene
  170. // uni.showModal({
  171. // title: 'scene',
  172. // content: option.scene
  173. // })
  174. if (typeof option.scene == 'string') {
  175. // let scene = ('{' + option.scene + "}").replace('qr%26', '').replace(/%3D/g, ':').replace(/%26/g, ',')
  176. // .replace('id', '\"id\"').replace('pid', '\"pid\"');
  177. let scene = ('{' + option.scene + "}").replace('qr%26', '').replace(/%3D/g, ':').replace(/%26/g, ',')
  178. .replace('id', '\"id\"').replace('pid', '\"pid\"').replace(/=/g,':').replace(/&/g,',');
  179. console.log(scene,'scene')
  180. let opt = JSON.parse(scene);
  181. console.log(opt)
  182. // 保存拼团订单id
  183. this.gp_id = opt.id;
  184. if (opt.pid) {
  185. // 存储邀请人
  186. this.spread = opt.pid;
  187. uni.setStorageSync('spread', opt.pid);
  188. }
  189. }
  190. } else {
  191. // 保存拼团订单id
  192. this.gp_id = option.id;
  193. if (option.spread) {
  194. // 存储邀请人
  195. this.spread = option.spread;
  196. uni.setStorageSync('spread', option.spread);
  197. }
  198. }
  199. // 判断是否有拼团
  200. if (option.unique) {
  201. this.unique = option.unique
  202. }
  203. this.getData();
  204. // // 保存拼团订单id
  205. // this.gp_id = e.id;
  206. // // 判断是否有人邀请
  207. // if (e.spread) {
  208. // // 存储邀请人
  209. // this.spread = e.spread;
  210. // uni.setStorageSync('spread', option.spread);
  211. // }
  212. },
  213. onShow() {
  214. // this.getData();
  215. },
  216. components: {
  217. uniCountdowns
  218. },
  219. methods: {
  220. //前往参团
  221. goBuy() {
  222. let _self = this;
  223. uni.navigateTo({
  224. url: '/pages/order/createOrder?pinkId=' + this.gp_id + '&type=pink' + '&pid=' + this.goods
  225. .product_id + '&gid=' + this.goods.id + '&merid=' + this.goods.mer_id +'&unique=' + this.goods.productValue[this.goods.productAttr[0].attr_values[0]].unique
  226. });
  227. },
  228. //邀请参团
  229. invitation() {
  230. let obj = this;
  231. // 判断拼团是否已经结束
  232. if (obj.userBool == 0) {
  233. uni.showModal({
  234. title: '提示',
  235. content: '该拼团已经结束!',
  236. showCancel: false,
  237. success: res => {},
  238. fail: () => {},
  239. complete: () => {}
  240. });
  241. return;
  242. }
  243. uni.navigateTo({
  244. url: '/pages/product/groupBooking/inviteImg?id=' + this.pinkT.id + '&spread=' + this.userInfo
  245. .uid,
  246. success: res => {},
  247. fail: e => {
  248. console.log(e);
  249. },
  250. complete: () => {}
  251. });
  252. },
  253. // #ifdef H5
  254. // 加载微信html5页面分享方法
  255. shareDate() {
  256. let obj = this;
  257. // 判断是否微信浏览器
  258. let bool = uni.getStorageSync('weichatBrowser') || '';
  259. if (bool) {
  260. // 过滤微信强制添加的链接地址
  261. url = url.replace('?from=singlemessage', '');
  262. let data = {
  263. link: url, // 分享链接
  264. imgUrl: obj.goodsObjact.image, // 分享图标
  265. desc: obj.goodsObjact.store_info,
  266. title: obj.goodsObjact.store_name,
  267. success: function() {}
  268. };
  269. obj.weichatObj.updateAppMessageShareData(data);
  270. obj.weichatObj.updateTimelineShareData(data);
  271. }
  272. },
  273. // #endif
  274. // 获取拼团信息
  275. getData() {
  276. let obj = this;
  277. // let data = {gp_id:_self.gp_id},
  278. getCombinationLisPink({}, this.gp_id).then(e => {
  279. let r = e.data;
  280. // 保存拼团商品详细
  281. obj.goods = r.store_combination;
  282. // 保存团长信息
  283. obj.pinkT = r.pinkT;
  284. /* 计算倒计时 */
  285. obj.timeComputed(obj.pinkT.stop_time * 1000);
  286. // 获取拼团用户列表
  287. obj.people = r.pinkAll;
  288. // 获取当前是否已参与过这个拼团
  289. obj.userBool = r.userBool;
  290. // 判断当前用户是否为团长
  291. if (r.pinkT.uid == r.userInfo.uid) {
  292. // 显示邀请好用选项
  293. obj.status = 1;
  294. }
  295. // 保存当前登录用户信息
  296. obj.userInfo = r.userInfo;
  297. // 获取拼团是否已经过期
  298. obj.pinkBool = r.pinkBool;
  299. obj.peopleNub = obj.pinkT.people - 1 - obj.people.length;
  300. // #ifdef H5
  301. // 加载微信分享配置
  302. this.shareDate();
  303. // #endif
  304. });
  305. },
  306. // 计算倒计时时间
  307. timeComputed(da) {
  308. let obj = this;
  309. let stopTime = timeComputed(da);
  310. obj.stopTime.stopTimeH = stopTime.hours;
  311. obj.stopTime.stopTimeM = stopTime.minutes;
  312. obj.stopTime.stopTimeS = stopTime.seconds;
  313. }
  314. }
  315. };
  316. </script>
  317. <style lang="scss">
  318. .box {
  319. /* #ifdef APP-PLUS | MP */
  320. padding-top: var(--status-bar-height);
  321. /* #endif */
  322. }
  323. .lyy-c {
  324. width: 100%;
  325. background: rgba(255, 255, 255, 1);
  326. .lyy-c-word {
  327. font-size: 28rpx;
  328. color: rgba(102, 102, 102, 1);
  329. line-height: 50rpx;
  330. }
  331. .lyy-c-p {
  332. padding: 39rpx 30rpx;
  333. }
  334. }
  335. .lyy-wrap {
  336. background-color: #f4f4f4;
  337. }
  338. .lyy-hx {
  339. height: 14rpx;
  340. }
  341. .image1 {
  342. width: 200rpx;
  343. height: 33rpx;
  344. background-size: 200rpx auto;
  345. }
  346. .lyy-b {
  347. width: 100%;
  348. background-color: white;
  349. .lyy-b-p {
  350. padding: 30rpx 45rpx;
  351. .lyy-b-word2,
  352. .lyy-b-word3 {
  353. font-size: 28rpx;
  354. font-weight: bold;
  355. }
  356. .lyy-b-word2 {
  357. color: #901b21;
  358. }
  359. .lyy-b-word3 {
  360. color: #1d2023;
  361. }
  362. .lyy-b-jz {
  363. width: 100%;
  364. justify-content: center;
  365. margin-bottom: 20rpx;
  366. .lyy-y {
  367. width: 80rpx;
  368. height: 80rpx;
  369. margin: 0px 15rpx;
  370. border-radius: 40rpx;
  371. overflow: hidden;
  372. .user-list-img {
  373. width: 100%;
  374. height: 100%;
  375. }
  376. }
  377. .lyy-y-word {
  378. margin-top: 10rpx;
  379. font-size: 28rpx;
  380. text-align: center;
  381. width: 110rpx;
  382. }
  383. .lyy-b-but {
  384. width: 550rpx;
  385. height: 80rpx;
  386. background: #901b21;
  387. border-radius: 100rpx;
  388. text-align: center;
  389. color: white;
  390. line-height: 80rpx;
  391. font-size: 32rpx;
  392. }
  393. .cmy-user-box {
  394. .user-list {
  395. display: inline-block;
  396. line-height: 1;
  397. }
  398. }
  399. }
  400. .lyy-b-word {
  401. text-align: center;
  402. font-size: 26rpx;
  403. color: rgba(29, 32, 35, 1);
  404. }
  405. }
  406. }
  407. // 商品列表样式
  408. .lyy-a {
  409. width: 100%;
  410. background-color: white;
  411. .lyy-a-p {
  412. padding: 22rpx 30rpx;
  413. .lyy-a-f {
  414. display: flex;
  415. align-items: center;
  416. .lyy-a-f2 {
  417. flex: 1;
  418. }
  419. .lyy-a-tu {
  420. width: 122rpx;
  421. height: 122rpx;
  422. }
  423. .lyy-a-z {
  424. padding-left: 30rpx;
  425. flex-grow: 1;
  426. .money-box {
  427. justify-content: flex-start;
  428. .lyy-a-tu2 {
  429. background: rgba(255, 255, 255, 1);
  430. border: 1rpx solid #901b21;
  431. .lyy-a-tu3 {
  432. background-color: #901b21;
  433. padding: 2px 4px 0px 4px;
  434. text-align: center;
  435. height: 26rpx;
  436. .lyy-a-tu5 {
  437. width: 20rpx;
  438. height: 20rpx;
  439. display: block;
  440. }
  441. }
  442. .lyy-a-tu4 {
  443. margin-left: 2px;
  444. font-size: 10px;
  445. color: #901b21;
  446. padding: 0px 10rpx;
  447. text-align: center;
  448. }
  449. }
  450. }
  451. .lyy-a-word {
  452. line-height: 56rpx;
  453. .lyy-a-word3 {
  454. font-size: 28rpx;
  455. font-weight: bold;
  456. color: #901b21;
  457. }
  458. }
  459. .lyy-a-word2 {
  460. font-size: 30rpx;
  461. color: rgba(29, 32, 35, 1);
  462. }
  463. }
  464. }
  465. }
  466. }
  467. </style>