confirmOrder.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  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 v-for="(item,index) in carts" :key="index" class="item">
  33. <view class="img-box">
  34. <image :src="item.productAttrImage!=null?item.productAttrImage:item.productImage" mode="aspectFill"></image>
  35. </view>
  36. <view class="info-box">
  37. <view>
  38. <view class="name-box ellipsis2">
  39. <view class="tag">{{utils.getDictLabelName("storeProductType",item.productType)}}</view>{{item.productName}}
  40. </view>
  41. <view class="spec ellipsis2">{{item.productAttrName}}</view>
  42. </view>
  43. <view class="price-num">
  44. <view class="price">
  45. <text class="unit">¥</text>
  46. <text class="num">{{item.price.toFixed(2)}}</text>
  47. </view>
  48. <view class="num">x{{item.cartNum}}</view>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 小计 -->
  53. <view class="sub-total">
  54. <text class="label">小计:</text>
  55. <view class="price">
  56. <text class="unit">¥</text>
  57. <text class="num">{{price.totalPrice.toFixed(2)}}</text>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 积分 -->
  62. <view class="points">
  63. <view class="left">
  64. <image src="../../static/images/points.png" mode=""></image>
  65. <text class="text">可用积分</text>
  66. </view>
  67. <view class="right">
  68. <text class="text">{{price.usedIntegral}}积分</text>
  69. <evan-switch @change="integralChange" v-model="checked" activeColor="#2BC7B9" inactiveColor="rgba(0, 0, 0, 0.1)"></evan-switch>
  70. </view>
  71. </view>
  72. <view class="points" @click="openCoupon()">
  73. <view class="left">
  74. <text class="text">优惠券</text>
  75. </view>
  76. <view class="right">
  77. <text class="text">{{couponText}}</text>
  78. <image src="/static/images/arrow4.png" mode=""></image>
  79. </view>
  80. </view>
  81. <view class="points">
  82. <view class="left">
  83. <text class="text">运费</text>
  84. </view>
  85. <view class="right">
  86. <text class="text" v-if="address!=null">{{price.payPostage==null||price.payPostage==0?'免运费':price.payPostage.toFixed(2)}}</text>
  87. <text class="text" v-if="address==null">--</text>
  88. </view>
  89. </view>
  90. <view class="points">
  91. <view class="left">
  92. <text class="text">服务费</text>
  93. </view>
  94. <view class="right">
  95. <text class="text">{{price.serviceFee.toFixed(2)}}</text>
  96. </view>
  97. </view>
  98. <!-- 备注 -->
  99. <view class="remarks">
  100. <input type="text" v-model="form.mark" placeholder="备注留言(选填)" placeholder-class="input" />
  101. </view>
  102. </view>
  103. <!-- 底部按钮 -->
  104. <view class="btn-foot">
  105. <view class="right">
  106. <view class="total">
  107. <text class="label">合计:</text>
  108. <view class="price">
  109. <text class="unit">¥</text>
  110. <text class="num">{{price.payPrice.toFixed(2)}}</text>
  111. </view>
  112. </view>
  113. <view class="btn" @click="submitOrder">提交订单</view>
  114. </view>
  115. </view>
  116. <popupBottom ref="popup" :visible.sync="couponVisible" title=" " bgColor="#f5f5f5" radius="30" maxHeight="60%">
  117. <view class="coupon" style="height:650rpx;">
  118. <div class="coupon-list" v-if="couponsList.length > 0">
  119. <div class="item acea-row row-center-wrapper" v-for="(item, index) in couponsList" :key="index">
  120. <div class="money" >
  121. <image v-if="item.status==0" class="img" src="../../static/images/coupon1.png" mode="widthFix"></image>
  122. <image v-if="item.status!=0" class="img" src="../../static/images/coupon2.png" mode="widthFix"></image>
  123. <div style="z-index: 999;">
  124. ¥<span class="num">{{ item.couponPrice }}</span>
  125. </div>
  126. <div class="pic-num" >满{{ item.useMinPrice }}元可用</div>
  127. </div>
  128. <div class="text">
  129. <div class="condition line1">
  130. {{ item.couponTitle }}
  131. </div>
  132. <div class="data acea-row row-between-wrapper">
  133. <div >{{ item.limitTime }}到期</div>
  134. <div class="bnt bg-color-red" @click="couponSelect(item)" >选择</div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <view v-if="couponsList.length == 0" class="no-data-box" >
  140. <image src="/static/images/no_data.png" mode="aspectFit"></image>
  141. <view class="empty-title">暂无数据</view>
  142. </view>
  143. </view>
  144. </popupBottom>
  145. </view>
  146. </template>
  147. <script>
  148. import {getWeixinOrderTemps} from '@/api/common'
  149. import {confirm,computed,create} from '@/api/storeOrder'
  150. import { getMyEnableCouponList } from '@/api/coupon'
  151. import EvanSwitch from '@/components/evan-switch/evan-switch.vue'
  152. import popupBottom from '@/components/px-popup-bottom/px-popup-bottom.vue'
  153. export default {
  154. components: {
  155. EvanSwitch,
  156. popupBottom
  157. },
  158. data() {
  159. return {
  160. temps:[],
  161. couponUserId:null,
  162. couponText:"请选择",
  163. couponsList:[],
  164. couponVisible:false,
  165. price:{
  166. payPrice:0,
  167. totalPostage:0,
  168. usedIntegral:0,
  169. totalPrice:0.00,
  170. },
  171. address:null,
  172. carts:[],
  173. checked: false,
  174. type:null,
  175. cartIds:null,
  176. form:{
  177. useIntegral:0,
  178. orderKey:null,
  179. addressId:null,
  180. mark:null,
  181. companyId:null,
  182. companyUserId:null
  183. }
  184. }
  185. },
  186. onLoad(option) {
  187. this.form.companyId=option.companyId;
  188. this.form.companyUserId=option.companyUserId;
  189. this.cartIds=option.cartIds;
  190. this.type=option.type;
  191. this.confirm();
  192. uni.$on('updateAddress', (e) => {
  193. this.address=e;
  194. this.form.addressId=e.id;
  195. this.computed()
  196. })
  197. this.getWeixinOrderTemps();
  198. },
  199. methods: {
  200. getWeixinOrderTemps:function(){
  201. getWeixinOrderTemps().then(
  202. res => {
  203. if(res.code==200){
  204. this.temps=res.temp
  205. console.log(this.temps)
  206. }else{
  207. }
  208. },
  209. rej => {}
  210. );
  211. },
  212. couponSelect(item){
  213. this.couponText="-¥"+item.couponPrice.toFixed(2);
  214. this.couponUserId=item.id;
  215. this.couponVisible=false;
  216. this.computed();
  217. },
  218. openCoupon(){
  219. let that = this;
  220. var data={couponType:0,useMinPrice:this.price.payPrice};
  221. getMyEnableCouponList(data).then(res => {
  222. this.couponVisible=true;
  223. that.couponsList = res.data
  224. })
  225. },
  226. integralChange(e){
  227. console.log(e)
  228. this.form.useIntegral=e?1:0
  229. this.computed()
  230. },
  231. confirm(item){
  232. let data = {type:this.type,cartIds:this.cartIds};
  233. confirm(data).then(
  234. res => {
  235. if(res.code==200){
  236. this.carts=res.carts;
  237. this.form.orderKey=res.orderKey;
  238. if(res.address!=null){
  239. this.form.addressId=res.address.id;
  240. this.address=res.address;
  241. console.log(this.form.addreddId)
  242. }
  243. this.computed()
  244. }else{
  245. uni.showToast({
  246. icon:'none',
  247. title: res.msg,
  248. });
  249. }
  250. },
  251. rej => {}
  252. );
  253. },
  254. computed(){
  255. let data = {companyId:this.form.companyId,couponUserId:this.couponUserId,orderKey:this.form.orderKey,addressId:this.form.addressId,useIntegral:this.form.useIntegral};
  256. computed(data).then(
  257. res => {
  258. if(res.code==200){
  259. console.log(res)
  260. this.price=res.data
  261. }else{
  262. if(res.code==501){
  263. uni.showToast({
  264. icon:'none',
  265. title: res.msg,
  266. });
  267. setTimeout(function(){
  268. uni.navigateBack({
  269. delta:1
  270. })
  271. },500);
  272. return;
  273. }
  274. else{
  275. uni.showToast({
  276. icon:'none',
  277. title: res.msg,
  278. });
  279. }
  280. }
  281. },
  282. rej => {}
  283. );
  284. },
  285. // 提交订单
  286. submitOrder() {
  287. var that=this;
  288. if(this.form.orderKey==null){
  289. uni.showToast({
  290. icon:'none',
  291. title: '订单KEY不存在',
  292. });
  293. return;
  294. }
  295. if(this.form.addressId==null){
  296. uni.showToast({
  297. icon:'none',
  298. title: '收货地址不能为空',
  299. });
  300. return;
  301. }
  302. uni.requestSubscribeMessage({
  303. tmplIds: this.temps,
  304. success(res) {
  305. that.createOrder();
  306. },
  307. fail(res) {
  308. that.createOrder();
  309. }
  310. })
  311. },
  312. createOrder(){
  313. var that=this;
  314. var data=null;
  315. var tuiUserId=uni.getStorageSync('tuiUserId');
  316. uni.showLoading({
  317. title: '正在处理中...'
  318. });
  319. if(tuiUserId!=null&&tuiUserId!=undefined&&tuiUserId>0){
  320. data = {orderCreateType:1,tuiUserId:tuiUserId,companyId:this.form.companyId,companyUserId:this.form.companyUserId,couponUserId:this.couponUserId,mark:this.form.mark,orderKey:this.form.orderKey,addressId:this.form.addressId,useIntegral:this.form.useIntegral,payType:1};
  321. }
  322. else{
  323. data = {orderCreateType:1,companyId:this.form.companyId,companyUserId:this.form.companyUserId,couponUserId:this.couponUserId,mark:this.form.mark,orderKey:this.form.orderKey,addressId:this.form.addressId,useIntegral:this.form.useIntegral,payType:1};
  324. }
  325. create(data).then(
  326. res => {
  327. uni.hideLoading()
  328. if(res.code==200){
  329. uni.hideLoading()
  330. if(res.order.isPrescribe==1){
  331. setTimeout(function(){
  332. uni.redirectTo({
  333. url:"prescribe?orderId="+res.order.id
  334. })
  335. },200);
  336. }
  337. else{
  338. setTimeout(function(){
  339. uni.redirectTo({
  340. url: './paymentOrder?orderId='+res.order.id
  341. })
  342. },200);
  343. }
  344. return;
  345. }
  346. else{
  347. if(res.code==501){
  348. uni.showToast({
  349. icon:'none',
  350. title: res.msg,
  351. });
  352. setTimeout(function(){
  353. uni.navigateBack({
  354. delta:1
  355. })
  356. },200);
  357. return;
  358. }
  359. else{
  360. uni.showToast({
  361. icon:'none',
  362. title: res.msg,
  363. });
  364. }
  365. }
  366. },
  367. rej => {}
  368. );
  369. },
  370. openAddress(){
  371. uni.navigateTo({
  372. url: '/pages_user/user/address'
  373. })
  374. }
  375. }
  376. }
  377. </script>
  378. <style lang="scss">
  379. .inner-box{
  380. padding: 20upx 20upx 140upx;
  381. .address-box{
  382. box-sizing: border-box;
  383. min-height: 171upx;
  384. background: #FFFFFF;
  385. border-radius: 16upx;
  386. background-image: url(../../static/images/address_bg.png);
  387. background-repeat: no-repeat;
  388. background-size: 100% 30upx;
  389. background-position: left bottom;
  390. padding: 38upx 30upx 36upx;
  391. display: flex;
  392. align-items: center;
  393. justify-content: space-between;
  394. .left{
  395. width: 92%;
  396. .name-box{
  397. display: flex;
  398. align-items: center;
  399. .text{
  400. font-size: 32upx;
  401. font-family: PingFang SC;
  402. font-weight: bold;
  403. color: #111111;
  404. line-height: 1;
  405. &.name{
  406. margin-right: 30upx;
  407. }
  408. }
  409. }
  410. .address{
  411. font-size: 28upx;
  412. font-family: PingFang SC;
  413. font-weight: 500;
  414. color: #666666;
  415. line-height: 42upx;
  416. text-align:left;
  417. margin-top: 23upx;
  418. }
  419. }
  420. .arrow-box{
  421. width: 12upx;
  422. height: 23upx;
  423. display: flex;
  424. align-items: cenetr;
  425. justify-content: cenetr;
  426. image{
  427. width: 100%;
  428. height: 100%;
  429. }
  430. }
  431. }
  432. .goods-list{
  433. margin-top: 20upx;
  434. padding: 0 30upx;
  435. background-color: #FFFFFF;
  436. border-radius: 16upx;
  437. .item{
  438. padding: 30upx 0;
  439. border-bottom: 1px solid #EDEEEF;
  440. display: flex;
  441. align-items: center;
  442. .img-box{
  443. width: 160upx;
  444. height: 160upx;
  445. margin-right: 30upx;
  446. image{
  447. width: 100%;
  448. height: 100%;
  449. }
  450. }
  451. .info-box{
  452. width: calc(100% - 190upx);
  453. height: 160upx;
  454. display: flex;
  455. flex-direction: column;
  456. justify-content: space-between;
  457. .name-box{
  458. font-size: 28upx;
  459. font-family: PingFang SC;
  460. font-weight: 500;
  461. color: #111111;
  462. line-height: 40upx;
  463. .tag{
  464. display: inline-block;
  465. padding: 0 6upx;
  466. height: 30upx;
  467. background: linear-gradient(90deg, #2BC7B9 0%, #2BC7A4 100%);
  468. border-radius: 4upx;
  469. margin-right: 10upx;
  470. font-size: 22upx;
  471. font-family: PingFang SC;
  472. font-weight: bold;
  473. color: #FFFFFF;
  474. line-height: 30upx;
  475. float: left;
  476. margin-top: 7upx;
  477. }
  478. }
  479. .spec{
  480. margin-top: 10upx;
  481. font-size: 24upx;
  482. font-family: PingFang SC;
  483. font-weight: 500;
  484. color: #999999;
  485. line-height: 1;
  486. }
  487. .price-num{
  488. display: flex;
  489. align-items: center;
  490. justify-content: space-between;
  491. .price{
  492. display: flex;
  493. align-items: flex-end;
  494. .unit{
  495. font-size: 24upx;
  496. font-family: PingFang SC;
  497. font-weight: 500;
  498. color: #111111;
  499. line-height: 1.2;
  500. margin-right: 4upx;
  501. }
  502. .num{
  503. font-size: 32upx;
  504. font-family: PingFang SC;
  505. font-weight: 500;
  506. color: #111111;
  507. line-height: 1;
  508. }
  509. }
  510. .num{
  511. font-size: 24upx;
  512. font-family: PingFang SC;
  513. font-weight: 500;
  514. color: #999999;
  515. line-height: 1;
  516. }
  517. }
  518. }
  519. }
  520. .sub-total{
  521. height: 88upx;
  522. display: flex;
  523. align-items: center;
  524. justify-content: flex-end;
  525. .label{
  526. font-size: 24upx;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. color: #999999;
  530. }
  531. .price{
  532. display: flex;
  533. align-items: flex-end;
  534. .unit{
  535. font-size: 24upx;
  536. font-family: PingFang SC;
  537. font-weight: 500;
  538. color: #FF6633;
  539. line-height: 1.2;
  540. margin-right: 4upx;
  541. }
  542. .num{
  543. font-size: 32upx;
  544. font-family: PingFang SC;
  545. font-weight: bold;
  546. color: #FF6633;
  547. line-height: 1;
  548. }
  549. }
  550. }
  551. }
  552. .points{
  553. height: 88upx;
  554. padding: 0 30upx;
  555. background: #FFFFFF;
  556. border-radius: 16upx;
  557. display: flex;
  558. align-items: center;
  559. justify-content: space-between;
  560. .left{
  561. display: flex;
  562. align-items: center;
  563. image{
  564. width: 28upx;
  565. height: 28upx;
  566. margin-right: 20upx;
  567. }
  568. .text{
  569. font-size: 28upx;
  570. font-family: PingFang SC;
  571. font-weight: 500;
  572. color: #666666;
  573. }
  574. }
  575. .right{
  576. display: flex;
  577. align-items: center;
  578. .text{
  579. font-size: 28upx;
  580. font-family: PingFang SC;
  581. font-weight: 500;
  582. color: #111111;
  583. }
  584. image{
  585. margin-left: 15upx;
  586. width: 14upx;
  587. height: 24upx;
  588. }
  589. }
  590. }
  591. .remarks{
  592. height: 88upx;
  593. padding: 0 30upx;
  594. background: #FFFFFF;
  595. border-radius: 16upx;
  596. margin-top: 20upx;
  597. display: flex;
  598. align-items: center;
  599. input{
  600. width: 100%;
  601. font-size: 28upx;
  602. font-family: PingFang SC;
  603. font-weight: 500;
  604. color: #000000;
  605. }
  606. .input{
  607. font-size: 28upx;
  608. font-family: PingFang SC;
  609. font-weight: 500;
  610. color: #999999;
  611. }
  612. }
  613. }
  614. .btn-foot{
  615. box-sizing: border-box;
  616. width: 100%;
  617. height: 121upx;
  618. background: #FFFFFF;
  619. padding: 16upx 30upx 16upx 60upx;
  620. display: flex;
  621. align-items: center;
  622. justify-content: flex-end;
  623. position: fixed;
  624. left: 0;
  625. bottom: 0;
  626. z-index: 99;
  627. .right{
  628. display: flex;
  629. align-items: center;
  630. .total{
  631. display: flex;
  632. align-items: flex-end;
  633. margin-right: 36upx;
  634. .label{
  635. font-size: 26upx;
  636. font-family: PingFang SC;
  637. font-weight: 500;
  638. color: #999999;
  639. line-height: 1.5;
  640. }
  641. .price{
  642. display: flex;
  643. align-items: flex-end;
  644. .unit{
  645. font-size: 32upx;
  646. font-family: PingFang SC;
  647. font-weight: bold;
  648. color: #FF6633;
  649. line-height: 1.2;
  650. margin-right: 10upx;
  651. }
  652. .num{
  653. font-size: 50upx;
  654. font-family: PingFang SC;
  655. font-weight: bold;
  656. color: #FF6633;
  657. line-height: 1;
  658. }
  659. }
  660. }
  661. .btn{
  662. width: 200upx;
  663. height: 88upx;
  664. line-height: 88upx;
  665. text-align: center;
  666. font-size: 30upx;
  667. font-family: PingFang SC;
  668. font-weight: bold;
  669. color: #FFFFFF;
  670. background: #2BC7B9;
  671. border-radius: 44upx;
  672. }
  673. }
  674. }
  675. </style>
  676. <style lang="less" scoped>
  677. .coupon {
  678. height: 100%;
  679. }
  680. /*优惠券列表公共*/
  681. .coupon-list {
  682. }
  683. .coupon-list .item {
  684. display: flex;
  685. flex-direction: column;
  686. justify-content: center;
  687. align-items: center;
  688. width: 100%;
  689. height: 1.7 * 100rpx;
  690. margin-bottom: 0.16 * 100rpx;
  691. }
  692. .coupon-list .item .money {
  693. background-size: 100% 100%;
  694. width: 2.4 * 100rpx;
  695. height: 100%;
  696. color: #fff;
  697. font-size: 0.36 * 100rpx;
  698. font-weight: bold;
  699. text-align: center;
  700. display: flex;
  701. flex-direction: column;
  702. align-items: center;
  703. justify-content: center;
  704. position: relative;
  705. }
  706. .coupon-list .item .money .img{
  707. position: absolute;
  708. width: 2.4 * 100rpx;
  709. height: 100%;
  710. color: #fff;
  711. }
  712. .coupon-list .item .money .num {
  713. font-size: 0.6 * 100rpx;
  714. }
  715. .coupon-list .item .money .pic-num {
  716. font-size: 20rpx;
  717. z-index: 99;
  718. }
  719. .coupon-list .item .text {
  720. width: 4.5 * 100rpx;
  721. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  722. background-color: #fff;
  723. box-sizing: border-box;
  724. }
  725. .coupon-list .item .text .condition {
  726. font-size: 0.3 * 100rpx;
  727. color: #282828;
  728. height: 0.93 * 100rpx;
  729. line-height: 0.93 * 100rpx;
  730. border-bottom: 1px solid #f0f0f0;
  731. }
  732. .coupon-list .item .text .data {
  733. font-size: 0.2 * 100rpx;
  734. color: #999;
  735. height: 0.76 * 100rpx;
  736. }
  737. .coupon-list .item .text .data .bnt {
  738. width: 1.36 * 100rpx;
  739. height: 0.44 * 100rpx;
  740. border-radius: 0.22 * 100rpx;
  741. font-size: 0.22 * 100rpx;
  742. color: #fff;
  743. text-align: center;
  744. line-height: 0.44 * 100rpx;
  745. background-color: red;
  746. }
  747. .coupon-list .item .text .data .bnt.gray {
  748. background-color: #ccc;
  749. }
  750. </style>