confirmPackageOrder.vue 17 KB

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