score.vue 6.1 KB

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