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

523 lines
14 KiB

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