index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. .splitOrder {
  128. width: 710rpx;
  129. background-color: #fff;
  130. border-radius: 16rpx;
  131. margin: 24rpx auto 0 auto;
  132. padding: 32rpx 26rpx;
  133. }
  134. .splitOrder .all {
  135. padding: 20rpx 30rpx;
  136. }
  137. .splitOrder .all .checkAll {
  138. margin-left: 20rpx;
  139. }
  140. .splitOrder .items~.items {
  141. margin-top: 48rpx;
  142. }
  143. .splitOrder .items .picTxt {
  144. width: 604rpx;
  145. position: relative;
  146. }
  147. .splitOrder .items .picTxt .name {
  148. width: 444rpx;
  149. }
  150. .splitOrder .items .picTxt .pictrue {
  151. width: 136rpx;
  152. height: 136rpx;
  153. }
  154. .splitOrder .items .picTxt .pictrue image {
  155. width: 100%;
  156. height: 100%;
  157. border-radius: 16rpx;
  158. }
  159. .splitOrder .items .picTxt .text {
  160. width: 450rpx;
  161. font-size: 28rpx;
  162. color: #333;
  163. font-weight: 400;
  164. }
  165. .splitOrder .items .picTxt .text .reColor {
  166. color: #999;
  167. }
  168. .splitOrder .items .picTxt .text .reElection {
  169. margin-top: 20rpx;
  170. }
  171. .splitOrder .items .picTxt .text .reElection .title {
  172. font-size: 24rpx;
  173. }
  174. .splitOrder .items .picTxt .text .reElection .reBnt {
  175. width: 120rpx;
  176. height: 46rpx;
  177. border-radius: 23rpx;
  178. font-size: 26rpx;
  179. }
  180. .splitOrder .items .picTxt .text .infor {
  181. font-size: 22rpx;
  182. color: #999;
  183. margin-top: 12rpx;
  184. width: 284rpx;
  185. }
  186. .splitOrder .items .picTxt .text .money-section {
  187. margin-top: 18rpx;
  188. font-size: 22rpx;
  189. color: #999999;
  190. }
  191. .splitOrder .items .picTxt .text .money {
  192. font-size: 36rpx;
  193. color: #333;
  194. font-family: 'Regular';
  195. color: #FF7D00;
  196. }
  197. .splitOrder .items .picTxt .carnum {
  198. height: 36rpx;
  199. position: absolute;
  200. bottom: 0;
  201. right: 0;
  202. }
  203. .splitOrder .items .picTxt .carnum view {
  204. width: 66rpx;
  205. text-align: center;
  206. height: 100%;
  207. line-height: 36rpx;
  208. font-size: 24rpx;
  209. color: #333;
  210. }
  211. .splitOrder .items .picTxt .carnum .reduce {
  212. border-right: 0;
  213. border-radius: 3rpx 0 0 3rpx;
  214. }
  215. .splitOrder .items .picTxt .carnum .reduce.on {
  216. border-color: #e3e3e3;
  217. color: #dedede;
  218. }
  219. .splitOrder .items .picTxt .carnum .plus {
  220. border-left: 0;
  221. border-radius: 0 3rpx 3rpx 0;
  222. font-size: 26rpx;
  223. }
  224. .splitOrder .items .picTxt .carnum .plus.on {
  225. border-color: #e3e3e3;
  226. color: #dedede;
  227. }
  228. .splitOrder .items .picTxt .carnum .num {
  229. color: #282828;
  230. background: #F5F5F5;
  231. width: 72rpx;
  232. }
  233. </style>