confirmOrder.vue 14 KB

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