confirmCreateOrder.vue 18 KB

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