index.vue 9.2 KB

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