kjDetail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <view>
  3. <!--activity/bargain/kjDetail/kjDetail.wxml-->
  4. <view class="banner">
  5. <image src="/activity/static/activity/images/kjban.jpg" mode="widthFix"></image>
  6. </view>
  7. <view class="con">
  8. <view class="info dflex" @tap="goPrcdetail">
  9. <view class="pinimgs">
  10. <image :src="acProduc.pic" mode="aspectFit" class="pinimg"></image>
  11. </view>
  12. <view class="pininfo flex">
  13. <view class="proname">{{acProduc.productName?acProduc.productName:''}}</view>
  14. <!-- <view class="guige">规格:15G</view> -->
  15. <view class="sta dflex">
  16. <view class="price"><text>¥</text>{{acProduc.money?acProduc.money:0}}<text class="del" v-if="acProduc.orPrice!=0&&acProduc.orPrice>acProduc.money">原价:¥{{acProduc.orPrice?acProduc.orPrice:'0'}}</text></view>
  17. <!-- <view class="nums">×1</view> -->
  18. </view>
  19. </view>
  20. </view>
  21. <view class="cantuan bgfff mt20 r10">
  22. <view class="faqir">
  23. <image :src="aprList.groupMainP.uavatar"></image>
  24. <view>{{aprList.groupMainP.unickName}}</view>
  25. <icon class="icon iconfont iconbaojiaquotation2"></icon><text>我想要这件好物,快来帮我砍一刀吧</text>
  26. <icon class="icon iconfont iconbaojiaquotation"></icon>
  27. </view>
  28. <view class="sheng dflex" v-if="!act.isJieshu || !acProduc.end">
  29. 剩余
  30. <view class="sheng-time dflex">
  31. <!-- <block wx:if="acProduc.end">
  32. <text>{{timer[0]}}</text>
  33. <text>{{timer[1]}}</text>:
  34. <text>{{timer[2]}}</text>:
  35. <text>{{timer[3]}}</text>
  36. </block> -->
  37. <!-- <block wx:else> -->
  38. <block v-if="timer.length==4">
  39. <block v-if="timer[0] !=0"><text>{{timer[0]}}</text>天</block>
  40. <text>{{timer[1]}}</text>:
  41. <text>{{timer[2]}}</text>:
  42. <text>{{timer[3]}}</text>
  43. </block>
  44. <block v-else>
  45. <text>{{timer[0]}}</text>:
  46. <text>{{timer[1]}}</text>:
  47. <text>{{timer[2]}}</text>
  48. </block>
  49. <!-- </block> -->
  50. </view>
  51. 结束
  52. </view>
  53. <view v-else class="sheng dflex">已过期</view>
  54. <view class="can-info">已邀{{participateCount}}人,共砍<text>¥{{bargainingMoney}},</text>仅差<text>¥{{surplusMoney<=0?'0':surplusMoney}}</text></view>
  55. <view class="process">
  56. <view class="ing" :style="'width:' + percent + ';'"></view>
  57. </view>
  58. <block v-if="!act.isJieshu">
  59. <block v-if="isSuccess">
  60. <view class="can-btn mbglinear" @tap="confirmBuy" v-if="whether == 2&&topay==null">立即购买</view>
  61. <view class="can-btn mbglinear" @tap="toOrder" v-if="whether == 2&&topay!=null">查看订单详情</view>
  62. <view class="kai-btn" v-if="whether == 1" @tap="goUrl">我也要发起砍价</view>
  63. </block>
  64. <block v-else>
  65. <block v-if="isKanjia!=1">
  66. <button @tap="initState" class="can-btn mbglinear" v-if="whether == 2 &&isKanjia!=1">立即砍价</button>
  67. <view class="can-btn mbglinear" v-if="whether == 1&&isKanjia!=1" @tap="initState">帮TA砍一刀</view>
  68. </block>
  69. <block v-else>
  70. <button open-type="share" class="can-btn mbglinear" v-if="whether == 1">邀请好友帮TA砍价</button>
  71. <view class="kai-btn" v-if="whether == 1" @tap="goUrl">我也要发起砍价</view>
  72. </block>
  73. <button open-type="share" class="can-btn mbglinear" v-if="whether == 2">邀请好友砍价</button>
  74. </block>
  75. </block>
  76. <view v-else class="can-btn end">已过期</view>
  77. </view>
  78. <view class="detail bgfff mt20 r10">
  79. <view class="tab dflex">
  80. <view :class="'li ' + (currentTab == 0? 'on' : '')" data-current="0" @tap="tab">商品详情</view>
  81. <view :class="'li ' + (currentTab == 1? 'on' : '')" data-current="1" @tap="tab">砍价亲友团</view>
  82. <view :class="'li ' + (currentTab == 2? 'on' : '')" data-current="2" @tap="tab">活动规则</view>
  83. </view>
  84. <view :class="currentTab == 0? 'show' : 'hide'">
  85. <mp-html :content="nodes" lazy-load="true"></mp-html>
  86. <block v-if="diyNodes || diyImgs.length > 0">
  87. <view class="details">
  88. <rich-text :nodes="diyNodes" @tap="richImg"></rich-text>
  89. </view>
  90. <view class="details">
  91. <block v-for="(item, index) in diyImgs" :key="index">
  92. <image class="img" :src="item" mode="widthFix" @tap="chooseImg1" :data-src="item"></image>
  93. </block>
  94. </view>
  95. </block>
  96. </view>
  97. <view :class="'friend ' + (currentTab == 1? 'show' : 'hide')">
  98. <block v-if="aprList.groupList.length > 0">
  99. <view v-for="(item, index) in aprList.groupList" :key="index" class="li dflex">
  100. <view class="timg">
  101. <image :src="item.uavatar" mode="aspectFit"></image>
  102. </view>
  103. <view class="name flex">{{item.unickName}}<text>{{item.careatDate}}</text></view>
  104. <view class="time">帮砍{{item.bargainingAmount}}元</view>
  105. </view>
  106. </block>
  107. <view class="nopeople" v-else>
  108. <image :src="picUrlss+'sqimg2.png'"></image>
  109. <text>还没有人帮你砍价,去邀请好友帮忙</text>
  110. </view>
  111. </view>
  112. <view :class="'guize ' + (currentTab == 2? 'show' : 'hide')">
  113. <rich-text :nodes="activityMain.rule"></rich-text>
  114. </view>
  115. </view>
  116. </view>
  117. <view class="mask" @tap="closeLayer" :hidden="isShow"></view>
  118. <view class="kjpop" :hidden="isShow">
  119. <image src="/static/pages/images/close3.png" class="kjclose" @tap="closeLayer"></image>
  120. <!-- <image :src="picUrlss+'sqimg2.png'" class="kjimg"></image>砍价了 -->
  121. <image src="/activity/static/activity/images/kanle1.png" class="kanle1" v-if="whether == 1"></image>
  122. <!--帮TA砍掉-->
  123. <image src="/activity/static/activity/images/kanle2.png" class="kanle2" v-if="whether == 2"></image>
  124. <!--您已砍了-->
  125. <!-- <image :src="picUrlss+'thsb.png'" class="kjimg"></image> -->
  126. <!--砍价失败了-->
  127. <!-- <view class="kjtip" wx:if="{{participate == 1}}">您已经砍过了</view> -->
  128. <!-- <view class="kjtip">砍价失败了</view> -->
  129. <view class="kandiao" v-if="whether == 2 && isSuccess">您已经砍到底价了</view>
  130. <!--砍到底价-->
  131. <view class="kandiao" v-if="whether == 1">帮TA砍掉<text>{{money}}元</text></view>
  132. <!--帮TA砍掉-->
  133. <view class="kandiao" v-if="whether == 2 && !isSuccess">您砍了<text>{{money}}元</text></view>
  134. <!--帮TA砍掉-->
  135. <view class="process">
  136. <view class="ing" :style="'width:' + percent + ';'"></view>
  137. </view>
  138. <view class="kjbtn dflex">
  139. <view class="back" @tap="closeLayer">返回</view>
  140. <block v-if="whether == 2">
  141. <view class="ljgm" @tap="confirmBuy" v-if="isSuccess&&topay==null">立即购买</view>
  142. <view class="ljgm" @tap="toOrder" v-if="isSuccess&&topay!=null">查看订单详情</view>
  143. <button open-type="share" class="fenx" v-if="!isSuccess">分享给好友</button>
  144. </block>
  145. <block v-else>
  146. <view class="ljgm" @tap="goUrl" v-if="whether == 1">我也要砍价</view>
  147. </block>
  148. </view>
  149. </view>
  150. </view>
  151. </template>
  152. <script>
  153. // activity/bargain/kjDetail/kjDetail.js
  154. const app = getApp();
  155. const req = require("../../../utils/request.js");
  156. const utils = require("../../../utils/util.js");
  157. const route =require("../../../utils/route.js");
  158. import mpHtml from "../../../components/mp-html/components/mp-html/mp-html";
  159. export default {
  160. data() {
  161. return {
  162. picUrlss: req.public.picUrls,
  163. currentTab: 0,
  164. isShow: true,
  165. money: '',
  166. isSuccess: false,
  167. isKanjia: '',
  168. start: false,
  169. percent: "",
  170. timer: "",
  171. merchantId: "",
  172. topay: ""
  173. };
  174. },
  175. components: {mpHtml},
  176. props: {},
  177. async onLoad(options) {
  178. this.query = options;
  179. // console.log(options);
  180. if (options.money) {
  181. this.setData({
  182. isShow: false,
  183. money: options.money
  184. });
  185. }
  186. if (options.isShow) {
  187. this.setData({
  188. isShow: true
  189. });
  190. }
  191. },
  192. async onShow() {
  193. req.isLogin().then(success => {});
  194. this.getData();
  195. await this.loadProudct();
  196. this.gettoPay();
  197. },
  198. // onShareTimeline(){
  199. // let merchantId = '';
  200. // let path = '/activity/bargain/kjDetail/kjDetail?id=' + this.query.id + '&superiorId=' + this.aprList.groupMainP.userId + '&proid=' + this.query.proid ;
  201. // console.log(!req.getStorage('userInfo').id);
  202. // if (!req.getStorage('userInfo').id) {} else {
  203. // path += '&userId=' + req.getStorage('userInfo').id;
  204. // }
  205. // console.log(this.query.merchantId);
  206. // let shopId = '';
  207. // if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  208. // path += '&merchantId=' + req.getStorage('MERCHANT').id;
  209. // merchantId = req.getStorage('MERCHANT').id;
  210. // if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  211. // path += '&shopId=' + req.getStorage('smallShop').id;
  212. // shopId = req.getStorage('smallShop').id;
  213. // merchantId = req.getStorage('smallShop').merchantDTO.id;
  214. // }
  215. // }
  216. // console.log(path,"456")
  217. // route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 9, this.query.proid + '_' + this.query.id);
  218. // return {
  219. // title: req.getStorage("userInfo").nickName + '邀请您帮忙砍价:' + this.acProduc.productName,
  220. // imageUrl: this.acProduc.pic,
  221. // path: path
  222. // };
  223. // },
  224. onShareAppMessage: function () {
  225. let merchantId = '';
  226. let path = '/activity/bargain/kjDetail/kjDetail?id=' + this.query.id + '&superiorId=' + this.aprList.groupMainP.userId + '&proid=' + this.query.proid ;
  227. // console.log(!req.getStorage('userInfo').id);
  228. if (!req.getStorage('userInfo').id) {} else {
  229. path += '&userId=' + req.getStorage('userInfo').id;
  230. }
  231. // console.log(this.query.merchantId);
  232. let shopId = '';
  233. if (req.getStorage('MERCHANT') && req.getStorage('MERCHANT').id != null) {
  234. path += '&merchantId=' + req.getStorage('MERCHANT').id;
  235. merchantId = req.getStorage('MERCHANT').id;
  236. if (req.getStorage('smallShop') && req.getStorage('MERCHANT').id != null) {
  237. path += '&shopId=' + req.getStorage('smallShop').id;
  238. shopId = req.getStorage('smallShop').id;
  239. merchantId = req.getStorage('smallShop').merchantDTO.id;
  240. }
  241. }
  242. // console.log(path,"456")
  243. route.share(1, req.getStorage('userInfo').id, path, merchantId, shopId, 9, this.query.proid + '_' + this.query.id);
  244. return {
  245. title: req.getStorage("userInfo").nickName + '邀请您帮忙砍价:' + this.acProduc.productName,
  246. imageUrl: this.acProduc.pic,
  247. path: path
  248. };
  249. // return {
  250. // title: req.getStorage("userInfo").nickName + '邀请您帮忙砍价:' + this.acProduc.productName,
  251. // imageUrl: this.acProduc.pic,
  252. // path: '/activity/bargain/kjDetail/kjDetail?id=' + this.query.id + '&superiorId=' + this.aprList.groupMainP.userId + '&proid=' + this.query.proid + "&merchantId=" + this.query.merchantId
  253. // };
  254. },
  255. methods: {
  256. tab(event) {
  257. const tabIndex = event.currentTarget.dataset.current;
  258. if (this.currentTab === tabIndex) return false;
  259. this.setData({
  260. currentTab: tabIndex
  261. });
  262. },
  263. closeLayer() {
  264. this.setData({
  265. isShow: true
  266. });
  267. },
  268. loadProudct() {
  269. let that = this;
  270. const query = that.query;
  271. // console.log(query.id);
  272. return new Promise((resolve, reject) => {
  273. req.getRequest('/api/activity/bargainPriceDetail', {
  274. id: query.id,
  275. merchantId: query.merchantId
  276. }, data => {
  277. if(data){
  278. data.bargainingMoney = parseFloat(data.bargainingMoney).toFixed(2);
  279. data.surplusMoney = parseFloat(data.surplusMoney).toFixed(2);
  280. this.setData(data);
  281. this.initStates();
  282. let percent = Math.round(data.bargainingMoney / (data.acProduc.orPrice - data.acProduc.money) * 100) + '%';
  283. if (data.bargainingMoney == (data.acProduc.orPrice * 10000 - data.acProduc.money * 10000) / 10000) {
  284. this.setData({
  285. isSuccess: true
  286. });
  287. }
  288. this.setData({
  289. percent: percent
  290. });
  291. this.initTimer(data.acProduc, data.aprList);
  292. }
  293. resolve(); // that.getCodeUrl();
  294. });
  295. });
  296. },
  297. getData() {
  298. let that = this;
  299. const query = this.query;
  300. return new Promise((resolve, reject) => {
  301. req.getRequest('/api/product/detail', { id: query.proid }, data => {
  302. // console.log("/api/product/detail")
  303. var nodes = data.detail;
  304. that.setData({ bannerUrls: data.images, pro: data, nodes: nodes });
  305. resolve();
  306. })
  307. })
  308. },
  309. initTimer(group, list) {
  310. //计时器
  311. let _ts = this;
  312. let nowTime = new Date(group.nowTime.replace(/-/g, '/')).getTime();
  313. let startTime = new Date(group.createDate.replace(/-/g, '/')).getTime();
  314. let endTime = new Date(list.endDate.replace(/-/g, '/')).getTime();
  315. let times = parseInt((endTime - nowTime) / 1000);
  316. this.timer = setInterval(() => {
  317. times--;
  318. if (times === 0) {
  319. //重新加载列表
  320. _ts.setData({
  321. 'act.end': true
  322. });
  323. return false;
  324. }
  325. if (times < 0) {
  326. _ts.setData({
  327. 'act.isJieshu': true
  328. });
  329. }
  330. let n = utils.formatDayTimes(times);
  331. _ts.setData({
  332. timer: n.split(/:|天/g)
  333. });
  334. }, 1000);
  335. if (this.start) {
  336. clearInterval(this.timer);
  337. }
  338. },
  339. goUrl() {
  340. app.globalData.redirectTab('activity/bargain/index/index?merchantId=' + this.query.merchantId);
  341. },
  342. confirmBuy() {
  343. //直接购买
  344. if (this.start) return req.msg('活动已结束'); // let merchant = req.getStorage('defaultMerchant');
  345. if (this.query.merchantId) {
  346. this.setData({
  347. merchantId: this.query.merchantId
  348. });
  349. } // else{
  350. // if (req.getStorage('smallShop')) {
  351. // this.setData({ merchant: req.getStorage('smallShop').merchantDTO })
  352. // this.setData({ merchantId: req.getStorage('smallShop').merchantDTO.id })
  353. // } else if (req.getStorage('MERCHANT')) {
  354. // this.setData({ merchantId: req.getStorage('MERCHANT').id })
  355. // this.setData({ merchant: req.getStorage('MERCHANT') })
  356. // }
  357. // }
  358. // console.log(this.acProduc);
  359. const params = {
  360. skuId: this.acProduc.skuId,
  361. quantity: 1,
  362. productId: this.acProduc.productId,
  363. activityId: this.acProduc.id,
  364. aprId: this.query.id
  365. };
  366. if (this.query.merchantId) {
  367. params.merchantId = this.query.merchantId;
  368. } // if (this.data.merchant && this.data.merchant.type == 5) {
  369. // params.shopId = this.data.merchant.id
  370. // }
  371. // if (this.data.merchantId) params.merchantId = this.data.merchantId;
  372. req.postRequest('/api/purchase/direct/buy', params, res => {
  373. let redirect = '/product/subOrder/subOrder?ids=' + res;
  374. let orderType = 7; //砍价订单类型
  375. redirect += '&orderType=' + orderType;
  376. redirect += '&aprId=' + params.aprId;
  377. if (params.merchantId) {
  378. redirect += '&merchantId=' + this.merchantId;
  379. }
  380. if (params.shopId) {
  381. redirect += '&shopId=' + params.shopId;
  382. }
  383. uni.navigateTo({
  384. url: redirect
  385. });
  386. });
  387. },
  388. initState() {
  389. //判断是否发起砍价
  390. req.isLogin().then(success => {});
  391. let superid = this.query.id;
  392. let proid = this.acProduc.productId;
  393. if (this.isStates == 0) return req.msg('活动还未开始'); // if (this.data.isStates == 2) return req.msg('活动已结束');
  394. if (this.start) return req.msg('活动已结束');
  395. let param = {
  396. acpId: this.acProduc.id,
  397. actId: this.acProduc.actId,
  398. productId: this.acProduc.productId,
  399. type: 5,
  400. initOrPart: 2,
  401. superiorId: superid
  402. };
  403. req.getRequest('/api/activity/participationActivity', param, res => {
  404. //判断是否帮砍过
  405. // console.log("/api/activity/participationActivity");
  406. if (res.state == 1) {
  407. this.setData({
  408. isKanjia: res.state,
  409. isShow: false
  410. });
  411. return false;
  412. }
  413. let params = {
  414. acpId: this.acProduc.id,
  415. type: 5
  416. };
  417. if (superid) {
  418. params.superiorId = superid;
  419. }
  420. req.postRequest('/api/activity/carterActivityPurchaseRecords', params, res => {
  421. if (res) {
  422. let money = '';
  423. let id = '';
  424. if (superid) money = res, id = superid;else id = res;
  425. this.setData({
  426. isShow: false,
  427. money: money
  428. });
  429. this.loadProudct(); // wx.redirectTo({ url: '/activity/bargain/kjDetail/kjDetail?id=' + id + '&money=' + money + '&proid=' + proid })
  430. // app.openPage('activity/bargain/kjDetail/kjDetail?id=' + id + '&money=' + money + '&proid=' + proid)
  431. }
  432. });
  433. });
  434. },
  435. initStates() {
  436. //判断是否发起砍价
  437. req.isLogin().then(success => {});
  438. let params = {
  439. acpId: this.acProduc.id,
  440. actId: this.acProduc.actId,
  441. productId: this.acProduc.productId,
  442. type: 5,
  443. initOrPart: 2,
  444. superiorId: this.query.id
  445. };
  446. return new Promise((resolve, reject) => {
  447. req.getRequest('/api/activity/participationActivity', params, res => {
  448. // console.log("/api/activity/participationActivity");
  449. if (res.state != 1) {
  450. this.setData({
  451. isKanjia: res.state,
  452. isShow: true
  453. });
  454. } else {
  455. this.setData({
  456. isKanjia: res.state
  457. });
  458. }
  459. resolve();
  460. });
  461. });
  462. },
  463. gettoPay() {
  464. req.postRequest('/api/activity/toPay', {
  465. aprId: this.query.id,
  466. type: 5
  467. }, data => {
  468. this.setData({
  469. topay: data
  470. });
  471. });
  472. },
  473. toOrder() {
  474. uni.navigateTo({
  475. url: '/mine/orderDet/orderDet?id=' + this.topay
  476. });
  477. },
  478. // 活动商品详情
  479. goPrcdetail() {
  480. app.globalData.openPage('activity/bargain/detail/detail?acid=' + this.acProduc.id + '&id=' + this.acProduc.productId);
  481. }
  482. }
  483. };
  484. </script>
  485. <style>
  486. @import "./kjDetail.css";
  487. </style>