add.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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.total}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="foot">
  50. <view class="foot_1">
  51. 合计<text>¥</text><text>{{shopInfo.total||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. methods: {
  77. async search(e) {
  78. const that = this;
  79. if (that.id && that.order) {
  80. let res;
  81. res = await that.$api(`cart/${that.id}`, 'GET', {});
  82. if (res.errcode == '0') {
  83. that.$set(that, `list`, res.data.list)
  84. that.$set(that.shopInfo, `total`, res.data.total)
  85. let table = await that.$api(`table/${res.data.table}`, `GET`)
  86. that.$set(that.shopInfo, `table_name`, table.data.name)
  87. }
  88. res = await that.$api(`order/${that.order}`, 'GET', {});
  89. if (res.errcode == '0') {
  90. that.$set(that.shopInfo, `num`, res.data.num)
  91. that.$set(that.shopInfo, `remark`, res.data.remark)
  92. }
  93. }
  94. },
  95. // 下单
  96. async toBuy() {
  97. const that = this;
  98. let type = '0';
  99. if (that.is_show == true) type = '0'
  100. else type = '1'
  101. let obj = {
  102. time: moment().format('YYYY-MM-DD HH:mm:ss'),
  103. list: that.list
  104. }
  105. if (that.shopInfo.remark) obj.remark = that.shopInfo.remark
  106. let res = await that.$api(`order/${that.order}`, 'POST', obj);
  107. if (res.errcode == '0') {
  108. uni.showToast({
  109. title: '下单成功',
  110. icon: 'none'
  111. })
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. .content {
  119. background-color: #f1f1f1;
  120. font-family: 12px/1 Tahoma, Helvetica, Arial, "\5b8b\4f53", sans-serif;
  121. .info {
  122. display: flex;
  123. flex-direction: column;
  124. position: relative;
  125. flex-grow: 1;
  126. padding: 2vw;
  127. .one {
  128. padding: 2vw;
  129. background-color: #ffffff;
  130. border-radius: 4vw;
  131. .one_1 {
  132. display: flex;
  133. justify-content: space-between;
  134. align-items: center;
  135. background-color: #ffffff;
  136. border-radius: 3vw;
  137. padding: 4vw 2vw;
  138. border-bottom: 1px solid #f1f1f1;
  139. .left {
  140. font-size: 16px;
  141. font-weight: 600;
  142. }
  143. .right {
  144. font-size: 14px;
  145. }
  146. }
  147. .one_2 {
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. padding: 3vw 2vw;
  152. font-size: 14px;
  153. .right {
  154. display: flex;
  155. align-items: flex-end;
  156. color: #858585;
  157. /deep/input {
  158. text-align: right;
  159. }
  160. }
  161. }
  162. }
  163. .two {
  164. margin: 2vw 0;
  165. padding: 2vw;
  166. background-color: #ffffff;
  167. border-radius: 4vw;
  168. .two_1 {
  169. padding: 2vw 0;
  170. font-size: 16px;
  171. font-weight: 600;
  172. }
  173. .two_2 {
  174. position: relative;
  175. display: flex;
  176. flex-direction: column;
  177. height: 32vh;
  178. .list {
  179. display: flex;
  180. width: 88vw;
  181. margin: 0 0 2vw 0;
  182. padding: 2vw;
  183. box-shadow: 0 0 5px #f1f1f1;
  184. border-radius: 5px;
  185. .img {
  186. width: 30vw;
  187. .image {
  188. width: 30vw;
  189. height: 20vw;
  190. border-radius: 5px;
  191. }
  192. }
  193. .info {
  194. width: 40vw;
  195. padding: 0 0 0 2vw;
  196. .name {
  197. font-size: 16px;
  198. }
  199. .spec {
  200. font-size: 12px;
  201. color: #858585;
  202. }
  203. }
  204. .money {
  205. display: flex;
  206. flex-direction: column;
  207. align-items: flex-end;
  208. width: 20vw;
  209. text:first-child {
  210. font-size: 14px;
  211. color: #FF8C00;
  212. }
  213. }
  214. }
  215. }
  216. .two_3 {
  217. padding: 3vw;
  218. text-align: right;
  219. font-size: 14px;
  220. color: #858585;
  221. border-top: 1px solid #f1f1f1;
  222. text:first-child {
  223. color: #FF7800;
  224. }
  225. text:last-child {
  226. color: #FF7800;
  227. font-size: 18px;
  228. }
  229. }
  230. }
  231. }
  232. .foot {
  233. display: flex;
  234. justify-content: space-between;
  235. align-items: center;
  236. padding: 2vw 3vw;
  237. background-color: #ffffff;
  238. border-top: 1px solid #f1f1f1;
  239. .foot_1 {
  240. font-size: 14px;
  241. color: #858585;
  242. text:first-child {
  243. color: #FF7800;
  244. }
  245. text:last-child {
  246. color: #FF7800;
  247. font-size: 18px;
  248. }
  249. }
  250. .foot_2 {
  251. .button {
  252. background-color: #FF8C00;
  253. color: #ffffff;
  254. border-radius: 5vw;
  255. font-size: 16px;
  256. }
  257. }
  258. }
  259. }
  260. .scroll-view {
  261. position: absolute;
  262. top: 0;
  263. left: 0;
  264. right: 0;
  265. bottom: 0;
  266. .list-scroll-view {
  267. display: flex;
  268. flex-direction: column;
  269. }
  270. }
  271. </style>