confirm-order.vue 11 KB

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