金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

560 lines
15 KiB

  1. <template>
  2. <view>
  3. <lf-nav title="确认订单" :showIcon="true"></lf-nav>
  4. <block v-if="$isRight(order_detail)">
  5. <view class="card head">
  6. <view class="lf-font-32 lf-color-222">选择收货方式</view>
  7. <view class="capsule">
  8. <view class="item" :class="{'capsule-active': mode == 0}" @click="mode = 0">邮寄</view>
  9. <view class="item" :class="{'capsule-active': mode == 1}" @click="mode = 1">自提</view>
  10. </view>
  11. </view>
  12. <view class="card address" v-if="mode == 0">
  13. <view @click="$url('/pages/address/list/list?is_select=1')">
  14. <text class="lf-font-28 lf-color-primary lf-m-r-10">更换收获地址</text>
  15. <text class="lf-iconfont icon-xiangyou lf-font-24 lf-color-777"></text>
  16. </view>
  17. <view v-if="address">
  18. <view class="lf-m-t-20">
  19. <text class="lf-font-28 lf-color-222 lf-font-bold">{{ address.accept_name }}</text>
  20. <text class="lf-font-28 lf-color-777 lf-m-l-20">{{ address.mobile }}</text>
  21. </view>
  22. <view class="lf-font-28 lf-color-333 lf-m-t-10">
  23. <text>{{ address.address_name }}{{ address.address }}</text>
  24. </view>
  25. </view>
  26. <view v-else class="lf-font-28 lf-color-777">
  27. 暂无收货地址,请前往添加
  28. </view>
  29. </view>
  30. <view class="card address" v-else>
  31. <view @click="$url('/pages/address/list/list?is_select=1')">
  32. <text class="lf-font-28 lf-color-primary lf-m-r-10">店铺地址</text>
  33. </view>
  34. <view v-if="address">
  35. <view class="lf-m-t-20">
  36. <text class="lf-font-28 lf-color-222 lf-font-bold">{{ order_detail.brand.name }}</text>
  37. <text class="lf-font-28 lf-color-777 lf-m-l-20">{{ order_detail.brand.tel }}</text>
  38. </view>
  39. <view class="lf-font-28 lf-color-333 lf-m-t-10">
  40. <text>{{ order_detail.brand.floor }}</text>
  41. </view>
  42. </view>
  43. <view v-else class="lf-font-28 lf-color-777">
  44. 暂无收货地址,请前往添加
  45. </view>
  46. </view>
  47. <view class="card goods">
  48. <view @click="$url('/pages/shop/shopdetail?id='+ order_detail.brand.id)">
  49. <text class="lf-iconfont icon-Group- lf-font-30"></text>
  50. <text class="shop-name">{{ order_detail.brand.name }}</text>
  51. <text class="lf-iconfont icon-xiangyou lf-font-24"></text>
  52. </view>
  53. <view class="lf-flex lf-m-t-20" v-for="(item, index) in order_detail.order.items" :key="index">
  54. <image class="goods-img" :src="item.item_meta.image"></image>
  55. <view class="info">
  56. <view class="lf-font-26 lf-color-333 lf-line-1">{{ item.item_name }}</view>
  57. <view class="lf-font-24 lf-color-777">{{ item.item_meta.specs_text }}</view>
  58. <view class="lf-row-between" style="line-height: 1;">
  59. <text class="price"><text v-if="goods_type==1">¥</text>{{ item.redeem_point }}<text class="lf-font-24" v-if="goods_type==0">积分</text></text>
  60. <text class="lf-font-28 lf-color-777">x {{ item.quantity }}</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- <view class="tips">支付成功后15天内柜台提货</view> -->
  65. <view class="lf-flex lf-m-t-20">
  66. <view class="lf-font-28 lf-color-777">留言</view>
  67. <input v-model="value" class="input" placeholder="有什么要求,请备注留言" />
  68. </view>
  69. </view>
  70. <view class="card lf-m-t-20">
  71. <view class="lf-row-between lf-m-t-20">
  72. <view class="lf-font-28 lf-color-777">商品金额</view>
  73. <view class="lf-font-26 lf-color-222"><text v-if="goods_type==1">¥</text>{{ order_detail.order.redeem_point }}<text v-if="goods_type==0">积分</text></view>
  74. </view>
  75. <view class="lf-row-between lf-m-t-20" v-if="mode == 0">
  76. <view class="lf-font-28 lf-color-777">运费</view>
  77. <view class="lf-font-26" style="color: #F63434;">+¥{{ order_detail.order.payable_freight_yuan }}</view>
  78. </view>
  79. </view>
  80. <view class="spread-out"></view>
  81. <view class="fixed-bottom" v-if="$isRight(order_detail.order)">
  82. <view class="fixed-content">
  83. <view class="lf-font-24 lf-color-777">{{ order_detail.order.count }}</view>
  84. <view class="lf-flex">
  85. <!-- <view class="lf-font-32 lf-color-primary" style="max-width: 400rpx;">合计 ¥{{ order_detail.order.total_yuan }}</view> -->
  86. <view class="lf-font-32 lf-color-primary" style="max-width: 400rpx;">
  87. <text class="lf-m-r-10">运费: {{order_detail.order.payable_freight_yuan}}</text>
  88. <text>积分: {{order_detail.order.redeem_point}}积分</text>
  89. </view>
  90. <view class="confirm-btn" hover-class="lf-opacity" @click="confirm">立即兑换</view>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 选择优惠券弹出层 -->
  95. <u-popup v-model="show_coupon" mode="bottom" :round="true" borderRadius="20">
  96. <view class="popup-content">
  97. <view class="lf-row-between" v-for="(item, index) in order_detail.coupons" :key="index">
  98. <radio-group @change="couponChange">
  99. <radio :value="index" :checked="coupon_index == index"></radio>
  100. </radio-group>
  101. <view class="coupon-card lf-m-b-30" :class="{'invalid-bg': item.ifpast == true}">
  102. <view class="coupon-circle-top">
  103. <view class="coupon-circle1"></view>
  104. </view>
  105. <view class="coupon-circle-bottom">
  106. <view class="coupon-circle1"></view>
  107. </view>
  108. <view class="coupon-radius">
  109. <view class="coupon-left">
  110. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'cash'">
  111. <text v-if="goods_type==1"></text>
  112. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  113. <text v-if="goods_type==0">积分</text>
  114. </view>
  115. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'discount'">
  116. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  117. <text>%</text>
  118. </view>
  119. <view class="coupon-tag" v-if="item.used_at != ''">
  120. 已使用
  121. </view>
  122. <view class="coupon-tag" v-if="item.ifpast">
  123. 已过期
  124. </view>
  125. <view class="coupon-tag" v-if="!item.ifpast && item.used_at == ''">
  126. 待使用
  127. </view>
  128. </view>
  129. <view class="coupon-right">
  130. <view class="lf-font-32 lf-font-bold lf-color-white">{{item.discount.title}}</view>
  131. <view class="lf-font-24 lf-color-white">有效期{{item.discount.starts_at}}~{{item.discount.ends_at}}</view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <!-- 不使用优惠券 -->
  137. <view class="lf-flex">
  138. <radio-group @change="couponChange">
  139. <radio value="null" :checked="coupon_index == null"></radio>
  140. </radio-group>
  141. <view>不使用优惠券</view>
  142. </view>
  143. </view>
  144. </u-popup>
  145. </block>
  146. </view>
  147. </template>
  148. <script>
  149. import Bigc from '@/common/js/bigc.js';
  150. export default {
  151. data(){
  152. return {
  153. mode: 0, // 0邮寄,1自提
  154. value: '', // 备注
  155. token: '',
  156. address: {},
  157. address_id: null,
  158. order_detail: {coupons: []},
  159. show_coupon: false,
  160. coupon_index: null,
  161. goods_type: 0,
  162. params: {},
  163. clickContinue: true
  164. }
  165. },
  166. computed: {
  167. showCouponTitle(){
  168. if(this.coupon_index != null){
  169. return this.order_detail.coupons[this.coupon_index].discount.title;
  170. }else{
  171. if(this.order_detail.coupons.length){
  172. return '不使用优惠券';
  173. }else{
  174. return '暂无可用优惠券';
  175. }
  176. }
  177. },
  178. totalPrice(){
  179. let order = this.order_detail.order;
  180. if(!this.$isRight(order)){
  181. return 0;
  182. }
  183. if(this.mode){
  184. return order.total_yuan;
  185. }else{
  186. return new Bigc(order.total_yuan).plus(order.payable_freight_yuan);
  187. }
  188. }
  189. },
  190. onLoad(e){
  191. this.token = this.$cookieStorage.get('user_token');
  192. this.goods_type = e.goods_type;
  193. if(e.product_id) {
  194. this.params = {
  195. quantity: e.quantity,
  196. product_id: e.product_id
  197. }
  198. }else {
  199. this.params = {
  200. quantity: e.quantity,
  201. goods_id: e.goods_id
  202. }
  203. }
  204. this.getPointDetails();
  205. },
  206. onUnload(){
  207. this.$cookieStorage.clear('order_confirm');
  208. },
  209. onShow(){
  210. if(this.address_id){
  211. this.getSelectAddress();
  212. }
  213. },
  214. methods: {
  215. getPointDetails() {
  216. uni.showLoading({
  217. title: '正在生成订单'
  218. })
  219. this.$http.post({
  220. api: 'api/shopping/order/checkout/point',
  221. data: this.params,
  222. header: {
  223. Authorization: this.token
  224. }
  225. }).then(res => {
  226. if(res.data.code == true){
  227. let detail = res.data.data;
  228. this.order_detail = detail;
  229. this.address = res.data.data.address;
  230. uni.hideLoading()
  231. }else{
  232. this.$msg(res.data.message || '订单提交失败!').then(() => {
  233. this.$toBack();
  234. });
  235. }
  236. }).catch(err => uni.hideLoading())
  237. },
  238. // 获取默认地址
  239. getDefaultAddress(){
  240. this.$http.get({
  241. api: 'api/address/default',
  242. header: {
  243. Authorization: this.token
  244. }
  245. }).then(res => {
  246. this.address = res.data.data || {};
  247. })
  248. },
  249. // 获取用户自己选择的地址
  250. getSelectAddress(){
  251. this.$http.get({
  252. api: 'api/address/'+ this.address_id,
  253. header: {
  254. Authorization: this.token
  255. }
  256. }).then(res => {
  257. this.address = res.data.data || {};
  258. })
  259. },
  260. // 打开选择优惠券
  261. openCheckCoupon(){
  262. if(this.order_detail.coupons.length){
  263. this.show_coupon = true;
  264. }else{
  265. this.$msg('您没有可用的优惠券哦');
  266. }
  267. },
  268. // 提交订单
  269. confirm(){
  270. if(this.clickContinue == true) {
  271. this.clickContinue = false;
  272. console.log(this.address)
  273. if(this.address == null) {
  274. this.$msg('请先添加收货地址!');
  275. return
  276. }
  277. this.$http.post({
  278. api: 'api/shopping/order/confirm/point',
  279. data: {
  280. order_no: this.order_detail.order.order_no,
  281. // discount_id: 0, // 优惠券id? TODO
  282. pick_self: this.mode, // 0 配送,1自提
  283. address_id: this.address.id,
  284. note: this.value
  285. },
  286. header: {
  287. Authorization: this.token,
  288. }
  289. }).then(res => {
  290. if(res.data.code == 200 || res.data.code == true){
  291. console.log(res.data.data)
  292. if(res.data.data.order.payable_freight_yuan > 0) {
  293. let order = res.data.data.order;
  294. let url = '/pages/order/cashier/cashier';
  295. url += '?amount='+ order.payable_freight_yuan;
  296. url += '&order_no='+ order.order_no;
  297. this.$cookieStorage.set('last_pay_time', order.last_pay_time);
  298. this.$url(url, {type: 'redirect'});
  299. this.clickContinue = true;
  300. }else {
  301. this.clickContinue = true;
  302. this.$msg('兑换成功')
  303. setTimeout(() => {
  304. this.$toBack()
  305. },1000)
  306. }
  307. }else{
  308. this.$msg(res.data.message);
  309. this.clickContinue = true;
  310. }
  311. })
  312. }
  313. },
  314. // 选择优惠券
  315. couponChange(event){
  316. if(event.detail.value == 'null'){
  317. this.coupon_index = null;
  318. }else{
  319. this.coupon_index = Number(event.detail.value);
  320. }
  321. }
  322. }
  323. }
  324. </script>
  325. <style>
  326. page{
  327. background-color: #F8F8F8;
  328. }
  329. </style>
  330. <style lang="scss" scoped="scoped">
  331. .card{
  332. height: max-content;
  333. width: 750rpx;
  334. padding: 30rpx 32rpx;
  335. background-color: #FFFFFF;
  336. }
  337. .head{
  338. .capsule{
  339. width: 614rpx;
  340. height: 100rpx;
  341. margin: 30rpx auto 0;
  342. border-radius: 100px;
  343. border: 2rpx solid #15716E;
  344. display: flex;
  345. overflow: hidden;
  346. .item{
  347. width: 50%;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. font-size: 32rpx;
  352. font-weight: bold;
  353. color: #15716E;
  354. }
  355. .capsule-active{
  356. background-color: #15716E;
  357. color: #FFFFFF;
  358. }
  359. }
  360. }
  361. .address{
  362. margin-top: 20rpx;
  363. }
  364. .goods{
  365. margin-top: 20rpx;
  366. .shop-name{
  367. font-size: 28rpx;
  368. color: #222222;
  369. font-weight: bold;
  370. margin: 0 15rpx;
  371. }
  372. .goods-img{
  373. width: 130rpx;
  374. height: 130rpx;
  375. border-radius: 4rpx;
  376. margin-right: 15rpx;
  377. background-color: #EEEEEE;
  378. }
  379. .info{
  380. width: 540rpx;
  381. height: 130rpx;
  382. display: flex;
  383. flex-direction: column;
  384. justify-content: space-around;
  385. .price{
  386. font-size: 32rpx;
  387. color: #F63434;
  388. font-weight: bold;
  389. }
  390. }
  391. .tips{
  392. font-size: 22rpx;
  393. margin-top: 30rpx;
  394. color: #15716E;
  395. }
  396. .input{
  397. margin-left: 30rpx;
  398. font-size: 28rpx;
  399. width: 596rpx;
  400. }
  401. }
  402. .spread-out{
  403. height: 138rpx;
  404. padding-bottom: constant(safe-area-inset-bottom);
  405. padding-bottom: env(safe-area-inset-bottom);
  406. box-sizing: content-box;
  407. }
  408. .fixed-bottom{
  409. position: fixed;
  410. left: 0;
  411. bottom: 0;
  412. width: 750rpx;
  413. height: max-content;
  414. background-color: #FFFFFF;
  415. border-top: 1rpx solid #e5e5e5;
  416. padding-bottom: constant(safe-area-inset-bottom);
  417. padding-bottom: env(safe-area-inset-bottom);
  418. .fixed-content{
  419. width: 100%;
  420. height: 118rpx;
  421. padding: 0 32rpx;
  422. display: flex;
  423. align-items: center;
  424. justify-content: space-between;
  425. .confirm-btn{
  426. width: 167rpx;
  427. height: 80rpx;
  428. background: #15716E;
  429. border-radius: 40rpx;
  430. color: #FFFFFF;
  431. display: flex;
  432. justify-content: center;
  433. align-items: center;
  434. margin-left: 30rpx;
  435. font-size: 26rpx;
  436. }
  437. }
  438. }
  439. .popup-content{
  440. width: 750rpx;
  441. height: max-content;
  442. max-height: 70vh;
  443. overflow-y: scroll;
  444. padding: 40rpx 32rpx;
  445. background: #FFFFFF;
  446. }
  447. .coupon-circle1 {
  448. width: 40rpx;
  449. height: 40rpx;
  450. background-color: white;
  451. border-radius: 50%;
  452. }
  453. .coupon-circle-top {
  454. width: 50rpx;
  455. height: 50rpx;
  456. border-radius: 50%;
  457. // background-color: red;
  458. position: absolute;
  459. border: 1px dashed #ccc;
  460. left: 190rpx;
  461. top: -20rpx;
  462. display: flex;
  463. align-items: center;
  464. text-align: center;
  465. justify-content: center;
  466. }
  467. .coupon-circle-bottom {
  468. width: 50rpx;
  469. height: 50rpx;
  470. border-radius: 50%;
  471. // background-color: red;
  472. position: absolute;
  473. border: 1px dashed #ccc;
  474. left: 190rpx;
  475. bottom: -20rpx;
  476. display: flex;
  477. align-items: center;
  478. text-align: center;
  479. justify-content: center;
  480. }
  481. .coupon-right {
  482. text-align: left;
  483. justify-content: center;
  484. align-items: flex-start;
  485. display: flex;
  486. flex-direction: column;
  487. margin-left: 90rpx;
  488. }
  489. .coupon-left {
  490. margin-left: 30rpx;
  491. display: flex;
  492. flex-direction: column;
  493. justify-content: center;
  494. align-items: center;
  495. }
  496. .coupon-tag {
  497. width: max-content;
  498. margin-top: 10rpx;
  499. padding: 0 24rpx;
  500. height: 43rpx;
  501. border-radius: 22rpx;
  502. border: 2rpx solid #FFFFFF;
  503. font-size: 24rpx;
  504. color: white;
  505. }
  506. .coupon-wrap {
  507. display: flex;
  508. justify-content: center;
  509. margin-top: 30rpx;
  510. flex-direction: column;
  511. align-content: center;
  512. align-items: center;
  513. }
  514. .coupon-card {
  515. overflow: hidden;
  516. position: relative;
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. // width: 674rpx;
  521. width: 626rpx;
  522. height: 171rpx;
  523. background: #15716E;
  524. border-radius: 20rpx;
  525. }
  526. .invalid-bg{
  527. background-color: #999999;
  528. }
  529. .coupon-radius {
  530. // width: 664rpx;
  531. width: 616rpx;
  532. display: flex;
  533. height: 161rpx;
  534. border: 1rpx dashed #ccc;
  535. // background: #15716E;
  536. border-radius: 20rpx;
  537. }
  538. /deep/.u-scroll-box {
  539. display: flex;
  540. justify-content: center;
  541. align-items: center;
  542. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  543. }
  544. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  545. background-color: #15716E!important;
  546. width: 80rpx!important;
  547. position: absolute;
  548. height: 10rpx;
  549. left: 0;
  550. border-radius: 8rpx 8rpx 0px 0px!important;
  551. bottom: -12rpx;
  552. }
  553. /deep/ .u-tab-item {
  554. font-size: 28rpx!important;
  555. }
  556. </style>