breast.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="page" :style="{'height':(h-th)+'px','padding-top':mt+'px'}">
  3. <c-nav-bar title="添加商品" :showIcon="true"></c-nav-bar>
  4. <view class="content">
  5. <view class="item" v-for="(item,index) in list" :key="index">
  6. <text>{{item.breakfastName}}</text>
  7. <text>{{item.price}}</text>
  8. <u-number-box v-model="item.num" min="0">
  9. <view slot="minus" class="minus">
  10. <u-icon name="minus" size="22"></u-icon>
  11. </view>
  12. <text slot="input" class="input">{{item.num||0}}</text>
  13. <view slot="plus" class="plus">
  14. <u-icon name="plus" size="22"></u-icon>
  15. </view>
  16. </u-number-box>
  17. </view>
  18. <view class="item" v-for="(item,index) in list2" :key="index">
  19. <text>{{item.projectName}}</text>
  20. <text>{{item.defaultPrice}}</text>
  21. <u-number-box v-model="item.num" min="0">
  22. <view slot="minus" class="minus">
  23. <u-icon name="minus" size="22"></u-icon>
  24. </view>
  25. <text slot="input" class="input">{{item.num||0}}</text>
  26. <view slot="plus" class="plus">
  27. <u-icon name="plus" size="22"></u-icon>
  28. </view>
  29. </u-number-box>
  30. </view>
  31. </view>
  32. <view class="btn">
  33. <text @click="conform()">确定</text>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import listItem from '../../uni_modules/uview-ui/libs/config/props/listItem';
  39. export default {
  40. data() {
  41. return {
  42. homestayId: uni.getStorageSync('homestayId'),
  43. list: [],
  44. list2: []
  45. }
  46. },
  47. onLoad(opt) {
  48. console.log(opt)
  49. let list = JSON.parse(opt.list1);
  50. let list2 = JSON.parse(opt.list2);
  51. this.getBreastData(list);
  52. this.getOtherData(list2);
  53. },
  54. methods: {
  55. conform() {
  56. this.getOpenerEventChannel().emit('addSuccess', {
  57. 'data1': this.list,
  58. 'data2': this.list2
  59. });
  60. uni.navigateBack();
  61. },
  62. getBreastData(list) {
  63. this.$api.get('/merchant/hotel/order/getBreakfastList', {
  64. homestayId: this.homestayId
  65. }).then(res => {
  66. console.log(res)
  67. if (res.data.code == 0) {
  68. if (list && list.length != 0) {
  69. let filItem = null;
  70. for (let i = 0; i < res.data.data.length; i++) {
  71. filItem = list.filter(
  72. (item) =>
  73. item.breakfastName == res.data.data[i].breakfastName
  74. );
  75. if (filItem) {
  76. res.data.data[i].num = filItem[0].num;
  77. break;
  78. }
  79. }
  80. }
  81. this.list = res.data.data
  82. }
  83. console.log(this.list)
  84. })
  85. },
  86. getOtherData(list2) {
  87. this.$api.get('/merchant/hotel/order/getOtherList', {
  88. homestayId: this.homestayId
  89. }).then(res => {
  90. if (res.data.code == 0) {
  91. if (list2 && list2.length != 0) {
  92. let filItem = null;
  93. for (let i = 0; i < res.data.data.length; i++) {
  94. filItem = list2.filter(
  95. (item) =>
  96. item.projectName == res.data.data[i].projectName
  97. );
  98. if (filItem) {
  99. res.data.data[i].num = filItem[0].num;
  100. break;
  101. }
  102. }
  103. }
  104. this.list2 = res.data.data
  105. }
  106. })
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .btn {
  113. position: fixed;
  114. background-color: #fff;
  115. padding: 30rpx 0;
  116. z-index: 9;
  117. bottom: 0;
  118. width: 100%;
  119. left: 0;
  120. text-align: center;
  121. text {
  122. display: inline-block;
  123. width: 90%;
  124. height: 96rpx;
  125. line-height: 96rpx;
  126. background-color: #1372FF;
  127. color: #fff;
  128. font-size: 34rpx;
  129. border-radius: 48rpx;
  130. }
  131. }
  132. .page {
  133. background: #F3F4F4;
  134. box-sizing: border-box;
  135. overflow-y: auto;
  136. overflow-x: auto;
  137. }
  138. .content {
  139. padding: 0 30rpx 20rpx;
  140. width: 96%;
  141. margin: 20rpx auto 0;
  142. box-sizing: border-box;
  143. background-color: #fff;
  144. .item {
  145. padding: 36rpx 0;
  146. display: flex;
  147. align-items: center;
  148. justify-content: space-between;
  149. border-bottom: 1rpx solid #D1D1D1;
  150. &:last-child {
  151. border: 0;
  152. }
  153. text {
  154. font-size: 30rpx;
  155. color: #F14D4D;
  156. &:nth-of-type(1) {
  157. font-weight: bold;
  158. color: #333;
  159. }
  160. }
  161. }
  162. }
  163. .input {
  164. margin: 0 20rpx;
  165. font-size: 28rpx;
  166. }
  167. .minus,
  168. .plus {
  169. justify-content: center;
  170. display: flex;
  171. width: 34rpx;
  172. height: 34rpx;
  173. line-height: 34rpx;
  174. padding: 8rpx 6rpx;
  175. border: 1px solid #999;
  176. border-radius: 6rpx;
  177. }
  178. </style>