score.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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">
  14. <view class="bg" />
  15. </view>
  16. <view class="score-box ss-flex-col ss-row-center ss-col-center">
  17. <view class="ss-m-b-30">
  18. <text class="all-title ss-m-r-8">当前积分</text>
  19. </view>
  20. <text class="all-num">{{ userInfo.point || 0 }}</text>
  21. </view>
  22. </view>
  23. <!-- tab -->
  24. <su-sticky :customNavHeight="sys_navBar">
  25. <!-- 统计 -->
  26. <view class="filter-box ss-p-x-30 ss-flex ss-col-center ss-row-between">
  27. <uni-datetime-picker
  28. v-model="state.date"
  29. type="daterange"
  30. @change="onChangeTime"
  31. :end="state.today"
  32. >
  33. <button class="ss-reset-button date-btn">
  34. <text>{{ dateFilterText }}</text>
  35. <text class="cicon-drop-down ss-seldate-icon"></text>
  36. </button>
  37. </uni-datetime-picker>
  38. <!-- TODO 芋艿:优化 -->
  39. <!-- <view class="total-box">-->
  40. <!-- <view class="ss-m-b-10">总收入¥{{ state.pagination.income }}</view>-->
  41. <!-- <view>总支出¥{{ -state.pagination.expense }}</view>-->
  42. <!-- </view>-->
  43. </view>
  44. <su-tabs
  45. :list="tabMaps"
  46. @change="onChange"
  47. :scrollable="false"
  48. :current="state.currentTab"
  49. ></su-tabs>
  50. </su-sticky>
  51. <!-- list -->
  52. <view class="list-box">
  53. <view v-if="state.pagination.total > 0">
  54. <view
  55. class="list-item ss-flex ss-col-center ss-row-between"
  56. v-for="item in state.pagination.list"
  57. :key="item.id"
  58. >
  59. <view class="ss-flex-col">
  60. <view class="name"
  61. >{{ item.title }}{{ item.description ? ' - ' + item.description : '' }}</view
  62. >
  63. <view class="time">{{
  64. sheep.$helper.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss')
  65. }}</view>
  66. </view>
  67. <view class="add" v-if="item.point > 0">+{{ item.point }}</view>
  68. <view class="minus" v-else>{{ item.point }}</view>
  69. </view>
  70. </view>
  71. <s-empty v-else text="暂无数据" icon="/static/data-empty.png" />
  72. </view>
  73. <uni-load-more
  74. v-if="state.pagination.total > 0"
  75. :status="state.loadStatus"
  76. :content-text="{
  77. contentdown: '上拉加载更多',
  78. }"
  79. @tap="onLoadMore"
  80. />
  81. </s-layout>
  82. </template>
  83. <script setup>
  84. import sheep from '@/sheep';
  85. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  86. import { computed, reactive } from 'vue';
  87. import _ from 'lodash-es';
  88. import dayjs from 'dayjs';
  89. import PointApi from '@/sheep/api/member/point';
  90. import { resetPagination } from '@/sheep/util';
  91. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  92. const userInfo = computed(() => sheep.$store('user').userInfo);
  93. const sys_navBar = sheep.$platform.navbar;
  94. const state = reactive({
  95. currentTab: 0,
  96. pagination: {
  97. list: 0,
  98. total: 0,
  99. pageSize: 6,
  100. pageNo: 1,
  101. },
  102. loadStatus: '',
  103. date: [],
  104. today: '',
  105. });
  106. const tabMaps = [
  107. {
  108. name: '全部',
  109. value: 'all',
  110. },
  111. {
  112. name: '收入',
  113. value: 'true',
  114. },
  115. {
  116. name: '支出',
  117. value: 'false',
  118. },
  119. ];
  120. const dateFilterText = computed(() => {
  121. if (state.date[0] === state.date[1]) {
  122. return state.date[0];
  123. } else {
  124. return state.date.join('~');
  125. }
  126. });
  127. async function getLogList() {
  128. state.loadStatus = 'loading';
  129. let { code, data } = await PointApi.getPointRecordPage({
  130. pageNo: state.pagination.pageNo,
  131. pageSize: state.pagination.pageSize,
  132. addStatus: state.currentTab > 0 ? tabMaps[state.currentTab].value : undefined,
  133. 'createTime[0]': state.date[0] + ' 00:00:00',
  134. 'createTime[1]': state.date[1] + ' 23:59:59',
  135. });
  136. if (code !== 0) {
  137. return;
  138. }
  139. state.pagination.list = _.concat(state.pagination.list, data.list);
  140. state.pagination.total = data.total;
  141. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  142. }
  143. onLoad(() => {
  144. state.today = dayjs().format('YYYY-MM-DD');
  145. state.date = [state.today, state.today];
  146. getLogList();
  147. });
  148. function onChange(e) {
  149. state.currentTab = e.index;
  150. resetPagination(state.pagination);
  151. getLogList();
  152. }
  153. function onChangeTime(e) {
  154. state.date[0] = e[0];
  155. state.date[1] = e[e.length - 1];
  156. resetPagination(state.pagination);
  157. getLogList();
  158. }
  159. function onLoadMore() {
  160. if (state.loadStatus === 'noMore') {
  161. return;
  162. }
  163. state.pagination.pageNo++;
  164. getLogList();
  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>