index.vue 5.9 KB

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