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. state.pagination = pagination;
  156. getLogList();
  157. }
  158. function appendTimeHMS(arr) {
  159. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  160. }
  161. function onLoadMore() {
  162. if (state.loadStatus !== 'noMore') {
  163. getLogList(state.pagination.current_page + 1);
  164. }
  165. }
  166. onReachBottom(() => {
  167. onLoadMore();
  168. });
  169. </script>
  170. <style lang="scss" scoped>
  171. .header-box {
  172. width: 100%;
  173. background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%)
  174. no-repeat;
  175. background-size: 750rpx 100%;
  176. padding: 0 0 120rpx 0;
  177. box-sizing: border-box;
  178. .score-box {
  179. height: 100%;
  180. .all-num {
  181. font-size: 50rpx;
  182. font-weight: bold;
  183. color: #fff;
  184. font-family: OPPOSANS;
  185. }
  186. .all-title {
  187. font-size: 26rpx;
  188. font-weight: 500;
  189. color: #fff;
  190. }
  191. .cicon-help-o {
  192. color: #fff;
  193. font-size: 28rpx;
  194. }
  195. }
  196. }
  197. // 筛选
  198. .filter-box {
  199. height: 114rpx;
  200. background-color: $bg-page;
  201. .total-box {
  202. font-size: 24rpx;
  203. font-weight: 500;
  204. color: $dark-9;
  205. }
  206. .date-btn {
  207. background-color: $white;
  208. line-height: 54rpx;
  209. border-radius: 27rpx;
  210. padding: 0 20rpx;
  211. font-size: 24rpx;
  212. font-weight: 500;
  213. color: $dark-6;
  214. .ss-seldate-icon {
  215. font-size: 50rpx;
  216. color: $dark-9;
  217. }
  218. }
  219. }
  220. .list-box {
  221. .list-item {
  222. background: #fff;
  223. border-bottom: 1rpx solid #dfdfdf;
  224. padding: 30rpx;
  225. .name {
  226. font-size: 28rpx;
  227. font-weight: 500;
  228. color: rgba(102, 102, 102, 1);
  229. line-height: 28rpx;
  230. margin-bottom: 20rpx;
  231. }
  232. .time {
  233. font-size: 24rpx;
  234. font-weight: 500;
  235. color: rgba(196, 196, 196, 1);
  236. line-height: 24px;
  237. }
  238. .add {
  239. font-size: 30rpx;
  240. font-weight: 500;
  241. color: #e6b873;
  242. }
  243. .minus {
  244. font-size: 30rpx;
  245. font-weight: 500;
  246. color: $dark-3;
  247. }
  248. }
  249. }
  250. </style>