scoreAccumulate.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="content">
  3. <view class="top-bg">
  4. </view>
  5. <view class="yue-wrap flex">
  6. <view class="yue-tit">
  7. 总积分
  8. </view>
  9. <view class="yue-num flex">
  10. <view class="yue">
  11. {{userInfo.integral || '0.00'}}
  12. </view>
  13. <!-- <view class="cz" @click="navto('/pages/money/recharge')">
  14. 充值
  15. <image src="../../static/icon/dz.png" mode="widthFix"></image>
  16. </view> -->
  17. </view>
  18. <view class="lj-wrap flex">
  19. <view class="">
  20. <!-- 累计消费:¥{{ userInfo.orderStatusSum || '0'}} -->
  21. </view>
  22. <view class="">
  23. <!-- 累计充值:¥{{ userInfo.recharge || '0' }} -->
  24. </view>
  25. </view>
  26. </view>
  27. <scroll-view scroll-y="true" class="jl-wrap" :style="{'height': maxheight}" @scrolltolower="loadData">
  28. <view>
  29. <empty v-if="navList[tabCurrentIndex].orderList.length == 0 && navList[tabCurrentIndex].loaded" ></empty>
  30. <view class="jl " v-for="item in navList[tabCurrentIndex].orderList">
  31. <view class="jl-tit flex">
  32. <view class="clamp2 tit">
  33. {{item.mark}}
  34. </view>
  35. <view class="price" :class="{'add':item.pm == 1,'jian': item.pm == 0}">
  36. {{item.number*1}}
  37. </view>
  38. </view>
  39. <view class="jl-mark flex">
  40. <!-- <view class="mark">
  41. {{item.mark}}
  42. </view> -->
  43. <view class="">
  44. {{item.add_time}}
  45. </view>
  46. </view>
  47. </view>
  48. <uni-load-more :status="navList[tabCurrentIndex].loadingType" v-if="!(navList[tabCurrentIndex].orderList.length == 0 && navList[tabCurrentIndex].loaded)"></uni-load-more>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </template>
  53. <script>
  54. import { mapState, mapMutations } from 'vuex';
  55. import { integrallist } from '@/api/functionalUnit.js';
  56. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  57. import empty from '@/components/empty';
  58. export default {
  59. components: {
  60. empty,
  61. uniLoadMore
  62. },
  63. computed: {
  64. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  65. },
  66. onReady(res) {
  67. var obj = this;
  68. uni.getSystemInfo({
  69. success: resu => {
  70. const query = uni.createSelectorQuery();
  71. query.select('.swiper-box').boundingClientRect();
  72. query.exec(function(res) {
  73. obj.height = resu.windowHeight - res[0].top + 'px';
  74. console.log('打印页面的剩余高度', obj.height);
  75. });
  76. },
  77. fail: res => {}
  78. });
  79. },
  80. data() {
  81. return {
  82. height: '',
  83. maxheight: 0,
  84. tabCurrentIndex: 0,
  85. navList: [
  86. {
  87. state: 1,
  88. text: '收入',
  89. loadingType: 'more',
  90. orderList: [],
  91. page: 1, //当前页面
  92. limit: 10 //每次信息条数
  93. },
  94. {
  95. state: 0,
  96. text: '支出',
  97. loadingType: 'more',
  98. orderList: [],
  99. page: 1, //当前页面
  100. limit: 10 //每次信息条数
  101. }
  102. ],
  103. score: 0 //积分
  104. };
  105. },
  106. onShow() {
  107. // 载入积分数据
  108. this.loadData();
  109. },
  110. onReady() {
  111. // 初始化获取页面宽度
  112. var obj = this;
  113. uni.getSystemInfo({
  114. success: resu => {
  115. const query = uni.createSelectorQuery();
  116. query.select('.jl-wrap').boundingClientRect();
  117. query.exec(function(res) {
  118. obj.maxheight = resu.windowHeight - res[0].top + 'px';
  119. });
  120. },
  121. fail: res => {}
  122. });
  123. },
  124. methods: {
  125. // 页面跳转
  126. navto(e) {
  127. uni.navigateTo({
  128. url: e
  129. });
  130. },
  131. //获取收入支出信息
  132. async loadData(source) {
  133. //这里是将订单挂载到tab列表下
  134. let index = this.tabCurrentIndex;
  135. let navItem = this.navList[index];
  136. let state = navItem.state;
  137. if (source === 'tabChange' && navItem.loaded === true) {
  138. //tab切换只有第一次需要加载数据
  139. return;
  140. }
  141. if (navItem.loadingType === 'loading') {
  142. //防止重复加载
  143. return;
  144. }
  145. // 修改当前对象状态为加载中
  146. navItem.loadingType = 'loading';
  147. integrallist(
  148. {
  149. page: navItem.page,
  150. limit: navItem.limit
  151. }
  152. )
  153. .then(({ data }) => {
  154. console.log(data);
  155. if (data.length > 0) {
  156. let list = [];
  157. data.forEach(item => {
  158. list.push(item);
  159. });
  160. navItem.orderList = navItem.orderList.concat(list);
  161. navItem.page++;
  162. }
  163. if (navItem.limit == data.length) {
  164. //判断是否还有数据, 有改为 more, 没有改为noMore
  165. navItem.loadingType = 'more';
  166. return;
  167. } else {
  168. //判断是否还有数据, 有改为 more, 没有改为noMore
  169. navItem.loadingType = 'noMore';
  170. }
  171. uni.hideLoading();
  172. this.$set(navItem, 'loaded', true);
  173. })
  174. .catch(e => {
  175. console.log(e);
  176. });
  177. },
  178. //swiper 切换
  179. changeTab(e) {
  180. this.tabCurrentIndex = e.target.current;
  181. this.loadData('tabChange');
  182. },
  183. //顶部tab点击
  184. tabClick(index) {
  185. this.tabCurrentIndex = index;
  186. }
  187. }
  188. };
  189. </script>
  190. <style lang="scss">
  191. page {
  192. background-color: #fff;
  193. height: auto;
  194. min-height: 100%;
  195. }
  196. .top-bg {
  197. background-color: #ee2f72;
  198. height: 180rpx;
  199. width: 750rpx;
  200. }
  201. .yue-wrap {
  202. width: 670rpx;
  203. height: 320rpx;
  204. margin: -160rpx auto 30rpx;
  205. background: linear-gradient(-70deg, #FF77A7, #FF4A8A);
  206. box-shadow: 0px 15rpx 22rpx 6rpx rgba(238, 47, 114, 0.1);
  207. border-radius: 25rpx;
  208. color: #fff;
  209. font-size: 26rpx;
  210. padding: 50rpx 75rpx;
  211. flex-direction: column;
  212. justify-content: space-between;
  213. align-items: flex-start;
  214. .yue-num {
  215. width: 100%;
  216. justify-content: space-between;
  217. .yue {
  218. font-size: 76rpx;
  219. font-weight: bold;
  220. }
  221. .cz {
  222. image {
  223. width: 13rpx;
  224. margin-left: 10rpx;
  225. }
  226. }
  227. }
  228. .lj-wrap {
  229. width: 100%;
  230. justify-content: space-between;
  231. font-size: 24rpx;
  232. }
  233. }
  234. .jl {
  235. width: 670rpx;
  236. margin: 0 auto 20rpx;
  237. padding: 35rpx 30rpx;
  238. background: #FFFFFF;
  239. box-shadow: 0px 0px 28px 0px rgba(48, 48, 48, 0.1);
  240. border-radius: 8px;
  241. .jl-tit {
  242. width: 100%;
  243. font-size: 28rpx;
  244. font-weight: bold;
  245. color: #333333;
  246. .tit {
  247. max-width: 450rpx;
  248. }
  249. .price {
  250. font-size: 38rpx;
  251. font-weight: bold;
  252. }
  253. .add {
  254. color: #EE2F72;
  255. &::before {
  256. content: '+';
  257. font-size: 28rpx;
  258. color: #EE2F72;
  259. }
  260. }
  261. .jian {
  262. color: #808080;
  263. &::before {
  264. content: '-';
  265. font-size: 28rpx;
  266. }
  267. }
  268. }
  269. .jl-mark {
  270. padding-top: 20rpx;
  271. width: 100%;
  272. font-size: 24rpx;
  273. font-weight: 500;
  274. color: #808080;
  275. align-items: flex-start;
  276. // justify-content: flex-end;
  277. .mark {
  278. max-width: 470rpx;
  279. }
  280. }
  281. }
  282. </style>