score.vue 6.2 KB

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