index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 baseUrl = config.baseUrl
  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. record.mainOrderId && uni.navigateTo({
  108. url: `/pages_classify/pages/orderItem/orderdetails?mainOrderId=${record.mainOrderId}`
  109. });
  110. }
  111. const scrolltolower = () => {
  112. init('bottom')
  113. };
  114. const onCustomRefresh = () => {
  115. isRefreshing.value = true;
  116. pages.value.current = 1;
  117. // data.value.clientAccountChangeVOlist = [];
  118. init('top')
  119. };
  120. const init = async (type) => {
  121. try {
  122. if (type === 'bottom') {
  123. if (data.value.clientAccountChangeVOlist.length < pages.value.total) {
  124. loadmoreInfo.value.status = 'loading';
  125. pages.value.current++;
  126. } else {
  127. loadmoreInfo.value.status = 'nomore';
  128. return;
  129. }
  130. } else {
  131. uni.showLoading({
  132. title: '数据加载中...',
  133. })
  134. }
  135. const listApi = userType === 1 ? getAccountChangeList : getVolunteerChangeList;
  136. const res = await listApi({
  137. // createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  138. pageNum: pages.value.current,
  139. pageSize: pages.value.pageSize,
  140. });
  141. data.value.clientAccountChangeVOlist =type === 'top'? res.rows : [...data.value.clientAccountChangeVOlist, ...res.rows];
  142. pages.value.total = res.total;
  143. } catch (error) {
  144. console.log('error', error);
  145. uni.showToast({
  146. title: error.msg,
  147. icon: 'error',
  148. });
  149. } finally {
  150. if (type === 'top') {
  151. isRefreshing.value = false;
  152. uni.hideLoading();
  153. }
  154. if(data.value.clientAccountChangeVOlist.length === pages.value.total){
  155. loadmoreInfo.value.status = 'nomore';
  156. }
  157. //
  158. }
  159. }
  160. const totalInit = async () => {
  161. try {
  162. const listApi = userType === 1 ? getTotalMoney : getVolunteerTotalMoney;
  163. const res = await listApi({
  164. // createTime: dayjs(datetime.value).format('YYYY-MM-DD'),
  165. });
  166. data.value.totalEarning = res.data.totalEarning;
  167. data.value.totalExpend = res.data.totalExpend;
  168. } catch (error) {
  169. console.log('error', error);
  170. uni.showToast({
  171. title: error.msg,
  172. icon: 'error',
  173. });
  174. }
  175. }
  176. onShow(() => {
  177. init('top');
  178. totalInit();
  179. })
  180. </script>
  181. <style lang="scss" scoped>
  182. .card-box {
  183. border-radius: 8px;
  184. background: rgba(255, 255, 255, 1);
  185. padding: 12px;
  186. margin-bottom: 12px;
  187. }
  188. .income-main {
  189. // position: fixed;
  190. // top: 0px;
  191. // left: 0px;
  192. // right: 0px;
  193. // bottom: 0px;
  194. padding: 12px;
  195. // overflow: auto;
  196. .income-title {
  197. font-size: 16px;
  198. font-weight: 500;
  199. line-height: 23.17px;
  200. color: rgba(0, 0, 0, 1);
  201. }
  202. .income-header {
  203. display: flex;
  204. align-items: center;
  205. justify-content: space-between;
  206. .income-header-right {
  207. font-size: 14px;
  208. font-weight: 500;
  209. line-height: 20.27px;
  210. color: rgba(0, 0, 0, 1);
  211. display: flex;
  212. align-items: flex-start;
  213. justify-content: center;
  214. .income-header-right-right {
  215. margin-left: 8rpx;
  216. }
  217. }
  218. }
  219. }
  220. .icome-item {
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. .card-left {
  225. display: flex;
  226. align-items: center;
  227. .income-img {
  228. width: 40px;
  229. height: 40px;
  230. }
  231. .card-left-text {
  232. margin-left: 12px;
  233. .card-left-name {
  234. font-size: 16px;
  235. font-weight: 700;
  236. line-height: 23.17px;
  237. color: rgba(0, 0, 0, 1);
  238. margin-bottom: 6px;
  239. display: flex;
  240. align-items: center;
  241. }
  242. .card-left-date {
  243. font-size: 14px;
  244. font-weight: 500;
  245. line-height: 16.41px;
  246. color: rgba(153, 153, 153, 1);
  247. }
  248. }
  249. .card-rigth {
  250. font-size: 20px;
  251. font-weight: 700;
  252. line-height: 23.44px;
  253. color: rgba(51, 51, 51, 1);
  254. }
  255. }
  256. }
  257. .scroll-view-class {
  258. // height: 100%;
  259. height: 100vh;
  260. background: rgba(245, 245, 245, 1);
  261. // position: fixed;
  262. // top: 0px;
  263. // bottom: 0;
  264. // left: 0;
  265. // right: 0;
  266. }
  267. .is_pay_class {
  268. margin-top: 8rpx;
  269. font-size: 14px;
  270. }
  271. </style>