confirmOrder.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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||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. storeId:null,
  168. form:{
  169. useIntegral:0,
  170. orderKey:null,
  171. addressId:null,
  172. mark:null,
  173. companyId:null,
  174. companyUserId:null
  175. }
  176. }
  177. },
  178. onLoad(option) {
  179. this.form.companyId=option.companyId;
  180. this.form.companyUserId=option.companyUserId;
  181. this.cartIds=option.cartIds;
  182. this.type=option.type;
  183. this.storeId=option.storeId;
  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:0,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 = {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 = {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};
  318. }
  319. else{
  320. 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};
  321. }
  322. if(this.storeId!=null&& this.storeId>0){
  323. data.storeId=this.storeId;
  324. }
  325. uni.hideLoading()
  326. create(data).then(
  327. res => {
  328. uni.hideLoading()
  329. if(res.code==200){
  330. uni.hideLoading()
  331. if(res.order.isPrescribe==1){
  332. setTimeout(function(){
  333. uni.redirectTo({
  334. url:"prescribe?orderId="+res.order.id
  335. })
  336. },200);
  337. }
  338. else{
  339. setTimeout(function(){
  340. uni.redirectTo({
  341. url: './paymentOrder?orderId='+res.order.id
  342. })
  343. },200);
  344. }
  345. return;
  346. }
  347. else{
  348. if(res.code==501){
  349. uni.showToast({
  350. icon:'none',
  351. title: res.msg,
  352. });
  353. setTimeout(function(){
  354. uni.navigateBack({
  355. delta:1
  356. })
  357. },200);
  358. return;
  359. }
  360. else{
  361. uni.showToast({
  362. icon:'none',
  363. title: res.msg,
  364. });
  365. }
  366. }
  367. },
  368. rej => {}
  369. );
  370. },
  371. openAddress(){
  372. uni.navigateTo({
  373. url: '/pages_user/user/address'
  374. })
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="scss">
  380. .inner-box{
  381. padding: 20upx 20upx 140upx;
  382. .address-box{
  383. box-sizing: border-box;
  384. min-height: 171upx;
  385. background: #FFFFFF;
  386. border-radius: 16upx;
  387. background-image: url(../../static/images/address_bg.png);
  388. background-repeat: no-repeat;
  389. background-size: 100% 30upx;
  390. background-position: left bottom;
  391. padding: 38upx 30upx 36upx;
  392. display: flex;
  393. align-items: center;
  394. justify-content: space-between;
  395. .left{
  396. width: 92%;
  397. .name-box{
  398. display: flex;
  399. align-items: center;
  400. .text{
  401. font-size: 32upx;
  402. font-family: PingFang SC;
  403. font-weight: bold;
  404. color: #111111;
  405. line-height: 1;
  406. &.name{
  407. margin-right: 30upx;
  408. }
  409. }
  410. }
  411. .address{
  412. font-size: 28upx;
  413. font-family: PingFang SC;
  414. font-weight: 500;
  415. color: #666666;
  416. line-height: 42upx;
  417. text-align:left;
  418. margin-top: 23upx;
  419. }
  420. }
  421. .arrow-box{
  422. width: 12upx;
  423. height: 23upx;
  424. display: flex;
  425. align-items: cenetr;
  426. justify-content: cenetr;
  427. image{
  428. width: 100%;
  429. height: 100%;
  430. }
  431. }
  432. }
  433. .goods-list{
  434. margin-top: 20upx;
  435. padding: 0 30upx;
  436. background-color: #FFFFFF;
  437. border-radius: 16upx;
  438. .item{
  439. padding: 30upx 0;
  440. border-bottom: 1px solid #EDEEEF;
  441. display: flex;
  442. align-items: center;
  443. .img-box{
  444. width: 160upx;
  445. height: 160upx;
  446. margin-right: 30upx;
  447. image{
  448. width: 100%;
  449. height: 100%;
  450. }
  451. }
  452. .info-box{
  453. width: calc(100% - 190upx);
  454. height: 160upx;
  455. display: flex;
  456. flex-direction: column;
  457. justify-content: space-between;
  458. .name-box{
  459. font-size: 28upx;
  460. font-family: PingFang SC;
  461. font-weight: 500;
  462. color: #111111;
  463. line-height: 40upx;
  464. .tag{
  465. display: inline-block;
  466. padding: 0 6upx;
  467. height: 30upx;
  468. background: linear-gradient(90deg, #38e663 0%, #018C39 100%);
  469. border-radius: 4upx;
  470. margin-right: 10upx;
  471. font-size: 22upx;
  472. font-family: PingFang SC;
  473. font-weight: bold;
  474. color: #FFFFFF;
  475. line-height: 30upx;
  476. float: left;
  477. margin-top: 7upx;
  478. }
  479. }
  480. .spec{
  481. margin-top: 10upx;
  482. font-size: 24upx;
  483. font-family: PingFang SC;
  484. font-weight: 500;
  485. color: #999999;
  486. line-height: 1;
  487. }
  488. .price-num{
  489. display: flex;
  490. align-items: center;
  491. justify-content: space-between;
  492. .price{
  493. display: flex;
  494. align-items: flex-end;
  495. .unit{
  496. font-size: 24upx;
  497. font-family: PingFang SC;
  498. font-weight: 500;
  499. color: #111111;
  500. line-height: 1.2;
  501. margin-right: 4upx;
  502. }
  503. .num{
  504. font-size: 32upx;
  505. font-family: PingFang SC;
  506. font-weight: 500;
  507. color: #111111;
  508. line-height: 1;
  509. }
  510. }
  511. .num{
  512. font-size: 24upx;
  513. font-family: PingFang SC;
  514. font-weight: 500;
  515. color: #999999;
  516. line-height: 1;
  517. }
  518. }
  519. }
  520. }
  521. .sub-total{
  522. height: 88upx;
  523. display: flex;
  524. align-items: center;
  525. justify-content: flex-end;
  526. .label{
  527. font-size: 24upx;
  528. font-family: PingFang SC;
  529. font-weight: 500;
  530. color: #999999;
  531. }
  532. .price{
  533. display: flex;
  534. align-items: flex-end;
  535. .unit{
  536. font-size: 24upx;
  537. font-family: PingFang SC;
  538. font-weight: 500;
  539. color: #FF6633;
  540. line-height: 1.2;
  541. margin-right: 4upx;
  542. }
  543. .num{
  544. font-size: 32upx;
  545. font-family: PingFang SC;
  546. font-weight: bold;
  547. color: #FF6633;
  548. line-height: 1;
  549. }
  550. }
  551. }
  552. }
  553. .points{
  554. height: 88upx;
  555. padding: 0 30upx;
  556. background: #FFFFFF;
  557. border-radius: 16upx;
  558. display: flex;
  559. align-items: center;
  560. justify-content: space-between;
  561. .left{
  562. display: flex;
  563. align-items: center;
  564. image{
  565. width: 28upx;
  566. height: 28upx;
  567. margin-right: 20upx;
  568. }
  569. .text{
  570. font-size: 28upx;
  571. font-family: PingFang SC;
  572. font-weight: 500;
  573. color: #666666;
  574. }
  575. }
  576. .right{
  577. display: flex;
  578. align-items: center;
  579. .text{
  580. font-size: 28upx;
  581. font-family: PingFang SC;
  582. font-weight: 500;
  583. color: #111111;
  584. }
  585. image{
  586. margin-left: 15upx;
  587. width: 14upx;
  588. height: 24upx;
  589. }
  590. }
  591. }
  592. .remarks{
  593. height: 88upx;
  594. padding: 0 30upx;
  595. background: #FFFFFF;
  596. border-radius: 16upx;
  597. margin-top: 20upx;
  598. display: flex;
  599. align-items: center;
  600. input{
  601. width: 100%;
  602. font-size: 28upx;
  603. font-family: PingFang SC;
  604. font-weight: 500;
  605. color: #000000;
  606. }
  607. .input{
  608. font-size: 28upx;
  609. font-family: PingFang SC;
  610. font-weight: 500;
  611. color: #999999;
  612. }
  613. }
  614. }
  615. .btn-foot{
  616. box-sizing: border-box;
  617. width: 100%;
  618. height: 121upx;
  619. background: #FFFFFF;
  620. padding: 16upx 30upx 16upx 60upx;
  621. display: flex;
  622. align-items: center;
  623. justify-content: flex-end;
  624. position: fixed;
  625. left: 0;
  626. bottom: 0;
  627. z-index: 99;
  628. .right{
  629. display: flex;
  630. align-items: center;
  631. .total{
  632. display: flex;
  633. align-items: flex-end;
  634. margin-right: 36upx;
  635. .label{
  636. font-size: 26upx;
  637. font-family: PingFang SC;
  638. font-weight: 500;
  639. color: #999999;
  640. line-height: 1.5;
  641. }
  642. .price{
  643. display: flex;
  644. align-items: flex-end;
  645. .unit{
  646. font-size: 32upx;
  647. font-family: PingFang SC;
  648. font-weight: bold;
  649. color: #FF6633;
  650. line-height: 1.2;
  651. margin-right: 10upx;
  652. }
  653. .num{
  654. font-size: 50upx;
  655. font-family: PingFang SC;
  656. font-weight: bold;
  657. color: #FF6633;
  658. line-height: 1;
  659. }
  660. }
  661. }
  662. .btn{
  663. width: 200upx;
  664. height: 88upx;
  665. line-height: 88upx;
  666. text-align: center;
  667. font-size: 30upx;
  668. font-family: PingFang SC;
  669. font-weight: bold;
  670. color: #FFFFFF;
  671. background: #018C39;
  672. border-radius: 44upx;
  673. }
  674. }
  675. }
  676. </style>
  677. <style lang="less" scoped>
  678. .coupon {
  679. height: 100%;
  680. }
  681. /*优惠券列表公共*/
  682. .coupon-list {
  683. }
  684. .coupon-list .item {
  685. display: flex;
  686. flex-direction: column;
  687. justify-content: center;
  688. align-items: center;
  689. width: 100%;
  690. height: 1.7 * 100rpx;
  691. margin-bottom: 0.16 * 100rpx;
  692. }
  693. .coupon-list .item .money {
  694. background-size: 100% 100%;
  695. width: 2.4 * 100rpx;
  696. height: 100%;
  697. color: #fff;
  698. font-size: 0.36 * 100rpx;
  699. font-weight: bold;
  700. text-align: center;
  701. display: flex;
  702. flex-direction: column;
  703. align-items: center;
  704. justify-content: center;
  705. position: relative;
  706. }
  707. .coupon-list .item .money .img{
  708. position: absolute;
  709. width: 2.4 * 100rpx;
  710. height: 100%;
  711. color: #fff;
  712. }
  713. .coupon-list .item .money .num {
  714. font-size: 0.6 * 100rpx;
  715. }
  716. .coupon-list .item .money .pic-num {
  717. font-size: 20rpx;
  718. z-index: 99;
  719. }
  720. .coupon-list .item .text {
  721. width: 4.5 * 100rpx;
  722. padding: 0 0.17 * 100rpx 0 0.24 * 100rpx;
  723. background-color: #fff;
  724. box-sizing: border-box;
  725. }
  726. .coupon-list .item .text .condition {
  727. font-size: 0.3 * 100rpx;
  728. color: #282828;
  729. height: 0.93 * 100rpx;
  730. line-height: 0.93 * 100rpx;
  731. border-bottom: 1px solid #f0f0f0;
  732. }
  733. .coupon-list .item .text .data {
  734. font-size: 0.2 * 100rpx;
  735. color: #999;
  736. height: 0.76 * 100rpx;
  737. }
  738. .coupon-list .item .text .data .bnt {
  739. width: 1.36 * 100rpx;
  740. height: 0.44 * 100rpx;
  741. border-radius: 0.22 * 100rpx;
  742. font-size: 0.22 * 100rpx;
  743. color: #fff;
  744. text-align: center;
  745. line-height: 0.44 * 100rpx;
  746. background-color: red;
  747. }
  748. .coupon-list .item .text .data .bnt.gray {
  749. background-color: #ccc;
  750. }
  751. </style>