index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <view :style="colorStyle">
  3. <view :style="{ backgroundPositionY: `${statusBarHeight + navBarHeight}px` }" class="confirm-order">
  4. <view class="nav-bar fixed">
  5. <view :style="{ height: `${statusBarHeight}px` }"></view>
  6. <view :style="{ height: `${navBarHeight}px` }" class="inner">
  7. <navigator class="btn" open-type="navigateBack" hover-class="none">
  8. <text class="iconfont icon-fanhui2"></text>
  9. </navigator>
  10. <view>提交订单</view>
  11. </view>
  12. </view>
  13. <view class="header">
  14. <view class="top acea-row row-middle">
  15. <view class="name">{{ codeData.storeName.storeName }}</view>
  16. <view class="number"><text class="light">{{ codeData.category.name }}{{ codeData.table_number }}</text>号桌</view>
  17. </view>
  18. <view>{{ codeData.serial_number }}</view>
  19. </view>
  20. <view class="dining acea-row row-between row-middle">
  21. <view class="total">共点{{ goodsNumber }}份</view>
  22. <view>{{ store_number_diners_window ? codeData.number_diners : tablePartake.length }}人就餐</view>
  23. </view>
  24. <view v-for="item in tablePartake" :key="item.userInfo.uid" class="dinner">
  25. <view class="head acea-row row-middle">
  26. <image class="image" :src="item.userInfo.avatar || '/static/images/f.png'" mode="aspectFill"></image>
  27. <view class="name">{{ item.userInfo.nickname }}</view>
  28. <!-- <view class="name">已点7份</view> -->
  29. <view>{{ item.order_time }}下单</view>
  30. </view>
  31. <view class="body">
  32. <view v-for="goods in item.goods" :key="goods.id" :class="{ gray: !goods.is_true_stock }" class="item acea-row">
  33. <image class="image" :src="goods.productInfo.image" mode="aspectFill"></image>
  34. <view class="text">
  35. <view class="name line2">{{ goods.productInfo.store_name }}</view>
  36. <view class="attr">{{ goods.productInfo.attrInfo.suk }}</view>
  37. <!-- <view class="money">¥{{ goods.truePrice }}</view> -->
  38. </view>
  39. <view class="">
  40. <BaseMoney :money="goods.truePrice" symbolSize="20" integerSize="32" decimalSize="20" color="#333333"></BaseMoney>
  41. <view class="number">共{{ goods.cart_num }}件</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="footer">
  47. <view class="inner"></view>
  48. </view>
  49. <view class="footer fixed">
  50. <view class="inner acea-row row-middle">
  51. <view class="total">
  52. 合计:<BaseMoney :money="total" symbolSize="28" integerSize="44" decimalSize="28"></BaseMoney>
  53. </view>
  54. <button class="btn" hover-class="none" @tap="getTableCode(onAdd)">加购</button>
  55. <button class="btn fill" hover-class="none" @tap="getTableCode(openDialog)">去结算</button>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="mask" v-if="dialogShow"></view>
  60. <view class="dialog" :class="{ show: dialogShow }">
  61. <view class="title">是否结账</view>
  62. <view class="info">您是否确认结算当前账单</view>
  63. <view class="btn-box acea-row">
  64. <view class="btn" @click="dialogShow = false">取消</view>
  65. <view class="btn primary" @click="confirm">确认</view>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import colors from '@/mixins/color.js';
  72. import {
  73. getCodeData,
  74. getTableCode,
  75. getTablePartake,
  76. settleTable,
  77. } from '@/api/store.js';
  78. export default {
  79. mixins: [colors],
  80. data() {
  81. return {
  82. statusBarHeight: 0,
  83. navBarHeight: 0,
  84. tablePartake: [],
  85. codeData: {},
  86. dialogShow: false,
  87. store_number_diners_window: 0,
  88. }
  89. },
  90. computed: {
  91. goodsNumber() {
  92. let goodsNumber = 0;
  93. this.tablePartake.forEach(item => {
  94. goodsNumber = item.goods.reduce((total, cell) => {
  95. return total + cell.cart_num;
  96. }, goodsNumber);
  97. })
  98. return goodsNumber;
  99. },
  100. total() {
  101. let total = 0;
  102. this.tablePartake.forEach(item => {
  103. total = item.goods.reduce((total, cell) => {
  104. return this.$util.$h.Add(total, this.$util.$h.Mul(cell.truePrice, cell.cart_num));
  105. }, total);
  106. });
  107. return total;
  108. }
  109. },
  110. onLoad(option) {
  111. const {
  112. tableId,
  113. store_number_diners_window,
  114. } = option;
  115. let {
  116. height,
  117. top
  118. } = uni.getMenuButtonBoundingClientRect();
  119. uni.getSystemInfo({
  120. success: ({
  121. statusBarHeight
  122. }) => {
  123. this.statusBarHeight = statusBarHeight;
  124. this.navBarHeight = 2 * (top - statusBarHeight) + height;
  125. }
  126. });
  127. this.tableId = tableId;
  128. this.store_number_diners_window = parseInt(store_number_diners_window);
  129. this.getCodeData();
  130. this.getTablePartake();
  131. },
  132. onPullDownRefresh() {
  133. this.getTablePartake();
  134. },
  135. methods: {
  136. // 获取桌码信息
  137. getCodeData() {
  138. getCodeData({
  139. tableId: this.tableId
  140. }).then(res => {
  141. this.codeData = res.data;
  142. });
  143. },
  144. getTablePartake(callback) {
  145. getTablePartake({
  146. tableId: this.tableId
  147. }).then(({
  148. data
  149. }) => {
  150. let tablePartake = [];
  151. Object.keys(data).forEach(key => {
  152. tablePartake.push(data[key]);
  153. });
  154. this.tablePartake = tablePartake;
  155. uni.stopPullDownRefresh();
  156. if (callback) {
  157. let is_true_stock = true;
  158. for (let partakeItem of this.tablePartake) {
  159. if (!is_true_stock) {
  160. break;
  161. }
  162. for (let goodsItem of partakeItem.goods) {
  163. is_true_stock = goodsItem.is_true_stock;
  164. if (!is_true_stock) {
  165. break;
  166. }
  167. }
  168. }
  169. if (!is_true_stock) {
  170. return this.$util.Tips({
  171. title: '存在库存不足的商品,请检查'
  172. });
  173. }
  174. callback();
  175. }
  176. }).catch(err => {
  177. this.$util.Tips({
  178. title: err
  179. });
  180. });
  181. },
  182. settleTable() {
  183. settleTable({
  184. tableId: this.tableId
  185. }).then(res => {
  186. uni.navigateTo({
  187. url: `/pages/goods/order_confirm/index?new=1&delivery_type=2&cartId=${res.data.cartIds}&store_id=${this.codeData.store_id}&tableId=${this.tableId}`
  188. });
  189. }).catch(err => {
  190. this.$util.Tips({
  191. title: err
  192. });
  193. });
  194. },
  195. // 去结账
  196. openDialog() {
  197. this.dialogShow = true;
  198. },
  199. confirm() {
  200. this.dialogShow = false;
  201. this.getTablePartake(this.settleTable);
  202. },
  203. // 加购
  204. onAdd() {
  205. uni.navigateTo({
  206. url: `/pages/store/table_code/index?store_id=${this.codeData.store_id}&qrcode_id=${this.codeData.id}`
  207. });
  208. },
  209. getTableCode(callback) {
  210. getTableCode({
  211. tableId: this.tableId
  212. }).then(res => {
  213. const status = res.data.table.status;
  214. switch (status) {
  215. case -1:
  216. case 2:
  217. case 3:
  218. this.$util.Tips({
  219. title: status == -1 ? '本单已取消' : '本单已结账'
  220. });
  221. break;
  222. default:
  223. callback();
  224. break;
  225. }
  226. }).catch(err => {
  227. this.$util.Tips({
  228. title: err
  229. });
  230. });
  231. }
  232. },
  233. }
  234. </script>
  235. <style>
  236. page {
  237. background-color: #F5F5F5;
  238. }
  239. </style>
  240. <style lang="scss" scoped>
  241. .mask {
  242. z-index: 10;
  243. }
  244. .confirm-order {
  245. background: linear-gradient(180deg, var(--view-theme) 0%, #F5F5F5 100%);
  246. background-size: 100% 292rpx;
  247. background-repeat: no-repeat;
  248. }
  249. .nav-bar {
  250. background-color: var(--view-theme);
  251. &.fixed {
  252. position: sticky;
  253. top: 0;
  254. right: 0;
  255. left: 0;
  256. z-index: 9;
  257. }
  258. .inner {
  259. position: relative;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. font-size: 30rpx;
  264. color: #FFFFFF;
  265. }
  266. .btn {
  267. position: absolute;
  268. top: 0;
  269. bottom: 0;
  270. left: 0;
  271. display: flex;
  272. align-items: center;
  273. padding: 0 30rpx;
  274. font-size: 24rpx;
  275. color: #FFFFFF;
  276. }
  277. }
  278. .header {
  279. padding: 32rpx;
  280. border-radius: 24rpx;
  281. margin: 20rpx;
  282. background: #FFFFFF;
  283. font-size: 24rpx;
  284. line-height: 34rpx;
  285. color: #999999;
  286. .top {
  287. margin-bottom: 12rpx;
  288. }
  289. .name {
  290. flex: 1;
  291. min-width: 0;
  292. font-weight: 500;
  293. font-size: 30rpx;
  294. line-height: 42rpx;
  295. color: #333333;
  296. }
  297. .number {
  298. font-size: 22rpx;
  299. line-height: 42rpx;
  300. color: #333333;
  301. }
  302. .light {
  303. font-weight: 500;
  304. font-size: 30rpx;
  305. color: var(--view-theme);
  306. }
  307. }
  308. .dining {
  309. height: 100rpx;
  310. padding: 0 24rpx 0 32rpx;
  311. border-radius: 24rpx;
  312. margin: 20rpx;
  313. background: #FFFFFF;
  314. font-size: 24rpx;
  315. color: #333333;
  316. .total {
  317. font-weight: 500;
  318. font-size: 30rpx;
  319. color: #3D3D3D;
  320. }
  321. }
  322. .dinner {
  323. border-radius: 24rpx;
  324. margin: 20rpx;
  325. background: #FFFFFF;
  326. .head {
  327. padding: 35rpx 24rpx;
  328. font-size: 28rpx;
  329. color: #333333;
  330. .image {
  331. display: block;
  332. width: 36rpx;
  333. height: 36rpx;
  334. border-radius: 50%;
  335. }
  336. .name {
  337. flex: 1;
  338. min-width: 0;
  339. padding: 0 10rpx;
  340. }
  341. }
  342. .body {
  343. padding: 0 24rpx 32rpx;
  344. }
  345. .item {
  346. position: relative;
  347. margin-top: 32rpx;
  348. &:first-child {
  349. margin-top: 0;
  350. }
  351. &.gray {
  352. background-color: #EEEEEE;
  353. }
  354. .image {
  355. display: block;
  356. width: 136rpx;
  357. height: 136rpx;
  358. border-radius: 16rpx;
  359. }
  360. .text {
  361. flex: 1;
  362. min-width: 0;
  363. padding: 0 20rpx;
  364. }
  365. .name {
  366. font-size: 28rpx;
  367. line-height: 40rpx;
  368. color: #333333;
  369. }
  370. .attr {
  371. margin-top: 12rpx;
  372. font-size: 24rpx;
  373. line-height: 34rpx;
  374. color: #999999;
  375. }
  376. .number {
  377. margin-top: 10rpx;
  378. text-align: right;
  379. font-size: 24rpx;
  380. line-height: 34rpx;
  381. color: #999999;
  382. }
  383. }
  384. }
  385. .footer {
  386. padding-bottom: constant(safe-area-inset-bottom);
  387. padding-bottom: env(safe-area-inset-bottom);
  388. &.fixed {
  389. position: fixed;
  390. right: 0;
  391. bottom: 0;
  392. left: 0;
  393. z-index: 9;
  394. background: #FFFFFF;
  395. }
  396. .inner {
  397. height: 96rpx;
  398. padding: 0 32rpx;
  399. }
  400. .total {
  401. flex: 1;
  402. min-width: 0;
  403. font-weight: 500;
  404. font-size: 28rpx;
  405. color: #333333;
  406. }
  407. .btn {
  408. transform: rotateZ(360deg);
  409. width: 142rpx;
  410. height: 72rpx;
  411. border: 1rpx solid var(--view-theme);
  412. border-radius: 36rpx;
  413. font-weight: 500;
  414. font-size: 26rpx;
  415. line-height: 70rpx;
  416. color: var(--view-theme);
  417. +.btn {
  418. margin-left: 16rpx;
  419. }
  420. &.fill {
  421. border: 0;
  422. background: linear-gradient(90deg, var(--view-gradient) 0%, var(--view-theme) 100%);
  423. line-height: 72rpx;
  424. color: #FFFFFF;
  425. }
  426. }
  427. }
  428. .dialog {
  429. position: fixed;
  430. top: 50%;
  431. right: 75rpx;
  432. left: 75rpx;
  433. z-index: 11;
  434. display: none;
  435. border-radius: 32rpx;
  436. background: #FFFFFF;
  437. overflow: hidden;
  438. transform: translateY(-50%);
  439. text-align: center;
  440. &.show {
  441. display: block;
  442. }
  443. .title {
  444. padding: 40rpx 32rpx 24rpx;
  445. font-weight: 500;
  446. font-size: 32rpx;
  447. line-height: 52rpx;
  448. color: #333333;
  449. }
  450. .info {
  451. padding: 0 40rpx;
  452. font-size: 30rpx;
  453. line-height: 42rpx;
  454. color: #666666;
  455. }
  456. .btn-box {
  457. padding: 40rpx;
  458. }
  459. .btn {
  460. flex: 1;
  461. height: 72rpx;
  462. border: 1rpx solid var(--view-theme);
  463. border-radius: 36rpx;
  464. font-weight: 500;
  465. font-size: 26rpx;
  466. line-height: 70rpx;
  467. color: var(--view-theme);
  468. transform: rotateZ(360deg);
  469. +.btn {
  470. margin-left: 32rpx;
  471. }
  472. &.primary {
  473. background: var(--view-theme);
  474. color: #FFFFFF;
  475. }
  476. }
  477. }
  478. </style>