add.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="content">
  3. <view class="info">
  4. <view class="one">
  5. <view class="one_1">
  6. <view class="left">桌号:{{shopInfo.table_name}}</view>
  7. <view class="right">人数:{{shopInfo.num}}人</view>
  8. </view>
  9. <view class="one_2">
  10. <view class="left">备注</view>
  11. <view class="right">
  12. <input v-model="shopInfo.remark" placeholder="填写备注" />
  13. <uni-icons color="#C0C0C0" type="forward" size="14"></uni-icons>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="two">
  18. <view class="two_1">消费明细</view>
  19. <view class="two_2">
  20. <scroll-view scroll-y="true" class="scroll-view">
  21. <view class="list-scroll-view">
  22. <view class="list" v-for="(item,index) in list" :key="index">
  23. <view class="img">
  24. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
  25. mode="">
  26. </image>
  27. </view>
  28. <view class="info">
  29. <view class="name textOver">
  30. <text>{{item.name}}</text>
  31. </view>
  32. <view class="spec" v-if="item.spec">
  33. <text>{{item.spec}}</text>
  34. </view>
  35. </view>
  36. <view class="money">
  37. <text>¥{{item.price}}</text>
  38. <text>×{{item.num}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </scroll-view>
  43. </view>
  44. <view class="two_3">
  45. 共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.money}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="foot">
  50. <view class="foot_1">
  51. 合计<text>¥</text><text>{{shopInfo.money||0}}</text>
  52. </view>
  53. <view class="foot_2">
  54. <button class="button" @tap.stop="toBuy">下单</button>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import moment from 'moment';
  61. export default {
  62. data() {
  63. return {
  64. id: "",
  65. order: '',
  66. shopInfo: {},
  67. list: [],
  68. }
  69. },
  70. onLoad: async function(e) {
  71. const that = this;
  72. that.$set(that, `id`, e.id);
  73. that.$set(that, `order`, e.order);
  74. that.search();
  75. },
  76. onShow() {
  77. const that = this;
  78. },
  79. methods: {
  80. async search(e) {
  81. const that = this;
  82. if (that.id) {
  83. let res = await that.$api(`order/${that.order}`, 'GET', {});
  84. if (res.errcode == '0') {
  85. that.$set(that, `list`, res.data.list)
  86. that.$set(that, `shopInfo`, res.data)
  87. let table = await that.$api(`table/${res.data.table}`, `GET`)
  88. that.$set(that.shopInfo, `table_name`, table.data.name)
  89. }
  90. }
  91. },
  92. // 下单
  93. async toBuy() {
  94. const that = this;
  95. let type = '0';
  96. if (that.is_show == true) type = '0'
  97. else type = '1'
  98. let obj = {
  99. time: moment().format('YYYY-MM-DD HH:mm:ss'),
  100. list: that.list
  101. }
  102. if (that.shopInfo.remark) obj.remark = that.shopInfo.remark
  103. let res = await that.$api(`order/${that.order}`, 'POST', obj);
  104. if (res.errcode == '0') {
  105. uni.showToast({
  106. title: '下单成功',
  107. icon: 'none'
  108. })
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .content {
  116. background-color: #f1f1f1;
  117. font-family: 12px/1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif;
  118. .info {
  119. display: flex;
  120. flex-direction: column;
  121. position: relative;
  122. flex-grow: 1;
  123. padding: 2vw;
  124. .one {
  125. padding: 2vw;
  126. background-color: #ffffff;
  127. border-radius: 4vw;
  128. .one_1 {
  129. display: flex;
  130. justify-content: space-between;
  131. align-items: center;
  132. background-color: #ffffff;
  133. border-radius: 3vw;
  134. padding: 4vw 2vw;
  135. border-bottom: 1px solid #f1f1f1;
  136. .left {
  137. font-size: 16px;
  138. font-weight: 600;
  139. }
  140. .right {
  141. font-size: 14px;
  142. }
  143. }
  144. .one_2 {
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. padding: 3vw 2vw;
  149. font-size: 14px;
  150. .right {
  151. display: flex;
  152. align-items: flex-end;
  153. color: #858585;
  154. /deep/input {
  155. text-align: right;
  156. }
  157. }
  158. }
  159. }
  160. .two {
  161. margin: 2vw 0;
  162. padding: 2vw;
  163. background-color: #ffffff;
  164. border-radius: 4vw;
  165. .two_1 {
  166. padding: 2vw 0;
  167. font-size: 16px;
  168. font-weight: 600;
  169. }
  170. .two_2 {
  171. position: relative;
  172. display: flex;
  173. flex-direction: column;
  174. height: 32vh;
  175. .list {
  176. display: flex;
  177. width: 88vw;
  178. margin: 0 0 2vw 0;
  179. padding: 2vw;
  180. box-shadow: 0 0 5px #f1f1f1;
  181. border-radius: 5px;
  182. .img {
  183. width: 30vw;
  184. .image {
  185. width: 30vw;
  186. height: 20vw;
  187. border-radius: 5px;
  188. }
  189. }
  190. .info {
  191. width: 40vw;
  192. padding: 0 0 0 2vw;
  193. .name {
  194. font-size: 16px;
  195. }
  196. .spec {
  197. font-size: 12px;
  198. color: #858585;
  199. }
  200. }
  201. .money {
  202. display: flex;
  203. flex-direction: column;
  204. align-items: flex-end;
  205. width: 20vw;
  206. text:first-child {
  207. font-size: 14px;
  208. color: #FF8C00;
  209. }
  210. }
  211. }
  212. }
  213. .two_3 {
  214. padding: 3vw;
  215. text-align: right;
  216. font-size: 14px;
  217. color: #858585;
  218. border-top: 1px solid #f1f1f1;
  219. text:first-child {
  220. color: #FF7800;
  221. }
  222. text:last-child {
  223. color: #FF7800;
  224. font-size: 18px;
  225. }
  226. }
  227. }
  228. }
  229. .foot {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. padding: 2vw 3vw;
  234. background-color: #ffffff;
  235. border-top: 1px solid #f1f1f1;
  236. .foot_1 {
  237. font-size: 14px;
  238. color: #858585;
  239. text:first-child {
  240. color: #FF7800;
  241. }
  242. text:last-child {
  243. color: #FF7800;
  244. font-size: 18px;
  245. }
  246. }
  247. .foot_2 {
  248. .button {
  249. background-color: #FF8C00;
  250. color: #ffffff;
  251. border-radius: 5vw;
  252. font-size: 16px;
  253. }
  254. }
  255. }
  256. }
  257. .scroll-view {
  258. position: absolute;
  259. top: 0;
  260. left: 0;
  261. right: 0;
  262. bottom: 0;
  263. .list-scroll-view {
  264. display: flex;
  265. flex-direction: column;
  266. }
  267. }
  268. </style>