金诚优选前端代码
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.

559 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.$url(url, {type: 'redirect'});
  298. this.clickContinue = true;
  299. }else {
  300. this.clickContinue = true;
  301. this.$msg('兑换成功')
  302. setTimeout(() => {
  303. this.$toBack()
  304. },1000)
  305. }
  306. }else{
  307. this.$msg(res.data.message);
  308. this.clickContinue = true;
  309. }
  310. })
  311. }
  312. },
  313. // 选择优惠券
  314. couponChange(event){
  315. if(event.detail.value == 'null'){
  316. this.coupon_index = null;
  317. }else{
  318. this.coupon_index = Number(event.detail.value);
  319. }
  320. }
  321. }
  322. }
  323. </script>
  324. <style>
  325. page{
  326. background-color: #F8F8F8;
  327. }
  328. </style>
  329. <style lang="scss" scoped="scoped">
  330. .card{
  331. height: max-content;
  332. width: 750rpx;
  333. padding: 30rpx 32rpx;
  334. background-color: #FFFFFF;
  335. }
  336. .head{
  337. .capsule{
  338. width: 614rpx;
  339. height: 100rpx;
  340. margin: 30rpx auto 0;
  341. border-radius: 100px;
  342. border: 2rpx solid #15716E;
  343. display: flex;
  344. overflow: hidden;
  345. .item{
  346. width: 50%;
  347. display: flex;
  348. justify-content: center;
  349. align-items: center;
  350. font-size: 32rpx;
  351. font-weight: bold;
  352. color: #15716E;
  353. }
  354. .capsule-active{
  355. background-color: #15716E;
  356. color: #FFFFFF;
  357. }
  358. }
  359. }
  360. .address{
  361. margin-top: 20rpx;
  362. }
  363. .goods{
  364. margin-top: 20rpx;
  365. .shop-name{
  366. font-size: 28rpx;
  367. color: #222222;
  368. font-weight: bold;
  369. margin: 0 15rpx;
  370. }
  371. .goods-img{
  372. width: 130rpx;
  373. height: 130rpx;
  374. border-radius: 4rpx;
  375. margin-right: 15rpx;
  376. background-color: #EEEEEE;
  377. }
  378. .info{
  379. width: 540rpx;
  380. height: 130rpx;
  381. display: flex;
  382. flex-direction: column;
  383. justify-content: space-around;
  384. .price{
  385. font-size: 32rpx;
  386. color: #F63434;
  387. font-weight: bold;
  388. }
  389. }
  390. .tips{
  391. font-size: 22rpx;
  392. margin-top: 30rpx;
  393. color: #15716E;
  394. }
  395. .input{
  396. margin-left: 30rpx;
  397. font-size: 28rpx;
  398. width: 596rpx;
  399. }
  400. }
  401. .spread-out{
  402. height: 138rpx;
  403. padding-bottom: constant(safe-area-inset-bottom);
  404. padding-bottom: env(safe-area-inset-bottom);
  405. box-sizing: content-box;
  406. }
  407. .fixed-bottom{
  408. position: fixed;
  409. left: 0;
  410. bottom: 0;
  411. width: 750rpx;
  412. height: max-content;
  413. background-color: #FFFFFF;
  414. border-top: 1rpx solid #e5e5e5;
  415. padding-bottom: constant(safe-area-inset-bottom);
  416. padding-bottom: env(safe-area-inset-bottom);
  417. .fixed-content{
  418. width: 100%;
  419. height: 118rpx;
  420. padding: 0 32rpx;
  421. display: flex;
  422. align-items: center;
  423. justify-content: space-between;
  424. .confirm-btn{
  425. width: 167rpx;
  426. height: 80rpx;
  427. background: #15716E;
  428. border-radius: 40rpx;
  429. color: #FFFFFF;
  430. display: flex;
  431. justify-content: center;
  432. align-items: center;
  433. margin-left: 30rpx;
  434. font-size: 26rpx;
  435. }
  436. }
  437. }
  438. .popup-content{
  439. width: 750rpx;
  440. height: max-content;
  441. max-height: 70vh;
  442. overflow-y: scroll;
  443. padding: 40rpx 32rpx;
  444. background: #FFFFFF;
  445. }
  446. .coupon-circle1 {
  447. width: 40rpx;
  448. height: 40rpx;
  449. background-color: white;
  450. border-radius: 50%;
  451. }
  452. .coupon-circle-top {
  453. width: 50rpx;
  454. height: 50rpx;
  455. border-radius: 50%;
  456. // background-color: red;
  457. position: absolute;
  458. border: 1px dashed #ccc;
  459. left: 190rpx;
  460. top: -20rpx;
  461. display: flex;
  462. align-items: center;
  463. text-align: center;
  464. justify-content: center;
  465. }
  466. .coupon-circle-bottom {
  467. width: 50rpx;
  468. height: 50rpx;
  469. border-radius: 50%;
  470. // background-color: red;
  471. position: absolute;
  472. border: 1px dashed #ccc;
  473. left: 190rpx;
  474. bottom: -20rpx;
  475. display: flex;
  476. align-items: center;
  477. text-align: center;
  478. justify-content: center;
  479. }
  480. .coupon-right {
  481. text-align: left;
  482. justify-content: center;
  483. align-items: flex-start;
  484. display: flex;
  485. flex-direction: column;
  486. margin-left: 90rpx;
  487. }
  488. .coupon-left {
  489. margin-left: 30rpx;
  490. display: flex;
  491. flex-direction: column;
  492. justify-content: center;
  493. align-items: center;
  494. }
  495. .coupon-tag {
  496. width: max-content;
  497. margin-top: 10rpx;
  498. padding: 0 24rpx;
  499. height: 43rpx;
  500. border-radius: 22rpx;
  501. border: 2rpx solid #FFFFFF;
  502. font-size: 24rpx;
  503. color: white;
  504. }
  505. .coupon-wrap {
  506. display: flex;
  507. justify-content: center;
  508. margin-top: 30rpx;
  509. flex-direction: column;
  510. align-content: center;
  511. align-items: center;
  512. }
  513. .coupon-card {
  514. overflow: hidden;
  515. position: relative;
  516. display: flex;
  517. align-items: center;
  518. justify-content: center;
  519. // width: 674rpx;
  520. width: 626rpx;
  521. height: 171rpx;
  522. background: #15716E;
  523. border-radius: 20rpx;
  524. }
  525. .invalid-bg{
  526. background-color: #999999;
  527. }
  528. .coupon-radius {
  529. // width: 664rpx;
  530. width: 616rpx;
  531. display: flex;
  532. height: 161rpx;
  533. border: 1rpx dashed #ccc;
  534. // background: #15716E;
  535. border-radius: 20rpx;
  536. }
  537. /deep/.u-scroll-box {
  538. display: flex;
  539. justify-content: center;
  540. align-items: center;
  541. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  542. }
  543. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  544. background-color: #15716E!important;
  545. width: 80rpx!important;
  546. position: absolute;
  547. height: 10rpx;
  548. left: 0;
  549. border-radius: 8rpx 8rpx 0px 0px!important;
  550. bottom: -12rpx;
  551. }
  552. /deep/ .u-tab-item {
  553. font-size: 28rpx!important;
  554. }
  555. </style>