confirmOrder.vue 18 KB

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