index.vue 5.2 KB

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