confirmPackageOrder.vue 16 KB

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