index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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' v-if="item.surplus_num>0">
  13. <!-- #ifndef MP -->
  14. <checkbox :value="(item.id).toString()" :checked="item.checked" :disabled="(type!=1&&item.surplus_num<1)?true:false" />
  15. <!-- #endif -->
  16. <!-- #ifdef MP -->
  17. <checkbox :value="item.id" :checked="item.checked" :disabled="(type!=1&&item.surplus_num<1)?true:false" />
  18. <!-- #endif -->
  19. <view class='picTxt acea-row row-between-wrapper'>
  20. <view class='pictrue'>
  21. <image :src='item.image'></image>
  22. </view>
  23. <view class='text'>
  24. <view class="acea-row row-between-wrapper">
  25. <view class='name line1'>{{item.productName}}</view>
  26. <!-- <view>×{{item.cart_num}}</view> -->
  27. </view>
  28. <view class='infor line1'>
  29. {{item.sku || '默认'}}</view>
  30. <view class="acea-row row-middle money-section">
  31. <text class="infor-num">购买 x{{item.payNum}}</text>
  32. <text class="infor-text" v-if="type==1">{{`(${item.refundNum}件已退 ${item.payNum-item.refundNum}件可退)`}}</text>
  33. <text class="infor-text" v-if="type==0">{{ `(${item.deliveryNum}件已发 ${item.refundNum}件已退)`}}</text>
  34. </view>
  35. </view>
  36. <view class='carnum acea-row row-center-wrapper'>
  37. <view class="reduce iconfont icon-shangpinshuliang-jian" :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-shangpinshuliang-jia" :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. //0-分单发货 1-分单付款
  59. type:{
  60. default:'0'
  61. }
  62. },
  63. data() {
  64. return {
  65. isAllSelect: false
  66. };
  67. },
  68. methods: {
  69. subCart(item) {
  70. item.surplus_num = item.surplus_num - 1;
  71. if (item.surplus_num <= 1) {
  72. item.surplus_num = 1
  73. }
  74. this.$emit('getList', this.splitGoods);
  75. },
  76. addCart(item) {
  77. item.surplus_num = item.surplus_num + 1;
  78. if (item.surplus_num >= item.numShow) {
  79. item.surplus_num = item.numShow
  80. }
  81. this.$emit('getList', this.splitGoods);
  82. },
  83. inArray: function(search, array) {
  84. for (let i in array) {
  85. if (array[i] == search) {
  86. return true;
  87. }
  88. }
  89. return false;
  90. },
  91. checkboxChange(event) {
  92. let idList = event.detail.value;
  93. this.splitGoods.forEach((item) => {
  94. if (this.inArray(item.id, idList)) {
  95. item.checked = true;
  96. } else {
  97. item.checked = false;
  98. }
  99. })
  100. this.$emit('getList', this.splitGoods);
  101. if (idList.length == this.splitGoods.length) {
  102. this.isAllSelect = true;
  103. } else {
  104. this.isAllSelect = false;
  105. }
  106. },
  107. forGoods(val) {
  108. let that = this;
  109. if (!that.splitGoods.length) return
  110. that.splitGoods.forEach((item) => {
  111. if (val) {
  112. item.checked = true;
  113. } else {
  114. item.checked = false;
  115. }
  116. })
  117. that.$emit('getList', that.splitGoods);
  118. },
  119. checkboxAllChange(event) {
  120. let value = event.detail.value;
  121. if (value.length) {
  122. this.forGoods(1)
  123. } else {
  124. this.forGoods(0)
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. /deep/checkbox .uni-checkbox-input.uni-checkbox-input-checked {
  132. border: 1px solid #007aff !important;
  133. background-color: #007aff !important;
  134. color: #fff !important;
  135. }
  136. .splitOrder {
  137. width: 710rpx;
  138. background-color: #fff;
  139. border-radius: 16rpx;
  140. margin: 24rpx auto 0 auto;
  141. padding: 32rpx 26rpx;
  142. }
  143. .splitOrder .all {
  144. padding: 20rpx 30rpx;
  145. }
  146. .splitOrder .all .checkAll {
  147. margin-left: 20rpx;
  148. }
  149. .splitOrder .items~.items {
  150. margin-top: 48rpx;
  151. }
  152. .splitOrder .items .picTxt {
  153. width: 604rpx;
  154. position: relative;
  155. }
  156. .splitOrder .items .picTxt .name {
  157. width: 444rpx;
  158. }
  159. .splitOrder .items .picTxt .pictrue {
  160. width: 136rpx;
  161. height: 136rpx;
  162. }
  163. .splitOrder .items .picTxt .pictrue image {
  164. width: 100%;
  165. height: 100%;
  166. border-radius: 16rpx;
  167. }
  168. .splitOrder .items .picTxt .text {
  169. width: 450rpx;
  170. font-size: 28rpx;
  171. color: #333;
  172. font-weight: 400;
  173. }
  174. .splitOrder .items .picTxt .text .reColor {
  175. color: #999;
  176. }
  177. .splitOrder .items .picTxt .text .reElection {
  178. margin-top: 20rpx;
  179. }
  180. .splitOrder .items .picTxt .text .reElection .title {
  181. font-size: 24rpx;
  182. }
  183. .splitOrder .items .picTxt .text .reElection .reBnt {
  184. width: 120rpx;
  185. height: 46rpx;
  186. border-radius: 23rpx;
  187. font-size: 26rpx;
  188. }
  189. .splitOrder .items .picTxt .text .infor {
  190. font-size: 22rpx;
  191. color: #999;
  192. margin-top: 12rpx;
  193. width: 284rpx;
  194. }
  195. .splitOrder .items .picTxt .text .money-section {
  196. margin-top: 18rpx;
  197. font-size: 22rpx;
  198. color: #999999;
  199. }
  200. .splitOrder .items .picTxt .text .money {
  201. font-size: 36rpx;
  202. color: #333;
  203. font-family: 'Regular';
  204. color: #FF7D00;
  205. }
  206. .splitOrder .items .picTxt .carnum {
  207. height: 36rpx;
  208. position: absolute;
  209. bottom: 0;
  210. right: 0;
  211. }
  212. .splitOrder .items .picTxt .carnum view {
  213. width: 66rpx;
  214. text-align: center;
  215. height: 100%;
  216. line-height: 36rpx;
  217. font-size: 24rpx;
  218. color: #333;
  219. }
  220. .splitOrder .items .picTxt .carnum .reduce {
  221. border-right: 0;
  222. border-radius: 3rpx 0 0 3rpx;
  223. }
  224. .splitOrder .items .picTxt .carnum .reduce.on {
  225. border-color: #e3e3e3;
  226. color: #dedede;
  227. }
  228. .splitOrder .items .picTxt .carnum .plus {
  229. border-left: 0;
  230. border-radius: 0 3rpx 3rpx 0;
  231. font-size: 26rpx;
  232. }
  233. .splitOrder .items .picTxt .carnum .plus.on {
  234. border-color: #e3e3e3;
  235. color: #dedede;
  236. }
  237. .splitOrder .items .picTxt .carnum .num {
  238. color: #282828;
  239. background: #F5F5F5;
  240. width: 72rpx;
  241. }
  242. .infor-num{
  243. font-size: 22rpx;
  244. color: #333333;
  245. }
  246. .infor-text{
  247. font-size: 22rpx;
  248. color: #2A7EFB;
  249. }
  250. </style>