confirmOrder.vue 13 KB

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