goods.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view>
  3. <uni-popup ref="orderPop" type="bottom" border-radius="10px 10px 0 0" background-color="#f1f1f1" :mask-click="false">
  4. <view class="order-popup">
  5. <view class="order-title">
  6. <view class="name">选择商品</view>
  7. <view class="close" @click="closeOrder()"><image src="/static/image/close.png"></image></view>
  8. </view>
  9. <view class="order-body-con" v-if="orderList.length > 0">
  10. <scroll-view class="order-body" scroll-y scroll-with-animation @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower" upper-threshold="80">
  11. <view class="m-order-s" v-for="(items,index) in orderList" :key="index">
  12. <view class="order-img" @click="checkOrder(index,items.check)"><image :src="items.image" mode="widthFix"></image></view>
  13. <view class="order-info">
  14. <view class="title" @click="checkOrder(index,items.check)">{{items.title}}</view>
  15. <view class="desc">
  16. <uni-number-box v-model="items.number" :min="1"></uni-number-box>
  17. </view>
  18. </view>
  19. <view class="status-btn-group" @click="checkOrder(index,items.check)">
  20. <view class="status danger" v-if="!items.check">选择</view>
  21. <view class="status success" v-else>已选择</view>
  22. </view>
  23. </view>
  24. <view class="view-more" v-if="orderData.loading">
  25. <uni-load-more status="loading"></uni-load-more>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. <view class="order-body" v-else>
  30. <view class="empty-body">暂无数据...</view>
  31. </view>
  32. <view class="address-footer" v-if="orderList.length > 0">
  33. <view class="footer-btn" @click="closeOrder">取消</view>
  34. <view class="footer-btn full" @click="sendGoods">确定</view>
  35. </view>
  36. </view>
  37. </uni-popup>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data () {
  43. return {
  44. orderList:[],
  45. orderData:{
  46. page:1,
  47. size:10,
  48. loading:false,
  49. isDone:false
  50. },
  51. orderId:0,
  52. goodsNum:0
  53. }
  54. },
  55. methods: {
  56. open() {
  57. this.$nextTick(()=>{
  58. this.$refs.orderPop.open()
  59. })
  60. return this;
  61. },
  62. checkOrder(index,state) {
  63. this.orderList[index].check = !state;
  64. },
  65. closeOrder(){
  66. this.$nextTick(()=>{
  67. this.$refs.orderPop.close()
  68. })
  69. },
  70. setData(data) {
  71. this.orderData.page = 1;
  72. this.orderData.loading = false;
  73. this.orderData.isDone = false;
  74. this.orderList = [];
  75. app.orderId = data.order;
  76. app.goodsNum = data.num;
  77. this.getOrder();
  78. },
  79. sendGoods(){
  80. var checkedItems = this.orderList.filter(item => item.check === true);
  81. if (checkedItems.length == 0) return this.$dialog.showSuccess("请至少选择一个")
  82. var total = checkedItems.reduce((sum, item) => sum + item.number, 0);
  83. if (total < app.goodsNum) return this.$dialog.showSuccess("请选择"+app.goodsNum+"份")
  84. if (total > app.goodsNum) return this.$dialog.showSuccess("最多只能选择"+app.goodsNum+"份")
  85. this.$refs.orderPop.close()
  86. this.$emit("send",checkedItems)
  87. },
  88. sendOrder(data){
  89. this.$refs.orderPop.close()
  90. this.$emit("send",data)
  91. },
  92. scrolltoupper(){},
  93. scrolltolower(e){
  94. if (this.orderData.isDone || this.orderList.length == 0) return ;
  95. this.getOrder()
  96. },
  97. async getOrder(){
  98. this.orderData.loading = true;
  99. var formData = {};
  100. formData.order = app.orderId;
  101. formData.page = this.orderData.page;
  102. formData.size = this.orderData.size;
  103. // formData.status = 1;
  104. var resp = await this.$api.order.goods.get(formData)
  105. this.orderData.loading = false;
  106. if (resp.code == 0) {
  107. return this.$dialog.showSuccess(resp.msg)
  108. }
  109. if (resp.data.data.length > 0) {
  110. this.orderData.page ++;
  111. this.orderList = [...this.orderList,...resp.data.data];
  112. } else {
  113. this.orderData.isDone = true;
  114. }
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .order-popup .order-title{display: flex;align-items: center;justify-content: space-between;font-size: 32upx;padding: 20upx;font-weight: bold;}
  121. .order-popup .input-value-border{border: 0;}
  122. .order-popup .order-title.bb1{border-bottom: 2upx solid #efefef;}
  123. .order-popup .order-title image{width: 40upx;height: 40upx;}
  124. .order-popup .order-body{
  125. height: 50vh;overflow: auto;background-color: #fff;border-radius: 20rpx;
  126. }
  127. .order-popup.address .order-body{height: 60vh;overflow: auto;padding: 20upx;}
  128. .order-body-con{margin: 20rpx;}
  129. .view-more{text-align: center;font-size: 24upx;color: #666;padding: 20upx;}
  130. .order-popup .u-input {height: 60upx;}
  131. .order-popup .submit-btn{
  132. border-top: 2upx solid #efefef;
  133. border-radius: 0;
  134. }
  135. .address-footer{
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-around;
  139. gap: 20rpx;
  140. padding: 0 20rpx 20rpx;
  141. .footer-btn{
  142. background-color: #fff;
  143. border: 2rpx solid $main-text-color;
  144. border-radius: 10rpx;
  145. color: $main-text-color;
  146. height: 80rpx;
  147. line-height: 80rpx;
  148. text-align: center;
  149. flex: 1;
  150. &.full{
  151. border: 2rpx solid $main-color;
  152. background-color: $main-color;
  153. color: #fff;
  154. }
  155. }
  156. }
  157. .m-order-s{border-bottom:2rpx solid #f1f1f1;border-radius: 10upx;display: flex;font-size: 28upx;position: relative;padding: 20upx;}
  158. .m-order-s .order-img {display: flex;align-items: center;justify-content: center;}
  159. .m-order-s .order-img image{width: 150upx;height: 150upx;}
  160. .m-order-s .order-info {padding: 15upx;flex:1;overflow: hidden;}
  161. .m-order-s .order-info .title{font-size: 28upx;overflow: hidden;text-overflow: ellipsis;-webkit-line-clamp: 2;display: -webkit-box;-webkit-box-orient: vertical;}
  162. .m-order-s .order-info .desc{font-size: 24upx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;color: #999;margin-top: 10rpx;}
  163. .m-order-s .order-info .price{font-size: 28upx;color: #f00;}
  164. .m-order-s .status-btn-group{position: absolute;right: 10rpx;bottom: 10rpx;display: flex;align-items: center;gap: 15upx;}
  165. .m-order-s .status{border-radius: 10upx 0 10upx 0;background-color: #909399;font-size: 24upx;color: #fff;padding: 10upx;}
  166. .m-order-s .status.info{background-color: #909399;}
  167. .m-order-s .status.primary{background-color: #409eff;}
  168. .m-order-s .status.success{background-color: #67c23a;}
  169. .m-order-s .status.danger{background-color: #f56c6c;}
  170. .m-order-s .status.warn{background-color: #e6a23c;}
  171. .empty-body{display: flex;align-items: center;justify-content: center;height: 100%;}
  172. </style>