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

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