goods-order.vue 13 KB

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