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

552 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. }
  164. },
  165. computed: {
  166. showCouponTitle(){
  167. if(this.coupon_index != null){
  168. return this.order_detail.coupons[this.coupon_index].discount.title;
  169. }else{
  170. if(this.order_detail.coupons.length){
  171. return '不使用优惠券';
  172. }else{
  173. return '暂无可用优惠券';
  174. }
  175. }
  176. },
  177. totalPrice(){
  178. let order = this.order_detail.order;
  179. if(!this.$isRight(order)){
  180. return 0;
  181. }
  182. if(this.mode){
  183. return order.total_yuan;
  184. }else{
  185. return new Bigc(order.total_yuan).plus(order.payable_freight_yuan);
  186. }
  187. }
  188. },
  189. onLoad(e){
  190. this.token = this.$cookieStorage.get('user_token');
  191. this.goods_type = e.goods_type;
  192. if(e.product_id) {
  193. this.params = {
  194. quantity: e.quantity,
  195. product_id: e.product_id
  196. }
  197. }else {
  198. this.params = {
  199. quantity: e.quantity,
  200. goods_id: e.goods_id
  201. }
  202. }
  203. this.getPointDetails();
  204. },
  205. onUnload(){
  206. this.$cookieStorage.clear('order_confirm');
  207. },
  208. onShow(){
  209. if(this.address_id){
  210. this.getSelectAddress();
  211. }
  212. },
  213. methods: {
  214. getPointDetails() {
  215. uni.showLoading({
  216. title: '正在生成订单'
  217. })
  218. this.$http.post({
  219. api: 'api/shopping/order/checkout/point',
  220. data: this.params,
  221. header: {
  222. Authorization: this.token
  223. }
  224. }).then(res => {
  225. if(res.data.code == true){
  226. let detail = res.data.data;
  227. this.order_detail = detail;
  228. this.address = res.data.data.address;
  229. uni.hideLoading()
  230. }else{
  231. this.$msg(res.data.message || '订单提交失败!').then(() => {
  232. this.$toBack();
  233. });
  234. }
  235. }).catch(err => uni.hideLoading())
  236. },
  237. // 获取默认地址
  238. getDefaultAddress(){
  239. this.$http.get({
  240. api: 'api/address/default',
  241. header: {
  242. Authorization: this.token
  243. }
  244. }).then(res => {
  245. this.address = res.data.data || {};
  246. })
  247. },
  248. // 获取用户自己选择的地址
  249. getSelectAddress(){
  250. this.$http.get({
  251. api: 'api/address/'+ this.address_id,
  252. header: {
  253. Authorization: this.token
  254. }
  255. }).then(res => {
  256. this.address = res.data.data || {};
  257. })
  258. },
  259. // 打开选择优惠券
  260. openCheckCoupon(){
  261. if(this.order_detail.coupons.length){
  262. this.show_coupon = true;
  263. }else{
  264. this.$msg('您没有可用的优惠券哦');
  265. }
  266. },
  267. // 提交订单
  268. confirm(){
  269. console.log(this.address)
  270. if(this.address == null) {
  271. this.$msg('请先添加收货地址!');
  272. return
  273. }
  274. this.$http.post({
  275. api: 'api/shopping/order/confirm/point',
  276. data: {
  277. order_no: this.order_detail.order.order_no,
  278. // discount_id: 0, // 优惠券id? TODO
  279. pick_self: this.mode, // 0 配送,1自提
  280. address_id: this.address.id,
  281. note: this.value
  282. },
  283. header: {
  284. Authorization: this.token
  285. }
  286. }).then(res => {
  287. if(res.data.code == 200 || res.data.code == true){
  288. console.log(res.data.data)
  289. if(res.data.data.order.payable_freight_yuan > 0) {
  290. let order = res.data.data.order;
  291. let url = '/pages/order/cashier/cashier';
  292. url += '?amount='+ order.payable_freight_yuan;
  293. url += '&order_no='+ order.order_no;
  294. this.$url(url, {type: 'redirect'});
  295. }else {
  296. this.$msg('兑换成功')
  297. setTimeout(() => {
  298. this.$toBack()
  299. },1000)
  300. }
  301. }else{
  302. this.$msg(res.data.message);
  303. }
  304. })
  305. },
  306. // 选择优惠券
  307. couponChange(event){
  308. if(event.detail.value == 'null'){
  309. this.coupon_index = null;
  310. }else{
  311. this.coupon_index = Number(event.detail.value);
  312. }
  313. }
  314. }
  315. }
  316. </script>
  317. <style>
  318. page{
  319. background-color: #F8F8F8;
  320. }
  321. </style>
  322. <style lang="scss" scoped="scoped">
  323. .card{
  324. height: max-content;
  325. width: 750rpx;
  326. padding: 30rpx 32rpx;
  327. background-color: #FFFFFF;
  328. }
  329. .head{
  330. .capsule{
  331. width: 614rpx;
  332. height: 100rpx;
  333. margin: 30rpx auto 0;
  334. border-radius: 100px;
  335. border: 2rpx solid #15716E;
  336. display: flex;
  337. overflow: hidden;
  338. .item{
  339. width: 50%;
  340. display: flex;
  341. justify-content: center;
  342. align-items: center;
  343. font-size: 32rpx;
  344. font-weight: bold;
  345. color: #15716E;
  346. }
  347. .capsule-active{
  348. background-color: #15716E;
  349. color: #FFFFFF;
  350. }
  351. }
  352. }
  353. .address{
  354. margin-top: 20rpx;
  355. }
  356. .goods{
  357. margin-top: 20rpx;
  358. .shop-name{
  359. font-size: 28rpx;
  360. color: #222222;
  361. font-weight: bold;
  362. margin: 0 15rpx;
  363. }
  364. .goods-img{
  365. width: 130rpx;
  366. height: 130rpx;
  367. border-radius: 4rpx;
  368. margin-right: 15rpx;
  369. background-color: #EEEEEE;
  370. }
  371. .info{
  372. width: 540rpx;
  373. height: 130rpx;
  374. display: flex;
  375. flex-direction: column;
  376. justify-content: space-around;
  377. .price{
  378. font-size: 32rpx;
  379. color: #F63434;
  380. font-weight: bold;
  381. }
  382. }
  383. .tips{
  384. font-size: 22rpx;
  385. margin-top: 30rpx;
  386. color: #15716E;
  387. }
  388. .input{
  389. margin-left: 30rpx;
  390. font-size: 28rpx;
  391. width: 596rpx;
  392. }
  393. }
  394. .spread-out{
  395. height: 138rpx;
  396. padding-bottom: constant(safe-area-inset-bottom);
  397. padding-bottom: env(safe-area-inset-bottom);
  398. box-sizing: content-box;
  399. }
  400. .fixed-bottom{
  401. position: fixed;
  402. left: 0;
  403. bottom: 0;
  404. width: 750rpx;
  405. height: max-content;
  406. background-color: #FFFFFF;
  407. border-top: 1rpx solid #e5e5e5;
  408. padding-bottom: constant(safe-area-inset-bottom);
  409. padding-bottom: env(safe-area-inset-bottom);
  410. .fixed-content{
  411. width: 100%;
  412. height: 118rpx;
  413. padding: 0 32rpx;
  414. display: flex;
  415. align-items: center;
  416. justify-content: space-between;
  417. .confirm-btn{
  418. width: 167rpx;
  419. height: 80rpx;
  420. background: #15716E;
  421. border-radius: 40rpx;
  422. color: #FFFFFF;
  423. display: flex;
  424. justify-content: center;
  425. align-items: center;
  426. margin-left: 30rpx;
  427. font-size: 26rpx;
  428. }
  429. }
  430. }
  431. .popup-content{
  432. width: 750rpx;
  433. height: max-content;
  434. max-height: 70vh;
  435. overflow-y: scroll;
  436. padding: 40rpx 32rpx;
  437. background: #FFFFFF;
  438. }
  439. .coupon-circle1 {
  440. width: 40rpx;
  441. height: 40rpx;
  442. background-color: white;
  443. border-radius: 50%;
  444. }
  445. .coupon-circle-top {
  446. width: 50rpx;
  447. height: 50rpx;
  448. border-radius: 50%;
  449. // background-color: red;
  450. position: absolute;
  451. border: 1px dashed #ccc;
  452. left: 190rpx;
  453. top: -20rpx;
  454. display: flex;
  455. align-items: center;
  456. text-align: center;
  457. justify-content: center;
  458. }
  459. .coupon-circle-bottom {
  460. width: 50rpx;
  461. height: 50rpx;
  462. border-radius: 50%;
  463. // background-color: red;
  464. position: absolute;
  465. border: 1px dashed #ccc;
  466. left: 190rpx;
  467. bottom: -20rpx;
  468. display: flex;
  469. align-items: center;
  470. text-align: center;
  471. justify-content: center;
  472. }
  473. .coupon-right {
  474. text-align: left;
  475. justify-content: center;
  476. align-items: flex-start;
  477. display: flex;
  478. flex-direction: column;
  479. margin-left: 90rpx;
  480. }
  481. .coupon-left {
  482. margin-left: 30rpx;
  483. display: flex;
  484. flex-direction: column;
  485. justify-content: center;
  486. align-items: center;
  487. }
  488. .coupon-tag {
  489. width: max-content;
  490. margin-top: 10rpx;
  491. padding: 0 24rpx;
  492. height: 43rpx;
  493. border-radius: 22rpx;
  494. border: 2rpx solid #FFFFFF;
  495. font-size: 24rpx;
  496. color: white;
  497. }
  498. .coupon-wrap {
  499. display: flex;
  500. justify-content: center;
  501. margin-top: 30rpx;
  502. flex-direction: column;
  503. align-content: center;
  504. align-items: center;
  505. }
  506. .coupon-card {
  507. overflow: hidden;
  508. position: relative;
  509. display: flex;
  510. align-items: center;
  511. justify-content: center;
  512. // width: 674rpx;
  513. width: 626rpx;
  514. height: 171rpx;
  515. background: #15716E;
  516. border-radius: 20rpx;
  517. }
  518. .invalid-bg{
  519. background-color: #999999;
  520. }
  521. .coupon-radius {
  522. // width: 664rpx;
  523. width: 616rpx;
  524. display: flex;
  525. height: 161rpx;
  526. border: 1rpx dashed #ccc;
  527. // background: #15716E;
  528. border-radius: 20rpx;
  529. }
  530. /deep/.u-scroll-box {
  531. display: flex;
  532. justify-content: center;
  533. align-items: center;
  534. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  535. }
  536. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  537. background-color: #15716E!important;
  538. width: 80rpx!important;
  539. position: absolute;
  540. height: 10rpx;
  541. left: 0;
  542. border-radius: 8rpx 8rpx 0px 0px!important;
  543. bottom: -12rpx;
  544. }
  545. /deep/ .u-tab-item {
  546. font-size: 28rpx!important;
  547. }
  548. </style>