detail.vue 11 KB

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