index.vue 7.8 KB

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