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

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