confirmCreateOrder.vue 18 KB

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