confirmPackageOrder.vue 17 KB

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