score.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!-- 页面 -->
  2. <template>
  3. <s-layout class="wallet-wrap" title="我的积分" navbar="inner">
  4. <view
  5. class="header-box ss-flex ss-flex-col ss-row-center ss-col-center"
  6. :style="[
  7. {
  8. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  9. paddingTop: Number(statusBarHeight + 88) + 'rpx',
  10. },
  11. ]"
  12. >
  13. <view class="header-bg"><view class="bg"></view></view>
  14. <view class="score-box ss-flex-col ss-row-center ss-col-center">
  15. <view class="ss-m-b-30">
  16. <text class="all-title ss-m-r-8">当前积分</text>
  17. <text class="cicon-help-o"></text>
  18. </view>
  19. <text class="all-num">{{ userInfo.score || 0 }}</text>
  20. </view>
  21. </view>
  22. <!-- tab -->
  23. <su-sticky :customNavHeight="sys_navBar">
  24. <!-- 统计 -->
  25. <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
  26. <uni-datetime-picker v-model="state.data" type="daterange" @change="onChangeTime">
  27. <button class="ss-reset-button date-btn">
  28. <text>{{ dateFilterText }}</text>
  29. <text class="cicon-drop-down ss-seldate-icon"></text>
  30. </button>
  31. </uni-datetime-picker>
  32. <view class="total-box">
  33. <view class="ss-m-b-10">总收入¥{{ state.pagination.income }}</view>
  34. <view>总支出¥{{ -state.pagination.expense }}</view>
  35. </view>
  36. </view>
  37. <su-tabs
  38. :list="tabMaps"
  39. @change="onChange"
  40. :scrollable="false"
  41. :current="state.currentTab"
  42. ></su-tabs>
  43. </su-sticky>
  44. <!-- list -->
  45. <view class="list-box">
  46. <view v-if="state.pagination.total > 0">
  47. <view
  48. class="list-item ss-flex ss-col-center ss-row-between"
  49. v-for="item in state.pagination.data"
  50. :key="item.id"
  51. >
  52. <view class="ss-flex-col">
  53. <view class="name">{{ item.event_text }}{{ item.memo ? '-' + item.memo : '' }}</view>
  54. <view class="time">{{ item.create_time }}</view>
  55. </view>
  56. <view class="add" v-if="item.amount > 0">+{{ parseInt(item.amount) }}</view>
  57. <view class="minus" v-else>{{ parseInt(item.amount) }}</view>
  58. </view>
  59. </view>
  60. <s-empty v-else text="暂无数据" icon="/static/data-empty.png" />
  61. </view>
  62. <uni-load-more
  63. v-if="state.pagination.total > 0"
  64. :status="state.loadStatus"
  65. :content-text="{
  66. contentdown: '上拉加载更多',
  67. }"
  68. @tap="onLoadMore"
  69. />
  70. </s-layout>
  71. </template>
  72. <script setup>
  73. import sheep from '@/sheep';
  74. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  75. import { computed, reactive } from 'vue';
  76. import _ from 'lodash';
  77. import dayjs from 'dayjs';
  78. import { onPageScroll } from '@dcloudio/uni-app';
  79. onPageScroll(() => {});
  80. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  81. const userInfo = computed(() => sheep.$store('user').userInfo);
  82. const sys_navBar = sheep.$platform.navbar;
  83. const pagination = {
  84. data: [],
  85. current_page: 1,
  86. total: 1,
  87. last_page: 1,
  88. expense: 0,
  89. income: 0,
  90. };
  91. const state = reactive({
  92. currentTab: 0,
  93. pagination,
  94. loadStatus: '',
  95. date: [],
  96. });
  97. const tabMaps = [
  98. {
  99. name: '全部',
  100. value: 'all',
  101. },
  102. {
  103. name: '收入',
  104. value: 'income',
  105. },
  106. {
  107. name: '支出',
  108. value: 'expense',
  109. },
  110. ];
  111. const dateFilterText = computed(() => {
  112. if (state.date[0] === state.date[1]) {
  113. return state.date[0];
  114. } else {
  115. return state.date.join('~');
  116. }
  117. });
  118. async function getLogList(page = 1, list_rows = 8) {
  119. state.loadStatus = 'loading';
  120. let res = await sheep.$api.user.wallet.log({
  121. type: 'score',
  122. list_rows,
  123. page,
  124. tab: tabMaps[state.currentTab].value,
  125. date: appendTimeHMS(state.date),
  126. });
  127. if (res.error === 0) {
  128. let list = _.concat(state.pagination.data, res.data.list.data);
  129. state.pagination = {
  130. ...res.data.list,
  131. data: list,
  132. income: res.data.income,
  133. expense: res.data.expense,
  134. };
  135. if (state.pagination.current_page < state.pagination.last_page) {
  136. state.loadStatus = 'more';
  137. } else {
  138. state.loadStatus = 'noMore';
  139. }
  140. }
  141. }
  142. onLoad(async (options) => {
  143. const today = dayjs().format('YYYY-MM-DD');
  144. state.date = [today, today];
  145. getLogList();
  146. });
  147. function onChange(e) {
  148. state.pagination = pagination;
  149. state.currentTab = e.index;
  150. getLogList();
  151. }
  152. function onChangeTime(e) {
  153. state.date[0] = e[0];
  154. state.date[1] = e[e.length - 1];
  155. getLogList();
  156. }
  157. function appendTimeHMS(arr) {
  158. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  159. }
  160. function onLoadMore() {
  161. if (state.loadStatus !== 'noMore') {
  162. getLogList(state.pagination.current_page + 1);
  163. }
  164. }
  165. onReachBottom(() => {
  166. onLoadMore();
  167. });
  168. </script>
  169. <style lang="scss" scoped>
  170. .header-box {
  171. width: 100%;
  172. background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%)
  173. no-repeat;
  174. background-size: 750rpx 100%;
  175. padding: 0 0 120rpx 0;
  176. box-sizing: border-box;
  177. .score-box {
  178. height: 100%;
  179. .all-num {
  180. font-size: 50rpx;
  181. font-weight: bold;
  182. color: #fff;
  183. font-family: OPPOSANS;
  184. }
  185. .all-title {
  186. font-size: 26rpx;
  187. font-weight: 500;
  188. color: #fff;
  189. }
  190. .cicon-help-o {
  191. color: #fff;
  192. font-size: 28rpx;
  193. }
  194. }
  195. }
  196. // 筛选
  197. .filter-box {
  198. height: 114rpx;
  199. background-color: $bg-page;
  200. .total-box {
  201. font-size: 24rpx;
  202. font-weight: 500;
  203. color: $dark-9;
  204. }
  205. .date-btn {
  206. background-color: $white;
  207. line-height: 54rpx;
  208. border-radius: 27rpx;
  209. padding: 0 20rpx;
  210. font-size: 24rpx;
  211. font-weight: 500;
  212. color: $dark-6;
  213. .ss-seldate-icon {
  214. font-size: 50rpx;
  215. color: $dark-9;
  216. }
  217. }
  218. }
  219. .list-box {
  220. .list-item {
  221. background: #fff;
  222. border-bottom: 1rpx solid #dfdfdf;
  223. padding: 30rpx;
  224. .name {
  225. font-size: 28rpx;
  226. font-weight: 500;
  227. color: rgba(102, 102, 102, 1);
  228. line-height: 28rpx;
  229. margin-bottom: 20rpx;
  230. }
  231. .time {
  232. font-size: 24rpx;
  233. font-weight: 500;
  234. color: rgba(196, 196, 196, 1);
  235. line-height: 24px;
  236. }
  237. .add {
  238. font-size: 30rpx;
  239. font-weight: 500;
  240. color: #e6b873;
  241. }
  242. .minus {
  243. font-size: 30rpx;
  244. font-weight: 500;
  245. color: $dark-3;
  246. }
  247. }
  248. }
  249. </style>