index.vue 8.9 KB

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