index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <!-- 拆单订单 -->
  3. <view class='splitOrder' v-if="splitGoods.length">
  4. <view class="all" v-if="select_all">
  5. <checkbox-group @change="checkboxAllChange">
  6. <checkbox value="all" :checked="isAllSelect" />
  7. <text class='checkAll'>全选</text>
  8. </checkbox-group>
  9. </view>
  10. <checkbox-group @change="checkboxChange">
  11. <block v-for="(item,index) in splitGoods" :key="index">
  12. <view class='items acea-row row-between-wrapper'>
  13. <!-- #ifndef MP -->
  14. <checkbox :value="(item.id).toString()" :checked="item.checked" />
  15. <!-- #endif -->
  16. <!-- #ifdef MP -->
  17. <checkbox :value="item.id" :checked="item.checked"/>
  18. <!-- #endif -->
  19. <view class='picTxt acea-row row-between-wrapper'>
  20. <view class='pictrue'>
  21. <image :src='item.cart_info.productInfo.image'></image>
  22. </view>
  23. <view class='text'>
  24. <view class="acea-row row-between-wrapper">
  25. <view class='name line1'>{{item.cart_info.productInfo.store_name}}</view>
  26. <view>×{{item.cart_num}}</view>
  27. </view>
  28. <view class='infor line1'>
  29. 属性:{{item.cart_info.productInfo.attrInfo.suk || '默认'}}</view>
  30. <view class='money'>¥{{item.cart_info.truePrice}}</view>
  31. </view>
  32. <view class='carnum acea-row row-center-wrapper'>
  33. <view class="reduce" :class="item.surplus_num == 1 ? 'on' : ''"
  34. @click.stop='subCart(item)'>-</view>
  35. <view class='num'>{{item.surplus_num}}</view>
  36. <view class="plus" :class="item.surplus_num == item.numShow ? 'on' : ''"
  37. @click.stop='addCart(item)'>+</view>
  38. </view>
  39. </view>
  40. </view>
  41. </block>
  42. </checkbox-group>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. props:{
  48. splitGoods: {
  49. type: Array,
  50. default: () => []
  51. },
  52. select_all: {
  53. type: Boolean,
  54. default: true
  55. }
  56. },
  57. data() {
  58. return {
  59. isAllSelect:false
  60. };
  61. },
  62. mounted(){
  63. },
  64. methods: {
  65. subCart(item){
  66. item.surplus_num = Number(item.surplus_num) - 1;
  67. if(item.surplus_num<=1){
  68. item.surplus_num = 1
  69. }
  70. this.$emit('getList',this.splitGoods);
  71. },
  72. addCart(item){
  73. item.surplus_num = Number(item.surplus_num) + 1;
  74. if(item.surplus_num>=item.numShow){
  75. item.surplus_num = item.numShow
  76. }
  77. this.$emit('getList',this.splitGoods);
  78. },
  79. inArray: function(search, array) {
  80. for (let i in array) {
  81. if (array[i] == search) {
  82. return true;
  83. }
  84. }
  85. return false;
  86. },
  87. checkboxChange(event){
  88. let idList = event.detail.value;
  89. this.splitGoods.forEach((item)=>{
  90. if(this.inArray(item.id, idList)){
  91. item.checked = true;
  92. }else{
  93. item.checked = false;
  94. }
  95. })
  96. this.$emit('getList',this.splitGoods);
  97. if(idList.length == this.splitGoods.length){
  98. this.isAllSelect = true;
  99. }else{
  100. this.isAllSelect = false;
  101. }
  102. },
  103. forGoods(val){
  104. let that = this;
  105. if(!that.splitGoods.length) return
  106. that.splitGoods.forEach((item)=>{
  107. if(val){
  108. item.checked = true;
  109. }else{
  110. item.checked = false;
  111. }
  112. })
  113. that.$emit('getList',that.splitGoods);
  114. },
  115. checkboxAllChange(event){
  116. let value = event.detail.value;
  117. if(value.length){
  118. this.forGoods(1)
  119. }else{
  120. this.forGoods(0)
  121. }
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss">
  127. .splitOrder {
  128. border-bottom: 1px solid #f0f0f0;
  129. }
  130. .splitOrder .all{
  131. padding: 20rpx 30rpx;
  132. }
  133. .splitOrder .all .checkAll{
  134. margin-left: 20rpx;
  135. }
  136. .splitOrder .items {
  137. padding: 25rpx 30rpx;
  138. background-color: #fff;
  139. margin-bottom: 15rpx;
  140. }
  141. .splitOrder .items .picTxt {
  142. width: 627rpx;
  143. position: relative;
  144. }
  145. .splitOrder .items .picTxt .name{
  146. width: 360rpx;
  147. }
  148. .splitOrder .items .picTxt .pictrue {
  149. width: 160rpx;
  150. height: 160rpx;
  151. }
  152. .splitOrder .items .picTxt .pictrue image {
  153. width: 100%;
  154. height: 100%;
  155. border-radius: 6rpx;
  156. }
  157. .splitOrder .items .picTxt .text {
  158. width: 444rpx;
  159. font-size: 28rpx;
  160. color: #282828;
  161. }
  162. .splitOrder .items .picTxt .text .reColor {
  163. color: #999;
  164. }
  165. .splitOrder .items .picTxt .text .reElection {
  166. margin-top: 20rpx;
  167. }
  168. .splitOrder .items .picTxt .text .reElection .title {
  169. font-size: 24rpx;
  170. }
  171. .splitOrder .items .picTxt .text .reElection .reBnt {
  172. width: 120rpx;
  173. height: 46rpx;
  174. border-radius: 23rpx;
  175. font-size: 26rpx;
  176. }
  177. .splitOrder .items .picTxt .text .infor {
  178. font-size: 24rpx;
  179. color: #868686;
  180. margin-top: 16rpx;
  181. }
  182. .splitOrder .items .picTxt .text .money {
  183. font-size: 32rpx;
  184. color: #282828;
  185. margin-top: 28rpx;
  186. }
  187. .splitOrder .items .picTxt .carnum {
  188. height: 47rpx;
  189. position: absolute;
  190. bottom: 7rpx;
  191. right: 0;
  192. }
  193. .splitOrder .items .picTxt .carnum view {
  194. border: 1rpx solid #a4a4a4;
  195. width: 66rpx;
  196. text-align: center;
  197. height: 100%;
  198. line-height: 40rpx;
  199. font-size: 28rpx;
  200. color: #a4a4a4;
  201. }
  202. .splitOrder .items .picTxt .carnum .reduce {
  203. border-right: 0;
  204. border-radius: 3rpx 0 0 3rpx;
  205. }
  206. .splitOrder .items .picTxt .carnum .reduce.on {
  207. border-color: #e3e3e3;
  208. color: #dedede;
  209. }
  210. .splitOrder .items .picTxt .carnum .plus {
  211. border-left: 0;
  212. border-radius: 0 3rpx 3rpx 0;
  213. }
  214. .splitOrder .items .picTxt .carnum .plus.on {
  215. border-color: #e3e3e3;
  216. color: #dedede;
  217. }
  218. .splitOrder .items .picTxt .carnum .num {
  219. color: #282828;
  220. }
  221. </style>