goods-order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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)||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 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)||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. }, 1000)
  297. },
  298. fail: (err) => {
  299. this.isAJAX = false;
  300. tools.error("支付失败");
  301. setTimeout(() => {
  302. uni.switchTab({
  303. url: "/pages/order/index"
  304. })
  305. }, 1000)
  306. },
  307. });
  308. } else {
  309. this.isAJAX = false;
  310. tools.error("支付失败");
  311. setTimeout(() => {
  312. uni.switchTab({
  313. url: "/pages/order/index"
  314. })
  315. }, 1000)
  316. }
  317. })
  318. } else {
  319. this.isAJAX = false;
  320. tools.error(res.msg);
  321. }
  322. })
  323. },
  324. },
  325. }
  326. </script>
  327. <style scoped lang="scss">
  328. .yhq-icons {
  329. width: 32rpx;
  330. height: 32rpx;
  331. margin: 0 6rpx 0 0;
  332. }
  333. .code-box {
  334. min-height: 100rpx;
  335. background-color: #F3F4F6;
  336. border-radius: 12rpx;
  337. padding: 24rpx 24rpx 0 24rpx;
  338. .code-item {
  339. width: 156rpx;
  340. margin-right: 52rpx;
  341. margin-bottom: 16rpx;
  342. }
  343. .code-item:nth-child(3n) {
  344. margin-right: 0 !important;
  345. }
  346. }
  347. .tz-an-f {
  348. position: relative;
  349. .tz-an {
  350. position: absolute;
  351. right: 16rpx;
  352. top: 0;
  353. }
  354. }
  355. .r-right {
  356. margin-top: 24rpx;
  357. width: 88rpx;
  358. height: 52rpx;
  359. border-radius: 200rpx;
  360. position: relative;
  361. .r-y {
  362. width: 44rpx;
  363. height: 44rpx;
  364. background: #FFFFFF;
  365. border-radius: 200rpx;
  366. position: absolute;
  367. top: 4rpx;
  368. }
  369. }
  370. .s-r {
  371. background-color: #41ABF5;
  372. transition: all 1s;
  373. .r-y {
  374. right: 4rpx !important;
  375. transition: all 1s;
  376. }
  377. }
  378. .n-r {
  379. background-color: #ccc;
  380. transition: all 1s;
  381. .r-y {
  382. left: 4rpx !important;
  383. transition: all 1s;
  384. }
  385. }
  386. .goods-img {
  387. width: 108rpx;
  388. height: 108rpx;
  389. border-radius: 8rpx;
  390. margin-right: 16rpx;
  391. }
  392. .right-icon {
  393. width: 32rpx;
  394. height: 32rpx;
  395. }
  396. .w376 {
  397. width: 376rpx;
  398. }
  399. .w570 {
  400. width: 570rpx;
  401. }
  402. .sd-box {
  403. padding: 3rpx 16rpx;
  404. height: 40rpx;
  405. line-height: 40rpx;
  406. background: rgba(251, 61, 3, 0.1);
  407. border-radius: 8rpx 8rpx 8rpx 8rpx;
  408. }
  409. .confirm-order-box {
  410. position: relative;
  411. .bg-box {
  412. width: 100%;
  413. height: 448rpx;
  414. filter: blur(80rpx);
  415. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  416. position: absolute;
  417. top: 0;
  418. left: 0;
  419. z-index: -1;
  420. }
  421. .bottom-box {
  422. background-color: #fff;
  423. .box-1 {
  424. flex: 1;
  425. height: 100rpx;
  426. background: #333;
  427. border-radius: 200rpx 0rpx 0rpx 200rpx;
  428. box-sizing: border-box;
  429. padding-left: 32rpx;
  430. padding-bottom: 20rpx;
  431. }
  432. .box-2 {
  433. width: 200rpx;
  434. height: 100rpx;
  435. line-height: 100rpx;
  436. background: #41ABF5;
  437. border-radius: 0rpx 200rpx 200rpx 0rpx;
  438. text-align: center;
  439. }
  440. }
  441. .box-card {
  442. width: 100%;
  443. min-height: 88rpx;
  444. border-radius: 20rpx;
  445. padding: 24rpx 24rpx 0 24rpx;
  446. }
  447. .wx-box {
  448. image {
  449. width: 40rpx;
  450. height: 40rpx;
  451. }
  452. }
  453. .box-input {
  454. border-bottom: 2rpx solid #F9F9F9;
  455. }
  456. }
  457. </style>