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

553 lines
15 KiB

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