score.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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" :end="state.today">
  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. today:'',
  97. });
  98. const tabMaps = [
  99. {
  100. name: '全部',
  101. value: 'all',
  102. },
  103. {
  104. name: '收入',
  105. value: 'income',
  106. },
  107. {
  108. name: '支出',
  109. value: 'expense',
  110. },
  111. ];
  112. const dateFilterText = computed(() => {
  113. if (state.date[0] === state.date[1]) {
  114. return state.date[0];
  115. } else {
  116. return state.date.join('~');
  117. }
  118. });
  119. async function getLogList(page = 1, list_rows = 8) {
  120. state.loadStatus = 'loading';
  121. let res = await sheep.$api.user.wallet.log({
  122. type: 'score',
  123. list_rows,
  124. page,
  125. tab: tabMaps[state.currentTab].value,
  126. date: appendTimeHMS(state.date),
  127. });
  128. if (res.error === 0) {
  129. let list = _.concat(state.pagination.data, res.data.list.data);
  130. state.pagination = {
  131. ...res.data.list,
  132. data: list,
  133. income: res.data.income,
  134. expense: res.data.expense,
  135. };
  136. if (state.pagination.current_page < state.pagination.last_page) {
  137. state.loadStatus = 'more';
  138. } else {
  139. state.loadStatus = 'noMore';
  140. }
  141. }
  142. }
  143. onLoad(async (options) => {
  144. state.today = dayjs().format('YYYY-MM-DD');
  145. state.date = [state.today, state.today];
  146. getLogList();
  147. });
  148. function onChange(e) {
  149. state.pagination = pagination;
  150. state.currentTab = e.index;
  151. getLogList();
  152. }
  153. function onChangeTime(e) {
  154. state.date[0] = e[0];
  155. state.date[1] = e[e.length - 1];
  156. state.pagination = pagination;
  157. getLogList();
  158. }
  159. function appendTimeHMS(arr) {
  160. return [arr[0] + ' 00:00:00', arr[1] + ' 23:59:59'];
  161. }
  162. function onLoadMore() {
  163. if (state.loadStatus !== 'noMore') {
  164. getLogList(state.pagination.current_page + 1);
  165. }
  166. }
  167. onReachBottom(() => {
  168. onLoadMore();
  169. });
  170. </script>
  171. <style lang="scss" scoped>
  172. .header-box {
  173. width: 100%;
  174. background: linear-gradient(180deg, var(--ui-BG-Main) 0%, var(--ui-BG-Main-gradient) 100%)
  175. no-repeat;
  176. background-size: 750rpx 100%;
  177. padding: 0 0 120rpx 0;
  178. box-sizing: border-box;
  179. .score-box {
  180. height: 100%;
  181. .all-num {
  182. font-size: 50rpx;
  183. font-weight: bold;
  184. color: #fff;
  185. font-family: OPPOSANS;
  186. }
  187. .all-title {
  188. font-size: 26rpx;
  189. font-weight: 500;
  190. color: #fff;
  191. }
  192. .cicon-help-o {
  193. color: #fff;
  194. font-size: 28rpx;
  195. }
  196. }
  197. }
  198. // 筛选
  199. .filter-box {
  200. height: 114rpx;
  201. background-color: $bg-page;
  202. .total-box {
  203. font-size: 24rpx;
  204. font-weight: 500;
  205. color: $dark-9;
  206. }
  207. .date-btn {
  208. background-color: $white;
  209. line-height: 54rpx;
  210. border-radius: 27rpx;
  211. padding: 0 20rpx;
  212. font-size: 24rpx;
  213. font-weight: 500;
  214. color: $dark-6;
  215. .ss-seldate-icon {
  216. font-size: 50rpx;
  217. color: $dark-9;
  218. }
  219. }
  220. }
  221. .list-box {
  222. .list-item {
  223. background: #fff;
  224. border-bottom: 1rpx solid #dfdfdf;
  225. padding: 30rpx;
  226. .name {
  227. font-size: 28rpx;
  228. font-weight: 500;
  229. color: rgba(102, 102, 102, 1);
  230. line-height: 28rpx;
  231. margin-bottom: 20rpx;
  232. }
  233. .time {
  234. font-size: 24rpx;
  235. font-weight: 500;
  236. color: rgba(196, 196, 196, 1);
  237. line-height: 24px;
  238. }
  239. .add {
  240. font-size: 30rpx;
  241. font-weight: 500;
  242. color: #e6b873;
  243. }
  244. .minus {
  245. font-size: 30rpx;
  246. font-weight: 500;
  247. color: $dark-3;
  248. }
  249. }
  250. }
  251. </style>