confirm.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <view>
  3. <navbar :scroll="scrollNum" title-color="#ffffff" background="#1b43c4" :iSimmersive="false" :placeholder="true" title="订单详情"></navbar>
  4. <view class="distribution" v-if="isShipping">
  5. <text @click="onShipping(1)" :class="{active: shippingType == 1}">快递配送</text>
  6. <text @click="onShipping(2)" :class="{active: shippingType == 2}">到店自提</text>
  7. </view>
  8. <view v-if="isShipping" class="distribution-placeholder"></view>
  9. <view class="top" v-if="shippingType == 1">
  10. <view class="top-map">
  11. <text class="iconfont">&#xe61e;</text>
  12. </view>
  13. <view class="address" @click="isAddressStatus = true">
  14. <view class="info" v-if="address.tel">
  15. <text v-if="address.name">收件人:{{ address.name }} </text>
  16. <text v-if="address.tel">手机号:{{ address.tel }}</text>
  17. </view>
  18. <view class="info" v-if="!address.tel">
  19. <text style="position: relative; top: -10rpx;">请选择地址</text>
  20. </view>
  21. <view class="address-info" v-if="address.address">{{ address.address }}</view>
  22. </view>
  23. <view class="arrow-right">
  24. <text class="iconfont">&#xe60d;</text>
  25. </view>
  26. </view>
  27. <view class="top" v-if="shippingType == 2">
  28. <view class="top-map">
  29. <text class="iconfont">&#xe61e;</text>
  30. </view>
  31. <view class="address" @click="isStoreStatus = true">
  32. <view class="info">
  33. <text v-if="store.name">门店名称:{{ store.name }}</text>
  34. </view>
  35. <view class="info" v-if="!store.tel">
  36. <text style="position: relative; top: -10rpx;">请选择地址</text>
  37. </view>
  38. <view class="address-info">
  39. <view v-if="store.tel">手机号:{{ store.tel }}</view>
  40. <view v-if="store.address">{{ store.address }}</view>
  41. </view>
  42. </view>
  43. <view class="arrow-right">
  44. <text class="iconfont">&#xe60d;</text>
  45. </view>
  46. </view>
  47. <view class="goods">
  48. <view class="title">
  49. <text>共{{orderData.item.length}}件商品</text>
  50. </view>
  51. <view class="goods-box">
  52. <view class="goods-item clear" v-for="(item,index) in orderData.item" :key="index">
  53. <view class="goods-img">
  54. <image :src="item.thumb_image"></image>
  55. </view>
  56. <view class="goods-info">
  57. <view class="t">
  58. <text>{{item.title}}</text>
  59. <text>¥{{item.sell_price}}</text>
  60. </view>
  61. <view class="b">
  62. <view v-if="item.goods_array">
  63. <text v-for="(value,j) in item.goods_array" :key="j">
  64. {{value.name}}:{{value.value}}&nbsp;&nbsp;
  65. </text>
  66. </view>
  67. <text class="goods-nums">× {{item.goods_nums}}</text>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="order">
  74. <view class="title">
  75. <text>订单信息</text>
  76. </view>
  77. <view class="list clear">
  78. <view class="list-box clear" @click="isCouponStatus = !isCouponStatus">
  79. <view>优惠劵:</view>
  80. <view>{{bonusText}}</view>
  81. </view>
  82. <view class="list-box clear">
  83. <view>商品金额:</view>
  84. <view>¥{{orderData.real_amount}}</view>
  85. </view>
  86. <view class="list-box clear">
  87. <view>运费金额:</view>
  88. <view>¥{{orderData.real_freight}}</view>
  89. </view>
  90. <view class="list-box clear" v-if="orderData.real_point > 0">
  91. <view>需要积分:</view>
  92. <view class="money">{{orderData.real_point}}积分</view>
  93. </view>
  94. <view class="list-box clear">
  95. <view>订单总额:</view>
  96. <view class="money">¥{{orderData.payable_amount}}</view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="order">
  101. <view class="title">
  102. <text>备注内容</text>
  103. </view>
  104. <view class="list clear">
  105. <view style="padding: 20rpx 25rpx;">
  106. <textarea @input="onRemarks" placeholder="请输入留言" style="width: 100%; height: 100rpx;"></textarea>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="order">
  111. <view class="title">
  112. <text>支付方式</text>
  113. </view>
  114. <view class="payment-box">
  115. <view
  116. v-for="(item,index) in providerList"
  117. :key="index"
  118. class="payment-item"
  119. @click="selectPayment(item.id)"
  120. >
  121. <view><text class="iconfont pay" :id="item.id" :class="item.class"></text></view>
  122. <view :class="{activeColor:payment == item.id}">{{item.name}}<text v-if="item.id == 'balance'" style="padding-left: 15rpx; padding-top: 2rpx; font-size: 24rpx;">可用余额: ¥{{orderData.users_price}}元</text></view>
  123. <view :class="{active:payment == item.id}"><text class="iconfont">&#xe631;</text></view>
  124. </view>
  125. </view>
  126. </view>
  127. <coupon-list
  128. v-model="isCouponStatus"
  129. :coupons="coupons"
  130. @coupon-event="onCoupons"
  131. ></coupon-list>
  132. <address-list
  133. v-model="isAddressStatus"
  134. :array="addressList"
  135. @onAdd="onAdd"
  136. @address-event="onSelectedAddress"
  137. >
  138. </address-list>
  139. <address-list
  140. v-model="isStoreStatus"
  141. :array="storeList"
  142. :add="false"
  143. tips="暂无自提门店"
  144. @address-event="onSelectedStore"
  145. >
  146. </address-list>
  147. <view class="operation-placeholder"></view>
  148. <view class="operation">
  149. <view class="amount">
  150. <text>合计:</text>
  151. <text v-if="orderData.order_amount">¥{{orderData.order_amount}}</text>
  152. <text v-else>¥{{orderData.payable_amount}}</text>
  153. </view>
  154. <view class="pay" @click="onOrderSubmit">提交订单</view>
  155. </view>
  156. <loading v-if="isLoading" :color="loadingColor" :text="loadingText" :layer="true"></loading>
  157. </view>
  158. </template>
  159. <script>
  160. import MallInfo from '@/components/tool/info.vue'
  161. import loading from '../../components/tool/loading'
  162. import navbar from "@/components/navbar/navbar";
  163. import subscribe from "@/common/subscribe";
  164. import payment from '@/common/payment';
  165. export default {
  166. components:{
  167. MallInfo,loading,navbar
  168. },
  169. data() {
  170. return {
  171. scrollNum: 0,
  172. shippingType: 1,
  173. isShipping: 0,
  174. storeList: [],
  175. store:{
  176. id: "",
  177. name: "",
  178. tel: "",
  179. address: ""
  180. },
  181. isLoading: true,
  182. loadingColor: "rgba(255,255,255,1)",
  183. loadingText: "正在加载订单中",
  184. chosenStoreId: '0',
  185. isStoreStatus: false,
  186. isCouponStatus: false,
  187. isAddressStatus: false,
  188. bonusText: "请选择",
  189. address:{
  190. id: "",
  191. name: "",
  192. tel: "",
  193. address: ""
  194. },
  195. chosenAddressId: '0',
  196. bonusId: '0',
  197. addressList: [],
  198. orderData: {
  199. item:{},
  200. real_amount: 0.00,
  201. real_freight: 0.00,
  202. payable_amount: 0.00,
  203. order_amount: 0.00,
  204. users_price:0.00,
  205. real_point: 0,
  206. users_point: 0,
  207. type: 0
  208. },
  209. remarks: "",
  210. payment: "wechat",
  211. coupons: [],
  212. params:null,
  213. orderBtnFlag:false,
  214. providerList: []
  215. };
  216. },
  217. onLoad(options) {
  218. let type = options.type;
  219. let id = options.id;
  220. let params = {
  221. id: id,type: type
  222. };
  223. if(this.$utils.in_array(type,["buy","point","second","regiment","special","group"])){
  224. params.sku_id = options.sku_id;
  225. params.num = options.num;
  226. if(options.kid){
  227. params.kid = options.kid;
  228. }
  229. }
  230. params.shipping_type = this.shippingType;
  231. this.params = params;
  232. payment.getPaymentList().then(res=>{
  233. this.providerList = res;
  234. })
  235. subscribe.order();
  236. },
  237. onShow() {
  238. this.$nextTick(()=>{
  239. let users = this.$storage.getJson("users");
  240. if(users == null){
  241. this.$utils.navigateTo('public/login');
  242. }else{
  243. this.onLoadOrder();
  244. }
  245. });
  246. },
  247. onPageScroll(obj){
  248. this.scrollNum = obj.scrollTop;
  249. },
  250. methods: {
  251. onRemarks(ev){
  252. this.remarks = ev.detail.value;
  253. },
  254. onShipping(type){
  255. this.shippingType = type;
  256. this.params.shipping_type = type;
  257. if(type == 1){
  258. this.onSelectedAddress(this.address);
  259. }else{
  260. this.onSelectedStore(this.store);
  261. }
  262. },
  263. onSelectedStore(value){
  264. this.isStoreStatus = false;
  265. this.chosenStoreId = value.id;
  266. this.params.store_id = this.chosenStoreId;
  267. this.store = value;
  268. delete this.params.address_id;
  269. this.onLoadOrder();
  270. },
  271. onSelectedAddress(value){
  272. this.isAddressStatus = false;
  273. this.chosenAddressId = value.id;
  274. this.params.address_id = this.chosenAddressId;
  275. this.address = value;
  276. delete this.params.store_id;
  277. this.onLoadOrder();
  278. },
  279. onLoadOrder(){
  280. this.$http.getCartConfirm(this.params).then((res)=>{
  281. if(res.status){
  282. this.orderData = res.data;
  283. this.isShipping = parseInt(res.data.is_shipping);
  284. this.storeList = res.data.store;
  285. this.addressList = res.data.address.list;
  286. // address
  287. if(res.data.address.default == undefined || res.data.address.default.length <= 0){
  288. if(res.data.address.list[0] != undefined){
  289. this.address = res.data.address.list[0];
  290. this.chosenAddressId = this.address.id;
  291. }
  292. }else{
  293. this.chosenAddressId = res.data.address.default.id;
  294. this.address = res.data.address.default;
  295. }
  296. if(this.storeList.length && this.store.id == ""){
  297. this.store = this.storeList[0];
  298. this.chosenStoreId = this.store.id;
  299. }
  300. this.coupons = res.data.bonus;
  301. if(this.bonusText == '请选择'){
  302. this.bonusText = res.data.bonus.length <= 0 ? "暂无优惠劵" : res.data.bonus.length + "张可用"
  303. }
  304. this.isLoading = false;
  305. }else{
  306. this.isLoading = false;
  307. this.$storage.set("order_msg",res.info);
  308. this.$utils.redirectTo("cart/msg");
  309. }
  310. });
  311. },
  312. onOrderSubmit(){
  313. if(this.orderBtnFlag){
  314. return false;
  315. }
  316. if(this.orderData.real_point > this.orderData.users_point){
  317. this.$utils.msg("您的积分不足,不能购买此商品");
  318. return false;
  319. }
  320. if(this.shippingType == 2 && this.store.id == ""){
  321. this.$utils.msg("请先选择自提门店");
  322. return false;
  323. }
  324. this.orderBtnFlag = true;
  325. this.isLoading = true;
  326. this.loadingColor = 'rgba(255,255,255,0.3)';
  327. this.loadingText = "正在提交订单中";
  328. let params = {};
  329. Object.assign(params,{
  330. id: this.params.id,
  331. type: this.params.type,
  332. address_id: this.chosenAddressId,
  333. store_id: this.chosenStoreId,
  334. shipping_type: this.shippingType,
  335. bonus_id: this.bonusId,
  336. payment: this.payment,
  337. remarks: this.remarks,
  338. source: payment.getPaymentType(),
  339. // #ifdef H5
  340. url: document.location.href
  341. // #endif
  342. },this.params);
  343. this.$http.createOrder(params).then((res)=>{
  344. this.isLoading = false;
  345. if(res.status){
  346. payment.crreateOrder(res.data,true);
  347. }else{
  348. this.$utils.msg(res.info);
  349. }
  350. this.orderBtnFlag = false;
  351. }).catch((err)=>{
  352. this.isLoading = false;
  353. this.$utils.msg("网络连接错误,请检查网络是否可用");
  354. this.orderBtnFlag = false;
  355. });
  356. },
  357. onShipping(type){
  358. this.shippingType = type;
  359. this.params.shipping_type = type;
  360. if(type == 1){
  361. this.onSelectedAddress(this.address);
  362. }else{
  363. this.onSelectedStore(this.store);
  364. }
  365. },
  366. selectPayment(value){
  367. this.payment = value;
  368. },
  369. onCoupons(value) {
  370. this.isCouponStatus = false;
  371. this.params.bonus_id = value.id;
  372. this.bonusText = value.value;
  373. this.bonusId = value.id;
  374. this.onLoadOrder();
  375. },
  376. onSelectedStore(value){
  377. this.isStoreStatus = false;
  378. this.chosenStoreId = value.id;
  379. this.params.store_id = this.chosenStoreId;
  380. this.store = value;
  381. delete this.params.address_id;
  382. this.onLoadOrder();
  383. },
  384. onSelectedAddress(value){
  385. this.isAddressStatus = false;
  386. this.chosenAddressId = value.id;
  387. this.params.address_id = this.chosenAddressId;
  388. this.address = value;
  389. delete this.params.store_id;
  390. this.onLoadOrder();
  391. },
  392. onAdd() {
  393. this.$storage.set("ORDER_CONFIRM_SELECT",true);
  394. this.$utils.navigateTo("ucenter/address_editor");
  395. }
  396. }
  397. }
  398. </script>
  399. <style lang="scss">
  400. .distribution {
  401. width: 100%;
  402. height: 90rpx;
  403. line-height: 90rpx;
  404. background-color: #fff;
  405. text {
  406. display: inline-block; font-size: 30rpx; width: 50%;
  407. height: 90rpx; line-height: 90rpx; text-align: center;
  408. &.active { color: #b91922; }
  409. }
  410. }
  411. .distribution-placeholder { width: 100%; height: 12rpx; }
  412. .money{ color: #fc4141; }
  413. .van-address-item__edit { display: none; }
  414. .top{
  415. background-color: #fff;
  416. position: relative;
  417. &:before{
  418. position: absolute;
  419. right: 0;
  420. bottom: 0;
  421. left: 0;
  422. height: 4rpx;
  423. background: -webkit-repeating-linear-gradient(135deg,#ff6c6c 0,#ff6c6c 20%,transparent 0,transparent 25%,#1989fa 0,#1989fa 45%,transparent 0,transparent 50%);
  424. background: repeating-linear-gradient(-45deg,#ff6c6c 0,#ff6c6c 20%,transparent 0,transparent 25%,#1989fa 0,#1989fa 45%,transparent 0,transparent 50%);
  425. background-size: 160rpx;
  426. content: '';
  427. }
  428. .top-map{
  429. width: 60rpx;
  430. height: 60rpx;
  431. position: absolute;
  432. top: 50%;
  433. transform: translateY(-50%);
  434. left: 20rpx;
  435. text {
  436. font-size: 32rpx;
  437. }
  438. }
  439. .arrow-right{
  440. width: 60rpx;
  441. height: 60rpx;
  442. position: absolute;
  443. top: 50%;
  444. transform: translateY(-50%);
  445. right: 0px;
  446. text {
  447. transform: rotate(180deg); display: inline-block;
  448. }
  449. }
  450. .address{
  451. font-size: 28rpx;
  452. width: 85%;
  453. margin: 0 auto;
  454. padding: 20rpx 0px;
  455. padding-left: 40rpx;
  456. position: relative;
  457. .info{
  458. height: 60rpx;
  459. line-height: 60rpx;
  460. span:first-child{
  461. padding-right: 20rpx;
  462. }
  463. span:last-child{
  464. }
  465. }
  466. .address-info{
  467. height: auto !important;
  468. height: 60rpx;
  469. min-height: 40rpx;
  470. line-height: 40rpx;
  471. }
  472. }
  473. }
  474. .goods{
  475. background-color: #fff;
  476. margin-top: 30rpx;
  477. padding-bottom: 20rpx;
  478. .title{
  479. width: 100%;
  480. margin: 0 auto;
  481. color: #666;
  482. font-size: 28rpx;
  483. height: 80rpx;
  484. line-height: 80rpx;
  485. border-bottom: 2rpx solid #eee;
  486. text {
  487. padding-left: 20rpx;
  488. }
  489. }
  490. .goods-box{
  491. padding: 0 32rpx;
  492. .goods-item {
  493. padding-top: 20rpx;
  494. .goods-img {
  495. width: 154rpx;
  496. height: 154rpx;
  497. display: inline-block;
  498. float: left;
  499. image{
  500. width: 100%;
  501. height: 100%;
  502. }
  503. }
  504. .goods-info {
  505. display: inline-block;
  506. width: 72%;
  507. font-size: 28rpx;
  508. float: right;
  509. text{
  510. font-style: normal;
  511. }
  512. .t {
  513. width: 100%;
  514. height: 45px;
  515. text:first-child{
  516. float: left;
  517. display: -webkit-box;overflow: hidden;-webkit-line-clamp: 2;
  518. -webkit-box-orient: vertical;
  519. width: 70%;
  520. }
  521. text:last-child{
  522. width: 30%;
  523. float: right;
  524. text-align: right;
  525. }
  526. }
  527. .b{
  528. width: 100%;
  529. height: 40px;
  530. font-size: 13px;
  531. view{
  532. float: left;
  533. color: #999;
  534. }
  535. .goods-nums {
  536. float: right;
  537. color: #666;
  538. }
  539. }
  540. }
  541. }
  542. }
  543. }
  544. .order{
  545. background-color: #fff;
  546. margin-top: 30rpx;
  547. padding-bottom: 20rpx;
  548. .title{
  549. width: 100%;
  550. margin: 0 auto;
  551. color: #666;
  552. font-size: 30rpx;
  553. height: 80rpx;
  554. line-height: 80rpx;
  555. border-bottom: 1px solid #eee;
  556. text {
  557. padding-left: 30rpx;
  558. }
  559. }
  560. .list {
  561. width: 100%;
  562. .list-box{
  563. width: 92%;
  564. height: auto !important;
  565. height: 80rpx;
  566. min-height: 80rpx;
  567. line-height: 80rpx;
  568. margin: 0 auto;
  569. font-size: 26rpx; color: #333;
  570. border-bottom: 2rpx solid #ebedf0;
  571. view{ display: inline-block; }
  572. view:first-child { float: left; }
  573. view:last-child { float: right; }
  574. textarea { height: 150rpx; }
  575. }
  576. }
  577. }
  578. .payment-box{
  579. .payment-item{
  580. padding: 20rpx 32rpx;
  581. border-bottom: 2rpx solid #eee;
  582. view { display: inline; }
  583. view:first-child{
  584. font-size: 28rpx;
  585. text{
  586. width: 40rpx;
  587. height: 40rpx;
  588. line-height: 40rpx;
  589. text-align: center;
  590. border-radius:50%;
  591. padding: 4rpx;
  592. }
  593. }
  594. view:nth-child(2){
  595. font-size: 28rpx;
  596. padding-left: 20rpx;
  597. i{
  598. font-size: 24rpx;
  599. font-style: normal;
  600. color: #999;
  601. padding-left: 20rpx;
  602. }
  603. }
  604. view:nth-child(3){
  605. float: right;
  606. display: none;
  607. color: #999;
  608. }
  609. view.active{
  610. display: block;
  611. }
  612. view.activeColor{
  613. color: red;
  614. }
  615. }
  616. #wechat{
  617. position: relative;
  618. top: 2rpx;
  619. width: 40rpx;
  620. height: 40rpx;
  621. display: inline-block;
  622. color: #fff;
  623. background-color: #41b035;
  624. }
  625. #alipay{
  626. position: relative;
  627. top: 2rpx;
  628. width: 40rpx;
  629. height: 40rpx;
  630. display: inline-block;
  631. color: #fff;
  632. background-color: #1296db;
  633. }
  634. #appleiap{
  635. position: relative;
  636. top: 2rpx;
  637. width: 40rpx;
  638. height: 40rpx;
  639. display: inline-block;
  640. color: #333;
  641. background-color: #fff;
  642. border: 1px solid #eee;
  643. }
  644. #balance{
  645. position: relative;
  646. top: 2rpx;
  647. width: 40rpx;
  648. height: 40rpx;
  649. background-repeat: no-repeat;
  650. background-size: 40rpx 40rpx;
  651. display: inline-block;
  652. color: #fff;
  653. background-color: #fe960f;
  654. }
  655. .check {
  656. position: relative;
  657. top: 12rpx;
  658. width: 40rpx;
  659. height: 40rpx;
  660. display: inline-block;
  661. }
  662. }
  663. .operation-placeholder{
  664. width: 100%;
  665. height: 140rpx;
  666. line-height: 140rpx;
  667. }
  668. .operation{
  669. width: 100%;
  670. height: 110rpx;
  671. line-height: 110rpx;
  672. text-align: right;
  673. background-color: #fff;
  674. position: fixed;
  675. left: 0;
  676. bottom: 0;
  677. border-top: 2rpx solid #eee;
  678. z-index: 11111;
  679. .amount{
  680. float: left;
  681. padding-top: 0;
  682. font-size: 28rpx;
  683. text-align: center;
  684. background-color: #fff;
  685. padding: 6rpx 30rpx;
  686. display: inline;
  687. margin-right: 20rpx;
  688. text{
  689. font-style: normal;
  690. font-size: 32rpx;
  691. color: #555;
  692. }
  693. text:last-child{
  694. color: #db1111;
  695. font-size: 34rpx;
  696. position: relative;
  697. top: 2rpx;
  698. }
  699. }
  700. .pay {
  701. font-size: 28rpx;
  702. text-align: center;
  703. border-radius: 30rpx;
  704. background-color: #fff;
  705. padding: 16rpx 30rpx;
  706. display: inline;
  707. background-color: #1b43c4;
  708. margin-right: 20rpx;
  709. color: #fff;
  710. }
  711. }
  712. </style>