index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <!-- 结算中心页面 -->
  3. <view>
  4. <view class="top">
  5. <view class="content" v-for="(item,index) in datalist" :key="index">
  6. <view class="content-one">
  7. </view>
  8. <view style="display: flex;justify-content: space-between;">
  9. <text class="content-two">{{item.agentName}}</text>
  10. <text class="content-three" @click="button(index)">核销返利</text>
  11. </view>
  12. <view class="content-four">
  13. <text>品牌</text>
  14. <text>奖励</text>
  15. <text @click="checkedAll(index,item)" :key='index'>全选</text>
  16. </view>
  17. <checkbox-group @change="checkboxChange($event,index,item.storegentBrandList)">
  18. <view class="content-five" v-for="(item,brandIndex) in item.storegentBrandList" :key="brandIndex">
  19. <view class="content-five-img">
  20. <u-image width="100%" height="65%" scaleType="matrix" :src="item.logoUrl"></u-image>
  21. </view>
  22. <view class="content-five-view">
  23. {{item.usableMoney}}元
  24. </view>
  25. <view>
  26. <label>
  27. <checkbox v-model="JSON.stringify(item)" :value="JSON.stringify(item)" :checked="checkboxList[index]" :disabled="item.usableMoney==0" v-if="item.usableMoney!=0" color="#FFCC33" style="transform:scale(0.7)"/>
  28. </label>
  29. </view>
  30. </view>
  31. </checkbox-group>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. request
  39. } from '../../../common/request/request'
  40. require("promise.prototype.finally").shim()
  41. export default {
  42. data() {
  43. return {
  44. datalist: [],
  45. agentId: '',
  46. Arry: [],
  47. brandCodeCheckList:[],
  48. amount: '',
  49. choice: 0,
  50. kunnr: '',
  51. brandCode: '',
  52. agentOpDate: '',
  53. src: 'https://b2bcnfile.sailuntire.com/upload//sailun-allsteel-admin/2020110616154607343814..jpg',
  54. storegentBrandList: [],
  55. checked: true,
  56. list: [{}],
  57. checkboxList: [],
  58. idList:[],
  59. listaa:['a','b','c'],
  60. checkedAllList:[],
  61. // isCheckedAll:false
  62. };
  63. },
  64. created() {
  65. this.getData()
  66. },
  67. computed:{
  68. ckeck(){
  69. return this.checkboxList
  70. }
  71. },
  72. methods: {
  73. // 获取结算中心数据
  74. getData() {
  75. request({
  76. url: '/myapp/storeSettlementCenter',
  77. method: 'post',
  78. data: {
  79. 'storeId':this.$store.state.storeInfo.storeId,
  80. 'userId':this.$store.state.storeInfo.userId
  81. }
  82. }).then(res => {
  83. console.log(res.data)
  84. this.datalist = res.data.data
  85. this.Arry.length = this.datalist.length
  86. // 每个新建数组长度为空,全选为false
  87. for(var i=0;i<this.datalist.length;i++){
  88. this.Arry[i] = []
  89. this.checkboxList[i] = false
  90. }
  91. }).catch(err => {
  92. console.log(err + "")
  93. })
  94. .finally(() => {
  95. setTimeout(() => {
  96. uni.hideLoading();
  97. this.loading = false;
  98. }, 1000)
  99. })
  100. },
  101. checkboxChange1() {
  102. },
  103. // 选中某个复选框时,由checkbox时触发
  104. // ,bollean,index
  105. checkboxChange(e,index,dataArr){
  106. console.log(index)
  107. console.log(e)
  108. let newArr = []
  109. console.log(this.Arry)
  110. e.detail.value.forEach((item) =>{
  111. var obj = {
  112. "storeId":this.$store.state.storeInfo.storeId,
  113. "amount": JSON.parse(item).usableMoney,
  114. "brandCode": JSON.parse(item).brandCode,
  115. "kunnr": JSON.parse(item).kunnr,
  116. 'userId':this.$store.state.storeInfo.userId
  117. }
  118. console.log(obj)
  119. newArr.push(obj)
  120. })
  121. this.Arry[index] = newArr
  122. console.log(newArr)
  123. if(this.Arry[index].length == dataArr.filter((item)=>{
  124. return item.usableMoney != 0
  125. }).length ){
  126. this.$set(this.checkboxList, index, true);
  127. }else{
  128. this.$set(this.checkboxList, index, false);
  129. }
  130. },
  131. // 核销返利
  132. button(index) {
  133. console.log(index)
  134. console.log(this.Arry[index])
  135. request({
  136. url: '/myapp/storeCancel',
  137. method: 'post',
  138. data: this.Arry[index]
  139. }).then(res => {
  140. console.log(res)
  141. if(res.data.msg=="success") {
  142. uni.showToast({
  143. title: '核销返利成功',
  144. duration: 2000
  145. });
  146. this.getData()
  147. }else {
  148. uni.showToast({
  149. title: '核销返利失败',
  150. icon: false,
  151. duration: 2000
  152. });
  153. }
  154. }).catch(err => {
  155. console.log(err)
  156. })
  157. .finally(() => {
  158. setTimeout(() => {
  159. uni.hideLoading();
  160. this.loading = false;
  161. }, 1000)
  162. })
  163. },
  164. // 选中任一checkbox时,由checkbox-group触发
  165. checkboxGroupChange(e) {
  166. },
  167. // 全选
  168. checkedAll(index,e) {
  169. console.log(index,e)
  170. let newArr=[]
  171. if(this.Arry[index].length == e.storegentBrandList.filter((item)=>{
  172. return item.usableMoney != 0
  173. }).length ){
  174. this.$set(this.checkboxList, index, false);
  175. this.Arry[index] = []
  176. }else{
  177. this.$set(this.checkboxList, index, true);
  178. for(var i=0;i<e.storegentBrandList.length;i++){
  179. if( e.storegentBrandList[i].usableMoney !=0){
  180. var obj = {
  181. "storeId": this.$store.state.storeInfo.storeId,
  182. "amount": e.storegentBrandList[i].usableMoney,
  183. "brandCode": e.storegentBrandList[i].brandCode,
  184. "kunnr": e.storegentBrandList[i].agentId
  185. }
  186. newArr.push(obj)
  187. }
  188. }
  189. this.Arry[index] = newArr
  190. }
  191. console.log(this.Arry,this.checkboxList)
  192. }
  193. },
  194. }
  195. </script>
  196. <style>
  197. .top {
  198. width: 750rpx;
  199. height: 331rpx;
  200. background: url(../../../static/sailun/background.png) no-repeat;
  201. background-size: 750rpx 331rpx;
  202. }
  203. .content {
  204. width: 712rpx;
  205. /* height: 445rpx; */
  206. margin: 0 auto;
  207. margin-bottom: 30rpx;
  208. background: #FFFFFF;
  209. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  210. border-radius: 18px;
  211. position: relative;
  212. top: 30rpx;
  213. margin-bottom: 50rpx;
  214. }
  215. .content2 {
  216. width: 712rpx;
  217. height: 351rpx;
  218. margin: 0 auto;
  219. background: #FFFFFF;
  220. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  221. border-radius: 18px;
  222. position: relative;
  223. top: 170rpx;
  224. }
  225. .content-one {
  226. width: 6rpx;
  227. height: 30rpx;
  228. background-color: #0589F8;
  229. position: relative;
  230. top: 20rpx;
  231. left: 30rpx;
  232. }
  233. .content-two {
  234. font: 26rpx;
  235. font-weight: bolder;
  236. position: relative;
  237. top: -14rpx;
  238. left: 60rpx;
  239. }
  240. .content-three {
  241. width: 114rpx;
  242. height: 40rpx;
  243. display: inline-block;
  244. background-color: #3A9FF2;
  245. margin-top: -20rpx;
  246. margin-right: 20rpx;
  247. border-radius: 10rpx;
  248. font-size: 24rpx;
  249. color: #fff;
  250. text-align: center;
  251. line-height: 40rpx;
  252. }
  253. .content-four {
  254. display: flex;
  255. justify-content: space-between;
  256. font-weight: bolder;
  257. font-size: 26rpx;
  258. margin-top: 40rpx;
  259. margin-left: 80rpx;
  260. margin-right: 50rpx;
  261. }
  262. .content-five {
  263. display: flex;
  264. justify-content: space-between;
  265. font-size: 24rpx;
  266. margin-top: 40rpx;
  267. margin-left: 100rpx;
  268. font-weight: bolder;
  269. margin-right: 30rpx;
  270. padding-bottom: 20rpx;
  271. }
  272. .content-five-img {
  273. width: 164rpx;
  274. height: 50rpx;
  275. margin-left: -50rpx;
  276. }
  277. .content-five-view {
  278. margin-left: -150rpx;
  279. }
  280. </style>