confirm-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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" @click="selectFun(3)">
  21. <view class="fs-28 fw-600">预计送达</view>
  22. <view class="align-items-center">
  23. <view class="fs-28 fw-400 fc-41ABF5">预计 12:30 送达</view>
  24. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  25. </view>
  26. </view> -->
  27. <!-- <view class="box-input flex-justify-space box-border-box p-b-20 mb-20">
  28. <view class="fs-28 fw-600">配送方式</view>
  29. <view class="fs-24 fw-400 sd-box fc-FB3D03">送达宿舍</view>
  30. </view> -->
  31. <view class="p-b-20">
  32. <view class=" flex-justify-space box-border-box p-b-20">
  33. <view class="fs-28 fw-600">取件码</view>
  34. <view class="align-items-center" @click="selectFun(4)">
  35. <view class="fs-24 fw-400 fc-9">修改</view>
  36. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  37. </view>
  38. </view>
  39. <view class="code-box box-border-box flex-wrap-wrap">
  40. <view class="code-item fs-28 text-overflow-ellipsis-one"
  41. v-for="(item,i) in fromData.pickup_code" :key="i">{{item}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="box-card box-border-box bgc-f mb-20">
  46. <view class="mb-32 b-b-F9F9F9">
  47. <!-- <view class="fs-28 fw-600 mb-24">宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)</view> -->
  48. <view class="flex-justify-space mb-28" v-for="(item,i) in cardData.goods_list" :key="i">
  49. <image class="goods-img" :src="item.serve_image" mode="aspectFill"></image>
  50. <view class="w376">
  51. <view class="fs-28 fw-400 mb-4">
  52. {{item.serve_name}}
  53. </view>
  54. <view class="fs-24 fc-9 mb-4">{{item.serve_desc}}</view>
  55. <view class="fs-24 fc-9">x{{item.number}}</view>
  56. </view>
  57. <view class="fs-32 fw-600">¥{{Number(item.number * Number(item.price)).toFixed(2)}}</view>
  58. </view>
  59. </view>
  60. <!-- <view class="flex-justify-space mb-24">
  61. <view class="fs-28 fw-400">打包费</view>
  62. <view class="fs-32 fw-600">¥3</view>
  63. </view> -->
  64. <!-- <view class="flex-justify-space mb-24">
  65. <view class="fs-28 fw-400">配送费</view>
  66. <view class="fs-32 fw-600">¥3</view>
  67. </view> -->
  68. <view class="flex-justify-space mb-24 p-b-20 b-b-F9F9F9" @click="selectFun(1)">
  69. <view class="fs-28 fw-400">优惠券</view>
  70. <view class="align-items-center">
  71. <view :class="fromData.coupon_id?'fc-FB3D03 fw-600 fs-32':'fw-400 fs-28'">
  72. {{fromData.coupon_id?'-¥'+ quanMoney:'请选择优惠券'}}</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">{{((cardData.total_price - quanMoney) < 0?'0':(cardData.total_price - quanMoney)||0).toFixed(2)}}</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 mb-24">
  85. <view class="fs-28 fw-600 w158 mr-12">备注</view>
  86. <input class="flex-1 text-align-right fs-28" type="text" placeholder="请填写你的备注">
  87. </view>
  88. <!-- <view class="fs-28 fw-600 mb-16">平台将通过服务通知向你推送最新动态</view>
  89. <view class="p-16 bgc-F3F4F6 b-rad-12 tz-an-f">
  90. <view class="fc-0 fw-400 fs-24 mb-4">是否电话通知</view>
  91. <view class="fc-9 fw-400 fs-24">若开启,则订单送达系统自动曝光(电话)通知</view>
  92. <view class="tz-an">
  93. <view class="r-right" @click="fromData.is_default == 1?fromData.is_default=0:fromData.is_default=1"
  94. :class="fromData.is_default == 0?'n-r':'s-r'">
  95. <view class="r-y"></view>
  96. </view>
  97. </view>
  98. </view> -->
  99. <view class="p-b-20"></view>
  100. </view>
  101. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  102. <view class="fs-28 fw-600 w158">支付方式</view>
  103. <view class="wx-box display-flex">
  104. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  105. <view class="fs-28 fw-400 ml-10">微信支付</view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="bottom-box box-border-box p-24">
  110. <view class="flex-justify-space">
  111. <view class="align-items-flex-end box-1">
  112. <span class="fs-28 fc-f fw-600">¥</span>
  113. <span
  114. class="fs-44 fc-f fw-600">{{((cardData.total_price - quanMoney) < 0?'0':(cardData.total_price - quanMoney)||0).toFixed(2)}}</span>
  115. </view>
  116. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  117. </view>
  118. </view>
  119. <Coupon ref="coupon" @giveCouPon='giveCouPon'></Coupon>
  120. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  121. <Time ref="selectTime" @giveTime='giveTime'></Time>
  122. <EditCode ref='editCode' v-model="fromData.pickup_code"></EditCode>
  123. </view>
  124. </template>
  125. <script>
  126. import {
  127. getExpressCoupon,
  128. getExpressCreate,
  129. getExpressPay
  130. } from '@/api/express.js';
  131. import {
  132. getAddressDefault
  133. } from '@/api/member.js'
  134. import {
  135. getShopIngList
  136. } from '@/api/shopping.js'
  137. import tools from "@/service/tools";
  138. import Coupon from './confirm-mod/dryClean-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: 2, //1外卖 2代取 3干洗
  152. fromData: {
  153. school_id: '',
  154. site_id: '',
  155. address_id: '',
  156. coupon_id: '',
  157. note: '',
  158. // is_default:0,
  159. pickup_code: [],
  160. },
  161. addressData: {},
  162. cardData: {
  163. goods_list: [],
  164. },
  165. quanMoney: "",
  166. isAJAX: false,
  167. }
  168. },
  169. onLoad(e) {
  170. this.type = Number(e.type)
  171. if (this.type == 2) {
  172. this.fromData.pickup_code = e.pickup_code.split(',').map(String)
  173. this.getCard();
  174. }
  175. this.getAddressDefault();
  176. },
  177. onShow() {
  178. let isConfirmAddressFlag = uni.getStorageSync('isConfirmAddressFlag');
  179. if (isConfirmAddressFlag) {
  180. this.selectFun(2);
  181. }
  182. },
  183. methods: {
  184. // 获取购物车
  185. getCard() {
  186. getShopIngList({
  187. type: this.type
  188. }).then((res) => {
  189. if (res.code === 1) {
  190. this.cardData = res.data;
  191. }
  192. })
  193. },
  194. // 获取默认地址
  195. getAddressDefault() {
  196. getAddressDefault().then((res) => {
  197. if (res.code === 1) {
  198. this.addressData = res.data
  199. if (this.addressData.id) {
  200. this.fromData.address_id = this.addressData.id;
  201. }
  202. }
  203. })
  204. },
  205. selectFun(type) {
  206. if (type === 1) {
  207. // 选择优惠券
  208. this.$refs.coupon.getList(this.type, this.fromData.coupon_id);
  209. } else if (type === 2) {
  210. // 选择地址
  211. if (this.addressData.id) {
  212. this.$refs.selectAddress.id = this.addressData.id;
  213. }
  214. this.$refs.selectAddress.getList();
  215. } else if (type === 3) {
  216. // 选择时间
  217. this.$refs.selectTime.getList();
  218. } else if (type === 4) {
  219. // 编辑code
  220. this.$refs.editCode.getList();
  221. }
  222. },
  223. giveCouPon(e) {
  224. this.quanMoney = Number(e.money);
  225. this.fromData.coupon_id = e.id;
  226. },
  227. giveAddress(e) {
  228. this.addressData = e;
  229. this.fromData.address_id = this.addressData.id;
  230. },
  231. giveTime(e) {
  232. console.log(e);
  233. },
  234. toSave() {
  235. if (!this.fromData.address_id) {
  236. return tools.error('请先选择地址')
  237. }
  238. if (this.isAJAX) {
  239. return
  240. }
  241. this.isAJAX = true;
  242. this.fromData.school_id = uni.getStorageSync('school_id');
  243. this.fromData.site_id = uni.getStorageSync('site_id');
  244. getExpressCreate(this.fromData).then((res) => {
  245. if (res.code === 1) {
  246. getExpressPay({
  247. order_id: res.data.order_id
  248. }).then((ret) => {
  249. if (ret.code === 1) {
  250. uni.requestPayment({
  251. provider: "wxpay", //支付类型-固定值
  252. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  253. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  254. package: ret.data.wx_pay.package, // 固定值
  255. signType: ret.data.wx_pay.signType, //固定值
  256. paySign: ret.data.wx_pay.paySign, //签名
  257. success: (ren) => {
  258. tools.success("支付成功");
  259. this.isAJAX = false;
  260. setTimeout(() => {
  261. uni.switchTab({
  262. url: "/pages/order/index"
  263. })
  264. }, 1000)
  265. },
  266. fail: (err) => {
  267. this.isAJAX = false;
  268. tools.error("支付失败");
  269. setTimeout(() => {
  270. uni.switchTab({
  271. url: "/pages/order/index"
  272. })
  273. }, 1000)
  274. },
  275. });
  276. } else {
  277. this.isAJAX = false;
  278. tools.error("支付失败");
  279. setTimeout(() => {
  280. uni.switchTab({
  281. url: "/pages/order/index"
  282. })
  283. }, 1000)
  284. }
  285. })
  286. } else {
  287. this.isAJAX = false;
  288. tools.error(res.msg);
  289. }
  290. })
  291. },
  292. },
  293. }
  294. </script>
  295. <style scoped lang="scss">
  296. .code-box {
  297. min-height: 100rpx;
  298. background-color: #F3F4F6;
  299. border-radius: 12rpx;
  300. padding: 24rpx 24rpx 0 24rpx;
  301. .code-item {
  302. width: 156rpx;
  303. margin-right: 52rpx;
  304. margin-bottom: 16rpx;
  305. }
  306. .code-item:nth-child(3n) {
  307. margin-right: 0 !important;
  308. }
  309. }
  310. .tz-an-f {
  311. position: relative;
  312. .tz-an {
  313. position: absolute;
  314. right: 16rpx;
  315. top: 0;
  316. }
  317. }
  318. .r-right {
  319. margin-top: 24rpx;
  320. width: 88rpx;
  321. height: 52rpx;
  322. border-radius: 200rpx;
  323. position: relative;
  324. .r-y {
  325. width: 44rpx;
  326. height: 44rpx;
  327. background: #FFFFFF;
  328. border-radius: 200rpx;
  329. position: absolute;
  330. top: 4rpx;
  331. }
  332. }
  333. .s-r {
  334. background-color: #41ABF5;
  335. transition: all 1s;
  336. .r-y {
  337. right: 4rpx !important;
  338. transition: all 1s;
  339. }
  340. }
  341. .n-r {
  342. background-color: #ccc;
  343. transition: all 1s;
  344. .r-y {
  345. left: 4rpx !important;
  346. transition: all 1s;
  347. }
  348. }
  349. .goods-img {
  350. width: 108rpx;
  351. height: 108rpx;
  352. border-radius: 8rpx;
  353. margin-right: 16rpx;
  354. }
  355. .right-icon {
  356. width: 32rpx;
  357. height: 32rpx;
  358. }
  359. .w376 {
  360. width: 376rpx;
  361. }
  362. .w570 {
  363. width: 570rpx;
  364. }
  365. .sd-box {
  366. padding: 3rpx 16rpx;
  367. height: 40rpx;
  368. line-height: 40rpx;
  369. background: rgba(251, 61, 3, 0.1);
  370. border-radius: 8rpx 8rpx 8rpx 8rpx;
  371. }
  372. .confirm-order-box {
  373. position: relative;
  374. .bg-box {
  375. width: 100%;
  376. height: 448rpx;
  377. filter: blur(80rpx);
  378. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  379. position: absolute;
  380. top: 0;
  381. left: 0;
  382. z-index: -1;
  383. }
  384. .bottom-box {
  385. background-color: #fff;
  386. .box-1 {
  387. flex: 1;
  388. height: 100rpx;
  389. background: #333;
  390. border-radius: 200rpx 0rpx 0rpx 200rpx;
  391. box-sizing: border-box;
  392. padding-left: 32rpx;
  393. padding-bottom: 20rpx;
  394. }
  395. .box-2 {
  396. width: 200rpx;
  397. height: 100rpx;
  398. line-height: 100rpx;
  399. background: #41ABF5;
  400. border-radius: 0rpx 200rpx 200rpx 0rpx;
  401. text-align: center;
  402. }
  403. }
  404. .box-card {
  405. width: 100%;
  406. min-height: 88rpx;
  407. border-radius: 20rpx;
  408. padding: 24rpx 24rpx 0 24rpx;
  409. }
  410. .wx-box {
  411. image {
  412. width: 40rpx;
  413. height: 40rpx;
  414. }
  415. }
  416. .box-input {
  417. border-bottom: 2rpx solid #F9F9F9;
  418. }
  419. }
  420. </style>