confirmPackageOrder.vue 16 KB

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