goods-order.vue 14 KB

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