ptDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view>
  3. <!--group/ptDetail/ptDetail.wxml-->
  4. <view class="banner">
  5. <image src="/activity/static/activity/images/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. </view>
  111. </template>
  112. <script>
  113. const app = getApp();
  114. const req = require("../../../utils/request.js");
  115. const utils = require("../../../utils/util.js");
  116. const route = require("../../../utils/route");
  117. import mpHtml from "../../../components/mp-html/components/mp-html/mp-html";
  118. export default {
  119. data() {
  120. return {
  121. picUrlss: req.public.picUrls,
  122. currentTab: 0,
  123. isJion: true,
  124. isGroup: true,
  125. isUser: false,
  126. start: false,
  127. actData: "",
  128. groupList: "",
  129. timer: "",
  130. hideShare: false
  131. };
  132. },
  133. components: {
  134. mpHtml
  135. },
  136. props: {},
  137. onLoad: function (options) {
  138. this.query = options; // this.getBargainPriceDetail();
  139. // console.log(options);
  140. },
  141. onShow: function () {
  142. // req.redirectIndex()
  143. req.isLogin().then(success => {});
  144. this.getBargainPriceDetail();
  145. },
  146. onShareAppMessage: function () {
  147. let merchantId = '';
  148. let path = '/activity/group/ptDetail/ptDetail?id=' + this.query.id + '&acid=' + this.actData.acProduc.id + '&isShare=' + true;
  149. // console.log(!req.getStorage('userInfo').id);
  150. if (!req.getStorage('userInfo').id) {} else {
  151. path += '&userId=' + req.getStorage('userInfo').id;
  152. }
  153. // console.log(this.query.merchantId);
  154. let shopId = '';
  155. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  156. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  157. merchantId = req.getStorage('MERCHANT').id;
  158. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  159. path += '&shopId=' + req.getStorage('smallShop').id;
  160. shopId = req.getStorage('smallShop').id;
  161. merchantId = req.getStorage('smallShop').merchantDTO.id;
  162. }
  163. }
  164. // console.log(path,"456")
  165. route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 7, this.actData.acProduc.id + '_' + this.query.id);
  166. return {
  167. title: this.actData.aprList.groupMainP.unickName + '邀请您一起拼团:' + this.actData.acProduc.productName,
  168. imageUrl: this.actData.acProduc.pic,
  169. path: path
  170. };
  171. },
  172. // onShareTimeline(){
  173. // let merchantId = '';
  174. // let path = '/activity/group/ptDetail/ptDetail?id=' + this.query.id + '&acid=' + this.actData.acProduc.id + '&isShareTimeline=' + true;
  175. // console.log(!req.getStorage('userInfo').id);
  176. // if (!req.getStorage('userInfo').id) {} else {
  177. // path += '&userId=' + req.getStorage('userInfo').id;
  178. // }
  179. // let shopId = '';
  180. // if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  181. // path += '&merchantId=' + req.getStorage('MERCHANT').id;
  182. // merchantId = req.getStorage('MERCHANT').id;
  183. // if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  184. // path += '&shopId=' + req.getStorage('smallShop').id;
  185. // shopId = req.getStorage('smallShop').id;
  186. // merchantId = req.getStorage('smallShop').merchantDTO.id;
  187. // }
  188. // }
  189. // console.log(path,"456")
  190. // route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 7, this.actData.acProduc.id + '_' + this.query.id);
  191. // return {
  192. // title: this.actData.aprList.groupMainP.unickName + '邀请您一起拼团:' + this.actData.acProduc.productName,
  193. // imageUrl: this.actData.acProduc.pic,
  194. // path: path
  195. // };
  196. // },
  197. methods: {
  198. tab(event) {
  199. const tabIndex = event.currentTarget.dataset.current;
  200. if (this.currentTab === tabIndex) return false;
  201. this.setData({
  202. currentTab: tabIndex
  203. });
  204. },
  205. //获取平团详情
  206. getBargainPriceDetail() {
  207. req.getRequest('/api/activity/groupDetail', {
  208. id: this.query.id,
  209. merchantId: this.query.merchantId
  210. }, data => {
  211. // console.log(data);
  212. if(data){
  213. this.setData({
  214. actData: data
  215. });
  216. this.initTimer(data.acProduc.nowTime, data.aprList.groupMainP, data.acProduc.endTime);
  217. var groupList = []; // groupList.push(data.aprList.groupMainP);
  218. if (data.aprList.groupList) {
  219. groupList = groupList.concat(data.aprList.groupList);
  220. groupList.forEach(res => {
  221. if (res.userId == req.getStorage("userInfo").id) {
  222. this.setData({
  223. isUser: true
  224. });
  225. }
  226. });
  227. }
  228. if (groupList.length < data.activityMain.numberPeople) {
  229. for (var i = 0; i < data.activityMain.numberPeople - data.count; i++) {
  230. // console.log(data.activityMain.numberPeople - data.count);
  231. var nullGroup = {};
  232. groupList.push(nullGroup);
  233. }
  234. }
  235. // console.log(groupList);
  236. this.isJionFun(groupList);
  237. this.setData({
  238. groupList: groupList
  239. });
  240. this.loadProudct(data.acProduc.productId);
  241. }
  242. });
  243. },
  244. initTimer(nowdata, group, end) {
  245. //计时器
  246. let _ts = this;
  247. let nowTime = new Date(nowdata.replace(/-/g, '/')).getTime();
  248. let endTime = new Date(group.endDate.replace(/-/g, '/')).getTime(); // let actend=new Date(end.replace(/-/g, '/')).getTime();
  249. // let times
  250. // if(actend-endTime>0){
  251. // times = parseInt((endTime - nowTime) / 1000);
  252. // }else{
  253. // times = parseInt((actend - nowTime) / 1000);
  254. // }
  255. let times = parseInt((endTime - nowTime) / 1000);
  256. // console.log(times);
  257. this.timer = setInterval(() => {
  258. times--;
  259. if (times === 0) {
  260. return false;
  261. }
  262. if (times < 0) {
  263. this.setData({
  264. isGroup: false
  265. });
  266. }
  267. let n = utils.formatDayTimes(times);
  268. _ts.setData({
  269. timer: n.split(/:|天/g)
  270. });
  271. }, 1000);
  272. },
  273. loadProudct(proId) {
  274. let that = this;
  275. req.getRequest('/api/product/detail', { id: proId }, data => {
  276. //富文本图片放大
  277. var nodes = data.detail;
  278. // if (nodes) {
  279. // if (nodes.indexOf("src") >= 0) {
  280. // //正则匹配所有图片路径
  281. // var imgs = [];
  282. // nodes = nodes.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
  283. // imgs.push(capture);
  284. // that.setData({
  285. // imgs: imgs
  286. // });
  287. // return '';
  288. // });
  289. // }
  290. // }
  291. that.setData({ bannerUrls: data.images, pro: data ,nodes: nodes});
  292. })
  293. },
  294. // 活动商品详情
  295. goPrcdetail() {
  296. app.globalData.openPage('activity/group/detail/detail?acid=' + this.actData.acProduc.id + '&id=' + this.actData.acProduc.productId);
  297. },
  298. //创建拼团
  299. createGroup() {
  300. if (this.start) return req.msg('活动已结束');
  301. req.postRequest('/api/activity/carterActivityPurchaseRecords', {
  302. acpId: this.actData.aprList.groupMainP.acpId,
  303. type: 3
  304. }, res => {
  305. this.createGroupOrder(res);
  306. });
  307. },
  308. //加入平团
  309. addGroup() {
  310. if (this.start) return req.msg('活动已结束');
  311. if (this.actData.aprList.groupList.length == this.actData.activityMain.numberPeople) return req.msg('该团参与人数已满');
  312. this.createGroupOrder(this.actData.aprList.id);
  313. },
  314. showShare() {
  315. // #ifndef H5
  316. req.isLogin().then(success => {
  317. if (success) {
  318. this.setData({
  319. hideShare: false
  320. });
  321. }
  322. });
  323. // #endif
  324. },
  325. goSeept() {
  326. uni.redirectTo({
  327. url: '/activity/group/index/index'
  328. });
  329. },
  330. createGroupOrder(aprId) {
  331. // let merchant = req.getStorage('defaultMerchant');
  332. const params = {
  333. skuId: this.actData.acProduc.skuId,
  334. quantity: 1,
  335. productId: this.actData.acProduc.productId,
  336. aprId: aprId
  337. };
  338. if (this.query.merchantId) {
  339. params.merchantId = this.query.merchantId;
  340. if(this.query.shopId){
  341. params.shopId = this.query.shopId;
  342. }
  343. }
  344. // if (this.query.merchantId) params.merchantId = this.query.merchantId;
  345. params.activityId = this.actData.acProduc.id;
  346. req.postRequest('/api/purchase/direct/buy', params, res => {
  347. let redirect = '/product/subOrder/subOrder?ids=' + res;
  348. redirect += '&orderType=' + 4;
  349. redirect += '&aprId=' + aprId;
  350. redirect += '&activityId=' + this.actData.acProduc.id;
  351. redirect += '&pay=' + 1;
  352. if (params.merchantId) {
  353. redirect += '&merchantId=' + params.merchantId;
  354. }
  355. if (params.shopId) {
  356. redirect += '&shopId=' + params.shopId;
  357. }
  358. uni.navigateTo({
  359. url: redirect
  360. });
  361. });
  362. },
  363. /**判断是否已经参团 */
  364. isJionFun(groupList) {
  365. let userInfo = req.getStorage('userInfo');
  366. groupList.forEach(res => {
  367. // console.log(res.userId == userInfo.id);
  368. if (res.userId == userInfo.id) this.setData({
  369. isJion: false
  370. });
  371. }); // console.log(groupList)
  372. },
  373. toOrder() {
  374. uni.navigateTo({
  375. url: '/mine/orderDet/orderDet?id=' + this.actData.orderId
  376. });
  377. }
  378. }
  379. };
  380. </script>
  381. <style>
  382. @import "./ptDetail.css";
  383. </style>