confirmCreateOrder.vue 18 KB

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