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