rechargeRecord.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <view>
  3. <u-navbar title="充值记录" title-color="#101010"></u-navbar>
  4. <view class="tabs-box" v-if="!popShow" >
  5. <view class="tabs1" v-show="tenantList.length>1" :style="{width: tenantList.length>4 ? '' : '100%'}" >
  6. <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  7. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs>
  8. </view>
  9. <view class="icon" @click="popShow=true" v-if="tenantList.length >= 4" >
  10. <u-icon name="arrow-down" color="#777777" size="28"></u-icon>
  11. </view>
  12. </view>
  13. <!-- 标签弹出层 -->
  14. <u-popup v-model="popShow" length="80%" @close="keyword=''" duration="10" mode="top" :negative-top="188" border-radius="32">
  15. <u-navbar title="充值记录" title-color="#101010"></u-navbar>
  16. <view class="head-head">
  17. <u-search placeholder="请输入关键字" :show-action="false" v-model="keyword"></u-search>
  18. </view>
  19. <view class="head-head-placeholder ">
  20. </view>
  21. <view class="popup-tabs" v-if="false">
  22. <view class="tabs1">
  23. <!-- <u-tabs :list="tenantList1" inactive-color="#777777" active-color="#333333 "
  24. bg-color="#fff" :is-scroll="false" :current="current" @change="change"></u-tabs> -->
  25. <u-tabs :list="tenantList1" :is-scroll="false" :current="current" @change="change"></u-tabs >
  26. </view>
  27. <view class="more">
  28. <u-icon name="arrow-up" color="#777777" size="40" @click="popShow=false"></u-icon>
  29. </view>
  30. </view>
  31. <view class="tabs-options">
  32. <view class="item" v-for="(item, index) in tenantList"
  33. v-show="keyword==''||(item.name&&item.name.indexOf(keyword)!=-1)"
  34. :class="{
  35. 'item-index' : item.id==formData.tenantId
  36. }"
  37. :key="index"
  38. @click="merchantChange(item,index)">
  39. {{item.name}}
  40. </view>
  41. <u-divider nonetext="没有找到相关内容"
  42. border-color="#CFD2D5">已经到底了</u-divider>
  43. </view>
  44. </u-popup>
  45. <!-- 折线图 -->
  46. <view class="chart-box">
  47. <view class="chart">
  48. <view id="pieEcharts" >
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 标签 -->
  53. <view class="tabs">
  54. <u-picker v-model="tabsFrom.show1" mode="selector"
  55. :default-selector="[tabsFrom.show1Index]"
  56. :range="tabsFrom.selector1" range-key="label" @confirm="selector1confirm" ></u-picker>
  57. <u-picker-select title="日期选择" v-model="tabsFrom.show2"
  58. :defaultTime="tabsFrom.show2Index" :endYear="endYear"
  59. mode="time" :params="params" @confirm="selector2confirm" @reset="selector2reset" ></u-picker-select>
  60. <view class="tabsItem" @click="tabsFrom.show1=!tabsFrom.show1">{{tabsFrom.show1Text}} <u-icon name="arrow-up"
  61. v-if="tabsFrom.show1"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  62. <view class="tabsItem" @click="tabsFrom.show2=!tabsFrom.show2">{{tabsFrom.show2Text}} <u-icon name="arrow-up"
  63. v-if="tabsFrom.show2"></u-icon><u-icon v-else name="arrow-down"></u-icon></view>
  64. </view>
  65. <!-- 记录 -->
  66. <view class="records" >
  67. <view class="time">
  68. {{queryMonth}} 充值 {{jpAmount(sumAmount)}}元
  69. </view>
  70. <view class="details" v-for="(item,i) in list" :key="i">
  71. <view class="details-title">
  72. <view class="name">
  73. {{item.remark}}-{{item.methodN}}
  74. </view>
  75. <view class="record-time" v-if="item.extraInfo" v-html="extraInfoText(item.extraInfo)" >
  76. </view>
  77. <view class="record-time">
  78. {{item.createTime}}
  79. </view>
  80. </view>
  81. <view class="sum">
  82. {{jpAmount(item.amount)}}
  83. </view>
  84. </view>
  85. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容"
  86. border-color="#CFD2D5">已经到底了</u-divider>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. //import * as API from '@/apis/pagejs/deduction.js'
  92. import * as API from '@/apis/pagejs/tenantList.js'
  93. import {
  94. nextDay,
  95. nextMonth,
  96. } from '@/apis/utils'
  97. import * as echarts from "echarts";
  98. export default {
  99. data() {
  100. return {
  101. myChart:null,
  102. list:[],
  103. formData:{
  104. pageIndex:1,
  105. pageSize:9999,
  106. },
  107. popShow:false,
  108. keyword:'',
  109. current:0,
  110. current1: 0,
  111. current2: 0,
  112. tenantList:[],
  113. tenantList1:[],
  114. endYear:'',
  115. queryMonth:"",
  116. params: {
  117. year: true,
  118. month: true,
  119. day: true,
  120. hour: false,
  121. minute: false,
  122. second: false
  123. },
  124. tabsFrom: {
  125. show1: false,
  126. show1Index:0,
  127. show2Index:'',
  128. show2: false,
  129. show1Text: "全部类型",
  130. show2Text: "全部时间",
  131. selector1:[
  132. {
  133. label: '全部类型',
  134. value: '',
  135. },
  136. {
  137. label: '线上充值',
  138. value: '1',
  139. },
  140. {
  141. label: '线下充值',
  142. value: '2',
  143. },
  144. ]
  145. },
  146. }
  147. },
  148. onLoad() {
  149. this.endYear=new Date().getFullYear()
  150. var date=new Date()
  151. this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  152. this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1) +"月"
  153. this.getTenantList()
  154. },
  155. computed:{
  156. sumAmount(){
  157. let totalAmount =0
  158. if(this.list){
  159. var amounts=this.list.map(item=>{
  160. return item.amount
  161. })
  162. totalAmount = amounts.reduce((accumulator, currentValue) => {
  163. return accumulator + currentValue;
  164. }, 0);
  165. }
  166. return totalAmount
  167. }
  168. },
  169. methods:{
  170. merchantChangeApi(){
  171. this.rechargeRecord();
  172. this.rechargeRecordGraph();
  173. },
  174. change(index) {
  175. this.current = index;
  176. this.formData.tenantId = this.tenantList1[index].id;
  177. this.popShow = false;
  178. this.merchantChangeApi()
  179. },
  180. merchantChange(item, index) {
  181. // if(this.current==0){
  182. // this.current=1;
  183. // }
  184. this.formData.tenantId= item.id;
  185. //this.$forceUpdate()
  186. this.getTenantListSort(this.tenantList)
  187. this.merchantChangeApi()
  188. this.popShow = false;
  189. },
  190. getTenantList(){
  191. uni.showLoading({
  192. title: "加载中",
  193. mask: true,
  194. })
  195. API.tenantList().then((response) => {
  196. uni.hideLoading();
  197. var list=response.data.tenantInfoList;
  198. this.formData.tenantId=list[0].id
  199. this.getTenantListSort(list)
  200. this.merchantChangeApi()
  201. }).catch(error => {
  202. uni.showToast({
  203. title: error,
  204. icon: "none"
  205. })
  206. })
  207. },
  208. getTenantListSort(list){
  209. for(var i in list){
  210. var obj=list[i]
  211. if(this.formData.tenantId==obj.id){
  212. var obj1=list[this.current];
  213. list[this.current]=obj;
  214. list[i]=obj1;
  215. }
  216. }
  217. this.tenantList=list;
  218. var mList1 = [];
  219. for (var i = 0; i < list.length; i++) {
  220. if (i >= 4) {
  221. } else {
  222. mList1.push(list[i]);
  223. }
  224. }
  225. this.tenantList1 = mList1;
  226. },
  227. extraInfoText(extraInfo){
  228. var obj=JSON.parse(extraInfo)
  229. if(obj.outOrderNo){
  230. return `充值订单编号:${obj.outOrderNo}`
  231. }else{
  232. return ''
  233. }
  234. },
  235. selector2confirm(e){
  236. this.tabsFrom.show2Text=e.year+"年"+e.month+"月"
  237. this.tabsFrom.show2Index=e.year+"-"+e.month
  238. if(e.day){
  239. this.tabsFrom.show2Text+=e.day+"日"
  240. this.tabsFrom.show2Index+='-'+e.day
  241. }
  242. //this.tabsFrom.show2Index=this.tabsFrom.show2Text
  243. if(e.day){
  244. this.formData.startDate=e.year+"-"+e.month +"-"+e.day
  245. this.queryMonth=e.year+"年"+e.month+"月"+e.day+"日"
  246. this.formData.endDate=this.formData.startDate
  247. //nextDay(e.year,e.month, e.day)
  248. }else{
  249. this.queryMonth=e.year+"年"+e.month+"月"
  250. this.formData.startDate=e.year+"-"+e.month +"-1"
  251. this.formData.endDate=nextMonth(e.year,e.month, 1,1)
  252. }
  253. this.rechargeRecord()
  254. },
  255. selector2reset(e){
  256. this.tabsFrom.show2Text='全部时间'
  257. this.tabsFrom.show2Index='';
  258. this.formData.startDate=date.getFullYear()+"-"+(date.getMonth() + 1) +"-1"
  259. this.queryMonth=date.getFullYear()+"年"+(date.getMonth() + 1)+"月"
  260. this.rechargeRecord()
  261. },
  262. selector1confirm(e){
  263. var index=e[0]
  264. this.tabsFrom.show1Index=index
  265. this.tabsFrom.show1Text=this.tabsFrom.selector1[index].label
  266. this.formData.type=this.tabsFrom.selector1[index].value
  267. this.rechargeRecord()
  268. },
  269. rechargeRecordGraph(){
  270. API.rechargeRecordGraph({
  271. tenantId:this.formData.tenantId
  272. }).then((response) => {
  273. var list=response.data;
  274. // uni.getSystemInfo({
  275. // success: (res) => {
  276. // const screenWidth = res.windowWidth; // 屏幕宽度,单位为px
  277. // console.log('屏幕宽度:', screenWidth);
  278. // },
  279. // });
  280. this.getPle(list)
  281. //uni.upx2px(600)
  282. }).catch(error => {
  283. uni.showToast({
  284. title: error,
  285. icon: "none"
  286. })
  287. })
  288. },
  289. getPle(list){
  290. if (!this.myChart) {
  291. this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
  292. width:uni.upx2px(700),height:uni.upx2px(280)
  293. });
  294. }
  295. this.myChart.clear();
  296. var data1=list.map(item=>{
  297. return item.month.replace("-", "年")+"月"
  298. });
  299. var data2=list.map(item=>{
  300. return item.monthAmount
  301. });
  302. var headitemby=""
  303. var showkey = "";
  304. var option = {
  305. tooltip: {
  306. trigger: 'axis'
  307. },
  308. grid: {
  309. top: '6%',
  310. left: '3%',
  311. right: '8%',
  312. bottom: '8%',
  313. containLabel: true
  314. },
  315. xAxis: {
  316. type: 'category',
  317. data: data1,
  318. axisLabel: {
  319. formatter: (value) => {
  320. if (headitemby == "") {
  321. headitemby = value
  322. }
  323. var i = 0
  324. var showvalue = "";
  325. var key = value.substring(0, 5);
  326. if (showkey == "" || value == headitemby) {
  327. showkey = key
  328. showvalue = value
  329. showvalue = value.substring(2)
  330. } else {
  331. if (key != showkey) {
  332. showkey = key
  333. showvalue = value
  334. showvalue = value.substring(2)
  335. } else {
  336. showvalue = value.substring(5)
  337. }
  338. }
  339. return showvalue.replace("年", ".").replace("月", "");
  340. },
  341. textStyle: {
  342. color: "#333"
  343. }
  344. },
  345. },
  346. yAxis: {
  347. type: 'value'
  348. },
  349. series: [
  350. {
  351. name: '合计',
  352. data: data2,
  353. type: 'line'
  354. }
  355. ]
  356. }
  357. console.log(option)
  358. this.myChart.setOption(option);
  359. },
  360. rechargeRecord(){
  361. uni.showLoading({
  362. mask:true,title:'加载中...'
  363. })
  364. API.rechargeRecord(this.formData).then((response) => {
  365. uni.hideLoading();
  366. this.list=response.data.data;
  367. }).catch(error => {
  368. uni.hideLoading();
  369. uni.showToast({
  370. title: error,
  371. icon: "none"
  372. })
  373. })
  374. },
  375. }
  376. }
  377. </script>
  378. <style lang="scss" scoped>
  379. // 标签
  380. .tabs-box{
  381. display: flex;
  382. align-items: center;
  383. justify-content: space-between;
  384. padding: 16rpx 32rpx 16rpx 0;
  385. .tabs{
  386. width: 96%;
  387. }
  388. /deep/.u-tabs{
  389. background-color: inherit !important
  390. }
  391. }
  392. // 标签
  393. .tabs-box{
  394. display: flex;
  395. align-items: center;
  396. justify-content: space-between;
  397. padding: 16rpx 32rpx 16rpx 0;
  398. .tabs{
  399. width: 96%;
  400. }
  401. }
  402. .tabs-box{
  403. background-color: #fff;
  404. display: flex;
  405. align-items: center;
  406. justify-content: space-between;
  407. padding: 16rpx 32rpx 16rpx 32rpx;
  408. .tabs1{
  409. width: 96%;
  410. }
  411. }
  412. .popup-tabs {
  413. background-color: #fff;
  414. display: flex;
  415. align-items: center;
  416. justify-content: space-between;
  417. padding-top: 32rpx;
  418. padding-right: 32rpx;
  419. color: rgba(51, 51, 51, 1);
  420. font-size: 32rpx;
  421. .tabs1 {
  422. width: 88%;
  423. }
  424. }
  425. /deep/.u-tab-item {
  426. width: 25% !important;
  427. flex: none !important;
  428. }
  429. .tabs-options {
  430. //display: flex;
  431. padding: 24rpx 32rpx ;
  432. flex-wrap: wrap;
  433. .item {
  434. //width: 25%;
  435. color:rgb(119, 119, 119);
  436. margin-bottom: 24rpx;
  437. font-size: 32rpx;
  438. }
  439. .item-index{
  440. color: rgb(51, 51, 51);
  441. font-weight: bold;
  442. }
  443. }
  444. .head-head{
  445. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.15);
  446. background: #fff;
  447. padding:24rpx;
  448. position: fixed;
  449. left: 0;
  450. right: 0;
  451. top: 80rpx;
  452. z-index: 991;
  453. }
  454. .head-head-placeholder{
  455. height: 112rpx;
  456. }
  457. // 折线图
  458. .chart-box {
  459. padding: 24rpx 32rpx;
  460. background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
  461. .title {
  462. color: rgb(16, 16, 16);
  463. }
  464. .sum {
  465. color: rgb(51, 51, 51);
  466. font-size: 64rpx;
  467. margin-top: 16rpx;
  468. .unit {
  469. color: rgb(16, 16, 16);
  470. font-size: 28rpx;
  471. margin-left: 8rpx;
  472. }
  473. }
  474. .chart {
  475. width: 100%;
  476. height: 240rpx;
  477. margin-top: 8rpx;
  478. .img {
  479. width: 100%;
  480. height: 100%;
  481. }
  482. }
  483. }
  484. // 标签
  485. .tabs {
  486. height: 96rpx;
  487. line-height: 96rpx;
  488. background-color: #fff;
  489. border-top: 1px solid rgba(241, 241, 241, 1);
  490. display: flex;
  491. justify-content: space-around;
  492. }
  493. // 记录
  494. .records {
  495. .time {
  496. padding: 24rpx 32rpx;
  497. color: rgba(119, 119, 119, 1);
  498. font-size: 32rpx;
  499. }
  500. .details {
  501. background-color: #fff;
  502. padding: 32rpx;
  503. display: flex;
  504. justify-content: space-between;
  505. align-items: center;
  506. .details-title {
  507. .title {
  508. color: rgba(51, 51, 51, 1);
  509. font-size: 32rpx;
  510. }
  511. .record-time {
  512. color: rgb(153, 153, 153);
  513. font-size: 24rpx;
  514. margin-top: 8rpx;
  515. }
  516. }
  517. .sum {
  518. color: rgb(16, 16, 16);
  519. font-size: 40rpx;
  520. }
  521. }
  522. }
  523. </style>