guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="cashFlow"> |
| 3 | <!-- #ifdef APP-PLUS --> |
| 4 | <view class="bgColor"></view> |
| 5 | <!-- #endif --> |
| 6 | <view class="cashFlow-tabs"> |
| 7 | <u-icon name="play-left-fill" color="#999999" size="26" @click="topre"></u-icon> |
| 8 | <view class="cashFlow-tabs-tabs"> |
| 9 | <u-tabs :list="list" :current="current" @change="change" bar-width="250" item-width="250" class="cashFlow-tabs-tabs"></u-tabs> |
| 10 | </view> |
| 11 | <u-icon name="play-right-fill" color="#999999" size="26" @click="tonext"></u-icon> |
| 12 | </view> |
| 13 | <!-- <v-tabs v-model="current" :tabs="list" @change="change"></v-tabs> --> |
| 14 | <view class="cashFlow-content-ucharts"> |
| 15 | <ring-chart :dataAs="pieData" canvasId="index_ring_1" :titleAs="titleAs" v-if="showPie" /> |
| 16 | </view> |
| 17 | <view class="cashFlow-content"> |
| 18 | <view class="cashFlow-content-list"> |
| 19 | <view class="cashFlow-content-list-title">支出明细</view> |
| 20 | <scroll-view :scroll-y="true" class="scrollView" @scrolltolower="loadMoreBills" :style="{'height':height+'px'}" v-if="showPie"> |
| 21 | <view class="cashFlow-content-list-item" v-for="(v,i) in bills" :key="i" @click="toDetails(v)"> |
| 22 | <view class="cashFlow-content-list-item-content"> |
| 23 | <text class="cashFlow-content-list-item-content-kind">{{v.transdesc}}</text> |
| 24 | <text class="cashFlow-content-list-item-content-date">{{v.date}}</text> |
| 25 | </view> |
| 26 | <view class="cashFlow-content-list-item-cost"> |
| 27 | <text>{{v.amount}}</text> |
| 28 | </view> |
| 29 | </view> |
| 30 | <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="30" /> |
| 31 | </scroll-view> |
| 32 | </view> |
| 33 | </view> |
| 34 | |
| 35 | </view> |
| 36 | </template> |
| 37 | |
| 38 | <script> |
guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 39 | import RingChart from './components/stan-ucharts/RingChart.vue'; |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 40 | // import vtabs from '@/components/v-tabs/v-tabs.vue'; |
| 41 | export default { |
| 42 | components: { |
| 43 | RingChart, |
| 44 | // vtabs |
| 45 | }, |
| 46 | data() { |
| 47 | return { |
| 48 | showPie: false, |
| 49 | height: "", |
| 50 | status: "loadmore", |
| 51 | iconType: 'circle', |
| 52 | loadText: { |
| 53 | loadmore: '轻轻上拉', |
| 54 | loading: '努力加载中', |
| 55 | nomore: '暂无更多' |
| 56 | }, |
| 57 | list: [{ |
| 58 | name: "1月", |
| 59 | // ischecked: false |
| 60 | }, { |
| 61 | name: "2月", |
| 62 | // ischecked: false |
| 63 | }, { |
| 64 | name: "3月", |
| 65 | // ischecked: false |
| 66 | }, { |
| 67 | name: "4月", |
| 68 | // ischecked: false |
| 69 | }, { |
| 70 | name: "5月", |
| 71 | // ischecked: false |
| 72 | }, { |
| 73 | name: "6月", |
| 74 | // ischecked: false |
| 75 | }, { |
| 76 | name: "7月", |
| 77 | // ischecked: false |
| 78 | }, { |
| 79 | name: "8月", |
| 80 | // ischecked: false |
| 81 | }, { |
| 82 | name: "9月", |
| 83 | // ischecked: false |
| 84 | }, { |
| 85 | name: "10月", |
| 86 | // ischecked: false |
| 87 | }, { |
| 88 | name: "11月", |
| 89 | // ischecked: false |
| 90 | }, { |
| 91 | name: "12月", |
| 92 | // ischecked: false |
| 93 | }], |
| 94 | current: new Date().getMonth(), |
| 95 | pieData: { |
| 96 | //饼状图数据 |
| 97 | series: [] |
| 98 | }, |
| 99 | titleAs: { |
| 100 | title: { |
| 101 | name: '本卡总支出', |
| 102 | fontSize: 16 |
| 103 | }, |
| 104 | subtitle: { |
| 105 | name: '', |
| 106 | fontSize: 12 |
| 107 | } |
| 108 | }, |
| 109 | bills: [], |
| 110 | pageno: 1, |
| 111 | end: false, |
| 112 | date: "", |
| 113 | nullVal: [{ |
| 114 | name: "总消费", |
| 115 | data: 0, |
| 116 | legendShape: "rect" |
| 117 | }] |
| 118 | } |
| 119 | }, |
| 120 | methods: { |
| 121 | moveHandle() { |
| 122 | return |
| 123 | }, |
| 124 | topre() { |
| 125 | let that = this |
| 126 | if (that.current != 0) { |
| 127 | that.current = that.current - 1 |
| 128 | let time = new Date().getFullYear() + "" + (that.current + 1 >= 10 ? that.current + 1 : "0" + (that.current + 1)) |
| 129 | that.date = time |
| 130 | that.getbills(1, time) |
| 131 | that.getPieVal(time) |
| 132 | } |
| 133 | }, |
| 134 | tonext() { |
| 135 | let that = this |
| 136 | if (that.current != 11) { |
| 137 | that.current = that.current + 1 |
| 138 | let time = new Date().getFullYear() + "" + (that.current + 1 >= 10 ? that.current + 1 : "0" + (that.current + 1)) |
| 139 | that.date = time |
| 140 | that.pageno = 1 |
| 141 | that.getbills(1, time) |
| 142 | that.getPieVal(time) |
| 143 | } |
| 144 | }, |
| 145 | change(index) { |
| 146 | let that = this |
| 147 | that.current = index; |
| 148 | let time = new Date().getFullYear() + "" + (that.current + 1 >= 10 ? that.current + 1 : "0" + (that.current + 1)) |
| 149 | that.date = time |
| 150 | that.pageno = 1 |
| 151 | that.getbills(1, time) |
| 152 | that.getPieVal(time) |
| 153 | }, |
| 154 | getbills(no, mon) { |
| 155 | let that = this |
| 156 | let pageno = no |
| 157 | if (pageno == 1) { |
| 158 | that.bills = [] |
| 159 | } |
| 160 | let param = { |
| 161 | pageno: pageno, |
| 162 | month: mon |
| 163 | } |
| 164 | |
| 165 | that.$u.post("/v1/bills", param).then((res) => { |
| 166 | let list = res.page ? res.page.data : [] |
| 167 | if (list.length > 0) { |
| 168 | list.forEach((item, index) => { |
| 169 | let date = item.transdate + item.transtime |
| 170 | item.date = item.transdate.substr(0,4) + "-" + item.transdate.substr(4,2)+ "-" + item.transdate.substr(6,2)+ " " + item.transtime.substr(0,2)+ ":" + item.transtime.substr(2,2)+ ":" + item.transtime.substr(4,2); |
| 171 | }) |
| 172 | //console.log(list) |
| 173 | that.bills = that.bills.concat(list) |
| 174 | that.end = false |
| 175 | } else { |
| 176 | that.status = "nomore" |
| 177 | that.end = true |
| 178 | } |
| 179 | }) |
| 180 | }, |
| 181 | loadMoreBills() { |
| 182 | let that = this |
| 183 | let pageno = that.pageno++ |
| 184 | let end = that.end |
| 185 | let month = that.date |
| 186 | if (!end) { |
| 187 | that.getbills(pageno, month) |
| 188 | } |
| 189 | }, |
| 190 | toDetails(e) { |
| 191 | let data = JSON.stringify(e) |
| 192 | uni.navigateTo({ |
guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 193 | url: "/pages/sub_mine/billsDetails?data=" + data |
guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 194 | }) |
| 195 | }, |
| 196 | getSrcollViewHeight() { |
| 197 | let winHeight |
| 198 | let that = this |
| 199 | uni.getSystemInfo({ |
| 200 | success: function(res) { |
| 201 | winHeight = res.windowHeight |
| 202 | } |
| 203 | }); |
| 204 | //console.log(winHeight) |
| 205 | const query = uni.createSelectorQuery().in(that); |
| 206 | query.select('.cashFlow-content-list-title').boundingClientRect(data => { |
| 207 | console.log(data) |
| 208 | if(!data){ |
| 209 | setTimeout(()=>{ |
| 210 | that.getSrcollViewHeight() |
| 211 | },10) |
| 212 | return |
| 213 | } |
| 214 | that.height = winHeight - data.top - data.height - 15 |
| 215 | // that.height = (data.bottom - data.height)*2 |
| 216 | }).exec(); |
| 217 | }, |
| 218 | getPieVal(mon) { |
| 219 | let that = this |
| 220 | that.showPie = false |
| 221 | let param = { |
| 222 | month: mon |
| 223 | } |
| 224 | that.$u.post("/v1/billcount", param).then(res => { |
| 225 | let total = res.data ? res.data.total : null |
| 226 | //console.log(total) |
| 227 | that.titleAs.subtitle.name = "¥" + Math.abs(total) |
| 228 | if (total === 0 || !total) { |
| 229 | that.pieData.series = that.nullVal |
| 230 | that.showPie = true |
| 231 | return false |
| 232 | } |
| 233 | let list = res.data.group |
| 234 | let newList = [] |
| 235 | list.map((value, index, arry) => { |
| 236 | newList.push({ |
| 237 | "name": value.transtype, |
| 238 | "data": Math.abs(value.amount), |
| 239 | "legendShape": "rect" |
| 240 | }) |
| 241 | }) |
| 242 | that.pieData.series = newList |
| 243 | that.showPie = true |
| 244 | }) |
| 245 | } |
| 246 | }, |
| 247 | onLoad() { |
| 248 | let that = this |
| 249 | let mon = new Date().getFullYear() + "" + (new Date().getMonth() + 1 > 10 ? new Date().getMonth() + 1 : '0' + (new Date() |
| 250 | .getMonth() + 1)) |
| 251 | //console.log(mon) |
| 252 | that.date = mon |
| 253 | that.getbills(1, mon) |
| 254 | that.getPieVal(mon) |
| 255 | this.getSrcollViewHeight() |
| 256 | }, |
| 257 | } |
| 258 | </script> |
| 259 | |
| 260 | <style scoped lang="scss"> |
| 261 | .scrollView { |
| 262 | // height: calc(100vh - 710rpx) |
| 263 | } |
| 264 | .cashFlow-content-ucharts{ |
| 265 | height: 250px; |
| 266 | } |
| 267 | |
| 268 | scroll-view ::-webkit-scrollbar { |
| 269 | width: 0; |
| 270 | height: 0; |
| 271 | display: none; |
| 272 | background-color: transparent; |
| 273 | } |
| 274 | /* #ifdef APP-PLUS */ |
| 275 | .bgColor { |
| 276 | position: fixed; |
| 277 | top: 0; |
| 278 | left: 0; |
| 279 | right: 0; |
| 280 | bottom: 0; |
| 281 | background: #FFFFFF; |
| 282 | z-index: -1; |
| 283 | } |
| 284 | /* #endif */ |
| 285 | |
| 286 | |
| 287 | page { |
| 288 | background-color: #FFFFFF; |
| 289 | } |
| 290 | |
| 291 | .cashFlow { |
| 292 | background-color: #FFFFFF; |
| 293 | &-tabs { |
| 294 | display: flex; |
| 295 | // height: 500rpx; |
| 296 | justify-content: space-around; |
| 297 | padding: 10rpx 30rpx 0; |
| 298 | |
| 299 | &-tabs { |
| 300 | width: 95%; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | &-content { |
| 305 | |
| 306 | &-list { |
| 307 | padding: 30rpx; |
| 308 | |
| 309 | &-title { |
| 310 | font-family: "PingFang-SC-Medium"; |
| 311 | color: #343434; |
| 312 | font-size: 32rpx; |
| 313 | } |
| 314 | |
| 315 | &-item { |
| 316 | display: flex; |
| 317 | justify-content: space-between; |
| 318 | align-items: center; |
| 319 | border-bottom: 1rpx solid #CCCCCC; |
| 320 | padding: 30rpx 0; |
| 321 | |
| 322 | &-content { |
| 323 | display: flex; |
| 324 | flex-direction: column; |
| 325 | |
| 326 | &-kind { |
| 327 | color: #343434; |
| 328 | font-size: 30rpx; |
| 329 | font-family: "PingFang-SC-Medium"; |
| 330 | margin-bottom: 10rpx; |
| 331 | } |
| 332 | |
| 333 | &-date { |
| 334 | color: #9A9A9A; |
| 335 | font-size: 26rpx; |
| 336 | font-family: "PingFang-SC-Medium"; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | &-cost { |
| 341 | color: #666666; |
| 342 | font-size: 32rpx; |
| 343 | font-family: "PingFang-SC-Medium"; |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | </style> |