confirmOrder.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <view>
  3. <view class="inner-box">
  4. <!-- 商品列表 -->
  5. <view class="goods-list">
  6. <view v-for="(item,index) in carts" :key="index" class="item" @click="showDetail(item)">
  7. <view class="img-box">
  8. <image :src="item.productImage" mode="aspectFill"></image>
  9. </view>
  10. <view class="info-box">
  11. <view>
  12. <view class="name-box ellipsis2">
  13. <view class="tag">{{utils.getDictLabelName("storeProductType",item.productType)}}</view>{{item.productName}}
  14. </view>
  15. <view class="spec ellipsis2">{{item.productAttrName}}</view>
  16. </view>
  17. <view class="price-num">
  18. <view class="price">
  19. <text class="unit">¥</text>
  20. <text class="num">{{item.price.toFixed(2)}}</text>
  21. </view>
  22. <view class="num">x{{item.cartNum}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 小计 -->
  27. <view class="sub-total">
  28. <text class="label">订单金额:</text>
  29. <view class="price">
  30. <text class="unit">¥</text>
  31. <text class="num">{{price.totalPrice.toFixed(2)}}</text>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="mt12">赠送商品</view>
  36. <view class="goods-list">
  37. <view v-for="(item,index) in giftcarts" :key="index" class="item" @click="showDetail(item)">
  38. <view class="img-box">
  39. <image :src="item.productImage" mode="aspectFill"></image>
  40. </view>
  41. <view class="info-box">
  42. <view>
  43. <view class="name-box ellipsis2">
  44. <view class="tag">{{utils.getDictLabelName("storeProductType",item.productType)}}</view>{{item.productName}}
  45. </view>
  46. <view class="spec ellipsis2">{{item.productAttrName}}</view>
  47. </view>
  48. <view class="price-num">
  49. <view class="price">
  50. <text class="unit">¥</text>
  51. <text class="num">{{item.price.toFixed(2)}}</text>
  52. </view>
  53. <view class="num">x{{item.cartNum}}</view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 小计 -->
  58. <view class="sub-total">
  59. <text class="label">订单金额:</text>
  60. <view class="price">
  61. <text class="unit">¥</text>
  62. <text class="num">{{price.giftPrice.toFixed(2)}}</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 底部按钮 -->
  68. <view class="btn-foot">
  69. <view class="right">
  70. <view class="total">
  71. <text class="label">实付金额:</text>
  72. <view class="price">
  73. <text class="unit">¥</text>
  74. <text class="num">{{price.payPrice.toFixed(2)}}</text>
  75. </view>
  76. </view>
  77. <view class="btn" @click="submitOrder">支付{{price.payPrice.toFixed(2)}}</view>
  78. </view>
  79. </view>
  80. <view class="message-box" v-if="messageShow">
  81. <view class="left">
  82. <image src="/static/images/close24.png" mode="" @click="closeOrder()" ></image>
  83. <view class="text ellipsis">您有{{count0}}个待支付订单</view>
  84. </view>
  85. <view class="btn" @click="showOrder()">查看</view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import {getDicts} from '@/api/index'
  91. import {getOrderCount} from '@/api/storeOrder'
  92. import {getSalesOrder,addUserCart} from '@/api/companyOrder.js'
  93. export default {
  94. data() {
  95. return {
  96. count0:0,
  97. messageShow:false,
  98. orderKey:null,
  99. price:{
  100. totalPrice:0.00,
  101. giftPrice:0.00,
  102. payPrice:0.00,
  103. },
  104. carts:[],
  105. giftcarts:[]
  106. }
  107. },
  108. // onLoad(option) {
  109. // this.getDicts();
  110. // console.log("获取orderKey"+option.orderKey);
  111. // this.orderKey = option.orderKey;
  112. // console.log("获取orderKey"+this.orderKey);
  113. // },
  114. // onShow() {
  115. // if (this.utils.isLogin()) {
  116. // console.log("获取orderKey"+this.orderKey);
  117. // this.getOrderCount();
  118. // this.getSalesOrder(); // 每次页面显示时重新加载数据
  119. // }
  120. // },
  121. onLoad(option) {
  122. this.getDicts();
  123. this.orderKey=option.orderKey;
  124. if(this.utils.isLogin()){
  125. this.getOrderCount();
  126. }
  127. },
  128. onShow() {
  129. if(uni.getStorageSync('AppToken')){
  130. this.getSalesOrder();
  131. }
  132. },
  133. methods: {
  134. getDicts:function(){
  135. getDicts().then(
  136. res => {
  137. if(res.code==200){
  138. uni.setStorageSync('dicts',JSON.stringify(res));
  139. }
  140. },
  141. rej => {}
  142. );
  143. },
  144. showOrder(){
  145. this.utils.isLogin().then(res => {
  146. if(res){
  147. uni.navigateTo({
  148. url: '/pages_user/user/storeOrder?status=0'
  149. })
  150. }
  151. })
  152. },
  153. closeOrder(){
  154. this.messageShow=false;
  155. },
  156. getOrderCount(){
  157. getOrderCount().then(
  158. res => {
  159. if(res.code==200){
  160. this.count0=res.count0;
  161. console.log(this.count0);
  162. if(this.count0>0){
  163. this.messageShow=true;
  164. }
  165. }
  166. },
  167. rej => {}
  168. );
  169. },
  170. showDetail(item) {
  171. uni.navigateTo({
  172. url: './productShowDetails?productId='+item.productId
  173. })
  174. },
  175. getSalesOrder(item){
  176. console.log("获取orderKey"+this.orderKey);
  177. var that=this;
  178. that.totalPrice=0.00;
  179. that.payPrice=0.00;
  180. var data={createOrderKey:this.orderKey}
  181. getSalesOrder(data).then(
  182. res => {
  183. if(res.code==200){
  184. this.carts=res.carts;
  185. // res.carts.forEach(function(element) {
  186. // that.price.totalPrice+=element.price*element.cartNum;
  187. // });
  188. this.price.totalPrice = 0.00;
  189.                             this.carts.forEach(element => {
  190.                                 const price = Number(element.price) || 0;
  191.                                 const cartNum = Number(element.cartNum) || 0;
  192.                                 this.price.totalPrice += price * cartNum;
  193.                             });
  194. this.giftcarts=res.giftCarts
  195. this.giftcarts.forEach(element => {
  196.                                 const price = Number(element.price) || 0;
  197.                                 const cartNum = Number(element.cartNum) || 0;
  198.                                 this.price.giftPrice += price * cartNum;
  199.                             });
  200. that.price.payPrice=res.totalMoney
  201. }else{
  202. uni.showToast({
  203. icon:'none',
  204. title: res.msg,
  205. });
  206. }
  207. },
  208. rej => {}
  209. );
  210. },
  211. // 提交订单
  212. submitOrder() {
  213. this.utils.isLogin().then(res => {
  214. if(res){
  215. var data={createOrderKey:this.orderKey}
  216. addUserCart(data).then(
  217. res => {
  218. if(res.code==200){
  219. uni.navigateTo({
  220. url: '/pages_shopping/shopping/confirmCreateOrder?type=buy&cartIds='+res.cartIds.toString()+"&companyId="+res.companyId+
  221. "&companyUserId="+res.companyUserId+"&createOrderKey="+this.orderKey+"&giftCartIds="+res.giftCartIds
  222. })
  223. }else{
  224. uni.showToast({
  225. icon:'none',
  226. title: res.msg,
  227. });
  228. }
  229. },
  230. rej => {}
  231. );
  232. //将购物车产品更新为自己的购物车
  233. }
  234. })
  235. },
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. .inner-box{
  241. padding: 20upx 20upx 140upx;
  242. .goods-list{
  243. margin-top: 20upx;
  244. padding: 0 30upx;
  245. background-color: #FFFFFF;
  246. border-radius: 16upx;
  247. .item{
  248. padding: 30upx 0;
  249. border-bottom: 1px solid #EDEEEF;
  250. display: flex;
  251. align-items: center;
  252. .img-box{
  253. width: 160upx;
  254. height: 160upx;
  255. margin-right: 30upx;
  256. image{
  257. width: 100%;
  258. height: 100%;
  259. }
  260. }
  261. .info-box{
  262. width: calc(100% - 190upx);
  263. height: 160upx;
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: space-between;
  267. .name-box{
  268. font-size: 28upx;
  269. font-family: PingFang SC;
  270. font-weight: 500;
  271. color: #111111;
  272. line-height: 40upx;
  273. .tag{
  274. display: inline-block;
  275. padding: 0 6upx;
  276. height: 30upx;
  277. background: linear-gradient(90deg, #66b2ef 0%,#018C39 100%);
  278. border-radius: 4upx;
  279. margin-right: 10upx;
  280. font-size: 22upx;
  281. font-family: PingFang SC;
  282. font-weight: bold;
  283. color: #FFFFFF;
  284. line-height: 30upx;
  285. float: left;
  286. margin-top: 7upx;
  287. }
  288. }
  289. .spec{
  290. margin-top: 10upx;
  291. font-size: 24upx;
  292. font-family: PingFang SC;
  293. font-weight: 500;
  294. color: #999999;
  295. line-height: 1;
  296. }
  297. .price-num{
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. .price{
  302. display: flex;
  303. align-items: flex-end;
  304. .unit{
  305. font-size: 24upx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #111111;
  309. line-height: 1.2;
  310. margin-right: 4upx;
  311. }
  312. .num{
  313. font-size: 32upx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #111111;
  317. line-height: 1;
  318. }
  319. }
  320. .num{
  321. font-size: 24upx;
  322. font-family: PingFang SC;
  323. font-weight: 500;
  324. color: #999999;
  325. line-height: 1;
  326. }
  327. }
  328. }
  329. }
  330. .sub-total{
  331. height: 88upx;
  332. display: flex;
  333. align-items: center;
  334. justify-content: flex-end;
  335. .label{
  336. font-size: 24upx;
  337. font-family: PingFang SC;
  338. font-weight: 500;
  339. color: #999999;
  340. }
  341. .price{
  342. display: flex;
  343. align-items: flex-end;
  344. .unit{
  345. font-size: 24upx;
  346. font-family: PingFang SC;
  347. font-weight: 500;
  348. color: #FF6633;
  349. line-height: 1.2;
  350. margin-right: 4upx;
  351. }
  352. .num{
  353. font-size: 32upx;
  354. font-family: PingFang SC;
  355. font-weight: bold;
  356. color: #FF6633;
  357. line-height: 1;
  358. }
  359. }
  360. }
  361. }
  362. .points{
  363. height: 88upx;
  364. padding: 0 30upx;
  365. background: #FFFFFF;
  366. border-radius: 16upx;
  367. display: flex;
  368. align-items: center;
  369. justify-content: space-between;
  370. .left{
  371. display: flex;
  372. align-items: center;
  373. image{
  374. width: 28upx;
  375. height: 28upx;
  376. margin-right: 20upx;
  377. }
  378. .text{
  379. font-size: 28upx;
  380. font-family: PingFang SC;
  381. font-weight: 500;
  382. color: #666666;
  383. }
  384. }
  385. .right{
  386. display: flex;
  387. align-items: center;
  388. .text{
  389. font-size: 28upx;
  390. font-family: PingFang SC;
  391. font-weight: 500;
  392. color: #111111;
  393. }
  394. image{
  395. margin-left: 15upx;
  396. width: 14upx;
  397. height: 24upx;
  398. }
  399. }
  400. }
  401. .remarks{
  402. height: 88upx;
  403. padding: 0 30upx;
  404. background: #FFFFFF;
  405. border-radius: 16upx;
  406. margin-top: 20upx;
  407. display: flex;
  408. align-items: center;
  409. input{
  410. width: 100%;
  411. font-size: 28upx;
  412. font-family: PingFang SC;
  413. font-weight: 500;
  414. color: #000000;
  415. }
  416. .input{
  417. font-size: 28upx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #999999;
  421. }
  422. }
  423. }
  424. .btn-foot{
  425. box-sizing: border-box;
  426. width: 100%;
  427. height: 121upx;
  428. background: #FFFFFF;
  429. display: flex;
  430. align-items: center;
  431. justify-content: flex-end;
  432. position: fixed;
  433. left: 0;
  434. bottom: 0;
  435. z-index: 99;
  436. .right{
  437. display: flex;
  438. align-items: center;
  439. .total{
  440. display: flex;
  441. align-items: flex-end;
  442. margin-right: 15upx;
  443. .label{
  444. font-size: 26upx;
  445. font-family: PingFang SC;
  446. font-weight: 500;
  447. color: #999999;
  448. line-height: 1.5;
  449. }
  450. .price{
  451. display: flex;
  452. align-items: flex-end;
  453. .unit{
  454. font-size: 26upx;
  455. font-family: PingFang SC;
  456. font-weight: bold;
  457. color: #FF6633;
  458. line-height: 1.2;
  459. margin-right: 10upx;
  460. }
  461. .num{
  462. font-size: 32upx;
  463. font-family: PingFang SC;
  464. font-weight: bold;
  465. color: #FF6633;
  466. line-height: 1;
  467. }
  468. }
  469. }
  470. .btn{
  471. margin-right: 15upx;
  472. padding: 20rpx 30rpx;
  473. text-align: center;
  474. font-size: 30upx;
  475. font-family: PingFang SC;
  476. font-weight: bold;
  477. color: #FFFFFF;
  478. background:#018C39;
  479. border-radius: 44upx;
  480. }
  481. }
  482. }
  483. </style>
  484. <style lang="less" scoped>
  485. .coupon {
  486. height: 100%;
  487. }
  488. /*优惠券列表公共*/
  489. .coupon-list {
  490. }
  491. .coupon-list .item {
  492. display: flex;
  493. flex-direction: column;
  494. justify-content: center;
  495. align-items: center;
  496. width: 100%;
  497. height: 1.7 * 100rpx;
  498. margin-bottom: 0.16 * 100rpx;
  499. }
  500. .coupon-list .item .money {
  501. background-size: 100% 100%;
  502. width: 2.4 * 100rpx;
  503. height: 100%;
  504. color: #fff;
  505. font-size: 0.36 * 100rpx;
  506. font-weight: bold;
  507. text-align: center;
  508. display: flex;
  509. flex-direction: column;
  510. align-items: center;
  511. justify-content: center;
  512. position: relative;
  513. }
  514. .coupon-list .item .money .img{
  515. position: absolute;
  516. width: 2.4 * 100rpx;
  517. height: 100%;
  518. color: #fff;
  519. }
  520. .coupon-list .item .money .num {
  521. font-size: 0.6 * 100rpx;
  522. }
  523. .coupon-list .item .money .pic-num {
  524. font-size: 20rpx;
  525. z-index: 99;
  526. }
  527. .coupon-list .item .text {
  528. width: 4.5 * 100rpx;
  529. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  530. background-color: #fff;
  531. box-sizing: border-box;
  532. }
  533. .coupon-list .item .text .condition {
  534. font-size: 0.3 * 100rpx;
  535. color: #282828;
  536. height: 0.93 * 100rpx;
  537. line-height: 0.93 * 100rpx;
  538. border-bottom: 1px solid #f0f0f0;
  539. }
  540. .coupon-list .item .text .data {
  541. font-size: 0.2 * 100rpx;
  542. color: #999;
  543. height: 0.76 * 100rpx;
  544. }
  545. .coupon-list .item .text .data .bnt {
  546. width: 1.36 * 100rpx;
  547. height: 0.44 * 100rpx;
  548. border-radius: 0.22 * 100rpx;
  549. font-size: 0.22 * 100rpx;
  550. color: #fff;
  551. text-align: center;
  552. line-height: 0.44 * 100rpx;
  553. background-color: red;
  554. }
  555. .coupon-list .item .text .data .bnt.gray {
  556. background-color: #ccc;
  557. }
  558. .message-box{
  559. box-sizing: border-box;
  560. width: 693upx;
  561. height: 84upx;
  562. background: #F3FFFD;
  563. border: 1px solid #C7E9E5;
  564. box-shadow: 0px 4upx 12upx 0px rgba(90, 203, 138, 0.16);
  565. border-radius: 16upx;
  566. position: fixed;
  567. left: 50%;
  568. transform: translateX(-50%);
  569. bottom: 128upx;
  570. z-index: 99;
  571. display: flex;
  572. align-items: center;
  573. justify-content: space-between;
  574. padding: 0 20upx 0 30upx;
  575. .left{
  576. width: 80%;
  577. display: flex;
  578. align-items: center;
  579. image{
  580. width: 24upx;
  581. height: 24upx;
  582. margin-right: 18upx;
  583. }
  584. .text{
  585. width: 90%;
  586. font-size: 28upx;
  587. font-family: PingFang SC;
  588. font-weight: 500;
  589. color:#018C39;
  590. }
  591. }
  592. .btn{
  593. width: 100upx;
  594. height: 48upx;
  595. line-height: 48upx;
  596. text-align: center;
  597. font-size: 24upx;
  598. font-family: PingFang SC;
  599. font-weight: 500;
  600. color: #FFFFFF;
  601. border: 1px solid #D2E6FF;
  602. background: linear-gradient(135deg, #66b2ef 0%,#018C39 100%);
  603. border-radius: 24upx;
  604. margin-left: 30upx;
  605. }
  606. }
  607. </style>