confirmPackageOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. uni.requestSubscribeMessage({
  247. tmplIds: this.temps,
  248. success(res) {
  249. that.createPackageOrder();
  250. },
  251. fail(res) {
  252. that.createPackageOrder();
  253. }
  254. })
  255. },
  256. createPackageOrder(){
  257. var that=this;
  258. uni.showLoading({
  259. title: '正在处理中...'
  260. });
  261. let data = {couponUserId:this.couponUserId,mark:this.form.mark,orderKey:this.form.orderKey,addressId:this.form.addressId,packageId:this.packageId,companyUserId:this.companyUserId};
  262. createPackageOrder(data).then(
  263. res => {
  264. uni.hideLoading()
  265. if(res.code==200){
  266. if(res.order.isPrescribe==1){
  267. setTimeout(function(){
  268. uni.redirectTo({
  269. url:"prescribe?orderId="+res.order.id
  270. })
  271. },200);
  272. }
  273. else{
  274. setTimeout(function(){
  275. uni.redirectTo({
  276. url: './paymentOrder?orderId='+res.order.id
  277. })
  278. },200);
  279. }
  280. return;
  281. }
  282. else{
  283. if(res.code==501){
  284. uni.showToast({
  285. icon:'none',
  286. title: res.msg,
  287. });
  288. setTimeout(function(){
  289. uni.navigateBack({
  290. delta:1
  291. })
  292. },200);
  293. return;
  294. }
  295. else{
  296. uni.showToast({
  297. icon:'none',
  298. title: res.msg,
  299. });
  300. }
  301. }
  302. },
  303. rej => {}
  304. );
  305. },
  306. openAddress(){
  307. uni.navigateTo({
  308. url: '/pages_user/user/address'
  309. })
  310. }
  311. }
  312. }
  313. </script>
  314. <style lang="scss">
  315. .inner-box{
  316. padding: 20upx 20upx 140upx;
  317. .address-box{
  318. box-sizing: border-box;
  319. min-height: 171upx;
  320. background: #FFFFFF;
  321. border-radius: 16upx;
  322. background-image: url(../../static/images/address_bg.png);
  323. background-repeat: no-repeat;
  324. background-size: 100% 30upx;
  325. background-position: left bottom;
  326. padding: 38upx 30upx 36upx;
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. .left{
  331. width: 92%;
  332. .name-box{
  333. display: flex;
  334. align-items: center;
  335. .text{
  336. font-size: 32upx;
  337. font-family: PingFang SC;
  338. font-weight: bold;
  339. color: #111111;
  340. line-height: 1;
  341. &.name{
  342. margin-right: 30upx;
  343. }
  344. }
  345. }
  346. .address{
  347. font-size: 28upx;
  348. font-family: PingFang SC;
  349. font-weight: 500;
  350. color: #666666;
  351. line-height: 42upx;
  352. text-align:left;
  353. margin-top: 23upx;
  354. }
  355. }
  356. .arrow-box{
  357. width: 12upx;
  358. height: 23upx;
  359. display: flex;
  360. align-items: cenetr;
  361. justify-content: cenetr;
  362. image{
  363. width: 100%;
  364. height: 100%;
  365. }
  366. }
  367. }
  368. .goods-list{
  369. margin-top: 20upx;
  370. padding: 0 30upx;
  371. background-color: #FFFFFF;
  372. border-radius: 16upx;
  373. .item{
  374. padding: 30upx 0;
  375. border-bottom: 1px solid #EDEEEF;
  376. display: flex;
  377. align-items: center;
  378. .img-box{
  379. width: 160upx;
  380. height: 160upx;
  381. margin-right: 30upx;
  382. image{
  383. width: 100%;
  384. height: 100%;
  385. }
  386. }
  387. .info-box{
  388. width: calc(100% - 190upx);
  389. height: 160upx;
  390. display: flex;
  391. flex-direction: column;
  392. justify-content: space-between;
  393. .name-box{
  394. font-size: 28upx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. color: #111111;
  398. line-height: 40upx;
  399. .tag{
  400. display: inline-block;
  401. padding: 0 6upx;
  402. height: 30upx;
  403. background: linear-gradient(90deg, #2BC7B9 0%, #2BC7A4 100%);
  404. border-radius: 4upx;
  405. margin-right: 10upx;
  406. font-size: 22upx;
  407. font-family: PingFang SC;
  408. font-weight: bold;
  409. color: #FFFFFF;
  410. line-height: 30upx;
  411. float: left;
  412. margin-top: 7upx;
  413. }
  414. }
  415. .spec{
  416. margin-top: 10upx;
  417. font-size: 24upx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #999999;
  421. line-height: 1;
  422. }
  423. .price-num{
  424. display: flex;
  425. align-items: center;
  426. justify-content: space-between;
  427. .price{
  428. display: flex;
  429. align-items: flex-end;
  430. .unit{
  431. font-size: 24upx;
  432. font-family: PingFang SC;
  433. font-weight: 500;
  434. color: #111111;
  435. line-height: 1.2;
  436. margin-right: 4upx;
  437. }
  438. .num{
  439. font-size: 32upx;
  440. font-family: PingFang SC;
  441. font-weight: 500;
  442. color: #111111;
  443. line-height: 1;
  444. }
  445. }
  446. .num{
  447. font-size: 24upx;
  448. font-family: PingFang SC;
  449. font-weight: 500;
  450. color: #999999;
  451. line-height: 1;
  452. }
  453. }
  454. }
  455. }
  456. .sub-total{
  457. height: 88upx;
  458. display: flex;
  459. align-items: center;
  460. justify-content: flex-end;
  461. .label{
  462. font-size: 24upx;
  463. font-family: PingFang SC;
  464. font-weight: 500;
  465. color: #999999;
  466. }
  467. .price{
  468. display: flex;
  469. align-items: flex-end;
  470. .unit{
  471. font-size: 24upx;
  472. font-family: PingFang SC;
  473. font-weight: 500;
  474. color: #FF6633;
  475. line-height: 1.2;
  476. margin-right: 4upx;
  477. }
  478. .num{
  479. font-size: 32upx;
  480. font-family: PingFang SC;
  481. font-weight: bold;
  482. color: #FF6633;
  483. line-height: 1;
  484. }
  485. }
  486. }
  487. }
  488. .points{
  489. height: 88upx;
  490. padding: 0 30upx;
  491. background: #FFFFFF;
  492. border-radius: 16upx;
  493. margin-top: 20upx;
  494. display: flex;
  495. align-items: center;
  496. justify-content: space-between;
  497. .left{
  498. display: flex;
  499. align-items: center;
  500. image{
  501. width: 28upx;
  502. height: 28upx;
  503. margin-right: 20upx;
  504. }
  505. .text{
  506. font-size: 28upx;
  507. font-family: PingFang SC;
  508. font-weight: 500;
  509. color: #666666;
  510. }
  511. }
  512. .right{
  513. display: flex;
  514. align-items: center;
  515. .text{
  516. font-size: 28upx;
  517. font-family: PingFang SC;
  518. font-weight: 500;
  519. color: #111111;
  520. }
  521. image{
  522. margin-left: 15upx;
  523. width: 14upx;
  524. height: 24upx;
  525. }
  526. }
  527. }
  528. .remarks{
  529. height: 88upx;
  530. padding: 0 30upx;
  531. background: #FFFFFF;
  532. border-radius: 16upx;
  533. margin-top: 20upx;
  534. display: flex;
  535. align-items: center;
  536. input{
  537. width: 100%;
  538. font-size: 28upx;
  539. font-family: PingFang SC;
  540. font-weight: 500;
  541. color: #000000;
  542. }
  543. .input{
  544. font-size: 28upx;
  545. font-family: PingFang SC;
  546. font-weight: 500;
  547. color: #999999;
  548. }
  549. }
  550. }
  551. .btn-foot{
  552. box-sizing: border-box;
  553. width: 100%;
  554. height: 121upx;
  555. background: #FFFFFF;
  556. padding: 16upx 30upx 16upx 60upx;
  557. display: flex;
  558. align-items: center;
  559. justify-content: flex-end;
  560. position: fixed;
  561. left: 0;
  562. bottom: 0;
  563. z-index: 99;
  564. .right{
  565. display: flex;
  566. align-items: center;
  567. .total{
  568. display: flex;
  569. align-items: flex-end;
  570. margin-right: 36upx;
  571. .label{
  572. font-size: 26upx;
  573. font-family: PingFang SC;
  574. font-weight: 500;
  575. color: #999999;
  576. line-height: 1.5;
  577. }
  578. .price{
  579. display: flex;
  580. align-items: flex-end;
  581. .unit{
  582. font-size: 32upx;
  583. font-family: PingFang SC;
  584. font-weight: bold;
  585. color: #FF6633;
  586. line-height: 1.2;
  587. margin-right: 10upx;
  588. }
  589. .num{
  590. font-size: 50upx;
  591. font-family: PingFang SC;
  592. font-weight: bold;
  593. color: #FF6633;
  594. line-height: 1;
  595. }
  596. }
  597. }
  598. .btn{
  599. width: 200upx;
  600. height: 88upx;
  601. line-height: 88upx;
  602. text-align: center;
  603. font-size: 30upx;
  604. font-family: PingFang SC;
  605. font-weight: bold;
  606. color: #FFFFFF;
  607. background: #2BC7B9;
  608. border-radius: 44upx;
  609. }
  610. }
  611. }
  612. </style>
  613. <style lang="less" scoped>
  614. .coupon {
  615. height: 100%;
  616. }
  617. /*优惠券列表公共*/
  618. .coupon-list {
  619. }
  620. .coupon-list .item {
  621. display: flex;
  622. flex-direction: column;
  623. justify-content: center;
  624. align-items: center;
  625. width: 100%;
  626. height: 1.7 * 100rpx;
  627. margin-bottom: 0.16 * 100rpx;
  628. }
  629. .coupon-list .item .money {
  630. background-size: 100% 100%;
  631. width: 2.4 * 100rpx;
  632. height: 100%;
  633. color: #fff;
  634. font-size: 0.36 * 100rpx;
  635. font-weight: bold;
  636. text-align: center;
  637. display: flex;
  638. flex-direction: column;
  639. align-items: center;
  640. justify-content: center;
  641. position: relative;
  642. }
  643. .coupon-list .item .money .img{
  644. position: absolute;
  645. width: 2.4 * 100rpx;
  646. height: 100%;
  647. color: #fff;
  648. }
  649. .coupon-list .item .money .num {
  650. font-size: 0.6 * 100rpx;
  651. }
  652. .coupon-list .item .money .pic-num {
  653. font-size: 20rpx;
  654. z-index: 99;
  655. }
  656. .coupon-list .item .text {
  657. width: 4.5 * 100rpx;
  658. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  659. background-color: #fff;
  660. box-sizing: border-box;
  661. }
  662. .coupon-list .item .text .condition {
  663. font-size: 0.3 * 100rpx;
  664. color: #282828;
  665. height: 0.93 * 100rpx;
  666. line-height: 0.93 * 100rpx;
  667. border-bottom: 1px solid #f0f0f0;
  668. }
  669. .coupon-list .item .text .data {
  670. font-size: 0.2 * 100rpx;
  671. color: #999;
  672. height: 0.76 * 100rpx;
  673. }
  674. .coupon-list .item .text .data .bnt {
  675. width: 1.36 * 100rpx;
  676. height: 0.44 * 100rpx;
  677. border-radius: 0.22 * 100rpx;
  678. font-size: 0.22 * 100rpx;
  679. color: #fff;
  680. text-align: center;
  681. line-height: 0.44 * 100rpx;
  682. background-color: red;
  683. }
  684. .coupon-list .item .text .data .bnt.gray {
  685. background-color: #ccc;
  686. }
  687. </style>