goods-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box bgc-F5F4F9">
  3. <image class="order-bg" src="@/static/img/order-food/order-bg.png" mode=""></image>
  4. <newNav textName="提交订单" class="mb-20"></newNav>
  5. <view class="scroll-view-css plr-24 box-border-box z-3">
  6. <view class="way-box bgc-f b-rad-20 mb-20 p-24 box-border-box">
  7. <view class="fc-6 fw-400 fs-28 mb-24">
  8. 请选择就餐方式
  9. </view>
  10. <view class="align-items-center">
  11. <view class="pl-32 pr-24 box-border-box align-items-center flex-justify-space flex-1 mr-18 b-rad-16"
  12. :class="cartData.order_type === 1?'bgc-FFF3F3 b-FF3333':'b-b-d'" @click="wayTypeStyle(1)">
  13. <view class="fw-600 fs-32" :class="cartData.order_type === 1?'fc-FF3333':'fc-3'">
  14. 堂食
  15. </view>
  16. <image class="ts-img" src="/static/img/order-food/ts-img.png" mode="aspectFill"></image>
  17. </view>
  18. <view class="pl-32 pr-24 box-border-box align-items-center flex-justify-space flex-1 b-rad-16"
  19. :class="cartData.order_type === 2?'bgc-FFF3F3 b-FF3333':'b-b-d'" @click="wayTypeStyle(2)">
  20. <view class="fw-600 fs-32" :class="cartData.order_type === 2?'fc-FF3333':'fc-3'">
  21. 打包
  22. </view>
  23. <image class="ts-img" src="/static/img/order-food/db-img.png" mode="aspectFill"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="align-items-center b-rad-16 bgc-f mb-20 p-20 box-border-box">
  28. <uni-icons type="notification" size="15" color="#FF8D28" class="mr-12"></uni-icons>
  29. <view class="fs-24 fc-FF8D28">
  30. 依据法律规定,18周岁以下未成年人限制购买酒类商品
  31. </view>
  32. </view>
  33. <view class="box-card bgc-f b-rad-16 p-24 box-border-box mb-16">
  34. <view class="align-items-center flex-justify-space pb-24 b-b-eee mb-24">
  35. <view class="fs-28 fc-6">
  36. 店内点单
  37. </view>
  38. <view class="align-items-center">
  39. <image class="zz-icon mr-4" src="@/static/img/order-food/zz-icon.png" mode=""></image>
  40. <view class="fs-28 fc-6">
  41. 桌号:{{cartData.table_number}}
  42. </view>
  43. </view>
  44. </view>
  45. <view class="mb-24 b-b-F9F9F9">
  46. <view class="align-items-flex-start mb-28" v-for="(item,i) in cartData.shopping_cart.goods_list"
  47. :key="i">
  48. <image class="goods-img flex-shrink0" :src="item.goods_image" mode="aspectFill"></image>
  49. <view class="flex-1 flex-justify-space min-h-108">
  50. <view class="w376 flex-direction flex-justify-space">
  51. <view class="">
  52. <view class="fs-28 fw-600 mb-2 text-overflow-ellipsis-one">
  53. {{item.goods_name || ''}}
  54. </view>
  55. <view class="fs-24 fc-9 mb-2">{{item.goods_attr || ''}}</view>
  56. </view>
  57. <view class="fs-24 fc-9">x{{item.goods_number || ''}}</view>
  58. </view>
  59. <view class="fs-32 fw-600 fc-3">¥{{Number(item.price * item.goods_number).toFixed(2)}}
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="flex-justify-space mb-30" v-if="cartData.order_type === 2">
  65. <view class="fs-28 fw-400">打包费</view>
  66. <view class="fs-32 fw-600 fc-3">¥{{cartData.shopping_cart.pack_price}}</view>
  67. </view>
  68. <view class="flex-justify-space mb-30" v-if="cartData.order_type === 1">
  69. <view class="fs-28 fw-400">就餐人数</view>
  70. <view class="align-items-center" @click="openPop">
  71. <view class="fs-32 fw-600 fc-3 mr-4">{{cartData.diner_number}}人</view>
  72. <image class="right-b" src="@/static/img/order-food/right-b.png" mode=""></image>
  73. </view>
  74. </view>
  75. <!-- <view class="flex-justify-space mb-30">
  76. <view class="fs-28 fw-400">餐位费</view>
  77. <view class="fs-32 fw-600 fc-3">¥4</view>
  78. </view> -->
  79. <!-- <view class="flex-justify-space mb-30">
  80. <view class="fs-28 fw-400">店铺优惠</view>
  81. <view class="fs-32 fw-600">¥{{cardData.pack_price}}</view>
  82. </view> -->
  83. <view class="align-items-baseline flex-justify-end pt-20 b-t-F9F9F9">
  84. <view class="fs-28 fc-0 fw-400 mr-4">
  85. 应付
  86. </view>
  87. <span class="fw-600 fc-0 fs-28">¥</span>
  88. <span
  89. class="fw-600 fc-0 fs-40">{{cartData.order_type === 1 ?Number(cartData.shopping_cart.total_goods_money).toFixed(2):(cartData.shopping_cart.total_price).toFixed(2)}}</span>
  90. </view>
  91. </view>
  92. <view class="p-24 box-border-box bgc-f mb-20 b-rad-20 flex-justify-space">
  93. <view class="fs-28 fw-600 flex-shrink0 mr-18">备注</view>
  94. <input v-model="cartData.note" class="flex-1 text-align-right fs-28" type="text" placeholder="请填写你的需求">
  95. </view>
  96. <view class="p-24 box-border-box bgc-f mb-20 b-rad-20 flex-justify-space">
  97. <view class="fs-28 fw-600 flex-shrink0 mr-18">用餐时间</view>
  98. <view class="flex-1 text-align-right">
  99. <uni-datetime-picker :hide-second='true' v-model="cartData.reserve_time">
  100. <view class="fs-28" :class="cartData.reserve_time?'':'fc-6'">
  101. {{cartData.reserve_time?cartData.reserve_time:'默认立即就餐'}}
  102. </view>
  103. </uni-datetime-picker>
  104. </view>
  105. </view>
  106. <view class="p-24 box-border-box bgc-f mb-20 b-rad-20 flex-justify-space">
  107. <view class="fs-28 fw-600">支付方式</view>
  108. <view class="align-items-center">
  109. <image class="wx-zf mr-6" src="@/static/img/common/wx-zf.png" mode=""></image>
  110. <view class="fs-28 fc-3">
  111. 微信支付
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. <view class="plr-24 box-border-box">
  117. <view class="bottom-box flex-justify-space align-items-center pl-24 box-border-box pr-8 b-rad-200 bgc-f">
  118. <view class="align-items-baseline">
  119. <view class="fs-28 fc-3 fw-600">¥</view>
  120. <view class="fs-48 fc-3 fw-600">
  121. {{cartData.order_type === 1 ? (cartData.shopping_cart.total_goods_money).toFixed(2): (cartData.shopping_cart.total_price).toFixed(2) }}
  122. </view>
  123. </view>
  124. <view class="box-2 text-align-center fc-f fs-32 fw-600 b-rad-200" @click="toSave()">立即支付</view>
  125. </view>
  126. </view>
  127. <uni-popup ref="popup" type="bottom" background-color="transparent" borderRadius='10px 10px 0 0'>
  128. <view class="b-rad-20-20-0-0 bgc-f popup_diner_number p-32 box-border-box">
  129. <view class="fc-3 fw-600 fs-36 mb-32">
  130. 请选择用餐人数
  131. </view>
  132. <view class="align-items-center flex-justify-space flex-wrap-wrap mb-50">
  133. <view @click="dinerNumber(index+1)"
  134. class="w-25-100 b-rad-12 text-align-center flex-justify-center fs-36 fc-3 fw-500 mb-20"
  135. :class="cartData.diner_number === index+1 && !customizeType?'b-FF3333 bgc-FFF3F3':'b-FFF3F3 bgc-F2F2F2'"
  136. v-for="(item,index) in 10">
  137. {{index + 1}}
  138. </view>
  139. <view class="bgc-F2F2F2 b-rad-12 customize-box mb-20"
  140. :class="customizeType?'b-FF3333 bgc-FFF3F3':'b-FFF3F3 bgc-F2F2F2'">
  141. <input class="customize-input fs-32" type="number" v-model="customize_num" @focus='focusInput'
  142. @input='input' placeholder="请输入数量" placeholder-class="fc-9 fs-32" />
  143. </view>
  144. </view>
  145. <view class="pop-but fs-32 fc-f fw-500 text-align-center b-rad-200" @click="okPop">
  146. 确认选择
  147. </view>
  148. </view>
  149. </uni-popup>
  150. </view>
  151. </template>
  152. <script>
  153. import {
  154. getShopIngList
  155. } from '@/api/shopping.js'
  156. import {
  157. orderCreateVtwo,
  158. orderCreate,
  159. orderPay
  160. } from '@/api/order.js'
  161. import cartStore from '@/utils/cartStore.js';
  162. import tools from "@/service/tools";
  163. export default {
  164. components: {},
  165. data() {
  166. return {
  167. customize_num: '',
  168. customizeType: false,
  169. shop_id: '',
  170. wayType: 1,
  171. fromData: {
  172. school_id: '',
  173. shop_id: '',
  174. // site_id:'',
  175. type: '',
  176. time: '',
  177. address_id: '',
  178. coupon_id: '',
  179. note: '',
  180. },
  181. addressData: {},
  182. deliverText: '',
  183. delivery_money: '',
  184. quanMoney: "",
  185. total_price: '',
  186. isAJAX: false,
  187. cartData: {
  188. shopping_cart: {},
  189. order_type: 1, //1堂食 2打包
  190. table_number: 1,
  191. diner_number: 1,
  192. note: '',
  193. reserve_time: ''
  194. },
  195. CouponLength: 0, // 可用优惠券数量
  196. receiveLength: 0 // 可领优惠券数量
  197. }
  198. },
  199. onLoad(e) {
  200. this.cartData.table_number = uni.getStorageSync('table_number')
  201. this.getCartData()
  202. },
  203. onShow() {},
  204. onUnload() {},
  205. methods: {
  206. okPop() {
  207. if (this.cartData.diner_number === 0) {
  208. tools.error("选择就餐人数")
  209. return
  210. }
  211. this.$refs.popup.close()
  212. },
  213. input(e) {
  214. this.cartData.diner_number = e.detail.value
  215. },
  216. focusInput() {
  217. this.customizeType = true
  218. this.cartData.diner_number = 0
  219. },
  220. dinerNumber(num) {
  221. if (this.cartData.diner_number === num) {
  222. return
  223. } else {
  224. this.cartData.diner_number = num
  225. }
  226. this.customizeType = false
  227. this.customize_num = ''
  228. },
  229. getCartData() {
  230. cartStore.setShopId();
  231. const shopCart = cartStore.getShopCart();
  232. this.cartData.shopping_cart = shopCart
  233. },
  234. openPop() {
  235. if (this.cartData.diner_number > 10) {
  236. this.customize_num = this.cartData.diner_number
  237. }
  238. this.$refs.popup.open()
  239. },
  240. wayTypeStyle(type) {
  241. if (type === this.cartData.order_type) {
  242. return
  243. } else {
  244. this.cartData.order_type = type
  245. }
  246. },
  247. toSave() {
  248. if (this.isAJAX) {
  249. return
  250. }
  251. this.isAJAX = true;
  252. orderCreateVtwo(this.cartData).then((res) => {
  253. if (res.code === 1) {
  254. orderPay({
  255. order_id: res.data.order_id
  256. }).then((ret) => {
  257. if (ret.code === 1) {
  258. uni.requestPayment({
  259. provider: "wxpay", //支付类型-固定值
  260. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  261. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  262. package: ret.data.wx_pay.package, // 固定值
  263. signType: ret.data.wx_pay.signType, //固定值
  264. paySign: ret.data.wx_pay.paySign, //签名
  265. success: (ren) => {
  266. tools.success("支付成功");
  267. this.isAJAX = false;
  268. setTimeout(() => {
  269. uni.redirectTo({
  270. url: `/pages-order/takeout-info?orderId=` +
  271. res.data.order_id
  272. })
  273. cartStore.clearCurrentShopCart();
  274. }, 1000)
  275. },
  276. fail: (err) => {
  277. this.isAJAX = false;
  278. tools.error("支付失败");
  279. setTimeout(() => {
  280. uni.redirectTo({
  281. url: `/pages/order/index`
  282. })
  283. cartStore.clearCurrentShopCart();
  284. }, 1000)
  285. },
  286. });
  287. } else {
  288. this.isAJAX = false;
  289. tools.error("支付失败");
  290. setTimeout(() => {
  291. uni.redirectTo({
  292. url: `/pages/order/index`
  293. })
  294. cartStore.clearCurrentShopCart();
  295. }, 1000)
  296. }
  297. })
  298. } else {
  299. this.isAJAX = false;
  300. tools.error(res.msg);
  301. }
  302. })
  303. },
  304. setShopIngDel() {
  305. // 清除购物车
  306. cartStore.clearCurrentShopCart();
  307. }
  308. },
  309. }
  310. </script>
  311. <style scoped lang="scss">
  312. .min-h-108 {
  313. min-height: 108rpx;
  314. }
  315. .pop-but {
  316. width: 100%;
  317. height: 96rpx;
  318. line-height: 96rpx;
  319. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  320. }
  321. .customize-input {
  322. width: 100%;
  323. height: 100%;
  324. text-align: center;
  325. }
  326. .customize-box {
  327. width: 48%;
  328. height: 92rpx;
  329. }
  330. .w-25-100 {
  331. width: 22%;
  332. height: 92rpx;
  333. line-height: 92rpx;
  334. }
  335. .popup_diner_number {
  336. width: 100%;
  337. height: 42vh;
  338. position: fixed;
  339. left: 0;
  340. bottom: 0;
  341. }
  342. .wx-zf {
  343. width: 40rpx;
  344. height: 40rpx;
  345. }
  346. .zz-icon {
  347. width: 32rpx;
  348. height: 32rpx;
  349. }
  350. .right-b {
  351. width: 32rpx;
  352. height: 32rpx;
  353. }
  354. .ts-img {
  355. width: 128rpx;
  356. height: 128rpx;
  357. }
  358. .way-box {
  359. box-shadow: 0rpx 8rpx 56rpx 0rpx rgba(154, 152, 152, 0.34);
  360. }
  361. .z-3 {
  362. position: relative;
  363. z-index: 3;
  364. }
  365. .order-bg {
  366. width: 100%;
  367. height: 15vh;
  368. position: fixed;
  369. left: 0;
  370. top: 0;
  371. }
  372. .goods-img {
  373. width: 108rpx;
  374. height: 108rpx;
  375. border-radius: 8rpx;
  376. margin-right: 16rpx;
  377. }
  378. .right-icon {
  379. width: 32rpx;
  380. height: 32rpx;
  381. }
  382. .w376 {
  383. width: 376rpx;
  384. }
  385. .w570 {
  386. width: 570rpx;
  387. }
  388. .sd-box {
  389. padding: 3rpx 16rpx;
  390. height: 40rpx;
  391. line-height: 40rpx;
  392. background: rgba(251, 61, 3, 0.1);
  393. border-radius: 8rpx 8rpx 8rpx 8rpx;
  394. }
  395. .box-2 {
  396. width: 200rpx;
  397. height: 80rpx;
  398. line-height: 80rpx;
  399. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  400. }
  401. .bottom-box {
  402. width: 100%;
  403. height: 96rpx;
  404. }
  405. </style>