confirmOrder.vue 18 KB

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