addorder.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="content">
  3. <checkbox-group>
  4. <view class="good" v-for="item in list">
  5. <image :src="item.image" mode="" class="good-img"></image>
  6. <view class="good-info">
  7. <view class="good-tit clamp2">
  8. {{item.name}}
  9. </view>
  10. <view class="good-tip">
  11. 随时随地 预约服务
  12. </view>
  13. <view class="good-buy">
  14. 已售{{item.sold}}件
  15. </view>
  16. <view class="good-price">
  17. {{item.price}} <text class="ot-price">¥{{item.ot_price}}</text>
  18. </view>
  19. </view>
  20. <checkbox :checked="item.isCheck" class="good-check" :value="item.id" @click="changeCheck(item)"/>
  21. </view>
  22. </checkbox-group>
  23. <u-loadmore :status="loadingType" />
  24. <view class="" style="height: 120rpx;">
  25. </view>
  26. <view class="sub-btn" @click="addGood">
  27. 确认添加
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. loadingType: 'loadmore',
  36. page: 1,
  37. pageSize: 10,
  38. loaded: false,
  39. list: [],
  40. id: '',
  41. }
  42. },
  43. computed: {
  44. chooseList() {
  45. let arr = this.list.filter((item)=> {
  46. return item.isCheck == true
  47. })
  48. return arr
  49. },
  50. choose_id() {
  51. let dd = ''
  52. if(this.chooseList.length > 0) {
  53. this.chooseList.forEach(item => {
  54. dd = dd + item.id + ','
  55. })
  56. }
  57. return dd
  58. }
  59. },
  60. onLoad(opt) {
  61. this.id = opt.id
  62. },
  63. onShow() {
  64. this.getList()
  65. },
  66. onReachBottom() {
  67. // this.getList()
  68. },
  69. onReady() {
  70. },
  71. methods: {
  72. addGood() {
  73. if(this.choose_id == '') {
  74. this.$u.toast('请选择要添加的项目');
  75. }
  76. let res = {
  77. "id": this.id, //id
  78. "projectId": this.choose_id.slice(0,this.choose_id.length-1), //项目id
  79. }
  80. // console.log(res,'tijiao')
  81. this.$u.api.addProject(res).then(({data}) => {
  82. this.$u.toast('添加成功');
  83. setTimeout(()=> {
  84. uni.navigateBack()
  85. },1000)
  86. })
  87. },
  88. changeCheck(item) {
  89. item.isCheck = !item.isCheck
  90. console.log(this.list)
  91. },
  92. getList() {
  93. let that = this
  94. if(that.loadingType == 'nomore' || that.loadingType == 'loading') {
  95. return
  96. }
  97. that.loadingType = 'loading'
  98. this.$u.api.getYyItemList({
  99. page: that.page,
  100. pageSize: that.pageSize,
  101. }).then(res => {
  102. that.list = that.list.concat(res.data.map(item => {
  103. item.isCheck = false
  104. return item
  105. }))
  106. that.page++
  107. if(that.pageSize == res.data.length ) {
  108. that.loadingType = 'loadmore'
  109. }else {
  110. that.loadingType = 'nomore'
  111. }
  112. that.loaded = true
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. .content {
  120. padding-top: 1rpx;
  121. }
  122. .good {
  123. width: 690rpx;
  124. margin: 20rpx auto;
  125. display: flex;
  126. justify-content: flex-start;
  127. padding: 20rpx;
  128. background-color: #fff;
  129. border-radius: 20rpx;
  130. position: relative;
  131. .good-check {
  132. position: absolute;
  133. bottom: 20rpx;
  134. right: 20rpx;
  135. }
  136. .good-img {
  137. width: 256rpx;
  138. height: 256rpx;
  139. background: #D6DEE1;
  140. border-radius: 15rpx;
  141. flex-shrink: 0;
  142. margin-right: 15rpx;
  143. }
  144. .good-info {
  145. display: flex;
  146. flex-direction: column;
  147. // align-items: ;
  148. justify-content: space-between;
  149. align-items: flex-start;
  150. .good-tit {
  151. font-size: 28rpx;
  152. font-weight: 500;
  153. color: #333333;
  154. }
  155. .good-buy {
  156. font-size: 24rpx;
  157. font-weight: 500;
  158. color: #9a9a9a;
  159. }
  160. .good-tip {
  161. font-size: 24rpx;
  162. font-weight: 500;
  163. color: #FA7014;
  164. }
  165. .good-price {
  166. color: #fd463e;
  167. font-size: 32rpx;
  168. &::before {
  169. content: '¥';
  170. font-size: 22rpx;
  171. color: #fd463e;
  172. }
  173. text {
  174. padding-left: 15rpx;
  175. font-size: 26rpx;
  176. font-weight: 500;
  177. text-decoration: line-through;
  178. color: #999999;
  179. }
  180. }
  181. }
  182. }
  183. .sub-btn {
  184. width: 616rpx;
  185. height: 74rpx;
  186. background: #4D74CF;
  187. border-radius: 15rpx;
  188. font-size: 30rpx;
  189. font-weight: bold;
  190. color: #FFFFFF;
  191. text-align: center;
  192. line-height: 74rpx;
  193. position: fixed;
  194. bottom: 45rpx;
  195. left: 0;
  196. right: 0;
  197. margin: auto;
  198. }
  199. </style>