Bargain_order.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <view :class="[AppTheme]" class="box" v-if="shop_info">
  3. <u-popup :show="show" :custom-style="{background:'none'}" mode="center">
  4. <view class="bg">
  5. <view class="gx">
  6. 恭喜您
  7. <view class="text">
  8. {{msg}}
  9. </view>
  10. </view>
  11. <view class="close" @click="close">
  12. 我知道了
  13. </view>
  14. </view>
  15. </u-popup>
  16. <view class="info">
  17. <view class="left">
  18. <view class="icon" v-if="shop_info&&shop_info.vipinfo">
  19. <image :src="shop_info.vipinfo.headimgurl" mode=""></image>
  20. </view>
  21. <view class="user">
  22. <view class="name" v-if="shop_info&&shop_info.vipinfo">
  23. {{shop_info.vipinfo.nickname}}
  24. </view>
  25. <view class="time">
  26. 开砍时间 :{{shop_info.kjtime}}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="right text-primary" @click="go">
  31. 首页
  32. </view>
  33. </view>
  34. <view class="content">
  35. <view class="cont-t" @click="go_shopinfo">
  36. <view class="cont-t-l">
  37. <image :src="shop_info.apppic" mode=""></image>
  38. </view>
  39. <view class="cont-t-r" v-if="shop_info.cache">
  40. <view class="shop-name">
  41. {{shop_info.cache.name}}
  42. </view>
  43. <view class="shop-num">
  44. 库存: {{shop_info.cache.num}} | 已售{{shop_info.cache.sells}}
  45. </view>
  46. <view class="shop-time">
  47. 剩余时间: <u-count-down color="#999" separator-color="#999" separator="zh" font-size="26"
  48. :timestamp="shop_info.data.time > timestamp ? shop_info.data.time - timestamp : 0">
  49. </u-count-down>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="cont-c" v-if="shop_info.cache">
  54. <view class="cont-c-l border-primary">
  55. <view class="act text-primary">当前成交价</view>
  56. <view class="price text-neutral">¥{{shop_info.data.price || shop_info.cache.oprice}}</view>
  57. <view class="old-price ccc">原价 <text>¥{{shop_info.cache.oprice}}</text></view>
  58. </view>
  59. <view class="cont-c-r border-primary">
  60. <view class="act text-primary">已砍金额</view>
  61. <view class="price text-neutral">¥{{shop_info.data.pmoney}}</view>
  62. <view class="cishu ccc">砍价次数 {{shop_info.data.aboutnum==-1?'0':shop_info.data.aboutnum}} 次</view>
  63. </view>
  64. </view>
  65. <view class="cont-b">
  66. <view class="purchase bg-linear-gradient" v-if="shop_info.people==1 && shop_info.isbuyed==0"
  67. @click="buy">
  68. 立刻购买
  69. </view>
  70. <view class="purchase bg-linear-gradient" v-if="shop_info.people==0">
  71. 我也要砍
  72. </view>
  73. <view class="Bargaining" v-if="shop_info.selfkan==0 && shop_info.cankan==1 " @click="help">
  74. <image :src="settingFile.root_img+'/static/app/imgs/mine/kan.png'" mode=""></image>
  75. 砍一刀
  76. </view>
  77. <view class="Bargaining" v-else-if="shop_info.cankan==1 && shop_info.over !=1" @click="opensharebox">
  78. <image :src="settingFile.root_img+'/static/app/imgs/mine/kan.png'" mode=""></image>
  79. 邀请好友砍
  80. </view>
  81. <view class="Bargaining" v-else-if="shop_info.cankan==0 || shop_info.isbuyed==1"
  82. style="background: #ccc;">
  83. 砍价已完成
  84. </view>
  85. <view class="Bargaining" v-else="shop_info.over==1" style="background: #ccc;">
  86. 您的砍价已结束
  87. </view>
  88. </view>
  89. </view>
  90. <view class="footer"><strong></strong>
  91. <view class="tab">
  92. <u-tabs :activeStyle='primary' :lineColor="primary" lineWidth="40" :list="list" :scrollable="true"
  93. :current="current" @click="change" @change="change"></u-tabs>
  94. </view>
  95. <!-- 亲友团 -->
  96. <view class="qinyou" v-if="current==0">
  97. <view class="item-q" v-if="shop_info&&shop_info.vips.length>0" v-for="(item,index) in shop_info.vips"
  98. :key="index">
  99. <view class="item-img">
  100. <image :src="item.headimgurl" mode=""></image>
  101. </view>
  102. <view class="item-name">
  103. {{item.nickname}}
  104. </view>
  105. <view class="item-price text-neutral">
  106. - {{item.money}}元
  107. </view>
  108. <view class="item-time">
  109. {{$u.timeFormat(item.time,'yyyy.mm.dd:hh:MM')}}
  110. </view>
  111. </view>
  112. <u-empty margin-top="60" v-if="shop_info&&shop_info.vips&&shop_info.vips.length==0" text="暂无更多数据"
  113. mode="list"></u-empty>
  114. </view>
  115. <!-- 商品详情 -->
  116. <view class="detail" v-if="current==1">
  117. <u-parse :content="content" :lazy-load="true" :autoscroll="false" :show-with-animation="true"></u-parse>
  118. <u-empty margin-top="60" v-if="!content" text="暂无更多数据" mode="list"></u-empty>
  119. </view>
  120. <!-- 活动规则 -->
  121. <view class="detail" v-if="current==2">
  122. <u-parse :content="summary" :lazy-load="true" :autoscroll="false" :show-with-animation="true"></u-parse>
  123. <u-empty margin-top="60" v-if="!summary" text="暂无更多数据" mode="list"></u-empty>
  124. </view>
  125. <!-- 参与榜 -->
  126. <view class="qinyou" v-if="current==3">
  127. <view class="item-q" v-if="shop_info&&shop_info.vips.length>0" v-for="(item,index) in shop_info.vips"
  128. :key="index">
  129. <view class="item-img">
  130. <image :src="item.headimgurl" mode=""></image>
  131. </view>
  132. <view class="item-name">
  133. {{item.nickname}}
  134. </view>
  135. <view class="item-price text-neutral">
  136. - {{item.money}}元
  137. </view>
  138. <view class="item-time">
  139. {{$u.timeFormat(item.etime,'yyyy.mm.dd:hh:MM')}}
  140. </view>
  141. </view>
  142. <u-empty margin-top="60" style="height: 0% !important;width: 100vw;" v-if="shop_info.vips.length==0"
  143. text="暂无更多数据" mode="list"></u-empty>
  144. </view>
  145. <!-- 分享 -->
  146. <sharebox ref="sbox" v-if="sharedata" :data="sharedata"></sharebox>
  147. </view>
  148. </view>
  149. </template>
  150. <!-- 商城 -->
  151. <script>
  152. import api from '@/api/mall/index.js'
  153. export default {
  154. data() {
  155. return {
  156. primary: this.$theme.primary,
  157. list: [{
  158. name: '亲友团'
  159. },
  160. {
  161. name: '商品详情'
  162. },
  163. {
  164. name: '活动规则'
  165. },
  166. // {name: '参与榜'},
  167. ],
  168. shop_info: {
  169. vips: []
  170. },
  171. current: 0,
  172. vipid: '',
  173. settingFile: getApp().globalData.siteinfo,
  174. id: '',
  175. show: false,
  176. msg: '',
  177. timestamp: '',
  178. content: '',
  179. summary: '',
  180. svipid: '',
  181. cache: null,
  182. sid: '',
  183. sharedata: null,
  184. };
  185. },
  186. onLoad(options) {
  187. //如果没有vipid的话就是正常砍价
  188. console.log(options.vipid)
  189. this.$bindid.getbindid(options, this.$store);
  190. if (options.vipid == undefined) {
  191. this.timestamp = Date.parse(new Date()) / 1000;
  192. this.id = options.id
  193. this.vipid = uni.getStorageSync('userInfo').id
  194. this.getdata()
  195. } else {
  196. // 否则就是帮助好友砍价
  197. this.timestamp = Date.parse(new Date()) / 1000;
  198. this.vipid = options.vipid
  199. this.svipid = options.vipid
  200. this.sid = options.id
  201. this.getdata(options)
  202. }
  203. },
  204. onShareAppMessage(res) {
  205. let that = this
  206. let data = {
  207. title: that.sharedata.title,
  208. imageUrl: that.sharedata.imageUrl,
  209. path: that.sharedata.path
  210. };
  211. return data;
  212. },
  213. onShareTimeline(res) {
  214. let that = this
  215. let data = {
  216. title: that.sharedata.title,
  217. imageUrl: that.sharedata.imageUrl,
  218. path: that.sharedata.path
  219. };
  220. return data;
  221. },
  222. methods: {
  223. goDetail() {
  224. uni.navigateTo({
  225. url: `./Bargain_cart?id=${this.shop_info.cache.id}`
  226. })
  227. },
  228. change(e) {
  229. this.current = e.index;
  230. },
  231. getdata(options) {
  232. let data = {
  233. ...options
  234. }
  235. console.log(data + '重新赋值')
  236. console.log(options + '帮你砍一刀')
  237. //有则是好友帮忙砍刀
  238. if (options) {
  239. api.bargain(options).then(ret => {
  240. if (ret.status == 200) {
  241. this.shop_info = ret.data
  242. this.cache = ret.data.cache
  243. this.content = this.shop_info.cache.content.replace(/\<img src="/gi,
  244. `<img style='width:100%;display:block' src="${this.settingFile.root_rich_img}`);
  245. this.summary = this.shop_info.cache.summary.replace(/\<img src="/gi,
  246. `<img style='width:100%;display:block' src="${this.settingFile.root_rich_img}`);
  247. }
  248. })
  249. } else {
  250. // 否则就是从详情页进行砍刀
  251. let data = {
  252. id: this.id,
  253. vipid: this.vipid
  254. }
  255. api.bargain(data).then(ret => {
  256. if (ret.status == 200) {
  257. this.shop_info = ret.data
  258. this.content = this.shop_info.cache.content.replace(/\<img src="/gi,
  259. `<img style='width:100%' src="${this.settingFile.root_rich_img}`);
  260. this.summary = this.shop_info.cache.summary.replace(/\<img src="/gi,
  261. `<img style='width:100%' src="${this.settingFile.root_rich_img}`);
  262. this.sharedata = {
  263. imageUrl: this.shop_info.apppic,
  264. title: `我正参加${this.shop_info.cache.price}元抢购${this.shop_info.cache.sname}活动,原价${this.shop_info.cache.oprice},还差一刀到底价`,
  265. path: `/pagesD/pages/mall/Bargain_order?pid=` + this.$getuid() +
  266. `&id=${this.shop_info.cache.id}&vipid=${this.shop_info.helpvipid}`
  267. };
  268. }
  269. })
  270. }
  271. },
  272. //立即购买
  273. buy() {
  274. let obj = {
  275. goodsnum: this.shop_info.cache.num,
  276. goodstype: this.shop_info.cache.type,
  277. num: 1,
  278. goodsid: this.shop_info.cache.id,
  279. vipid: this.vipid,
  280. sid: 0,
  281. bid: this.shop_info.bid
  282. }
  283. if (parseInt(this.shop_info.cache.num) - 1 < 0) {
  284. this.$api.msg('该产品库存不足!请调整购买量或选择其他属性!')
  285. return;
  286. }
  287. api.fastbuys(obj).then(res => {
  288. if (res.status == 200) {
  289. uni.showToast({
  290. icon: 'loading',
  291. title: '生成订单',
  292. duration: 2000
  293. });
  294. setTimeout(() => {
  295. this.$u.route('/pagesD/pages/order/createOrder', {
  296. goodstype: this.shop_info.cache.type,
  297. bid: this.shop_info.bid,
  298. sid: 0,
  299. lasturl: this.shop_info.lasturl,
  300. });
  301. }, 2000);
  302. } else {
  303. this.$u.toast(res.msg);
  304. }
  305. });
  306. },
  307. //砍一刀
  308. help() {
  309. let that = this
  310. let data = {
  311. helpvipid: this.shop_info.helpvipid, //用户id
  312. goodsid: this.shop_info.cache.id //商品id
  313. }
  314. api.help(data).then(ret => {
  315. console.log(ret)
  316. if (ret.status == 200) {
  317. this.msg = ret.msg
  318. this.show = true
  319. let options = {
  320. id: this.sid,
  321. vipid: this.svipid
  322. }
  323. if (this.svipid != '') {
  324. this.getdata(options)
  325. } else {
  326. this.getdata()
  327. }
  328. } else {
  329. this.$u.toast(ret.msg)
  330. }
  331. })
  332. },
  333. //邀请好友砍刀
  334. opensharebox() {
  335. this.$refs.sbox.opensharebox(this.sharedata);
  336. },
  337. close() {
  338. this.show = !this.show
  339. },
  340. go_shopinfo() {
  341. uni.navigateTo({
  342. url: './Bargain_cart?id=' + this.shop_info.cache.id
  343. })
  344. },
  345. go() {
  346. uni.switchTab({
  347. url: '/pages/mall/mall'
  348. })
  349. }
  350. },
  351. };
  352. </script>
  353. <style lang="scss">
  354. $color-fff: #fff;
  355. @mixin lineH($index) {
  356. height: $index;
  357. line-height: $index;
  358. }
  359. page {
  360. background: #f1f1f1;
  361. }
  362. .box {
  363. width: 100%;
  364. .u-mode-center-box {}
  365. .share {
  366. width: 100%;
  367. height: 100vh;
  368. image {
  369. width: 67vw;
  370. margin-top: 0upx;
  371. }
  372. }
  373. .bg {
  374. width: 400upx;
  375. background: none !important;
  376. .gx {
  377. width: 400upx;
  378. height: 350upx;
  379. background: url(../../../static/imgs/mine/bargain_bg.png) no-repeat;
  380. background-size: 100% 100%;
  381. padding-top: 80upx;
  382. box-sizing: border-box;
  383. text-align: center;
  384. font-size: 38upx;
  385. color: #ff0808;
  386. }
  387. .text {
  388. margin-top: 40upx;
  389. font-size: 24upx;
  390. color: #F29100;
  391. }
  392. .close {
  393. width: 70%;
  394. height: 70upx;
  395. background: $tab-color;
  396. margin: 60upx auto;
  397. border-radius: 10upx;
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. color: #fff;
  402. font-size: 30upx;
  403. }
  404. }
  405. .info {
  406. box-sizing: border-box;
  407. align-items: center;
  408. display: flex;
  409. background: white;
  410. padding: 15upx 0 15upx 40upx;
  411. margin-bottom: 20upx;
  412. .left {
  413. display: flex;
  414. align-items: center;
  415. .icon {
  416. width: 85upx;
  417. height: 85upx;
  418. margin-right: 20upx;
  419. border-radius: 50%;
  420. image {
  421. width: 100%;
  422. height: 100%;
  423. border-radius: 50%;
  424. }
  425. }
  426. .user {
  427. view {
  428. margin: 15upx 0;
  429. }
  430. .name {
  431. font-size: 30upx;
  432. font-weight: bold;
  433. }
  434. .time {
  435. color: #999999;
  436. font-size: 26upx;
  437. }
  438. }
  439. }
  440. .right {
  441. flex: 1;
  442. display: flex;
  443. align-items: center;
  444. justify-content: flex-end;
  445. padding-right: 40upx;
  446. font-size: 30upx;
  447. box-sizing: border-box;
  448. }
  449. }
  450. .content {
  451. width: 100%;
  452. min-height: 500upx;
  453. background: #fff;
  454. margin-bottom: 20upx;
  455. padding-bottom: 40upx;
  456. .cont-t {
  457. width: 86%;
  458. margin: 0 auto;
  459. padding: 40upx 0 35upx 0;
  460. border-bottom: 1px solid #f1f1f1;
  461. display: flex;
  462. align-items: center;
  463. .cont-t-l {
  464. width: 160upx;
  465. height: 165upx;
  466. margin-right: 30upx;
  467. image {
  468. width: 100%;
  469. height: 100%;
  470. border-radius: 15rpx;
  471. }
  472. }
  473. .cont-t-r {
  474. .shop-name {
  475. width: 450rpx;
  476. margin-bottom: 20upx;
  477. line-height: 40upx;
  478. font-weight: bold;
  479. }
  480. .shop-num {
  481. margin-bottom: 10upx;
  482. font-size: 24upx;
  483. color: #999999;
  484. }
  485. .shop-time {
  486. font-size: 24upx;
  487. color: #999999;
  488. }
  489. }
  490. }
  491. .cont-c {
  492. display: flex;
  493. justify-content: space-between;
  494. padding: 40upx;
  495. .act {
  496. width: 60%;
  497. padding: 5upx;
  498. position: absolute;
  499. top: -20upx;
  500. left: 50%;
  501. margin-left: -30%;
  502. background: #fff;
  503. font-size: 30upx;
  504. }
  505. .price {
  506. margin-top: 30upx;
  507. }
  508. .cont-c-l {
  509. width: 300upx;
  510. height: 125upx;
  511. border-width: 1px;
  512. border-style: solid;
  513. text-align: center;
  514. position: relative;
  515. .old-price {
  516. margin-top: 10upx;
  517. font-size: 22upx;
  518. margin-top: 15upx;
  519. }
  520. }
  521. .cont-c-r {
  522. width: 300upx;
  523. height: 125upx;
  524. position: relative;
  525. border-width: 1px;
  526. border-style: solid;
  527. text-align: center;
  528. .cishu {
  529. font-size: 22upx;
  530. margin-top: 15upx;
  531. }
  532. }
  533. }
  534. .cont-b {
  535. padding: 0 17px;
  536. display: flex;
  537. justify-content: flex-end;
  538. .purchase {
  539. width: 310upx;
  540. height: 75upx;
  541. border-radius: 20upx;
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. font-size: 30upx;
  546. color: #fff;
  547. margin-right: 65upx;
  548. }
  549. .Bargaining {
  550. width: 310upx;
  551. height: 75upx;
  552. border-radius: 20upx;
  553. display: flex;
  554. align-items: center;
  555. justify-content: center;
  556. font-size: 30upx;
  557. color: #fff;
  558. background: red;
  559. image {
  560. width: 40upx;
  561. height: 40upx;
  562. margin-right: 14upx;
  563. }
  564. }
  565. }
  566. }
  567. .footer {
  568. width: 100%;
  569. min-height: 50vh;
  570. background: #ffff;
  571. .tab {
  572. margin-bottom: 20upx;
  573. }
  574. .no {
  575. width: 100%;
  576. text-align: center;
  577. padding-top: 100upx;
  578. }
  579. .detail {
  580. display: flex;
  581. justify-content: space-between;
  582. line-height: 40rpx;
  583. padding: 0 20rpx 50rpx 20rpx;
  584. box-sizing: border-box;
  585. }
  586. .qinyou {
  587. width: 100%;
  588. .item-q {
  589. display: flex;
  590. align-items: center;
  591. justify-content: space-around;
  592. width: 100%;
  593. font-size: 26upx;
  594. border-bottom: 1px solid #f1f1f1;
  595. padding: 10upx 0;
  596. .item-img {
  597. width: 70upx;
  598. height: 70upx;
  599. border-radius: 50%;
  600. image {
  601. width: 100%;
  602. height: 100%;
  603. border-radius: 50%;
  604. }
  605. }
  606. .item-name {
  607. width: 105rpx;
  608. margin-left: -30upx;
  609. margin-right: 50upx;
  610. overflow: hidden;
  611. text-overflow: ellipsis;
  612. white-space: nowrap;
  613. }
  614. .item-price {
  615. min-width: 133rpx;
  616. }
  617. .item-time {}
  618. }
  619. }
  620. }
  621. }
  622. </style>