index.vue 7.4 KB

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