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

545 lines
15 KiB

4 years ago
4 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.order.brand.name }}</text>
  37. <text class="lf-font-28 lf-color-777 lf-m-l-20">{{ order_detail.order.brand.tel }}</text>
  38. </view>
  39. <view class="lf-font-28 lf-color-333 lf-m-t-10">
  40. <text>{{ order_detail.order.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.order.brand.id)">
  49. <text class="lf-iconfont icon-Group- lf-font-30"></text>
  50. <text class="shop-name">{{ order_detail.order.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.total_yuan }}<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" @click="openCheckCoupon">
  72. <view class="lf-font-28 lf-color-777">优惠券</view>
  73. <view>
  74. <text class="lf-font-26 lf-color-999 lf-m-r-10">{{ showCouponTitle }}</text>
  75. <text class="lf-iconfont icon-xiangyou lf-font-24"></text>
  76. </view>
  77. </view>
  78. <view class="lf-row-between lf-m-t-20">
  79. <view class="lf-font-28 lf-color-777">商品金额</view>
  80. <view class="lf-font-26 lf-color-222"><text v-if="goods_type==1">¥</text>{{ order_detail.order.items_total_yuan }}<text v-if="goods_type==0">积分</text></view>
  81. </view>
  82. <view class="lf-row-between lf-m-t-20" v-if="mode == 0">
  83. <view class="lf-font-28 lf-color-777">运费</view>
  84. <view class="lf-font-26" style="color: #F63434;">+¥{{ order_detail.order.payable_freight_yuan }}</view>
  85. </view>
  86. <view class="lf-row-between lf-m-t-20">
  87. <view class="lf-font-28 lf-color-777">优惠</view>
  88. <view class="lf-font-26" style="color: #F63434;">-¥{{ order_detail.order.adjustments_total_yuan }}</view>
  89. </view>
  90. </view>
  91. <view class="spread-out"></view>
  92. <view class="fixed-bottom">
  93. <view class="fixed-content">
  94. <view class="lf-font-24 lf-color-777">{{ order_detail.order.count }}</view>
  95. <view class="lf-flex">
  96. <!-- <view class="lf-font-32 lf-color-primary" style="max-width: 400rpx;">合计 ¥{{ order_detail.order.total_yuan }}</view> -->
  97. <view class="lf-font-32 lf-color-primary" style="max-width: 400rpx;">
  98. <text>合计</text>
  99. <text v-if="goods_type==1">¥</text>
  100. <text>{{ totalPrice }}</text>
  101. <text v-if="goods_type==0">积分</text>
  102. </view>
  103. <view class="confirm-btn" hover-class="lf-opacity" @click="confirm">提交订单</view>
  104. </view>
  105. </view>
  106. </view>
  107. <!-- 选择优惠券弹出层 -->
  108. <u-popup v-model="show_coupon" mode="bottom" :round="true" borderRadius="20">
  109. <view class="popup-content">
  110. <view class="lf-row-between" v-for="(item, index) in order_detail.coupons" :key="index">
  111. <radio-group @change="couponChange">
  112. <radio :value="index" :checked="coupon_index == index"></radio>
  113. </radio-group>
  114. <view class="coupon-card lf-m-b-30" :class="{'invalid-bg': item.ifpast == true}">
  115. <view class="coupon-circle-top">
  116. <view class="coupon-circle1"></view>
  117. </view>
  118. <view class="coupon-circle-bottom">
  119. <view class="coupon-circle1"></view>
  120. </view>
  121. <view class="coupon-radius">
  122. <view class="coupon-left">
  123. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'cash'">
  124. <text v-if="goods_type==1"></text>
  125. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  126. <text v-if="goods_type==0">积分</text>
  127. </view>
  128. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'discount'">
  129. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  130. <text>%</text>
  131. </view>
  132. <view class="coupon-tag" v-if="item.used_at != ''">
  133. 已使用
  134. </view>
  135. <view class="coupon-tag" v-if="item.ifpast">
  136. 已过期
  137. </view>
  138. <view class="coupon-tag" v-if="!item.ifpast && item.used_at == ''">
  139. 待使用
  140. </view>
  141. </view>
  142. <view class="coupon-right">
  143. <view class="lf-font-32 lf-font-bold lf-color-white">{{item.discount.title}}</view>
  144. <view class="lf-font-24 lf-color-white">有效期{{item.discount.starts_at}}~{{item.discount.ends_at}}</view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. <!-- 不使用优惠券 -->
  150. <view class="lf-flex">
  151. <radio-group @change="couponChange">
  152. <radio value="null" :checked="coupon_index == null"></radio>
  153. </radio-group>
  154. <view>不使用优惠券</view>
  155. </view>
  156. </view>
  157. </u-popup>
  158. </block>
  159. </view>
  160. </template>
  161. <script>
  162. import Bigc from '@/common/js/bigc.js';
  163. export default {
  164. data(){
  165. return {
  166. mode: 0, // 0邮寄,1自提
  167. value: '', // 备注
  168. token: '',
  169. address: {},
  170. address_id: null,
  171. order_detail: {coupons: []},
  172. show_coupon: false,
  173. coupon_index: null,
  174. goods_type: 1
  175. }
  176. },
  177. computed: {
  178. showCouponTitle(){
  179. if(this.coupon_index != null){
  180. return this.order_detail.coupons[this.coupon_index].discount.title;
  181. }else{
  182. if(this.order_detail.coupons.length){
  183. return '不使用优惠券';
  184. }else{
  185. return '暂无可用优惠券';
  186. }
  187. }
  188. },
  189. totalPrice(){
  190. let order = this.order_detail.order;
  191. if(!this.$isRight(order)){
  192. return 0;
  193. }
  194. if(this.mode){
  195. return order.total_yuan;
  196. }else{
  197. return new Bigc(order.total_yuan).plus(order.payable_freight);
  198. }
  199. }
  200. },
  201. onLoad(e){
  202. this.token = this.$cookieStorage.get('user_token');
  203. this.goods_type = e.goods_type;
  204. console.log('积分类型',e)
  205. let options = this.$cookieStorage.get('order_confirm');
  206. if(this.$isRight(options)){
  207. this.orderCheckout(options);
  208. }
  209. },
  210. onUnload(){
  211. this.$cookieStorage.clear('order_confirm');
  212. },
  213. onShow(){
  214. if(this.address_id){
  215. this.getSelectAddress();
  216. }
  217. },
  218. methods: {
  219. // 生成临时订单
  220. orderCheckout(options){
  221. uni.showLoading({
  222. title: '正在生成订单'
  223. })
  224. this.$http.post({
  225. api: 'api/shopping/order/checkout',
  226. data: options,
  227. header: {
  228. Authorization: this.token
  229. }
  230. }).then(res => {
  231. let detail = res.data.data;
  232. this.order_detail = detail;
  233. this.address = res.data.data.address;
  234. uni.hideLoading()
  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',
  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. console.log("`````````", res);
  288. if(res.data.code == 200 || res.data.code == true){
  289. let order = res.data.data.order;
  290. let url = '/pages/order/cashier/cashier';
  291. url += '?amount='+ order.total_yuan;
  292. url += '&order_no='+ order.order_no;
  293. this.$url(url, {type: 'redirect'});
  294. }else{
  295. this.$msg(res.data.message);
  296. }
  297. })
  298. },
  299. // 选择优惠券
  300. couponChange(event){
  301. if(event.detail.value == 'null'){
  302. this.coupon_index = null;
  303. }else{
  304. this.coupon_index = Number(event.detail.value);
  305. }
  306. }
  307. }
  308. }
  309. </script>
  310. <style>
  311. page{
  312. background-color: #F8F8F8;
  313. }
  314. </style>
  315. <style lang="scss" scoped="scoped">
  316. .card{
  317. height: max-content;
  318. width: 750rpx;
  319. padding: 30rpx 32rpx;
  320. background-color: #FFFFFF;
  321. }
  322. .head{
  323. .capsule{
  324. width: 614rpx;
  325. height: 100rpx;
  326. margin: 30rpx auto 0;
  327. border-radius: 100px;
  328. border: 2rpx solid #15716E;
  329. display: flex;
  330. overflow: hidden;
  331. .item{
  332. width: 50%;
  333. display: flex;
  334. justify-content: center;
  335. align-items: center;
  336. font-size: 32rpx;
  337. font-weight: bold;
  338. color: #15716E;
  339. }
  340. .capsule-active{
  341. background-color: #15716E;
  342. color: #FFFFFF;
  343. }
  344. }
  345. }
  346. .address{
  347. margin-top: 20rpx;
  348. }
  349. .goods{
  350. margin-top: 20rpx;
  351. .shop-name{
  352. font-size: 28rpx;
  353. color: #222222;
  354. font-weight: bold;
  355. margin: 0 15rpx;
  356. }
  357. .goods-img{
  358. width: 130rpx;
  359. height: 130rpx;
  360. border-radius: 4rpx;
  361. margin-right: 15rpx;
  362. background-color: #EEEEEE;
  363. }
  364. .info{
  365. width: 540rpx;
  366. height: 130rpx;
  367. display: flex;
  368. flex-direction: column;
  369. justify-content: space-around;
  370. .price{
  371. font-size: 32rpx;
  372. color: #F63434;
  373. font-weight: bold;
  374. }
  375. }
  376. .tips{
  377. font-size: 22rpx;
  378. margin-top: 30rpx;
  379. color: #15716E;
  380. }
  381. .input{
  382. margin-left: 30rpx;
  383. font-size: 28rpx;
  384. width: 596rpx;
  385. }
  386. }
  387. .spread-out{
  388. height: 138rpx;
  389. padding-bottom: constant(safe-area-inset-bottom);
  390. padding-bottom: env(safe-area-inset-bottom);
  391. box-sizing: content-box;
  392. }
  393. .fixed-bottom{
  394. position: fixed;
  395. left: 0;
  396. bottom: 0;
  397. width: 750rpx;
  398. height: max-content;
  399. background-color: #FFFFFF;
  400. border-top: 1rpx solid #e5e5e5;
  401. padding-bottom: constant(safe-area-inset-bottom);
  402. padding-bottom: env(safe-area-inset-bottom);
  403. .fixed-content{
  404. width: 100%;
  405. height: 118rpx;
  406. padding: 0 32rpx;
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. .confirm-btn{
  411. width: 167rpx;
  412. height: 80rpx;
  413. background: #15716E;
  414. border-radius: 40rpx;
  415. color: #FFFFFF;
  416. display: flex;
  417. justify-content: center;
  418. align-items: center;
  419. margin-left: 30rpx;
  420. font-size: 26rpx;
  421. }
  422. }
  423. }
  424. .popup-content{
  425. width: 750rpx;
  426. height: max-content;
  427. max-height: 70vh;
  428. overflow-y: scroll;
  429. padding: 40rpx 32rpx;
  430. background: #FFFFFF;
  431. }
  432. .coupon-circle1 {
  433. width: 40rpx;
  434. height: 40rpx;
  435. background-color: white;
  436. border-radius: 50%;
  437. }
  438. .coupon-circle-top {
  439. width: 50rpx;
  440. height: 50rpx;
  441. border-radius: 50%;
  442. // background-color: red;
  443. position: absolute;
  444. border: 1px dashed #ccc;
  445. left: 190rpx;
  446. top: -20rpx;
  447. display: flex;
  448. align-items: center;
  449. text-align: center;
  450. justify-content: center;
  451. }
  452. .coupon-circle-bottom {
  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. bottom: -20rpx;
  461. display: flex;
  462. align-items: center;
  463. text-align: center;
  464. justify-content: center;
  465. }
  466. .coupon-right {
  467. text-align: left;
  468. justify-content: center;
  469. align-items: flex-start;
  470. display: flex;
  471. flex-direction: column;
  472. margin-left: 90rpx;
  473. }
  474. .coupon-left {
  475. margin-left: 30rpx;
  476. display: flex;
  477. flex-direction: column;
  478. justify-content: center;
  479. align-items: center;
  480. }
  481. .coupon-tag {
  482. width: max-content;
  483. margin-top: 10rpx;
  484. padding: 0 24rpx;
  485. height: 43rpx;
  486. border-radius: 22rpx;
  487. border: 2rpx solid #FFFFFF;
  488. font-size: 24rpx;
  489. color: white;
  490. }
  491. .coupon-wrap {
  492. display: flex;
  493. justify-content: center;
  494. margin-top: 30rpx;
  495. flex-direction: column;
  496. align-content: center;
  497. align-items: center;
  498. }
  499. .coupon-card {
  500. overflow: hidden;
  501. position: relative;
  502. display: flex;
  503. align-items: center;
  504. justify-content: center;
  505. // width: 674rpx;
  506. width: 626rpx;
  507. height: 171rpx;
  508. background: #15716E;
  509. border-radius: 20rpx;
  510. }
  511. .invalid-bg{
  512. background-color: #999999;
  513. }
  514. .coupon-radius {
  515. // width: 664rpx;
  516. width: 616rpx;
  517. display: flex;
  518. height: 161rpx;
  519. border: 1rpx dashed #ccc;
  520. // background: #15716E;
  521. border-radius: 20rpx;
  522. }
  523. /deep/.u-scroll-box {
  524. display: flex;
  525. justify-content: center;
  526. align-items: center;
  527. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  528. }
  529. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  530. background-color: #15716E!important;
  531. width: 80rpx!important;
  532. position: absolute;
  533. height: 10rpx;
  534. left: 0;
  535. border-radius: 8rpx 8rpx 0px 0px!important;
  536. bottom: -12rpx;
  537. }
  538. /deep/ .u-tab-item {
  539. font-size: 28rpx!important;
  540. }
  541. </style>