index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <scroll-view refresher-enabled :refresher-triggered="isRefreshing" @refresherrefresh="onCustomRefresh"
  3. class="scroll-view-class" @scrolltolower="scrolltolower" scroll-y>
  4. <view class="income-main">
  5. <view class="income-header card-box">
  6. <text class="income-title" @click="onShows">
  7. {{ dataYMD }}
  8. </text>
  9. <view class="income-header-right">
  10. <text>收入: ¥{{ data.totalEarning }}</text>
  11. <text class="income-header-right-right">支出: ¥{{ data.totalExpend }}</text>
  12. </view>
  13. </view>
  14. <view v-if="data.clientAccountChangeVOlist && data.clientAccountChangeVOlist.length > 0">
  15. <view class="card-box icome-item" v-for="item in data.clientAccountChangeVOlist" :key="item.code"
  16. @click="onClick(item)">
  17. <view class="card-left">
  18. <!-- <img :src="baseUrl" alt="" class="income-img"> -->
  19. <view class="card-left-text">
  20. <view class="card-left-name">
  21. <dict-tag :options="jlzj_client_source_type" :value="item.sourceType" />
  22. ({{ item.businessTierName }})
  23. </view>
  24. <view class="card-left-date">{{ item.createTime }}</view>
  25. </view>
  26. </view>
  27. <view class="card-rigth"
  28. :style="{ color: item.changeType === '1' ? 'rgba(76, 175, 80, 1)' : 'rgba(244, 67, 54, 1)' }">
  29. {{ item.changeType === '1' ? '+' : '-' }}{{ item.changeMoney }}
  30. </view>
  31. </view>
  32. <up-loadmore style="margin-top: 40rpx;" :status="loadmoreInfo.status"
  33. :loadmoreText="loadmoreInfo.loadingText" :loadingText="loadmoreInfo.loadmoreText"
  34. :nomoreText="loadmoreInfo.nomoreText" @loadmore="handleLoadmore" />
  35. </view>
  36. <view v-else>
  37. <NoneView value="您还没有相关账单" />
  38. </view>
  39. <up-datetime-picker :show="show" v-model="datetime" mode="date" ref="uPickerRef" @confirm="confirm"
  40. @cancel="cancel"></up-datetime-picker>
  41. </view>
  42. </scroll-view>
  43. </template>
  44. <script setup>
  45. import { ref, computed } from 'vue'
  46. import { getAccountChangeList, getTotalMoney } from "@/api/mine";
  47. import {
  48. onShow
  49. } from '@dcloudio/uni-app';
  50. import config from '@/config'
  51. import DictTag from '@/components/DictTag/index.vue'
  52. import {
  53. useDict
  54. } from '@/utils/dict.js';
  55. import dayjs from 'dayjs/esm/index'
  56. import NoneView from '@/components/NoneView/index.vue'
  57. const {
  58. jlzj_money_change_type,
  59. jlzj_client_source_type
  60. } = useDict('jlzj_money_change_type', 'jlzj_client_source_type');
  61. const baseUrl = config.baseUrl
  62. const userType = uni.getStorageSync('userType') //读取本地存储
  63. const data = ref({
  64. totalEarning: 0,
  65. totalExpend: 0,
  66. clientAccountChangeVOlist: []
  67. })
  68. const show = ref(false);
  69. const datetime = ref(Date.now());
  70. const dataYMD = computed(() => {
  71. return dayjs(datetime.value).format("YYYY年MM月DD日")
  72. })
  73. const uPickerRef = ref(null)
  74. const isRefreshing = ref(false)
  75. const loadmoreInfo = ref({
  76. status: 'loadmore',
  77. loadingText: '努力加载中...',
  78. loadmoreText: '点击加载更多~',
  79. nomoreText: '已经到底啦~'
  80. })
  81. const pages = ref({
  82. current: 1,
  83. pageSize: 10,
  84. total: 0,
  85. })
  86. const onShows = () => {
  87. show.value = true;
  88. };
  89. const confirm = () => {
  90. show.value = false;
  91. init('top');
  92. totalInit();
  93. };
  94. const cancel = () => {
  95. show.value = false;
  96. };
  97. const onClick = (record) => {
  98. record.mainOrderId && uni.navigateTo({
  99. url: `/pages_classify/pages/orderItem/orderdetails?mainOrderId=${record.mainOrderId}`
  100. });
  101. }
  102. const scrolltolower = () => {
  103. init('bottom')
  104. };
  105. const onCustomRefresh = () => {
  106. isRefreshing.value = true;
  107. pages.value.current = 1;
  108. // data.value.clientAccountChangeVOlist = [];
  109. init('top')
  110. };
  111. const init = async (type) => {
  112. try {
  113. if (type === 'bottom') {
  114. if (data.value.clientAccountChangeVOlist.length < pages.value.total) {
  115. loadmoreInfo.value.status = 'loading';
  116. pages.value.current++;
  117. } else {
  118. loadmoreInfo.value.status = 'nomore';
  119. return;
  120. }
  121. } else {
  122. uni.showLoading({
  123. title: '数据加载中...',
  124. })
  125. }
  126. const listApi = userType === 1 ? getAccountChangeList : getAccountChangeList;
  127. const res = await listApi({
  128. createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  129. pageNum: pages.value.current,
  130. pageSize: pages.value.pageSize,
  131. });
  132. data.value.clientAccountChangeVOlist =type === 'top'? res.rows : [...data.value.clientAccountChangeVOlist, ...res.rows];
  133. pages.value.total = res.total;
  134. } catch (error) {
  135. console.log('error', error);
  136. uni.showToast({
  137. title: error.msg,
  138. icon: 'error',
  139. });
  140. } finally {
  141. if (type === 'top') {
  142. isRefreshing.value = false;
  143. uni.hideLoading();
  144. } else {
  145. loadmoreInfo.value.status = 'nomore';
  146. }
  147. }
  148. }
  149. const totalInit = async () => {
  150. try {
  151. const res = await getTotalMoney({
  152. createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  153. });
  154. data.value.totalEarning = res.data.totalEarning;
  155. data.value.totalExpend = res.data.totalExpend;
  156. } catch (error) {
  157. console.log('error', error);
  158. uni.showToast({
  159. title: error.msg,
  160. icon: 'error',
  161. });
  162. }
  163. }
  164. onShow(() => {
  165. init('top');
  166. totalInit();
  167. })
  168. </script>
  169. <style lang="scss" scoped>
  170. .card-box {
  171. border-radius: 8px;
  172. background: rgba(255, 255, 255, 1);
  173. padding: 12px;
  174. margin-bottom: 12px;
  175. }
  176. .income-main {
  177. // position: fixed;
  178. // top: 0px;
  179. // left: 0px;
  180. // right: 0px;
  181. // bottom: 0px;
  182. padding: 12px;
  183. // overflow: auto;
  184. .income-title {
  185. font-size: 16px;
  186. font-weight: 500;
  187. line-height: 23.17px;
  188. color: rgba(0, 0, 0, 1);
  189. }
  190. .income-header {
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. .income-header-right {
  195. font-size: 14px;
  196. font-weight: 500;
  197. line-height: 20.27px;
  198. color: rgba(0, 0, 0, 1);
  199. display: flex;
  200. align-items: flex-start;
  201. justify-content: center;
  202. .income-header-right-right {
  203. margin-left: 8rpx;
  204. }
  205. }
  206. }
  207. }
  208. .icome-item {
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. .card-left {
  213. display: flex;
  214. align-items: center;
  215. .income-img {
  216. width: 40px;
  217. height: 40px;
  218. }
  219. .card-left-text {
  220. margin-left: 12px;
  221. .card-left-name {
  222. font-size: 16px;
  223. font-weight: 700;
  224. line-height: 23.17px;
  225. color: rgba(0, 0, 0, 1);
  226. margin-bottom: 6px;
  227. display: flex;
  228. align-items: center;
  229. }
  230. .card-left-date {
  231. font-size: 14px;
  232. font-weight: 500;
  233. line-height: 16.41px;
  234. color: rgba(153, 153, 153, 1);
  235. }
  236. }
  237. .card-rigth {
  238. font-size: 20px;
  239. font-weight: 700;
  240. line-height: 23.44px;
  241. color: rgba(51, 51, 51, 1);
  242. }
  243. }
  244. }
  245. .scroll-view-class {
  246. // height: 100%;
  247. height: 100vh;
  248. background: rgba(245, 245, 245, 1);
  249. // position: fixed;
  250. // top: 0px;
  251. // bottom: 0;
  252. // left: 0;
  253. // right: 0;
  254. }
  255. </style>