goods-order.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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="wayType === 1?'bgc-FFF3F3 b-FF3333':'b-b-d'" @click="wayTypeStyle(1)">
  13. <view class="fw-600 fs-32" :class="wayType === 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="wayType === 2?'bgc-FFF3F3 b-FF3333':'b-b-d'" @click="wayTypeStyle(2)">
  20. <view class="fw-600 fs-32" :class="wayType === 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-F9F9F9">
  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. 桌号:17
  42. </view>
  43. </view>
  44. </view>
  45. <view class="mb-24 b-b-F9F9F9">
  46. <view class="flex-justify-space mb-28" v-for="(item,i) in cardData.goods_list" :key="i">
  47. <image class="goods-img" :src="item.goods_image" mode="aspectFill"></image>
  48. <view class="w376">
  49. <view class="fs-28 fw-600 mb-2">
  50. {{item.goods_name}}
  51. </view>
  52. <view class="fs-24 fc-9 mb-2">{{item.goods_desc}}</view>
  53. <view class="fs-24 fc-9">x{{item.goods_number}}</view>
  54. </view>
  55. <view class="fs-32 fw-600 fc-3">¥{{item.goods_money}}</view>
  56. </view>
  57. </view>
  58. <view class="flex-justify-space mb-30">
  59. <view class="fs-28 fw-400">就餐人数</view>
  60. <view class="align-items-center" @click="openPop">
  61. <view class="fs-32 fw-600 fc-3 mr-4">2人</view>
  62. <image class="right-b" src="@/static/img/order-food/right-b.png" mode=""></image>
  63. </view>
  64. </view>
  65. <view class="flex-justify-space mb-30">
  66. <view class="fs-28 fw-400">餐位费</view>
  67. <view class="fs-32 fw-600 fc-3">¥4</view>
  68. </view>
  69. <!-- <view class="flex-justify-space mb-30">
  70. <view class="fs-28 fw-400">店铺优惠</view>
  71. <view class="fs-32 fw-600">¥{{cardData.pack_price}}</view>
  72. </view> -->
  73. <view class="align-items-center flex-justify-end pt-20 b-t-F9F9F9">
  74. <view class="fs-28 fc-0 fw-400 mr-4">
  75. 应付
  76. </view>
  77. <span class="fw-600 fc-0 fs-28">¥</span>
  78. <span
  79. class="fw-600 fc-0 fs-44">{{(total_price - quanMoney) < 0?'0':(total_price - quanMoney).toFixed(2)||0}}</span>
  80. </view>
  81. </view>
  82. <view class="p-24 box-border-box bgc-f mb-20 b-rad-20 flex-justify-space">
  83. <view class="fs-28 fw-600">备注</view>
  84. <input v-model="fromData.note" class="flex-1 text-align-right fs-28" type="text"
  85. placeholder="请填写你的需求">
  86. </view>
  87. <view class="p-24 box-border-box bgc-f mb-20 b-rad-20 flex-justify-space">
  88. <view class="fs-28 fw-600">备注</view>
  89. <view class="align-items-center">
  90. <image class="wx-zf mr-6" src="@/static/img/common/wx-zf.png" mode=""></image>
  91. <view class="fs-28 fc-3">
  92. 微信支付
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="plr-24 box-border-box">
  98. <view class="bottom-box flex-justify-space align-items-center pl-24 box-border-box pr-8 b-rad-200 bgc-f">
  99. <view class="align-items-baseline">
  100. <view class="fs-28 fc-3 fw-600">¥</view>
  101. <view
  102. class="fs-44 fc-3 fw-600">{{(total_price - quanMoney) < 0?'0':(total_price - quanMoney).toFixed(2)||0}}</view>
  103. </view>
  104. <view class="box-2 text-align-center fc-f fs-32 fw-600 b-rad-200" @click="toSave()">立即支付</view>
  105. </view>
  106. </view>
  107. <uni-popup ref="popup" type="bottom" background-color="transparent" borderRadius='10px 10px 0 0'>
  108. <view class="b-rad-20-20-0-0 bgc-f">
  109. </view>
  110. </uni-popup>
  111. </view>
  112. </template>
  113. <script>
  114. import {
  115. getShopIngList
  116. } from '@/api/shopping.js'
  117. import {
  118. getDeliveryMoney
  119. } from '@/api/common.js'
  120. import {
  121. orderCreate,
  122. orderPay
  123. } from '@/api/order.js'
  124. import tools from "@/service/tools";
  125. export default {
  126. components: {},
  127. data() {
  128. return {
  129. wayType: 1, //1堂食 2打包
  130. fromData: {
  131. school_id: '',
  132. shop_id: '',
  133. // site_id:'',
  134. type: '',
  135. time: '',
  136. address_id: '',
  137. coupon_id: '',
  138. note: '',
  139. // is_default:0,
  140. // pickup_code:[],
  141. },
  142. addressData: {},
  143. deliverText: '',
  144. cardData: {
  145. goods_list: [],
  146. },
  147. delivery_money: '',
  148. quanMoney: "",
  149. total_price: '',
  150. isAJAX: false,
  151. CouponLength: 0, // 可用优惠券数量
  152. receiveLength: 0 // 可领优惠券数量
  153. }
  154. },
  155. onLoad(e) {},
  156. onShow() {},
  157. onUnload() {},
  158. methods: {
  159. openPop(){
  160. this.$refs.popup.open()
  161. },
  162. wayTypeStyle(type) {
  163. if (type === this.wayType) {
  164. return
  165. } else {
  166. this.wayType = type
  167. }
  168. },
  169. getDeliveryMoney(shop_id) {
  170. // 获取外卖配送费
  171. this.fromData.school_id = uni.getStorageSync('school_id');
  172. getDeliveryMoney({
  173. shop_id: shop_id,
  174. school_id: this.fromData.school_id
  175. }).then((res) => {
  176. if (res.code == 1) {
  177. this.delivery_money = res.data.delivery_money
  178. this.total_price = (Number(this.total_price) + Number(this.delivery_money)).toFixed(2)
  179. }
  180. })
  181. },
  182. // 获取购物车
  183. getCard(shop_id) {
  184. getShopIngList({
  185. shop_id: shop_id
  186. }).then((res) => {
  187. if (res.code === 1) {
  188. this.cardData = res.data;
  189. this.total_price = res.data.total_price
  190. this.getDeliveryMoney(shop_id)
  191. }
  192. })
  193. },
  194. giveCouPon(e) {
  195. if (e.id) {
  196. this.quanMoney = Number(e.money);
  197. this.fromData.coupon_id = e.id;
  198. } else {
  199. this.quanMoney = ''
  200. this.fromData.coupon_id = 0
  201. }
  202. },
  203. toSave() {
  204. if (this.isAJAX) {
  205. return
  206. }
  207. this.isAJAX = true;
  208. this.fromData.school_id = uni.getStorageSync('school_id');
  209. orderCreate(this.fromData).then((res) => {
  210. if (res.code === 1) {
  211. uni.redirectTo({
  212. url: `/pages-takeout/pay-page?orderId=${res.data.order_id}`
  213. });
  214. } else {
  215. this.isAJAX = false;
  216. tools.error(res.msg);
  217. }
  218. })
  219. },
  220. },
  221. }
  222. </script>
  223. <style scoped lang="scss">
  224. .wx-zf{
  225. width: 40rpx;
  226. height: 40rpx;
  227. }
  228. .zz-icon {
  229. width: 32rpx;
  230. height: 32rpx;
  231. }
  232. .right-b {
  233. width: 32rpx;
  234. height: 32rpx;
  235. }
  236. .ts-img {
  237. width: 128rpx;
  238. height: 128rpx;
  239. }
  240. .way-box {
  241. box-shadow: 0rpx 8rpx 56rpx 0rpx rgba(154, 152, 152, 0.34);
  242. }
  243. .z-3 {
  244. position: relative;
  245. z-index: 3;
  246. }
  247. .order-bg {
  248. width: 100%;
  249. height: 15vh;
  250. position: fixed;
  251. left: 0;
  252. top: 0;
  253. }
  254. .goods-img {
  255. width: 108rpx;
  256. height: 108rpx;
  257. border-radius: 8rpx;
  258. margin-right: 16rpx;
  259. }
  260. .right-icon {
  261. width: 32rpx;
  262. height: 32rpx;
  263. }
  264. .w376 {
  265. width: 376rpx;
  266. }
  267. .w570 {
  268. width: 570rpx;
  269. }
  270. .sd-box {
  271. padding: 3rpx 16rpx;
  272. height: 40rpx;
  273. line-height: 40rpx;
  274. background: rgba(251, 61, 3, 0.1);
  275. border-radius: 8rpx 8rpx 8rpx 8rpx;
  276. }
  277. .box-2 {
  278. width: 200rpx;
  279. height: 80rpx;
  280. line-height: 80rpx;
  281. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  282. }
  283. .bottom-box{
  284. width: 100%;
  285. height: 96rpx;
  286. }
  287. </style>