confirmPackageOrder.vue 17 KB

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