confirmPackageOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <view>
  3. <view class="inner-box">
  4. <!-- 收货人 -->
  5. <view class="address-box" v-if="address==null" @click="openAddress()">
  6. <view class="left">
  7. <view class="name-box">
  8. <text class="text name">添加收货地址</text>
  9. </view>
  10. </vie>
  11. </view>
  12. <view class="arrow-box">
  13. <image src="../../static/images/arrow_gray.png" mode=""></image>
  14. </view>
  15. </view>
  16. <view class="address-box" v-if="address!=null" @click="openAddress()">
  17. <view class="left">
  18. <view class="name-box">
  19. <text class="text name">{{address.realName}}</text>
  20. <text class="text" v-if="address.phone!=null">{{utils.parsePhone(address.phone)}}</text>
  21. </view>
  22. <view class="address">
  23. {{address.province}}{{address.city}}{{address.district}}{{address.detail}}
  24. </view>
  25. </view>
  26. <view class="arrow-box">
  27. <image src="../../static/images/arrow_gray.png" mode=""></image>
  28. </view>
  29. </view>
  30. <!-- 药品列表 -->
  31. <view class="goods-list">
  32. <view class="item">
  33. <view class="img-box">
  34. <image :src="package.imgUrl" mode="aspectFill"></image>
  35. </view>
  36. <view class="info-box">
  37. <view>
  38. <view class="name-box ellipsis2">
  39. {{package.title}}
  40. </view>
  41. <view class="spec ellipsis2">{{package.descs}}</view>
  42. </view>
  43. <view class="price-num">
  44. <view class="price">
  45. <text class="unit">¥</text>
  46. <text class="num" v-if="package.payMoney!=null">{{package.payMoney.toFixed(2)}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 小计 -->
  52. <view class="sub-total">
  53. <text class="label">合计:</text>
  54. <view class="price">
  55. <text class="unit">¥</text>
  56. <text class="num" v-if="package.payMoney!=null">{{package.payMoney.toFixed(2)}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="points" @click="openCoupon()">
  61. <view class="left">
  62. <text class="text">优惠券</text>
  63. </view>
  64. <view class="right">
  65. <text class="text">{{couponText}}</text>
  66. <image src="/static/images/arrow4.png" mode=""></image>
  67. </view>
  68. </view>
  69. <!-- 备注 -->
  70. <view class="remarks">
  71. <input type="text" v-model="form.mark" placeholder="备注留言(选填)" placeholder-class="input" />
  72. </view>
  73. </view>
  74. <!-- 底部按钮 -->
  75. <view class="btn-foot">
  76. <view class="right">
  77. <view class="total">
  78. <text class="label">应付金额:</text>
  79. <view class="price">
  80. <text class="unit">¥</text>
  81. <text class="num" v-if="totalMoney!=null">{{totalMoney.toFixed(2)}}</text>
  82. </view>
  83. </view>
  84. <view class="btn" @click="submitOrder">提交订单</view>
  85. </view>
  86. </view>
  87. <popupBottom ref="popup" :visible.sync="couponVisible" title=" " bgColor="#f5f5f5" radius="30" maxHeight="60%">
  88. <view class="coupon" style="height:650rpx;">
  89. <div class="coupon-list" v-if="couponsList.length > 0">
  90. <div class="item acea-row row-center-wrapper" v-for="(item, index) in couponsList" :key="index">
  91. <div class="money" >
  92. <image v-if="item.status==0" class="img" src="../../static/images/coupon1.png" mode="widthFix"></image>
  93. <image v-if="item.status!=0" class="img" src="../../static/images/coupon2.png" mode="widthFix"></image>
  94. <div style="z-index: 999;">
  95. ¥<span class="num">{{ item.couponPrice }}</span>
  96. </div>
  97. <div class="pic-num" >满{{ item.useMinPrice }}元可用</div>
  98. </div>
  99. <div class="text">
  100. <div class="condition line1">
  101. {{ item.couponTitle }}
  102. </div>
  103. <div class="data acea-row row-between-wrapper">
  104. <div >{{ item.limitTime }}到期</div>
  105. <div class="bnt bg-color-red" @click="couponSelect(item)" >选择</div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <view v-if="couponsList.length == 0" class="no-data-box" >
  111. <image src="/static/images/no_data.png" mode="aspectFit"></image>
  112. <view class="empty-title">暂无数据</view>
  113. </view>
  114. </view>
  115. </popupBottom>
  116. </view>
  117. </template>
  118. <script>
  119. import {getWeixinTemps} from '@/api/common'
  120. import {confirmPackageOrder,computedPackageOrder,createPackageOrder} from '@/api/storeOrder'
  121. import { getMyEnableCouponList } from '@/api/coupon'
  122. import EvanSwitch from '@/components/evan-switch/evan-switch.vue'
  123. import popupBottom from '@/components/px-popup-bottom/px-popup-bottom.vue'
  124. export default {
  125. components: {
  126. EvanSwitch,
  127. popupBottom
  128. },
  129. data() {
  130. return {
  131. temps:[],
  132. totalMoney:0,
  133. couponUserId:null,
  134. couponText:"请选择",
  135. couponsList:[],
  136. couponVisible:false,
  137. companyUserId:null,
  138. packageId:null,
  139. address:null,
  140. package:{},
  141. // checked: false,
  142. // type:null,
  143. // cartIds:null,
  144. form:{
  145. // useIntegral:0,
  146. orderKey:null,
  147. addressId:null,
  148. mark:null,
  149. }
  150. }
  151. },
  152. onLoad(option) {
  153. this.packageId=option.packageId;
  154. this.companyUserId=option.companyUserId;
  155. this.confirmPackageOrder();
  156. uni.$on('updateAddress', (e) => {
  157. this.address=e;
  158. this.form.addressId=e.id;
  159. })
  160. this.getWeixinTemps();
  161. },
  162. onShow() {
  163. },
  164. methods: {
  165. getWeixinTemps:function(){
  166. getWeixinTemps().then(
  167. res => {
  168. if(res.code==200){
  169. this.temps=res.temp
  170. }else{
  171. }
  172. },
  173. rej => {}
  174. );
  175. },
  176. couponSelect(item){
  177. console.log(item)
  178. this.couponText="-¥"+item.couponPrice.toFixed(2);
  179. this.couponUserId=item.id;
  180. this.couponVisible=false;
  181. this.computedPackageOrder();
  182. },
  183. openCoupon(){
  184. let that = this;
  185. var data={packageCateId:this.package.cateId,couponType:1,useMinPrice:this.totalMoney};
  186. getMyEnableCouponList(data).then(res => {
  187. this.couponVisible=true;
  188. that.couponsList = res.data
  189. })
  190. },
  191. confirmPackageOrder(){
  192. let data = {packageId:this.packageId,couponUserId:this.couponUserId};
  193. confirmPackageOrder(data).then(
  194. res => {
  195. if(res.code==200){
  196. this.form.orderKey=res.orderKey;
  197. this.address=res.address;
  198. this.package=res.package;
  199. if(res.address!=null){
  200. this.form.addressId=res.address.id;
  201. }
  202. this.totalMoney=res.totalMoney;
  203. }else{
  204. uni.showToast({
  205. icon:'none',
  206. title: res.msg,
  207. });
  208. }
  209. },
  210. rej => {}
  211. );
  212. },
  213. computedPackageOrder(){
  214. let data = {packageId:this.packageId,couponUserId:this.couponUserId};
  215. computedPackageOrder(data).then(
  216. res => {
  217. if(res.code==200){
  218. this.totalMoney=res.totalMoney;
  219. }else{
  220. uni.showToast({
  221. icon:'none',
  222. title: res.msg,
  223. });
  224. }
  225. },
  226. rej => {}
  227. );
  228. },
  229. // 提交订单
  230. submitOrder() {
  231. var that=this;
  232. if(this.form.orderKey==null){
  233. uni.showToast({
  234. icon:'none',
  235. title: '订单KEY不存在',
  236. });
  237. return;
  238. }
  239. if(this.form.addressId==null){
  240. uni.showToast({
  241. icon:'none',
  242. title: '收货地址不能为空',
  243. });
  244. return;
  245. }
  246. // #ifdef MP-WEIXIN
  247. uni.requestSubscribeMessage({
  248. tmplIds: this.temps,
  249. success(res) {
  250. that.createPackageOrder();
  251. },
  252. fail(res) {
  253. that.createPackageOrder();
  254. }
  255. })
  256. // #endif
  257. // #ifndef MP-WEIXIN
  258. that.createPackageOrder();
  259. // #endif
  260. },
  261. createPackageOrder(){
  262. var that=this;
  263. uni.showLoading({
  264. title: '正在处理中...'
  265. });
  266. let data = {couponUserId:this.couponUserId,mark:this.form.mark,orderKey:this.form.orderKey,addressId:this.form.addressId,packageId:this.packageId,companyUserId:this.companyUserId};
  267. createPackageOrder(data).then(
  268. res => {
  269. uni.hideLoading()
  270. if(res.code==200){
  271. if(res.order.isPrescribe==1){
  272. setTimeout(function(){
  273. uni.redirectTo({
  274. url:"prescribe?orderId="+res.order.id
  275. })
  276. },200);
  277. }
  278. else{
  279. setTimeout(function(){
  280. uni.redirectTo({
  281. url: './paymentOrder?orderId='+res.order.id
  282. })
  283. },200);
  284. }
  285. return;
  286. }
  287. else{
  288. if(res.code==501){
  289. uni.showToast({
  290. icon:'none',
  291. title: res.msg,
  292. });
  293. setTimeout(function(){
  294. uni.navigateBack({
  295. delta:1
  296. })
  297. },200);
  298. return;
  299. }
  300. else{
  301. uni.showToast({
  302. icon:'none',
  303. title: res.msg,
  304. });
  305. }
  306. }
  307. },
  308. rej => {}
  309. );
  310. },
  311. openAddress(){
  312. uni.navigateTo({
  313. url: '/pages_user/user/address'
  314. })
  315. }
  316. }
  317. }
  318. </script>
  319. <style lang="scss">
  320. .inner-box{
  321. padding: 20upx 20upx 140upx;
  322. .address-box{
  323. box-sizing: border-box;
  324. min-height: 171upx;
  325. background: #FFFFFF;
  326. border-radius: 16upx;
  327. background-image: url(../../static/images/address_bg.png);
  328. background-repeat: no-repeat;
  329. background-size: 100% 30upx;
  330. background-position: left bottom;
  331. padding: 38upx 30upx 36upx;
  332. display: flex;
  333. align-items: center;
  334. justify-content: space-between;
  335. .left{
  336. width: 92%;
  337. .name-box{
  338. display: flex;
  339. align-items: center;
  340. .text{
  341. font-size: 32upx;
  342. font-family: PingFang SC;
  343. font-weight: bold;
  344. color: #111111;
  345. line-height: 1;
  346. &.name{
  347. margin-right: 30upx;
  348. }
  349. }
  350. }
  351. .address{
  352. font-size: 28upx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #666666;
  356. line-height: 42upx;
  357. text-align:left;
  358. margin-top: 23upx;
  359. }
  360. }
  361. .arrow-box{
  362. width: 12upx;
  363. height: 23upx;
  364. display: flex;
  365. align-items: cenetr;
  366. justify-content: cenetr;
  367. image{
  368. width: 100%;
  369. height: 100%;
  370. }
  371. }
  372. }
  373. .goods-list{
  374. margin-top: 20upx;
  375. padding: 0 30upx;
  376. background-color: #FFFFFF;
  377. border-radius: 16upx;
  378. .item{
  379. padding: 30upx 0;
  380. border-bottom: 1px solid #EDEEEF;
  381. display: flex;
  382. align-items: center;
  383. .img-box{
  384. width: 160upx;
  385. height: 160upx;
  386. margin-right: 30upx;
  387. image{
  388. width: 100%;
  389. height: 100%;
  390. }
  391. }
  392. .info-box{
  393. width: calc(100% - 190upx);
  394. height: 160upx;
  395. display: flex;
  396. flex-direction: column;
  397. justify-content: space-between;
  398. .name-box{
  399. font-size: 28upx;
  400. font-family: PingFang SC;
  401. font-weight: 500;
  402. color: #111111;
  403. line-height: 40upx;
  404. .tag{
  405. display: inline-block;
  406. padding: 0 6upx;
  407. height: 30upx;
  408. background: linear-gradient(90deg, #38e663 0%, #018C39 100%);
  409. border-radius: 4upx;
  410. margin-right: 10upx;
  411. font-size: 22upx;
  412. font-family: PingFang SC;
  413. font-weight: bold;
  414. color: #FFFFFF;
  415. line-height: 30upx;
  416. float: left;
  417. margin-top: 7upx;
  418. }
  419. }
  420. .spec{
  421. margin-top: 10upx;
  422. font-size: 24upx;
  423. font-family: PingFang SC;
  424. font-weight: 500;
  425. color: #999999;
  426. line-height: 1;
  427. }
  428. .price-num{
  429. display: flex;
  430. align-items: center;
  431. justify-content: space-between;
  432. .price{
  433. display: flex;
  434. align-items: flex-end;
  435. .unit{
  436. font-size: 24upx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #111111;
  440. line-height: 1.2;
  441. margin-right: 4upx;
  442. }
  443. .num{
  444. font-size: 32upx;
  445. font-family: PingFang SC;
  446. font-weight: 500;
  447. color: #111111;
  448. line-height: 1;
  449. }
  450. }
  451. .num{
  452. font-size: 24upx;
  453. font-family: PingFang SC;
  454. font-weight: 500;
  455. color: #999999;
  456. line-height: 1;
  457. }
  458. }
  459. }
  460. }
  461. .sub-total{
  462. height: 88upx;
  463. display: flex;
  464. align-items: center;
  465. justify-content: flex-end;
  466. .label{
  467. font-size: 24upx;
  468. font-family: PingFang SC;
  469. font-weight: 500;
  470. color: #999999;
  471. }
  472. .price{
  473. display: flex;
  474. align-items: flex-end;
  475. .unit{
  476. font-size: 24upx;
  477. font-family: PingFang SC;
  478. font-weight: 500;
  479. color: #FF6633;
  480. line-height: 1.2;
  481. margin-right: 4upx;
  482. }
  483. .num{
  484. font-size: 32upx;
  485. font-family: PingFang SC;
  486. font-weight: bold;
  487. color: #FF6633;
  488. line-height: 1;
  489. }
  490. }
  491. }
  492. }
  493. .points{
  494. height: 88upx;
  495. padding: 0 30upx;
  496. background: #FFFFFF;
  497. border-radius: 16upx;
  498. margin-top: 20upx;
  499. display: flex;
  500. align-items: center;
  501. justify-content: space-between;
  502. .left{
  503. display: flex;
  504. align-items: center;
  505. image{
  506. width: 28upx;
  507. height: 28upx;
  508. margin-right: 20upx;
  509. }
  510. .text{
  511. font-size: 28upx;
  512. font-family: PingFang SC;
  513. font-weight: 500;
  514. color: #666666;
  515. }
  516. }
  517. .right{
  518. display: flex;
  519. align-items: center;
  520. .text{
  521. font-size: 28upx;
  522. font-family: PingFang SC;
  523. font-weight: 500;
  524. color: #111111;
  525. }
  526. image{
  527. margin-left: 15upx;
  528. width: 14upx;
  529. height: 24upx;
  530. }
  531. }
  532. }
  533. .remarks{
  534. height: 88upx;
  535. padding: 0 30upx;
  536. background: #FFFFFF;
  537. border-radius: 16upx;
  538. margin-top: 20upx;
  539. display: flex;
  540. align-items: center;
  541. input{
  542. width: 100%;
  543. font-size: 28upx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #000000;
  547. }
  548. .input{
  549. font-size: 28upx;
  550. font-family: PingFang SC;
  551. font-weight: 500;
  552. color: #999999;
  553. }
  554. }
  555. }
  556. .btn-foot{
  557. box-sizing: border-box;
  558. width: 100%;
  559. height: 121upx;
  560. background: #FFFFFF;
  561. padding: 16upx 30upx 16upx 60upx;
  562. display: flex;
  563. align-items: center;
  564. justify-content: flex-end;
  565. position: fixed;
  566. left: 0;
  567. bottom: 0;
  568. z-index: 99;
  569. .right{
  570. display: flex;
  571. align-items: center;
  572. .total{
  573. display: flex;
  574. align-items: flex-end;
  575. margin-right: 36upx;
  576. .label{
  577. font-size: 26upx;
  578. font-family: PingFang SC;
  579. font-weight: 500;
  580. color: #999999;
  581. line-height: 1.5;
  582. }
  583. .price{
  584. display: flex;
  585. align-items: flex-end;
  586. .unit{
  587. font-size: 32upx;
  588. font-family: PingFang SC;
  589. font-weight: bold;
  590. color: #FF6633;
  591. line-height: 1.2;
  592. margin-right: 10upx;
  593. }
  594. .num{
  595. font-size: 50upx;
  596. font-family: PingFang SC;
  597. font-weight: bold;
  598. color: #FF6633;
  599. line-height: 1;
  600. }
  601. }
  602. }
  603. .btn{
  604. width: 200upx;
  605. height: 88upx;
  606. line-height: 88upx;
  607. text-align: center;
  608. font-size: 30upx;
  609. font-family: PingFang SC;
  610. font-weight: bold;
  611. color: #FFFFFF;
  612. background: #018C39;
  613. border-radius: 44upx;
  614. }
  615. }
  616. }
  617. </style>
  618. <style lang="less" scoped>
  619. .coupon {
  620. height: 100%;
  621. }
  622. /*优惠券列表公共*/
  623. .coupon-list {
  624. }
  625. .coupon-list .item {
  626. display: flex;
  627. flex-direction: column;
  628. justify-content: center;
  629. align-items: center;
  630. width: 100%;
  631. height: 1.7 * 100rpx;
  632. margin-bottom: 0.16 * 100rpx;
  633. }
  634. .coupon-list .item .money {
  635. background-size: 100% 100%;
  636. width: 2.4 * 100rpx;
  637. height: 100%;
  638. color: #fff;
  639. font-size: 0.36 * 100rpx;
  640. font-weight: bold;
  641. text-align: center;
  642. display: flex;
  643. flex-direction: column;
  644. align-items: center;
  645. justify-content: center;
  646. position: relative;
  647. }
  648. .coupon-list .item .money .img{
  649. position: absolute;
  650. width: 2.4 * 100rpx;
  651. height: 100%;
  652. color: #fff;
  653. }
  654. .coupon-list .item .money .num {
  655. font-size: 0.6 * 100rpx;
  656. }
  657. .coupon-list .item .money .pic-num {
  658. font-size: 20rpx;
  659. z-index: 99;
  660. }
  661. .coupon-list .item .text {
  662. width: 4.5 * 100rpx;
  663. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  664. background-color: #fff;
  665. box-sizing: border-box;
  666. }
  667. .coupon-list .item .text .condition {
  668. font-size: 0.3 * 100rpx;
  669. color: #282828;
  670. height: 0.93 * 100rpx;
  671. line-height: 0.93 * 100rpx;
  672. border-bottom: 1px solid #f0f0f0;
  673. }
  674. .coupon-list .item .text .data {
  675. font-size: 0.2 * 100rpx;
  676. color: #999;
  677. height: 0.76 * 100rpx;
  678. }
  679. .coupon-list .item .text .data .bnt {
  680. width: 1.36 * 100rpx;
  681. height: 0.44 * 100rpx;
  682. border-radius: 0.22 * 100rpx;
  683. font-size: 0.22 * 100rpx;
  684. color: #fff;
  685. text-align: center;
  686. line-height: 0.44 * 100rpx;
  687. background-color: red;
  688. }
  689. .coupon-list .item .text .data .bnt.gray {
  690. background-color: #ccc;
  691. }
  692. </style>