index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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)
  84. console.log(res.data)
  85. this.datalist = res.data.data
  86. this.Arry.length = this.datalist.length
  87. for(var i=0;i<this.datalist.length;i++){
  88. this.Arry[i] = []
  89. this.checkboxList[i] = false
  90. }
  91. console.log(this.checkboxList)
  92. console.log(res.data.data[0].storegentBrandList)
  93. // 遍历
  94. if (this.choice == 0) {
  95. for (var l = 0; l < res.data.data.length; l++) {
  96. this.storegentBrandList = res.data.data[l].storegentBrandList
  97. for (var i = 0; i < res.data.data[l].storegentBrandList.length; i++) {
  98. // this.checkboxList[i] = false
  99. }
  100. }
  101. } else {
  102. for (var l = 0; l < res.data.data.length; l++) {
  103. this.storegentBrandList = res.data.data[l].storegentBrandList
  104. for (var i = 0; i < res.data.data[l].storegentBrandList.length; i++) {
  105. // this.checkboxList[i] = true
  106. }
  107. }
  108. }
  109. }).catch(err => {
  110. console.log(err + "")
  111. })
  112. .finally(() => {
  113. setTimeout(() => {
  114. uni.hideLoading();
  115. this.loading = false;
  116. }, 1000)
  117. })
  118. },
  119. checkboxChange1() {
  120. },
  121. // 选中某个复选框时,由checkbox时触发
  122. // ,bollean,index
  123. checkboxChange(e,index,dataArr){
  124. console.log(e)
  125. let newArr = []
  126. console.log(this.Arry)
  127. e.detail.value.forEach((item) =>{
  128. var obj = {
  129. "storeId":this.$store.state.storeInfo.storeId,
  130. "amount": JSON.parse(item).usableMoney,
  131. "brandCode": JSON.parse(item).brandCode,
  132. "kunnr": JSON.parse(item).kunnr,
  133. 'userId':this.$store.state.storeInfo.userId
  134. }
  135. console.log(obj)
  136. newArr.push(obj)
  137. })
  138. this.Arry[index] = newArr
  139. if(this.Arry[index].length == dataArr.filter((item)=>{
  140. return item.usableMoney != 0
  141. }).length ){
  142. this.$set(this.checkboxList, index, true);
  143. }else{
  144. this.$set(this.checkboxList, index, false);
  145. }
  146. },
  147. // 核销返利
  148. button(index) {
  149. console.log(index)
  150. console.log(this.Arry[index])
  151. request({
  152. url: '/myapp/storeCancel',
  153. method: 'post',
  154. data: this.Arry[index]
  155. }).then(res => {
  156. console.log(res)
  157. if(res.data.msg=="success") {
  158. uni.showToast({
  159. title: '核销返利成功',
  160. duration: 2000
  161. });
  162. this.getData()
  163. }else {
  164. uni.showToast({
  165. title: '核销返利失败',
  166. icon: false,
  167. duration: 2000
  168. });
  169. }
  170. }).catch(err => {
  171. console.log(err)
  172. })
  173. .finally(() => {
  174. setTimeout(() => {
  175. uni.hideLoading();
  176. this.loading = false;
  177. }, 1000)
  178. })
  179. },
  180. // 选中任一checkbox时,由checkbox-group触发
  181. checkboxGroupChange(e) {
  182. // console.log(e);
  183. // console.log("###");
  184. },
  185. // 全选
  186. checkedAll(index,e) {
  187. console.log(e)
  188. // this.isCheckedAll = !this.isCheckedAll
  189. // this.Arry[index] = []
  190. console.log(index,e)
  191. let newArr=[]
  192. // this.isCheckedAll = !this.isCheckedAll
  193. if(this.Arry[index].length == e.storegentBrandList.filter((item)=>{
  194. return item.usableMoney != 0
  195. }).length ){
  196. this.$set(this.checkboxList, index, false);
  197. this.Arry[index] = []
  198. }else{
  199. this.$set(this.checkboxList, index, true);
  200. for(var i=0;i<e.storegentBrandList.length;i++){
  201. if( e.storegentBrandList[i].usableMoney !=0){
  202. var obj = {
  203. "storeId": this.$store.state.storeInfo.storeId,
  204. "amount": e.storegentBrandList[i].usableMoney,
  205. "brandCode": e.storegentBrandList[i].brandCode,
  206. "kunnr": e.storegentBrandList[i].agentId
  207. }
  208. newArr.push(obj)
  209. }
  210. }
  211. this.Arry[index] = newArr
  212. }
  213. console.log(this.Arry,this.checkboxList)
  214. }
  215. },
  216. }
  217. </script>
  218. <style>
  219. .top {
  220. width: 750rpx;
  221. height: 331rpx;
  222. background: url(../../../static/sailun/background.png) no-repeat;
  223. background-size: 750rpx 331rpx;
  224. }
  225. .content {
  226. width: 712rpx;
  227. /* height: 445rpx; */
  228. margin: 0 auto;
  229. margin-bottom: 30rpx;
  230. background: #FFFFFF;
  231. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  232. border-radius: 18px;
  233. position: relative;
  234. top: 30rpx;
  235. margin-bottom: 50rpx;
  236. }
  237. .content2 {
  238. width: 712rpx;
  239. height: 351rpx;
  240. margin: 0 auto;
  241. background: #FFFFFF;
  242. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  243. border-radius: 18px;
  244. position: relative;
  245. top: 170rpx;
  246. }
  247. .content-one {
  248. width: 6rpx;
  249. height: 30rpx;
  250. background-color: #0589F8;
  251. position: relative;
  252. top: 20rpx;
  253. left: 30rpx;
  254. }
  255. .content-two {
  256. font: 26rpx;
  257. font-weight: bolder;
  258. position: relative;
  259. top: -14rpx;
  260. left: 60rpx;
  261. }
  262. .content-three {
  263. width: 114rpx;
  264. height: 40rpx;
  265. display: inline-block;
  266. background-color: #3A9FF2;
  267. margin-top: -20rpx;
  268. margin-right: 20rpx;
  269. border-radius: 10rpx;
  270. font-size: 24rpx;
  271. color: #fff;
  272. text-align: center;
  273. line-height: 40rpx;
  274. }
  275. .content-four {
  276. display: flex;
  277. justify-content: space-between;
  278. font-weight: bolder;
  279. font-size: 26rpx;
  280. margin-top: 40rpx;
  281. margin-left: 80rpx;
  282. margin-right: 50rpx;
  283. }
  284. .content-five {
  285. display: flex;
  286. justify-content: space-between;
  287. font-size: 24rpx;
  288. margin-top: 40rpx;
  289. margin-left: 100rpx;
  290. font-weight: bolder;
  291. margin-right: 30rpx;
  292. padding-bottom: 20rpx;
  293. }
  294. .content-five-img {
  295. width: 164rpx;
  296. height: 50rpx;
  297. margin-left: -50rpx;
  298. }
  299. .content-five-view {
  300. margin-left: -150rpx;
  301. }
  302. </style>