index.vue 11 KB

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