confirmPackageOrder.vue 16 KB

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