confirmPackageOrder.vue 17 KB

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