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

506 lines
13 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 goods">
  31. <view @click="$url('/pages/shop/shopdetail?id='+ order_detail.order.brand.id)">
  32. <text class="lf-iconfont icon-Group- lf-font-30"></text>
  33. <text class="shop-name">{{ order_detail.order.brand.name }}</text>
  34. <text class="lf-iconfont icon-xiangyou lf-font-24"></text>
  35. </view>
  36. <view class="lf-flex lf-m-t-20" v-for="(item, index) in order_detail.order.items" :key="index">
  37. <image class="goods-img" :src="item.item_meta.image"></image>
  38. <view class="info">
  39. <view class="lf-font-26 lf-color-333 lf-line-1">{{ item.item_name }}</view>
  40. <view class="lf-font-24 lf-color-777">{{ item.item_meta.specs_text }}</view>
  41. <view class="lf-row-between" style="line-height: 1;">
  42. <text class="price">¥{{ item.total_yuan }}</text>
  43. <text class="lf-font-28 lf-color-777">x {{ item.quantity }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- <view class="tips">支付成功后15天内柜台提货</view> -->
  48. <view class="lf-flex lf-m-t-20">
  49. <view class="lf-font-28 lf-color-777">留言</view>
  50. <input v-model="value" class="input" placeholder="有什么要求,请备注留言" />
  51. </view>
  52. </view>
  53. <view class="card lf-m-t-20">
  54. <view class="lf-row-between" @click="openCheckCoupon">
  55. <view class="lf-font-28 lf-color-777">优惠券</view>
  56. <view>
  57. <text class="lf-font-26 lf-color-999 lf-m-r-10">{{ showCouponTitle }}</text>
  58. <text class="lf-iconfont icon-xiangyou lf-font-24"></text>
  59. </view>
  60. </view>
  61. <view class="lf-row-between lf-m-t-20">
  62. <view class="lf-font-28 lf-color-777">商品金额</view>
  63. <view class="lf-font-26 lf-color-222">¥{{ order_detail.order.items_total_yuan }}</view>
  64. </view>
  65. <view class="lf-row-between lf-m-t-20" v-if="mode == 0">
  66. <view class="lf-font-28 lf-color-777">运费</view>
  67. <view class="lf-font-26" style="color: #F63434;">+¥{{ order_detail.order.payable_freight }}</view>
  68. </view>
  69. <view class="lf-row-between lf-m-t-20">
  70. <view class="lf-font-28 lf-color-777">优惠</view>
  71. <view class="lf-font-26" style="color: #F63434;">-¥{{ order_detail.order.adjustments_total_yuan }}</view>
  72. </view>
  73. </view>
  74. <view class="spread-out"></view>
  75. <view class="fixed-bottom">
  76. <view class="fixed-content">
  77. <view class="lf-font-24 lf-color-777">{{ order_detail.order.count }}</view>
  78. <view class="lf-flex">
  79. <view class="lf-font-32 lf-color-primary" style="max-width: 400rpx;">合计 ¥{{ order_detail.order.total_yuan }}</view>
  80. <view class="confirm-btn" hover-class="lf-opacity" @click="confirm">提交订单</view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 选择优惠券弹出层 -->
  85. <u-popup v-model="show_coupon" mode="bottom" :round="true" borderRadius="20">
  86. <view class="popup-content">
  87. <view class="lf-row-between" v-for="(item, index) in order_detail.coupons" :key="index">
  88. <radio-group @change="couponChange">
  89. <radio :value="index" :checked="coupon_index == index"></radio>
  90. </radio-group>
  91. <view class="coupon-card lf-m-b-30" :class="{'invalid-bg': item.ifpast == true}">
  92. <view class="coupon-circle-top">
  93. <view class="coupon-circle1"></view>
  94. </view>
  95. <view class="coupon-circle-bottom">
  96. <view class="coupon-circle1"></view>
  97. </view>
  98. <view class="coupon-radius">
  99. <view class="coupon-left">
  100. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'cash'">
  101. <text></text>
  102. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  103. </view>
  104. <view class="lf-font-36 lf-color-white" style="line-height: 1;" v-if="item.discount.action_type.type == 'discount'">
  105. <text class="lf-font-70 lf-font-bold">{{item.discount.action_type.value}}</text>
  106. <text>%</text>
  107. </view>
  108. <view class="coupon-tag" v-if="item.used_at != ''">
  109. 已使用
  110. </view>
  111. <view class="coupon-tag" v-if="item.ifpast">
  112. 已过期
  113. </view>
  114. <view class="coupon-tag" v-if="!item.ifpast && item.used_at == ''">
  115. 待使用
  116. </view>
  117. </view>
  118. <view class="coupon-right">
  119. <view class="lf-font-32 lf-font-bold lf-color-white">{{item.discount.title}}</view>
  120. <view class="lf-font-24 lf-color-white">有效期{{item.discount.starts_at}}~{{item.discount.ends_at}}</view>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 不使用优惠券 -->
  126. <view class="lf-flex">
  127. <radio-group @change="couponChange">
  128. <radio value="null" :checked="coupon_index == null"></radio>
  129. </radio-group>
  130. <view>不使用优惠券</view>
  131. </view>
  132. </view>
  133. </u-popup>
  134. </block>
  135. </view>
  136. </template>
  137. <script>
  138. export default {
  139. data(){
  140. return {
  141. mode: 0, // 0邮寄,1自提
  142. value: '', // 备注
  143. token: '',
  144. address: {},
  145. address_id: null,
  146. order_detail: {coupons: []},
  147. show_coupon: false,
  148. coupon_index: null
  149. }
  150. },
  151. computed: {
  152. showCouponTitle(){
  153. if(this.coupon_index != null){
  154. return this.order_detail.coupons[this.coupon_index].discount.title;
  155. }else{
  156. if(this.order_detail.coupons.length){
  157. return '不使用优惠券';
  158. }else{
  159. return '暂无可用优惠券';
  160. }
  161. }
  162. }
  163. },
  164. onLoad(){
  165. this.token = this.$cookieStorage.get('user_token');
  166. let options = this.$cookieStorage.get('order_confirm');
  167. if(this.$isRight(options)){
  168. this.orderCheckout(options);
  169. }
  170. },
  171. onUnload(){
  172. this.$cookieStorage.clear('order_confirm');
  173. },
  174. onShow(){
  175. if(this.address_id){
  176. this.getSelectAddress();
  177. }
  178. },
  179. methods: {
  180. // 生成临时订单
  181. orderCheckout(options){
  182. uni.showLoading({
  183. title: '正在生成订单'
  184. })
  185. this.$http.post({
  186. api: 'api/shopping/order/checkout',
  187. data: options,
  188. header: {
  189. Authorization: this.token
  190. }
  191. }).then(res => {
  192. let detail = res.data.data;
  193. this.order_detail = detail;
  194. this.address = res.data.data.address;
  195. uni.hideLoading()
  196. }).catch(err => uni.hideLoading())
  197. },
  198. // 获取默认地址
  199. getDefaultAddress(){
  200. this.$http.get({
  201. api: 'api/address/default',
  202. header: {
  203. Authorization: this.token
  204. }
  205. }).then(res => {
  206. this.address = res.data.data || {};
  207. })
  208. },
  209. // 获取用户自己选择的地址
  210. getSelectAddress(){
  211. this.$http.get({
  212. api: 'api/address/'+ this.address_id,
  213. header: {
  214. Authorization: this.token
  215. }
  216. }).then(res => {
  217. this.address = res.data.data || {};
  218. })
  219. },
  220. // 打开选择优惠券
  221. openCheckCoupon(){
  222. if(this.order_detail.coupons.length){
  223. this.show_coupon = true;
  224. }else{
  225. this.$msg('您没有可用的优惠券哦');
  226. }
  227. },
  228. // 提交订单
  229. confirm(){
  230. console.log(this.address)
  231. if(this.address == null) {
  232. this.$msg('请先添加收货地址!');
  233. return
  234. }
  235. this.$http.post({
  236. api: 'api/shopping/order/confirm',
  237. data: {
  238. order_no: this.order_detail.order.order_no,
  239. // discount_id: 0, // 优惠券id? TODO
  240. pick_self: this.mode, // 0 配送,1自提
  241. address_id: this.address.id,
  242. note: this.value
  243. },
  244. header: {
  245. Authorization: this.token
  246. }
  247. }).then(res => {
  248. console.log("`````````", res);
  249. if(res.data.code == 200 || res.data.code == true){
  250. let order = res.data.data.order;
  251. let url = '/pages/order/cashier/cashier';
  252. url += '?amount='+ order.total_yuan;
  253. url += '&order_no='+ order.order_no;
  254. this.$url(url, {type: 'redirect'});
  255. }else{
  256. this.$msg(res.data.message);
  257. }
  258. })
  259. },
  260. // 选择优惠券
  261. couponChange(event){
  262. if(event.detail.value == 'null'){
  263. this.coupon_index = null;
  264. }else{
  265. this.coupon_index = Number(event.detail.value);
  266. }
  267. }
  268. }
  269. }
  270. </script>
  271. <style>
  272. page{
  273. background-color: #F8F8F8;
  274. }
  275. </style>
  276. <style lang="scss" scoped="scoped">
  277. .card{
  278. height: max-content;
  279. width: 750rpx;
  280. padding: 30rpx 32rpx;
  281. background-color: #FFFFFF;
  282. }
  283. .head{
  284. .capsule{
  285. width: 614rpx;
  286. height: 100rpx;
  287. margin: 30rpx auto 0;
  288. border-radius: 100px;
  289. border: 2rpx solid #15716E;
  290. display: flex;
  291. overflow: hidden;
  292. .item{
  293. width: 50%;
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. font-size: 32rpx;
  298. font-weight: bold;
  299. color: #15716E;
  300. }
  301. .capsule-active{
  302. background-color: #15716E;
  303. color: #FFFFFF;
  304. }
  305. }
  306. }
  307. .address{
  308. margin-top: 20rpx;
  309. }
  310. .goods{
  311. margin-top: 20rpx;
  312. .shop-name{
  313. font-size: 28rpx;
  314. color: #222222;
  315. font-weight: bold;
  316. margin: 0 15rpx;
  317. }
  318. .goods-img{
  319. width: 130rpx;
  320. height: 130rpx;
  321. border-radius: 4rpx;
  322. margin-right: 15rpx;
  323. background-color: #EEEEEE;
  324. }
  325. .info{
  326. width: 540rpx;
  327. height: 130rpx;
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: space-around;
  331. .price{
  332. font-size: 32rpx;
  333. color: #F63434;
  334. font-weight: bold;
  335. }
  336. }
  337. .tips{
  338. font-size: 22rpx;
  339. margin-top: 30rpx;
  340. color: #15716E;
  341. }
  342. .input{
  343. margin-left: 30rpx;
  344. font-size: 28rpx;
  345. width: 596rpx;
  346. }
  347. }
  348. .spread-out{
  349. height: 138rpx;
  350. padding-bottom: constant(safe-area-inset-bottom);
  351. padding-bottom: env(safe-area-inset-bottom);
  352. box-sizing: content-box;
  353. }
  354. .fixed-bottom{
  355. position: fixed;
  356. left: 0;
  357. bottom: 0;
  358. width: 750rpx;
  359. height: max-content;
  360. background-color: #FFFFFF;
  361. border-top: 1rpx solid #e5e5e5;
  362. padding-bottom: constant(safe-area-inset-bottom);
  363. padding-bottom: env(safe-area-inset-bottom);
  364. .fixed-content{
  365. width: 100%;
  366. height: 118rpx;
  367. padding: 0 32rpx;
  368. display: flex;
  369. align-items: center;
  370. justify-content: space-between;
  371. .confirm-btn{
  372. width: 167rpx;
  373. height: 80rpx;
  374. background: #15716E;
  375. border-radius: 40rpx;
  376. color: #FFFFFF;
  377. display: flex;
  378. justify-content: center;
  379. align-items: center;
  380. margin-left: 30rpx;
  381. font-size: 26rpx;
  382. }
  383. }
  384. }
  385. .popup-content{
  386. width: 750rpx;
  387. height: max-content;
  388. max-height: 70vh;
  389. overflow-y: scroll;
  390. padding: 40rpx 32rpx;
  391. background: #FFFFFF;
  392. }
  393. .coupon-circle1 {
  394. width: 40rpx;
  395. height: 40rpx;
  396. background-color: white;
  397. border-radius: 50%;
  398. }
  399. .coupon-circle-top {
  400. width: 50rpx;
  401. height: 50rpx;
  402. border-radius: 50%;
  403. // background-color: red;
  404. position: absolute;
  405. border: 1px dashed #ccc;
  406. left: 190rpx;
  407. top: -20rpx;
  408. display: flex;
  409. align-items: center;
  410. text-align: center;
  411. justify-content: center;
  412. }
  413. .coupon-circle-bottom {
  414. width: 50rpx;
  415. height: 50rpx;
  416. border-radius: 50%;
  417. // background-color: red;
  418. position: absolute;
  419. border: 1px dashed #ccc;
  420. left: 190rpx;
  421. bottom: -20rpx;
  422. display: flex;
  423. align-items: center;
  424. text-align: center;
  425. justify-content: center;
  426. }
  427. .coupon-right {
  428. text-align: left;
  429. justify-content: center;
  430. align-items: flex-start;
  431. display: flex;
  432. flex-direction: column;
  433. margin-left: 90rpx;
  434. }
  435. .coupon-left {
  436. margin-left: 30rpx;
  437. display: flex;
  438. flex-direction: column;
  439. justify-content: center;
  440. align-items: center;
  441. }
  442. .coupon-tag {
  443. width: max-content;
  444. margin-top: 10rpx;
  445. padding: 0 24rpx;
  446. height: 43rpx;
  447. border-radius: 22rpx;
  448. border: 2rpx solid #FFFFFF;
  449. font-size: 24rpx;
  450. color: white;
  451. }
  452. .coupon-wrap {
  453. display: flex;
  454. justify-content: center;
  455. margin-top: 30rpx;
  456. flex-direction: column;
  457. align-content: center;
  458. align-items: center;
  459. }
  460. .coupon-card {
  461. overflow: hidden;
  462. position: relative;
  463. display: flex;
  464. align-items: center;
  465. justify-content: center;
  466. // width: 674rpx;
  467. width: 626rpx;
  468. height: 171rpx;
  469. background: #15716E;
  470. border-radius: 20rpx;
  471. }
  472. .invalid-bg{
  473. background-color: #999999;
  474. }
  475. .coupon-radius {
  476. // width: 664rpx;
  477. width: 616rpx;
  478. display: flex;
  479. height: 161rpx;
  480. border: 1rpx dashed #ccc;
  481. // background: #15716E;
  482. border-radius: 20rpx;
  483. }
  484. /deep/.u-scroll-box {
  485. display: flex;
  486. justify-content: center;
  487. align-items: center;
  488. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  489. }
  490. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  491. background-color: #15716E!important;
  492. width: 80rpx!important;
  493. position: absolute;
  494. height: 10rpx;
  495. left: 0;
  496. border-radius: 8rpx 8rpx 0px 0px!important;
  497. bottom: -12rpx;
  498. }
  499. /deep/ .u-tab-item {
  500. font-size: 28rpx!important;
  501. }
  502. </style>