add.vue 6.0 KB

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