ptDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view>
  3. <!--group/ptDetail/ptDetail.wxml-->
  4. <view class="banner">
  5. <image :src="picUrlss+'ptban1.jpg'" mode="widthFix"></image>
  6. </view>
  7. <view class="con">
  8. <view class="info dflex" @tap="goPrcdetail">
  9. <view class="pinimgs">
  10. <image :src="actData.acProduc.pic" mode="aspectFit" class="pinimg"></image>
  11. <view class="tuan">
  12. <image src="/static/pages/images/tagbg.png"></image>
  13. <text>{{actData.activityMain.numberPeople}}人团</text>
  14. </view>
  15. </view>
  16. <view class="pininfo flex">
  17. <view class="proname">{{actData.acProduc.productName}}</view>
  18. <view class="guige"></view>
  19. <view class="sta dflex">
  20. <view class="price"><text>¥</text>{{actData.acProduc.money}}<text class="del" v-if="actData.acProduc.marketPrice!=0&&actData.acProduc.marketPrice>actData.acProduc.money">原价:{{actData.acProduc.marketPrice}}</text></view>
  21. <!-- <view class="nums">×1</view> -->
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 0进行中 1标识拼团成功正常结束 2拼团特有状态,此状态下拼团未付款 3失败 4退款成功 -->
  26. <view v-if="actData.aprList.groupMainP.state==0" class="cantuan bgfff mt20 r10">
  27. <view class="can-info" v-if="actData.activityMain.numberPeople-actData.aprList.groupList.length<=0">{{actData.aprList.groupMainP.state==1?'拼团完成':'拼团待支付'}}</view>
  28. <view class="can-info" v-else>还差<text>{{actData.activityMain.numberPeople-actData.aprList.groupList.length}}人</text>成团</view>
  29. <view class="sheng dflex" v-if="actData.aprList.groupMainP.state==0">
  30. 剩余
  31. <view class="sheng-time dflex">
  32. <block v-if="timer.length==4">
  33. <block v-if="timer[0] !=0"><text>{{timer[0]}}</text>天</block>
  34. <text>{{timer[1]}}</text>:
  35. <text>{{timer[2]}}</text>:
  36. <text>{{timer[3]}}</text>
  37. </block>
  38. <block v-else>
  39. <text>{{timer[0]}}</text>:
  40. <text>{{timer[1]}}</text>:
  41. <text>{{timer[2]}}</text>
  42. </block>
  43. </view>
  44. 结束
  45. </view>
  46. <view class="can-infos dflex">
  47. <view v-for="(item, index) in groupList" :key="index" class="li">
  48. <image v-if="item.uavatar" :src="item.uavatar" mode="aspectFit" class="can-user"></image>
  49. <text v-if="index==0">团长</text>
  50. <text v-else>团员</text>
  51. <image v-if="!item.uavatar" src="/activity/static/activity/images/cha.png" class="can-bg"></image>
  52. </view>
  53. </view>
  54. <view class="can-btn mbglinear" @tap="addGroup" v-if="isJion&&actData.aprList.groupList.length!=actData.activityMain.numberPeople">我要参团</view>
  55. <button open-type="share" class="can-btn mbglinear" v-if="!isJion">邀请好友参团</button>
  56. <view class="kai-btn" v-if="actData.whether!=2" @tap="createGroup">我也要开团</view>
  57. </view>
  58. <view v-if="actData.aprList.groupMainP.state!=0" class="status bgfff mt20 r10">
  59. <view v-if="actData.aprList.groupMainP.state==1" class="status-c">
  60. <image :src="picUrlss+'sqimg3.png'"></image>
  61. <text>拼团成功啦~</text>
  62. </view>
  63. <view v-if="actData.aprList.groupMainP.state==3" class="status-c">
  64. <image :src="picUrlss+'sqimg2.png'"></image>
  65. <text>拼团失败,已退款~</text>
  66. </view>
  67. <view class="can-infos dflex" v-if="actData.aprList.groupMainP.state!=1">
  68. <view v-for="(item, index) in groupList" :key="index" class="li">
  69. <image v-if="item.uavatar" :src="item.uavatar" mode="aspectFit" class="can-user"></image>
  70. <text v-if="index==0">团长</text>
  71. <image v-if="!item.uavatar" src="/activity/static/activity/images/cha.png" class="can-bg"></image>
  72. </view>
  73. </view>
  74. <view class="can-btn mbglinear" v-if="isUser" @tap="toOrder">查看订单详情</view>
  75. <view class="can-btn mbglinear" @tap="goSeept">查看其他拼团</view>
  76. </view>
  77. <view class="detail bgfff mt20 r10">
  78. <view class="tab dflex">
  79. <view :class="'li ' + (currentTab == 0? 'on' : '')" data-current="0" @tap="tab">商品详情</view>
  80. <view :class="'li ' + (currentTab == 1? 'on' : '')" data-current="1" @tap="tab">拼团记录</view>
  81. <view :class="'li ' + (currentTab == 2? 'on' : '')" data-current="2" @tap="tab">活动规则</view>
  82. </view>
  83. <view :class="currentTab == 0? 'show' : 'hide'">
  84. <mp-html :content="nodes" lazy-load="true" @imgtap="chooseImg1"></mp-html>
  85. <!-- <view class="details det-text">
  86. <rich-text :nodes="nodes"></rich-text>
  87. </view>
  88. <view class="details">
  89. <block v-for="(item, index) in imgs" :key="index">
  90. <image class="img" :src="item" mode="widthFix" @tap="chooseImg1" :data-src="item"></image>
  91. </block>
  92. </view> -->
  93. </view>
  94. <view :class="'friend ' + (currentTab == 1? 'show' : 'hide')">
  95. <view v-for="(item, index) in groupList" :key="index" class="li dflex" v-if="item.careatDate">
  96. <view class="timg">
  97. <image :src="item.uavatar" mode="aspectFit"></image>
  98. <text v-if="item.userId==actData.aprList.groupMainP.userId">团长</text>
  99. <text v-else>团员</text>
  100. </view>
  101. <view class="name flex">{{item.unickName}}</view>
  102. <view class="time">{{item.careatDate}}{{item.userId==actData.aprList.groupMainP.userId?'开团':'参团'}}</view>
  103. </view>
  104. </view>
  105. <view :class="'guize ' + (currentTab == 2? 'show' : 'hide')">
  106. <rich-text :nodes="actData.activityMain.rule"></rich-text>
  107. </view>
  108. </view>
  109. </view>
  110. <!-- #ifdef H5 -->
  111. <wx-share ref="wxshare" />
  112. <!-- #endif -->
  113. </view>
  114. </template>
  115. <script>
  116. const app = getApp();
  117. const req = require("../../../utils/request.js");
  118. const utils = require("../../../utils/util.js");
  119. const route = require("../../../utils/route");
  120. import mpHtml from "../../../components/mp-html/components/mp-html/mp-html";
  121. export default {
  122. data() {
  123. return {
  124. picUrlss: req.public.picUrls,
  125. currentTab: 0,
  126. isJion: true,
  127. isGroup: true,
  128. isUser: false,
  129. start: false,
  130. actData: "",
  131. groupList: "",
  132. timer: "",
  133. hideShare: false
  134. };
  135. },
  136. components: {
  137. mpHtml
  138. },
  139. props: {},
  140. onLoad: function (options) {
  141. if(options.appId) req.setStorage('appId',options.appId);
  142. this.query = options; // this.getBargainPriceDetail();
  143. // console.log(options);
  144. },
  145. onShow: function () {
  146. // req.redirectIndex()
  147. req.isLogin().then(success => {});
  148. this.getBargainPriceDetail();
  149. },
  150. onShareAppMessage: function () {
  151. return this.onShareMessage();
  152. },
  153. // onShareTimeline(){
  154. // let merchantId = '';
  155. // let path = '/activity/group/ptDetail/ptDetail?id=' + this.query.id + '&acid=' + this.actData.acProduc.id + '&isShareTimeline=' + true;
  156. // console.log(!req.getStorage('userInfo').id);
  157. // if (!req.getStorage('userInfo').id) {} else {
  158. // path += '&userId=' + req.getStorage('userInfo').id;
  159. // }
  160. // let shopId = '';
  161. // if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  162. // path += '&merchantId=' + req.getStorage('MERCHANT').id;
  163. // merchantId = req.getStorage('MERCHANT').id;
  164. // if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  165. // path += '&shopId=' + req.getStorage('smallShop').id;
  166. // shopId = req.getStorage('smallShop').id;
  167. // merchantId = req.getStorage('smallShop').merchantDTO.id;
  168. // }
  169. // }
  170. // console.log(path,"456")
  171. // route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 7, this.actData.acProduc.id + '_' + this.query.id);
  172. // return {
  173. // title: this.actData.aprList.groupMainP.unickName + '邀请您一起拼团:' + this.actData.acProduc.productName,
  174. // imageUrl: this.actData.acProduc.pic,
  175. // path: path
  176. // };
  177. // },
  178. onReady() {
  179. // #ifdef H5
  180. var that = this;
  181. //初始化分享内容
  182. setTimeout(function() {
  183. var shareContent = that.onShareMessage();
  184. if (shareContent) {
  185. shareContent.path = window.location.origin + shareContent.path;
  186. }
  187. console.log('分享内容》》》》》', shareContent);
  188. that.$refs.wxshare.init(shareContent);
  189. }, 4 * 1000);
  190. // #endif
  191. },
  192. methods: {
  193. tab(event) {
  194. const tabIndex = event.currentTarget.dataset.current;
  195. if (this.currentTab === tabIndex) return false;
  196. this.setData({
  197. currentTab: tabIndex
  198. });
  199. },
  200. onShareMessage(){
  201. let merchantId = '';
  202. let path = '';
  203. let isSolution = '';
  204. // #ifndef H5
  205. isSolution = req.env[req.env.NODE_ENV].isSolution;
  206. // #endif
  207. // #ifdef H5
  208. isSolution = false;
  209. // #endif
  210. let userInfo = req.getStorage('userInfo');
  211. let shopId = '';
  212. if(isSolution){
  213. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  214. }else{
  215. path = '/activity/group/ptDetail/ptDetail?id=' + this.query.id + '&acid=' + this.actData.acProduc.id + '&isShare=' + true + '&appId=' + req.getStorage('appId');
  216. // console.log(!req.getStorage('userInfo').id);
  217. if (!userInfo.id) {} else {
  218. path += '&userId=' + userInfo.id;
  219. }
  220. // console.log(this.query.merchantId);
  221. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  222. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  223. merchantId = req.getStorage('MERCHANT').id;
  224. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  225. path += '&shopId=' + req.getStorage('smallShop').id;
  226. shopId = req.getStorage('smallShop').id;
  227. merchantId = req.getStorage('smallShop').merchantDTO.id;
  228. }
  229. }
  230. }
  231. // console.log(path,"456")
  232. route.share(1, userInfo.id, path, merchantId, shopId, 7, this.actData.acProduc.id + '_' + this.query.id);
  233. return {
  234. title: this.actData.aprList.groupMainP.unickName + '邀请您一起拼团:' + this.actData.acProduc.productName,
  235. imageUrl: this.actData.acProduc.pic,
  236. path: path
  237. };
  238. },
  239. //获取平团详情
  240. getBargainPriceDetail() {
  241. req.getRequest('/api/activity/groupDetail', {
  242. id: this.query.id,
  243. merchantId: this.query.merchantId
  244. }, data => {
  245. // console.log(data);
  246. if(data){
  247. this.setData({
  248. actData: data
  249. });
  250. this.initTimer(data.acProduc.nowTime, data.aprList.groupMainP, data.acProduc.endTime);
  251. var groupList = []; // groupList.push(data.aprList.groupMainP);
  252. if (data.aprList.groupList) {
  253. groupList = groupList.concat(data.aprList.groupList);
  254. groupList.forEach(res => {
  255. if (res.userId == req.getStorage("userInfo").id) {
  256. this.setData({
  257. isUser: true
  258. });
  259. }
  260. });
  261. }
  262. if (groupList.length < data.activityMain.numberPeople) {
  263. for (var i = 0; i < data.activityMain.numberPeople - data.count; i++) {
  264. // console.log(data.activityMain.numberPeople - data.count);
  265. var nullGroup = {};
  266. groupList.push(nullGroup);
  267. }
  268. }
  269. // console.log(groupList);
  270. this.isJionFun(groupList);
  271. this.setData({
  272. groupList: groupList
  273. });
  274. this.loadProudct(data.acProduc.productId);
  275. }
  276. });
  277. },
  278. initTimer(nowdata, group, end) {
  279. //计时器
  280. let _ts = this;
  281. let nowTime = new Date(nowdata.replace(/-/g, '/')).getTime();
  282. let endTime = new Date(group.endDate.replace(/-/g, '/')).getTime(); // let actend=new Date(end.replace(/-/g, '/')).getTime();
  283. // let times
  284. // if(actend-endTime>0){
  285. // times = parseInt((endTime - nowTime) / 1000);
  286. // }else{
  287. // times = parseInt((actend - nowTime) / 1000);
  288. // }
  289. let times = parseInt((endTime - nowTime) / 1000);
  290. // console.log(times);
  291. this.timer = setInterval(() => {
  292. times--;
  293. if (times === 0) {
  294. return false;
  295. }
  296. if (times < 0) {
  297. this.setData({
  298. isGroup: false
  299. });
  300. }
  301. let n = utils.formatDayTimes(times);
  302. _ts.setData({
  303. timer: n.split(/:|天/g)
  304. });
  305. }, 1000);
  306. },
  307. loadProudct(proId) {
  308. let that = this;
  309. req.getRequest('/api/product/detail', { id: proId }, data => {
  310. //富文本图片放大
  311. var nodes = data.detail;
  312. // if (nodes) {
  313. // if (nodes.indexOf("src") >= 0) {
  314. // //正则匹配所有图片路径
  315. // var imgs = [];
  316. // nodes = nodes.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
  317. // imgs.push(capture);
  318. // that.setData({
  319. // imgs: imgs
  320. // });
  321. // return '';
  322. // });
  323. // }
  324. // }
  325. that.setData({ bannerUrls: data.images, pro: data ,nodes: nodes});
  326. })
  327. },
  328. // 活动商品详情
  329. goPrcdetail() {
  330. app.globalData.openPage('activity/group/detail/detail?acid=' + this.actData.acProduc.id + '&id=' + this.actData.acProduc.productId);
  331. },
  332. //创建拼团
  333. createGroup() {
  334. if (this.start) return req.msg('活动已结束');
  335. req.postRequest('/api/activity/carterActivityPurchaseRecords', {
  336. acpId: this.actData.aprList.groupMainP.acpId,
  337. type: 3
  338. }, res => {
  339. this.createGroupOrder(res);
  340. });
  341. },
  342. //加入平团
  343. addGroup() {
  344. if (this.start) return req.msg('活动已结束');
  345. if (this.actData.aprList.groupList.length == this.actData.activityMain.numberPeople) return req.msg('该团参与人数已满');
  346. this.createGroupOrder(this.actData.aprList.id);
  347. },
  348. showShare() {
  349. // #ifndef H5
  350. req.isLogin().then(success => {
  351. if (success) {
  352. this.setData({
  353. hideShare: false
  354. });
  355. }
  356. });
  357. // #endif
  358. },
  359. goSeept() {
  360. uni.redirectTo({
  361. url: '/activity/group/index/index'
  362. });
  363. },
  364. createGroupOrder(aprId) {
  365. // let merchant = req.getStorage('defaultMerchant');
  366. const params = {
  367. skuId: this.actData.acProduc.skuId,
  368. quantity: 1,
  369. productId: this.actData.acProduc.productId,
  370. aprId: aprId
  371. };
  372. if (this.query.merchantId) {
  373. params.merchantId = this.query.merchantId;
  374. if(this.query.shopId){
  375. params.shopId = this.query.shopId;
  376. }
  377. }
  378. // if (this.query.merchantId) params.merchantId = this.query.merchantId;
  379. params.activityId = this.actData.acProduc.id;
  380. req.postRequest('/api/purchase/direct/buy', params, res => {
  381. let redirect = '/product/subOrder/subOrder?ids=' + res;
  382. redirect += '&orderType=' + 4;
  383. redirect += '&aprId=' + aprId;
  384. redirect += '&activityId=' + this.actData.acProduc.id;
  385. redirect += '&pay=' + 1;
  386. if (params.merchantId) {
  387. redirect += '&merchantId=' + params.merchantId;
  388. }
  389. if (params.shopId) {
  390. redirect += '&shopId=' + params.shopId;
  391. }
  392. uni.navigateTo({
  393. url: redirect
  394. });
  395. });
  396. },
  397. /**判断是否已经参团 */
  398. isJionFun(groupList) {
  399. let userInfo = req.getStorage('userInfo');
  400. groupList.forEach(res => {
  401. // console.log(res.userId == userInfo.id);
  402. if (res.userId == userInfo.id) this.setData({
  403. isJion: false
  404. });
  405. }); // console.log(groupList)
  406. },
  407. toOrder() {
  408. uni.navigateTo({
  409. url: '/mine/orderDet/orderDet?id=' + this.actData.orderId
  410. });
  411. }
  412. }
  413. };
  414. </script>
  415. <style>
  416. @import "./ptDetail.css";
  417. </style>