index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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="userType === 1?jlzj_client_source_type:jlzj_volunteer_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,getVolunteerTotalMoney,getVolunteerChangeList } 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. jlzj_volunteer_source_type
  61. } = useDict('jlzj_money_change_type', 'jlzj_client_source_type','jlzj_volunteer_source_type');
  62. const baseUrl = config.baseUrl
  63. const userType = uni.getStorageSync('userType') //读取本地存储
  64. const data = ref({
  65. totalEarning: 0,
  66. totalExpend: 0,
  67. clientAccountChangeVOlist: []
  68. })
  69. const show = ref(false);
  70. const datetime = ref(Date.now());
  71. const dataYMD = computed(() => {
  72. return dayjs(datetime.value).format("YYYY年MM月DD日")
  73. })
  74. const uPickerRef = ref(null)
  75. const isRefreshing = ref(false)
  76. const loadmoreInfo = ref({
  77. status: 'loadmore',
  78. loadingText: '努力加载中...',
  79. loadmoreText: '点击加载更多~',
  80. nomoreText: '已经到底啦~'
  81. })
  82. const pages = ref({
  83. current: 1,
  84. pageSize: 10,
  85. total: 0,
  86. })
  87. const onShows = () => {
  88. show.value = true;
  89. };
  90. const confirm = () => {
  91. show.value = false;
  92. init('top');
  93. totalInit();
  94. };
  95. const cancel = () => {
  96. show.value = false;
  97. };
  98. const onClick = (record) => {
  99. record.mainOrderId && uni.navigateTo({
  100. url: `/pages_classify/pages/orderItem/orderdetails?mainOrderId=${record.mainOrderId}`
  101. });
  102. }
  103. const scrolltolower = () => {
  104. init('bottom')
  105. };
  106. const onCustomRefresh = () => {
  107. isRefreshing.value = true;
  108. pages.value.current = 1;
  109. // data.value.clientAccountChangeVOlist = [];
  110. init('top')
  111. };
  112. const init = async (type) => {
  113. try {
  114. if (type === 'bottom') {
  115. if (data.value.clientAccountChangeVOlist.length < pages.value.total) {
  116. loadmoreInfo.value.status = 'loading';
  117. pages.value.current++;
  118. } else {
  119. loadmoreInfo.value.status = 'nomore';
  120. return;
  121. }
  122. } else {
  123. uni.showLoading({
  124. title: '数据加载中...',
  125. })
  126. }
  127. const listApi = userType === 1 ? getAccountChangeList : getVolunteerChangeList;
  128. const res = await listApi({
  129. createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  130. pageNum: pages.value.current,
  131. pageSize: pages.value.pageSize,
  132. });
  133. data.value.clientAccountChangeVOlist =type === 'top'? res.rows : [...data.value.clientAccountChangeVOlist, ...res.rows];
  134. pages.value.total = res.total;
  135. } catch (error) {
  136. console.log('error', error);
  137. uni.showToast({
  138. title: error.msg,
  139. icon: 'error',
  140. });
  141. } finally {
  142. if (type === 'top') {
  143. isRefreshing.value = false;
  144. uni.hideLoading();
  145. } else {
  146. loadmoreInfo.value.status = 'nomore';
  147. }
  148. }
  149. }
  150. const totalInit = async () => {
  151. try {
  152. const listApi = userType === 1 ? getTotalMoney : getVolunteerTotalMoney;
  153. const res = await listApi({
  154. createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  155. });
  156. data.value.totalEarning = res.data.totalEarning;
  157. data.value.totalExpend = res.data.totalExpend;
  158. } catch (error) {
  159. console.log('error', error);
  160. uni.showToast({
  161. title: error.msg,
  162. icon: 'error',
  163. });
  164. }
  165. }
  166. onShow(() => {
  167. init('top');
  168. totalInit();
  169. })
  170. </script>
  171. <style lang="scss" scoped>
  172. .card-box {
  173. border-radius: 8px;
  174. background: rgba(255, 255, 255, 1);
  175. padding: 12px;
  176. margin-bottom: 12px;
  177. }
  178. .income-main {
  179. // position: fixed;
  180. // top: 0px;
  181. // left: 0px;
  182. // right: 0px;
  183. // bottom: 0px;
  184. padding: 12px;
  185. // overflow: auto;
  186. .income-title {
  187. font-size: 16px;
  188. font-weight: 500;
  189. line-height: 23.17px;
  190. color: rgba(0, 0, 0, 1);
  191. }
  192. .income-header {
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. .income-header-right {
  197. font-size: 14px;
  198. font-weight: 500;
  199. line-height: 20.27px;
  200. color: rgba(0, 0, 0, 1);
  201. display: flex;
  202. align-items: flex-start;
  203. justify-content: center;
  204. .income-header-right-right {
  205. margin-left: 8rpx;
  206. }
  207. }
  208. }
  209. }
  210. .icome-item {
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. .card-left {
  215. display: flex;
  216. align-items: center;
  217. .income-img {
  218. width: 40px;
  219. height: 40px;
  220. }
  221. .card-left-text {
  222. margin-left: 12px;
  223. .card-left-name {
  224. font-size: 16px;
  225. font-weight: 700;
  226. line-height: 23.17px;
  227. color: rgba(0, 0, 0, 1);
  228. margin-bottom: 6px;
  229. display: flex;
  230. align-items: center;
  231. }
  232. .card-left-date {
  233. font-size: 14px;
  234. font-weight: 500;
  235. line-height: 16.41px;
  236. color: rgba(153, 153, 153, 1);
  237. }
  238. }
  239. .card-rigth {
  240. font-size: 20px;
  241. font-weight: 700;
  242. line-height: 23.44px;
  243. color: rgba(51, 51, 51, 1);
  244. }
  245. }
  246. }
  247. .scroll-view-class {
  248. // height: 100%;
  249. height: 100vh;
  250. background: rgba(245, 245, 245, 1);
  251. // position: fixed;
  252. // top: 0px;
  253. // bottom: 0;
  254. // left: 0;
  255. // right: 0;
  256. }
  257. </style>