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

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