confirmOrder.vue 18 KB

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