preview.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. <template>
  2. <view>
  3. <hx-navbar
  4. :border="false"
  5. :centerSlidiSwitch="true"
  6. :rightSlidiSwitch="false"
  7. :fixed="true"
  8. :backgroundColor="[255,193,7]"
  9. :pageScroll.sync="scrollData">
  10. <view style="text-align: center;width: 100%;">
  11. <text>提交订单</text>
  12. </view>
  13. <view slot="centerAfter" style="text-align: center;width: 100%;">
  14. <text>选择收获地址 ></text>
  15. </view>
  16. </hx-navbar>
  17. <view class="head tab-right-active">
  18. <view class="tab-box" v-if="tabIndex>0">
  19. <view class="item left" :class="{'active':tabIndex == 1}" @click="tabIndex = 1">
  20. <view class="tit-box">
  21. <text>配送</text>
  22. </view>
  23. </view>
  24. <view class="item right" :class="{'active':tabIndex == 2}" @click="tabIndex=2">
  25. <view class="tit-box">
  26. <text>到店自取</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="container head-bottom" :class="{'selectOne': tabIndex == 1,'selectTow':tabIndex == 2}">
  31. <view class="tab" v-if="tabIndex == 2">
  32. 2
  33. </view>
  34. <view class="tab" v-else>
  35. <view class="t-top">
  36. <view class="t-top-box">
  37. <block v-if="!addressData">
  38. <text class="txt1">选择收货地址</text>
  39. <i class="hxicon-right icon1"></i>
  40. </block>
  41. <block v-else>
  42. </block>
  43. </view>
  44. </view>
  45. <view class="t-bb"></view>
  46. <view class="t-bottom">
  47. <view class="row1">
  48. <view class="left">
  49. <text>送达时间</text>
  50. </view>
  51. <view class="right">
  52. <text>未选择(必选)</text>
  53. <i class="hxicon-right"></i>
  54. </view>
  55. </view>
  56. <view class="row2">
  57. <text>为减少接触,封闭管理时,请在地址中更新具体去餐点</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="b-r m-t container p12">
  64. <view class="store">
  65. <view class="name ">
  66. <text>{{storeData.store_name}}</text>
  67. <!-- 标志性位置 ,社区 如:白羊区店,玫瑰园小区 -->
  68. <text v-if="storeData.community">({{storeData.community}})</text>
  69. </view>
  70. <view class="p-bb b-b"></view>
  71. <view class="goods-box" >
  72. <block v-for="(goods,i) in storeData.shopping_cart" :key="i" v-if="storeData.shopping_cart">
  73. <view class="goods-item" >
  74. <view class="left">
  75. <image :src="goods.img" mode="aspectFit"></image>
  76. </view>
  77. <view class="right">
  78. <view class="row1">
  79. <view class="tit">
  80. <text class="zk" v-if="goods.oldprice && Number(goods.price) < Number(goods.oldprice)">折</text>
  81. <text>{{goods.name}}</text>
  82. </view>
  83. <view class="old-price" v-if="goods.oldprice">
  84. <text class="fh">¥</text><text class="lt">{{goods.oldprice}}</text>
  85. </view>
  86. <view class="price">
  87. <text class="fh">¥</text><text>{{goods.price}}</text>
  88. </view>
  89. </view>
  90. <view class="row2">
  91. <text>{{goods.descripe}}</text>
  92. </view>
  93. <view class="row3">
  94. x<text>{{goods.number}}</text>
  95. </view>
  96. </view>
  97. </view>
  98. </block>
  99. </view>
  100. <view class="p-bb b-b"></view>
  101. <view class="flex-rl peisong">
  102. <view class="right">
  103. <text>配送费</text>
  104. </view>
  105. <view class="left">
  106. <text class="fh">¥</text><text>{{storeData.shipping_dees}}</text>
  107. </view>
  108. </view>
  109. <view class="p-bb b-b"></view>
  110. <view class="zhekou-box">
  111. <block v-for="(item,i) in couponData" :key="i">
  112. <view class="zhekou">
  113. <view class="flex-rl row1">
  114. <view class="left">
  115. <i class="hxicon" :class="item.icon"></i>
  116. <text class="tit">{{item.tit}}</text>
  117. </view>
  118. <view class="right">
  119. <view class="tag1">
  120. <text>{{item.content}}</text>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 备注 -->
  125. <view class="row2" v-if="item.remark">
  126. {{item.remark}}
  127. </view>
  128. </view>
  129. </block>
  130. </view>
  131. <view class="p-bb b-b"></view>
  132. <view class="flex-rl totalbox" >
  133. <view class="left">
  134. <text>优惠规则</text>
  135. <i class="hxicon-question"></i>
  136. </view>
  137. <view class="right">
  138. <view class="yh">
  139. <text class="txt">已优惠</text>
  140. <text class="fh">¥</text>
  141. <text class="num">{{totalYhPrice}}</text>
  142. </view>
  143. <view class="total">
  144. <text class="txt">小计</text>
  145. <text class="fh">¥</text>
  146. <text class="num">{{totalPrice}}</text>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. <view class="b-r m-t container p12">
  153. <view class="privacy">
  154. <view class="flex-rl row1 ">
  155. <view class="left">
  156. <i class=" hxicon-cardboardfill icon1"></i>
  157. <text class="txt">号码保护</text>
  158. <i class=" hxicon-question icon2"></i>
  159. </view>
  160. <view class="right">
  161. <switch :checked="ysStatus" @change="privacyStatusChange" color="#ffc107"/>
  162. </view>
  163. </view>
  164. <view class="row2">
  165. 对商家,骑手隐藏您的真实手机号,保护您的隐私
  166. </view>
  167. <view class="row3" v-if="ysStatus">
  168. 为保障服务质量,开启号码保护的订单通话可能会被录音
  169. </view>
  170. </view>
  171. </view>
  172. <view class="b-r m-t container p12 other-box">
  173. <view class="flex-rl row">
  174. <view class="left">
  175. <text>备注</text>
  176. </view>
  177. <view class="right">
  178. <text v-if="remark">{{remark}}</text>
  179. <text v-if="!remark">点击可填写备注</text>
  180. <i class="hxicon-right"></i>
  181. </view>
  182. </view>
  183. </view>
  184. <view class="body-end"></view>
  185. <view class="foot">
  186. <view class="left">
  187. <view class="price">
  188. <text class="fh">¥</text>
  189. <text class="txt">{{totalPrice}}</text>
  190. </view>
  191. <view class="discount" v-if="totalYhPrice">
  192. <text>已优惠¥{{totalYhPrice}}</text>
  193. </view>
  194. </view>
  195. <view class="center">
  196. <text>找人付</text>
  197. </view>
  198. <view class="right" @click="submit">
  199. <text>提交订单</text>
  200. </view>
  201. </view>
  202. </view>
  203. </template>
  204. <script>
  205. export default {
  206. data() {
  207. return {
  208. scrollData: {},
  209. //购物车缓存 Storage 名称
  210. shoppingCartStorageName: 'shopping_cart',
  211. //门店信息
  212. storeData:{},
  213. //购物车
  214. shoppCart:[],
  215. //头部选项卡 参数为 0不显示选项卡,1,2
  216. tabIndex:1,
  217. //收获地址
  218. addressData: null,
  219. //手机隐私
  220. ysStatus: true,
  221. //优惠券
  222. couponData: [{
  223. id:"ASD2020410003",
  224. icon: "icon-ticket_money_fill",
  225. //标题
  226. tit: "门店新客立减",
  227. //说明
  228. content: "15元商家券",
  229. //备注
  230. remark: "满减券和商品折扣可同享",
  231. //面额
  232. value: 15
  233. },{
  234. id:"ASD2020410001",
  235. icon: "icon-ticket_money_fill",
  236. tit: "商家抵用立减",
  237. content: "-¥50",
  238. //面额
  239. value: 50
  240. }],
  241. //结算价
  242. totalPrice: 0,
  243. //已优惠价
  244. totalYhPrice: 0,
  245. //商品数量
  246. totalNumber: 0,
  247. remark: ""
  248. }
  249. },
  250. onLoad(option){
  251. let that = this
  252. let totalPrice = 0
  253. let totalNumber = 0
  254. let totalOldPrice = 0
  255. if(option.sid){
  256. let carts = uni.getStorageSync(that.shoppingCartStorageName) || []
  257. if(carts){
  258. //根据缓存数据 获取购物车中属于本商店的商品
  259. for(let i in carts){
  260. if(carts[i].store_id == option.sid){
  261. that.shoppCart = carts[i].shopping_cart;
  262. that.storeData = carts[i]
  263. break;
  264. }
  265. }
  266. }
  267. let cj = 0
  268. let op = 0
  269. let p = 0
  270. let num = 0
  271. //计算总商品数量和总价
  272. for(var i in that.shoppCart){
  273. p = Number(that.shoppCart[i].price);
  274. op = Number(that.shoppCart[i].oldprice);
  275. num = Number(that.shoppCart[i].number)
  276. totalNumber += num
  277. totalPrice += p * num
  278. if(op > p){
  279. cj += (op - p) * num
  280. }
  281. }
  282. that.totalPrice = totalPrice
  283. that.totalYhPrice = cj
  284. }
  285. },
  286. onPageScroll(e){
  287. this.scrollData = e;
  288. },
  289. methods: {
  290. privacyStatusChange(e){
  291. this.ysStatus = e.target.value
  292. },
  293. //提交订单
  294. submit(){
  295. let that = this
  296. let goodsID = []
  297. for (var i in that.shoppCart){
  298. goodsID.push(that.shoppCart[i].id)
  299. }
  300. let data = {
  301. //商品id
  302. goods : goodsID,
  303. //使用的优惠券 id
  304. coupon: [],
  305. //手机隐私
  306. privacy_status: that.ysStatus ? 1 : 0
  307. }
  308. //向后台发送 data 进行真实合计,生成订单,并返回订单信息
  309. //模拟请求数据
  310. uni.showLoading({
  311. title: '正在生成订单'
  312. });
  313. setTimeout(()=>{
  314. uni.hideLoading()
  315. },1000)
  316. //假设返回了订单信息,跳转至支付页面
  317. let orderId="DGSD2020041035"
  318. uni.redirectTo({
  319. url: '/pages/order/pay?id=' + orderId
  320. });
  321. }
  322. }
  323. }
  324. </script>
  325. <style lang="scss">
  326. .b-r{
  327. border-radius: 6px;
  328. }
  329. .m-t{
  330. margin-top: 6px;
  331. }
  332. .p-bb{
  333. margin: 16px 0;
  334. height: 1px;
  335. //background: #E4E7ED;
  336. }
  337. .flex-rl{
  338. display: flex;
  339. flex-direction: row;
  340. justify-content: space-between;
  341. }
  342. .container{
  343. margin-left: 12px;
  344. margin-right: 12px;
  345. background-color: #ffffff;
  346. }
  347. .p12{
  348. padding: 12px;
  349. }
  350. .head{
  351. background: linear-gradient(to bottom, #ffc107, #f1f1f1);
  352. padding-top: 20px;
  353. .tab-box{
  354. position: relative;
  355. height: 40px;
  356. margin: 0 12px;
  357. .item{
  358. position: absolute;
  359. top: 0;
  360. bottom: 0;
  361. height: 40px;
  362. text-align: center;
  363. font-size: 14px;
  364. width: 50%;
  365. .tit-box{
  366. position: relative;
  367. height: 36px;
  368. line-height: 36px;
  369. border-top-left-radius: 6px;
  370. border-top-right-radius: 6px;
  371. background-color: rgba(#ffffff, .6);
  372. width: 100%;
  373. }
  374. }
  375. .item:first-child{
  376. display: flex;
  377. flex-direction: row;
  378. justify-content: flex-start;
  379. align-items: flex-end;
  380. left: 0;
  381. }
  382. .item:last-child{
  383. display: flex;
  384. flex-direction: row;
  385. justify-content: flex-end;
  386. align-items: flex-end;
  387. right: 0;
  388. }
  389. .active{
  390. height: 40px;
  391. width: 51%;
  392. font-weight: bold;
  393. .tit-box{
  394. height: 40px;
  395. line-height: 40px;
  396. background-color:rgba(#ffffff, 1);
  397. }
  398. }
  399. .left .tit-box{
  400. margin-left: 12px;
  401. margin-right: -12px;
  402. padding-right: 12px;
  403. }
  404. .right .tit-box{
  405. margin-right: 12px;
  406. margin-left: -12px;
  407. padding-left: 12px;
  408. }
  409. .left.active .tit-box{
  410. margin: 0;
  411. }
  412. .right.active .tit-box{
  413. margin: 0;
  414. }
  415. .left.active .tit-box:after{
  416. content: '';
  417. position: absolute;
  418. right: -12px;
  419. bottom: 0;
  420. border-top: 12px solid transparent;
  421. border-right: 12px solid transparent;
  422. border-bottom: 36px solid #ffffff;
  423. }
  424. .right.active .tit-box:after{
  425. content: '';
  426. position: absolute;
  427. left: -12px;
  428. bottom: 0;
  429. border-top: 12px solid transparent;
  430. border-left: 12px solid transparent;
  431. border-bottom: 36px solid #ffffff;
  432. }
  433. }
  434. .head-bottom{
  435. overflow: hidden;
  436. background: #ffffff;
  437. border-top-left-radius: 6px;
  438. border-top-right-radius: 6px;
  439. border-bottom-left-radius: 6px;
  440. border-bottom-right-radius: 6px;
  441. .tab{
  442. .t-top{
  443. &-box{
  444. margin: 0;
  445. padding: 12px;
  446. .txt1{
  447. font-size: 18px;
  448. color: #888;
  449. }
  450. .icon1{
  451. margin-left: 8px;
  452. color: #bbb;
  453. }
  454. }
  455. &-box:active{
  456. background-color: #f5f5f5;
  457. }
  458. }
  459. .t-bb{
  460. margin: 0 12px;
  461. height: 0.5px;
  462. background-color: #E4E7ED;
  463. }
  464. .t-bottom{
  465. padding: 12px;
  466. .row1{
  467. display: flex;
  468. flex-direction: row;
  469. justify-content: space-between;
  470. //padding: 12px 0 0;
  471. .left{
  472. font-size: 14px;
  473. font-weight: bold;
  474. }
  475. .right{
  476. font-size: 14px;
  477. color: #ff9800;
  478. i{
  479. margin-left: 8px;
  480. color: #bbb;
  481. }
  482. }
  483. }
  484. .row2{
  485. margin-top: 6px;
  486. font-size: 12px;
  487. color: #ff9800;
  488. }
  489. }
  490. }
  491. }
  492. .head-bottom.selectOne{
  493. border-top-left-radius: 0;
  494. border-top-right-radius: px;
  495. }
  496. .head-bottom.selectTow{
  497. border-top-left-radius: 6px;
  498. border-top-right-radius: 0;
  499. }
  500. }
  501. .store{
  502. display: flex;
  503. flex-direction: column;
  504. .name{
  505. padding: 4px 0 0px;
  506. font-size: 14px;
  507. }
  508. .goods-box{
  509. .goods-item{
  510. margin-top: 20px;
  511. display: flex;
  512. flex-direction: row;
  513. .left{
  514. width: 60px;
  515. height: 60px;
  516. image{
  517. border-radius: 4px;
  518. overflow: hidden;
  519. width: 100%;
  520. height: 100%;
  521. background-color: #f1f1f1;
  522. }
  523. }
  524. .right{
  525. display: flex;
  526. flex-direction: column;
  527. justify-content: space-between;
  528. flex: 1;
  529. padding-left: 14px;
  530. .row1{
  531. display: flex;
  532. flex-direction: row;
  533. justify-content: space-between;
  534. .tit{
  535. font-size: 14px;
  536. color: #333333;
  537. font-weight: bold;
  538. flex: 1;
  539. flex-wrap: wrap;
  540. .zk{
  541. padding: 1px 3px;
  542. font-size: 10px;
  543. margin-right: 8px;
  544. border-radius: 4px;
  545. background-color: #F9221D;
  546. color: #ffffff;
  547. }
  548. }
  549. .old-price{
  550. padding-left: 12px;
  551. font-size: 14px;
  552. color: #888888;
  553. font-weight: bold;
  554. .lt{
  555. text-decoration: line-through;
  556. }
  557. .fh{
  558. font-size: 10px;
  559. }
  560. }
  561. .price{
  562. font-size: 16px;
  563. padding-left: 12px;
  564. color: #333333;
  565. font-weight: bold;
  566. .fh{
  567. font-size: 10px;
  568. }
  569. }
  570. }
  571. .row2{
  572. }
  573. .row3{
  574. font-size: 10px;
  575. color: #888888;
  576. }
  577. }
  578. }
  579. .goods-item:first-child{
  580. margin: 0;
  581. }
  582. }
  583. .peisong{
  584. .right{
  585. font-size: 14px;
  586. font-weight: bold;
  587. }
  588. .left{
  589. font-size: 16px;
  590. font-weight: bold;
  591. .fh{
  592. font-size: 10px;
  593. }
  594. }
  595. }
  596. .zhekou-box{
  597. .zhekou{
  598. display: flex;
  599. flex-direction: column;
  600. margin-top: 12px;
  601. .row1{
  602. align-items: center;
  603. .left{
  604. display: flex;
  605. flex-direction: row;
  606. align-items: center;
  607. height: 20px;
  608. line-height: 20px;
  609. i{
  610. font-size: 16px;
  611. color: #ff5722;
  612. }
  613. .tit{
  614. font-weight: bold;
  615. margin-left: 6px;
  616. font-size: 14px;
  617. color: #333;
  618. }
  619. }
  620. .right{
  621. .tag1{
  622. font-weight: bold;
  623. font-size: 14px;
  624. color: #ff5722;
  625. }
  626. }
  627. }
  628. .row2{
  629. height: 20px;
  630. line-height: 20px;
  631. font-size: 12px;
  632. color: #888;
  633. }
  634. }
  635. .zhekou:first-child{
  636. margin: 0;
  637. }
  638. }
  639. .totalbox{
  640. align-items: flex-end;
  641. .left{
  642. display: flex;
  643. flex-direction: row;
  644. align-items: center;
  645. font-size: 14px;
  646. color: #888;
  647. [class*="hxicon-"]{
  648. color: #aaa;
  649. margin-left: 4px;
  650. font-size: 16px;
  651. }
  652. }
  653. .right{
  654. display: flex;
  655. flex-direction: row;
  656. align-items: flex-end;
  657. .yh{
  658. color: #ff5722;
  659. .txt{
  660. color: #000;
  661. font-size: 15px;
  662. }
  663. .fh{
  664. font-weight: bold;
  665. margin-left: 3px;
  666. font-size: 13px;
  667. }
  668. .num{
  669. font-weight: bold;
  670. font-size: 18px;
  671. }
  672. }
  673. .total{
  674. margin-left: 16px;
  675. color: #333;
  676. .txt{
  677. font-size: 15px;
  678. }
  679. .fh{
  680. margin-left: 3px;
  681. font-size: 12px;
  682. font-weight: bold;
  683. }
  684. .num{
  685. font-weight: 900;
  686. font-size: 22px;
  687. }
  688. }
  689. }
  690. }
  691. }
  692. .privacy{
  693. display: flex;
  694. flex-direction: column;
  695. .row1{
  696. align-items: flex-end;
  697. .left{
  698. display: flex;
  699. flex-direction: row;
  700. align-items: center;
  701. .icon1{
  702. color: #444;
  703. font-size: 24px;
  704. }
  705. .icon2{
  706. color: #aaa;
  707. margin-left: 6px;
  708. font-size: 16px;
  709. }
  710. .txt{
  711. color: #333;
  712. margin-left: 6px;
  713. font-weight: bold;
  714. font-size: 14px;
  715. }
  716. }
  717. .right{
  718. }
  719. }
  720. .row2{
  721. margin-top: 4px;
  722. color: #888;
  723. font-size: 12px;
  724. }
  725. .row3{
  726. margin-top: 8px;
  727. font-size: 12px;
  728. color: #ff9800;
  729. }
  730. }
  731. .other-box{
  732. display: flex;
  733. flex-direction: column;
  734. .row{
  735. align-items: center;
  736. .left{
  737. font-size: 14px;
  738. color: #333;
  739. font-weight: bold;
  740. flex: 1;
  741. }
  742. .right{
  743. display: flex;
  744. flex-direction: column;
  745. justify-content: flex-end;
  746. align-items: center;
  747. flex-wrap: wrap;
  748. width: 60%;
  749. font-size: 14px;
  750. display: flex;
  751. flex-direction: row;
  752. color: #aaa;
  753. [class*="hxicon-"]{
  754. position: relative;
  755. top: 2px;
  756. font-size: 14px;
  757. }
  758. }
  759. }
  760. }
  761. .body-end{
  762. height: 100px;
  763. }
  764. .foot{
  765. z-index: 11;
  766. position: fixed;
  767. display: flex;
  768. flex-direction: row;
  769. border-radius: 50px;
  770. overflow: hidden;
  771. bottom: 12px;
  772. left: 12px;
  773. right: 12px;
  774. height: 50px;
  775. .left{
  776. padding: 0 12px;
  777. display: flex;
  778. flex-direction: column;
  779. justify-content: center;
  780. background-color: #222222;
  781. flex: 1;
  782. .price{
  783. display: flex;
  784. flex-direction: row;
  785. align-items: baseline;
  786. color: #fff;
  787. height: 25px;
  788. line-height: 25px;
  789. .fh{
  790. font-weight: bold;
  791. font-size: 12px;
  792. }
  793. .txt{
  794. font-size: 22px;
  795. font-weight: bold;
  796. }
  797. }
  798. .discount{
  799. margin-left: 2px;
  800. font-size: 10px;
  801. color: #bbb;
  802. }
  803. }
  804. .center{
  805. display: flex;
  806. align-items: center;
  807. background-color: #444;
  808. color: #FFC107;
  809. font-weight: bold;
  810. font-size: 16px;
  811. padding-left: 15px;
  812. padding-right: 15px;
  813. transition: all 0.3s;
  814. }
  815. .center:active{
  816. background-color: #666;
  817. }
  818. .right{
  819. display: flex;
  820. align-items: center;
  821. color: #222;
  822. font-weight: bold;
  823. font-size: 16px;
  824. padding-left: 15px;
  825. padding-right: 15px;
  826. transition: all 0.3s;
  827. background: linear-gradient(45deg, #FFEB3B, #FFC107);
  828. }
  829. .right:active{
  830. background: linear-gradient(45deg, #e0ce31, #e4ad06);
  831. }
  832. }
  833. </style>