confirmOrder.vue 14 KB

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