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