confirmOrder.vue 12 KB

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