index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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="acea-row row-middle money-section">
  31. 实付款:<view class='money'>¥{{item.cart_info.sum_true_price}}</view>
  32. </view>
  33. </view>
  34. <view class='carnum acea-row row-center-wrapper'>
  35. <view class="reduce iconfont icon-ic_Reduce" :class="item.surplus_num == 1 ? 'on' : ''" @click.stop='subCart(item)'></view>
  36. <view class='num'>{{item.surplus_num}}</view>
  37. <view class="plus iconfont icon-ic_increase" :class="item.surplus_num == item.numShow ? 'on' : ''" @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. /deep/checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  128. border: 1px solid #2A7EFB !important;
  129. background-color: #2A7EFB !important;
  130. color: #fff !important;
  131. }
  132. /deep/checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  133. border: 1px solid #2A7EFB !important;
  134. background-color: #2A7EFB !important;
  135. color: #fff !important;
  136. }
  137. .splitOrder {
  138. width: 710rpx;
  139. background-color: #fff;
  140. border-radius: 16rpx;
  141. margin: 24rpx auto 0 auto;
  142. padding: 32rpx 26rpx;
  143. }
  144. .splitOrder .all {
  145. padding: 20rpx 30rpx;
  146. }
  147. .splitOrder .all .checkAll {
  148. margin-left: 20rpx;
  149. }
  150. .splitOrder .items~.items {
  151. margin-top: 48rpx;
  152. }
  153. .splitOrder .items .picTxt {
  154. width: 604rpx;
  155. position: relative;
  156. }
  157. .splitOrder .items .picTxt .name {
  158. width: 444rpx;
  159. }
  160. .splitOrder .items .picTxt .pictrue {
  161. width: 136rpx;
  162. height: 136rpx;
  163. }
  164. .splitOrder .items .picTxt .pictrue image {
  165. width: 100%;
  166. height: 100%;
  167. border-radius: 16rpx;
  168. }
  169. .splitOrder .items .picTxt .text {
  170. width: 450rpx;
  171. font-size: 28rpx;
  172. color: #333;
  173. font-weight: 400;
  174. }
  175. .splitOrder .items .picTxt .text .reColor {
  176. color: #999;
  177. }
  178. .splitOrder .items .picTxt .text .reElection {
  179. margin-top: 20rpx;
  180. }
  181. .splitOrder .items .picTxt .text .reElection .title {
  182. font-size: 24rpx;
  183. }
  184. .splitOrder .items .picTxt .text .reElection .reBnt {
  185. width: 120rpx;
  186. height: 46rpx;
  187. border-radius: 23rpx;
  188. font-size: 26rpx;
  189. }
  190. .splitOrder .items .picTxt .text .infor {
  191. font-size: 22rpx;
  192. color: #999;
  193. margin-top: 12rpx;
  194. width: 284rpx;
  195. }
  196. .splitOrder .items .picTxt .text .money-section {
  197. margin-top: 18rpx;
  198. font-size: 22rpx;
  199. color: #999999;
  200. }
  201. .splitOrder .items .picTxt .text .money {
  202. font-size: 36rpx;
  203. color: #333;
  204. font-family: 'Regular';
  205. color: #FF7D00;
  206. }
  207. .splitOrder .items .picTxt .carnum {
  208. height: 36rpx;
  209. position: absolute;
  210. bottom: 0;
  211. right: 0;
  212. }
  213. .splitOrder .items .picTxt .carnum view {
  214. width: 66rpx;
  215. text-align: center;
  216. height: 100%;
  217. line-height: 36rpx;
  218. font-size: 24rpx;
  219. color: #333;
  220. }
  221. .splitOrder .items .picTxt .carnum .reduce {
  222. border-right: 0;
  223. border-radius: 3rpx 0 0 3rpx;
  224. }
  225. .splitOrder .items .picTxt .carnum .reduce.on {
  226. border-color: #e3e3e3;
  227. color: #dedede;
  228. }
  229. .splitOrder .items .picTxt .carnum .plus {
  230. border-left: 0;
  231. border-radius: 0 3rpx 3rpx 0;
  232. font-size: 26rpx;
  233. }
  234. .splitOrder .items .picTxt .carnum .plus.on {
  235. border-color: #e3e3e3;
  236. color: #dedede;
  237. }
  238. .splitOrder .items .picTxt .carnum .num {
  239. color: #282828;
  240. background: #F5F5F5;
  241. width: 72rpx;
  242. }
  243. </style>