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

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