goods-order.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="confirm-order-box iPhone-bottom flex-common-css box-border-box">
  3. <view class="bg-box"></view>
  4. <Nav title='订单支付' bgckgroundBox='transparent'></Nav>
  5. <view class="scroll-view-css box-border-box p-24">
  6. <view class="box-card box-border-box mb-20 bgc-f">
  7. <view class="box-input box-border-box p-b-20 mb-20" @click="selectFun(2)">
  8. <view class="flex-justify-space mb-12">
  9. <view v-if="addressData.id" class="fs-36 fw-600 text-overflow-ellipsis w570">
  10. {{addressData.address||''}}{{addressData.school_name||''}}{{addressData.dorm_name||''}}
  11. </view>
  12. <view v-else class="fs-36 fw-600 text-overflow-ellipsis w570">请选择地址</view>
  13. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  14. </view>
  15. <view class="" v-if="addressData.id">
  16. <span class="mr-24 fs-28 fc-9">{{addressData.consignee||''}}</span><span
  17. class="fs-28 fc-9">{{addressData.phone||''}}</span>
  18. </view>
  19. </view>
  20. <view class="box-input flex-justify-space align-items-center box-border-box p-b-20 mb-20"
  21. @click="selectFun(3)">
  22. <view class="fs-28 fw-600">预计送达</view>
  23. <view class="align-items-center">
  24. <view class="fs-28 fw-400 fc-41ABF5"> {{deliverText?'预计'+ deliverText+ '送达':'选择送达时间'}} </view>
  25. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  26. </view>
  27. </view>
  28. <!-- <view class="box-input flex-justify-space box-border-box p-b-20 mb-20">
  29. <view class="fs-28 fw-600">配送方式</view>
  30. <view class="fs-24 fw-400 sd-box fc-FB3D03">送达宿舍</view>
  31. </view> -->
  32. </view>
  33. <view class="box-card box-border-box bgc-f mb-20">
  34. <view class="mb-32 b-b-F9F9F9">
  35. <!-- <view class="fs-28 fw-600 mb-24">宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)</view> -->
  36. <view class="flex-justify-space mb-28" v-for="(item,i) in cardData.goods_list" :key="i">
  37. <image class="goods-img" :src="item.goods_image" mode="aspectFill"></image>
  38. <view class="w376">
  39. <view class="fs-28 fw-400 mb-4">
  40. {{item.goods_name}}
  41. </view>
  42. <view class="fs-24 fc-9 mb-4">{{item.goods_desc}}</view>
  43. <view class="fs-24 fc-9">x{{item.goods_number}}</view>
  44. </view>
  45. <view class="fs-32 fw-600">¥{{item.goods_money}}</view>
  46. </view>
  47. </view>
  48. <view class="flex-justify-space mb-24">
  49. <view class="fs-28 fw-400">打包费</view>
  50. <view class="fs-32 fw-600">¥{{cardData.pack_price}}</view>
  51. </view>
  52. <view class="flex-justify-space mb-24">
  53. <view class="fs-28 fw-400">配送费</view>
  54. <view class="fs-32 fw-600">¥{{delivery_money}}</view>
  55. </view>
  56. <view class="flex-justify-space mb-24 p-b-20 b-b-F9F9F9" @click="selectFun(1)">
  57. <view class="align-items-center">
  58. <image class="yhq-icons" src="@/static/img/order/yhq.png" mode=""></image>
  59. <view class="fs-28 fw-400">优惠券</view>
  60. </view>
  61. <view class="align-items-center">
  62. <view class="" v-if="!fromData.coupon_id && (receiveLength>0 || CouponLength>0)">
  63. <view class="fs-28 fc-ED301D" v-if='CouponLength>0'>
  64. 有{{CouponLength}}张优惠券可用
  65. </view>
  66. <view class="fs-28 fc-ED301D" v-else>
  67. 可领{{receiveLength}}张优惠券
  68. </view>
  69. </view>
  70. <view v-else :class="fromData.coupon_id?'fc-FB3D03 fw-600 fs-32':'fw-400 fs-28'">
  71. {{fromData.coupon_id?'-¥'+ quanMoney:'暂无可用优惠券'}}
  72. </view>
  73. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  74. </view>
  75. </view>
  76. <view class="text-align-right p-b-20">
  77. <span class="fc-9 fs-28">共{{cardData.total_num||0}}件,</span>
  78. <span class="fw-400 fc-0 fs-28">合计¥</span>
  79. <span
  80. class="fw-600 fc-0 fs-44">{{(total_price - quanMoney) < 0?'0':(total_price - quanMoney).toFixed(2)||0}}</span>
  81. </view>
  82. </view>
  83. <view class="box-card box-border-box bgc-f mb-20">
  84. <view class="flex-justify-space b-b-F9F9F9">
  85. <view class="fs-28 fw-600 w158 mr-12">备注</view>
  86. <input v-model="fromData.note" class="flex-1 text-align-right fs-28" type="text"
  87. placeholder="请填写你的备注">
  88. </view>
  89. <!-- <view class="fs-28 fw-600 mb-16">平台将通过服务通知向你推送最新动态</view>
  90. <view class="p-16 bgc-F3F4F6 b-rad-12 tz-an-f">
  91. <view class="fc-0 fw-400 fs-24 mb-4">是否电话通知</view>
  92. <view class="fc-9 fw-400 fs-24">若开启,则订单送达系统自动曝光(电话)通知</view>
  93. <view class="tz-an">
  94. <view class="r-right" @click="fromData.is_default == 1?fromData.is_default=0:fromData.is_default=1"
  95. :class="fromData.is_default == 0?'n-r':'s-r'">
  96. <view class="r-y"></view>
  97. </view>
  98. </view>
  99. </view> -->
  100. <view class="p-b-20"></view>
  101. </view>
  102. <!-- <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  103. <view class="fs-28 fw-600 w158">支付方式</view>
  104. <view class="wx-box display-flex">
  105. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  106. <view class="fs-28 fw-400 ml-10">微信支付</view>
  107. </view>
  108. </view> -->
  109. </view>
  110. <view class="bottom-box box-border-box p-24">
  111. <view class="flex-justify-space">
  112. <view class="align-items-flex-end box-1">
  113. <span class="fs-28 fc-f fw-600">¥</span>
  114. <span
  115. class="fs-44 fc-f fw-600">{{(total_price - quanMoney) < 0?'0':(total_price - quanMoney).toFixed(2)||0}}</span>
  116. </view>
  117. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  118. </view>
  119. </view>
  120. <Coupon ref="coupon" @giveCouPon='giveCouPon' @gbCouopnPop='shopOrderCoupon'></Coupon>
  121. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  122. <Time ref="selectTime" @giveTime='giveTime' @timeAndType='timeAndType'></Time>
  123. <EditCode ref='editCode' v-model="fromData.pickup_code"></EditCode>
  124. </view>
  125. </template>
  126. <script>
  127. import {
  128. getAddressDefault
  129. } from '@/api/member.js'
  130. import {
  131. getShopIngList
  132. } from '@/api/shopping.js'
  133. import {
  134. getDeliveryMoney
  135. } from '@/api/common.js'
  136. import {
  137. orderCreate,
  138. orderPay
  139. } from '@/api/order.js'
  140. import tools from "@/service/tools";
  141. import Coupon from './confirm-mod/coupon.vue';
  142. import SelectAddress from './confirm-mod/select-address.vue';
  143. import Time from './confirm-mod/time.vue';
  144. import EditCode from './confirm-mod/edit-code.vue';
  145. import {
  146. shopOrderCoupon
  147. } from '@/api/shop.js'
  148. export default {
  149. components: {
  150. Coupon,
  151. SelectAddress,
  152. Time,
  153. EditCode
  154. },
  155. data() {
  156. return {
  157. type: 1, //1外卖 2代取 3干洗
  158. fromData: {
  159. school_id: '',
  160. shop_id: '',
  161. // site_id:'',
  162. type: '',
  163. time: '',
  164. address_id: '',
  165. coupon_id: '',
  166. note: '',
  167. // is_default:0,
  168. // pickup_code:[],
  169. },
  170. addressData: {},
  171. deliverText: '',
  172. cardData: {
  173. goods_list: [],
  174. },
  175. delivery_money: '',
  176. quanMoney: "",
  177. total_price: '',
  178. isAJAX: false,
  179. CouponLength: 0, // 可用优惠券数量
  180. receiveLength: 0 // 可领优惠券数量
  181. }
  182. },
  183. onLoad(e) {
  184. if (e) {
  185. this.fromData.shop_id = e.shop_id
  186. this.getCard(e.shop_id)
  187. // this.getDeliveryMoney(e.shop_id)
  188. }
  189. this.getAddressDefault();
  190. },
  191. onShow() {
  192. let isConfirmAddressFlag = uni.getStorageSync('isConfirmAddressFlag');
  193. console.log("支付完后走了咩", isConfirmAddressFlag);
  194. if (isConfirmAddressFlag.flag) {
  195. this.selectFun(2, isConfirmAddressFlag);
  196. }
  197. this.shopOrderCoupon()
  198. },
  199. onUnload() {
  200. uni.removeStorageSync('isConfirmAddressFlag')
  201. },
  202. methods: {
  203. shopOrderCoupon(shop_id) {
  204. // 下单是获取优惠卷
  205. let operate_id = uni.getStorageSync('operate_id');
  206. shopOrderCoupon({
  207. operate_id: operate_id,
  208. shop_id: this.fromData.shop_id
  209. }).then((res) => {
  210. if (res.code === 1) {
  211. if (res.data.coupon.length > 0) {
  212. this.CouponLength = res.data.coupon.length
  213. } else {
  214. this.CouponLength = 0
  215. }
  216. if (res.data.receive.length > 0) {
  217. this.receiveLength = res.data.receive.length
  218. } else {
  219. this.receiveLength = 0
  220. }
  221. }
  222. })
  223. },
  224. getDeliveryMoney(shop_id) {
  225. // 获取外卖配送费
  226. this.fromData.school_id = uni.getStorageSync('school_id');
  227. getDeliveryMoney({
  228. shop_id: shop_id,
  229. school_id: this.fromData.school_id
  230. }).then((res) => {
  231. if (res.code == 1) {
  232. this.delivery_money = res.data.delivery_money
  233. this.total_price = (Number(this.total_price) + Number(this.delivery_money)).toFixed(2)
  234. }
  235. })
  236. },
  237. // 获取购物车
  238. getCard(shop_id) {
  239. getShopIngList({
  240. shop_id: shop_id
  241. }).then((res) => {
  242. if (res.code === 1) {
  243. this.cardData = res.data;
  244. this.total_price = res.data.total_price
  245. this.getDeliveryMoney(shop_id)
  246. }
  247. })
  248. },
  249. // 获取默认地址
  250. getAddressDefault() {
  251. getAddressDefault().then((res) => {
  252. if (res.code === 1) {
  253. this.addressData = res.data
  254. if (this.addressData.id) {
  255. this.fromData.address_id = this.addressData.id;
  256. }
  257. }
  258. })
  259. },
  260. selectFun(type, addressData) {
  261. if (type === 1) {
  262. // 选择优惠券
  263. this.$refs.coupon.getList(this.type, this.fromData.coupon_id, this.fromData.shop_id);
  264. } else if (type === 2) {
  265. // 选择地址
  266. if (this.addressData.id) {
  267. this.$refs.selectAddress.id = this.addressData.id;
  268. }
  269. if (addressData && addressData.is_default == 1) {
  270. this.$refs.selectAddress.id = addressData.id;
  271. this.$refs.selectAddress.getList(addressData.id);
  272. } else {
  273. this.$refs.selectAddress.getList();
  274. }
  275. } else if (type === 3) {
  276. // 选择时间
  277. this.$refs.selectTime.getList(this.fromData.shop_id);
  278. } else if (type === 4) {
  279. // 编辑code
  280. this.$refs.editCode.getList();
  281. }
  282. },
  283. giveCouPon(e) {
  284. if (e.id) {
  285. this.quanMoney = Number(e.money);
  286. this.fromData.coupon_id = e.id;
  287. } else {
  288. this.quanMoney = ''
  289. this.fromData.coupon_id = 0
  290. }
  291. },
  292. timeAndType(type, time) {
  293. // 时间选择
  294. this.fromData.type = type
  295. this.fromData.time = time
  296. if (type == 1) {
  297. this.deliverText = '今天' + time
  298. } else {
  299. this.deliverText = '明天' + time
  300. }
  301. console.log(type, time, '&&&&&&&&&&&&&&&&&&&&&&&&');
  302. },
  303. giveAddress(e) {
  304. this.addressData = e;
  305. this.fromData.address_id = this.addressData.id;
  306. },
  307. giveTime(e) {
  308. console.log(e);
  309. },
  310. toSave() {
  311. if (!this.fromData.address_id) {
  312. return tools.error('请先选择地址')
  313. }
  314. if (this.isAJAX) {
  315. return
  316. }
  317. this.isAJAX = true;
  318. this.fromData.school_id = uni.getStorageSync('school_id');
  319. // this.fromData.site_id = uni.getStorageSync('site_id');
  320. orderCreate(this.fromData).then((res) => {
  321. if (res.code === 1) {
  322. uni.redirectTo({
  323. url: `/pages-takeout/pay-page?orderId=${res.data.order_id}`
  324. });
  325. // orderPay({
  326. // order_id: res.data.order_id,
  327. // pay_type: 1
  328. // }).then((ret) => {
  329. // if (ret.code === 1) {
  330. // uni.requestPayment({
  331. // provider: "wxpay", //支付类型-固定值
  332. // timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  333. // nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  334. // package: ret.data.wx_pay.package, // 固定值
  335. // signType: ret.data.wx_pay.signType, //固定值
  336. // paySign: ret.data.wx_pay.paySign, //签名
  337. // success: (ren) => {
  338. // uni.removeStorageSync('isConfirmAddressFlag')
  339. // tools.success("支付成功");
  340. // this.isAJAX = false;
  341. // setTimeout(() => {
  342. // uni.switchTab({
  343. // url: '/pages/order/index'
  344. // })
  345. // uni.setStorageSync('orderPayType', 1)
  346. // }, 1000)
  347. // },
  348. // fail: (err) => {
  349. // uni.removeStorageSync('isConfirmAddressFlag')
  350. // this.isAJAX = false;
  351. // tools.error("支付失败");
  352. // setTimeout(() => {
  353. // uni.switchTab({
  354. // url: '/pages/order/index'
  355. // })
  356. // uni.setStorageSync('orderPayType', 1)
  357. // }, 1000)
  358. // },
  359. // });
  360. // } else {
  361. // uni.removeStorageSync('isConfirmAddressFlag')
  362. // this.isAJAX = false;
  363. // tools.error("支付失败");
  364. // setTimeout(() => {
  365. // uni.switchTab({
  366. // url: '/pages/order/index'
  367. // })
  368. // uni.setStorageSync('orderPayType', 1)
  369. // }, 1000)
  370. // }
  371. // })
  372. } else {
  373. this.isAJAX = false;
  374. tools.error(res.msg);
  375. }
  376. })
  377. },
  378. },
  379. }
  380. </script>
  381. <style scoped lang="scss">
  382. .yhq-icons {
  383. width: 32rpx;
  384. height: 32rpx;
  385. margin: 0 6rpx 0 0;
  386. }
  387. .code-box {
  388. min-height: 100rpx;
  389. background-color: #F3F4F6;
  390. border-radius: 12rpx;
  391. padding: 24rpx 24rpx 0 24rpx;
  392. .code-item {
  393. width: 156rpx;
  394. margin-right: 52rpx;
  395. margin-bottom: 16rpx;
  396. }
  397. .code-item:nth-child(3n) {
  398. margin-right: 0 !important;
  399. }
  400. }
  401. .tz-an-f {
  402. position: relative;
  403. .tz-an {
  404. position: absolute;
  405. right: 16rpx;
  406. top: 0;
  407. }
  408. }
  409. .r-right {
  410. margin-top: 24rpx;
  411. width: 88rpx;
  412. height: 52rpx;
  413. border-radius: 200rpx;
  414. position: relative;
  415. .r-y {
  416. width: 44rpx;
  417. height: 44rpx;
  418. background: #FFFFFF;
  419. border-radius: 200rpx;
  420. position: absolute;
  421. top: 4rpx;
  422. }
  423. }
  424. .s-r {
  425. background-color: #41ABF5;
  426. transition: all 1s;
  427. .r-y {
  428. right: 4rpx !important;
  429. transition: all 1s;
  430. }
  431. }
  432. .n-r {
  433. background-color: #ccc;
  434. transition: all 1s;
  435. .r-y {
  436. left: 4rpx !important;
  437. transition: all 1s;
  438. }
  439. }
  440. .goods-img {
  441. width: 108rpx;
  442. height: 108rpx;
  443. border-radius: 8rpx;
  444. margin-right: 16rpx;
  445. }
  446. .right-icon {
  447. width: 32rpx;
  448. height: 32rpx;
  449. }
  450. .w376 {
  451. width: 376rpx;
  452. }
  453. .w570 {
  454. width: 570rpx;
  455. }
  456. .sd-box {
  457. padding: 3rpx 16rpx;
  458. height: 40rpx;
  459. line-height: 40rpx;
  460. background: rgba(251, 61, 3, 0.1);
  461. border-radius: 8rpx 8rpx 8rpx 8rpx;
  462. }
  463. .confirm-order-box {
  464. position: relative;
  465. .bg-box {
  466. width: 100%;
  467. height: 448rpx;
  468. filter: blur(80rpx);
  469. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  470. position: absolute;
  471. top: 0;
  472. left: 0;
  473. z-index: -1;
  474. }
  475. .bottom-box {
  476. background-color: #fff;
  477. .box-1 {
  478. flex: 1;
  479. height: 100rpx;
  480. background: #333;
  481. border-radius: 200rpx 0rpx 0rpx 200rpx;
  482. box-sizing: border-box;
  483. padding-left: 32rpx;
  484. padding-bottom: 20rpx;
  485. }
  486. .box-2 {
  487. width: 200rpx;
  488. height: 100rpx;
  489. line-height: 100rpx;
  490. background: #41ABF5;
  491. border-radius: 0rpx 200rpx 200rpx 0rpx;
  492. text-align: center;
  493. }
  494. }
  495. .box-card {
  496. width: 100%;
  497. min-height: 88rpx;
  498. border-radius: 20rpx;
  499. padding: 24rpx 24rpx 0 24rpx;
  500. }
  501. .wx-box {
  502. image {
  503. width: 40rpx;
  504. height: 40rpx;
  505. }
  506. }
  507. .box-input {
  508. border-bottom: 2rpx solid #F9F9F9;
  509. }
  510. }
  511. </style>