scoreAccumulate.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <view class="bg"><image src="../../static/img/integral.png" mode=""></image></view>
  6. <view class="body-title">
  7. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  8. <view class="header">我的积分</view>
  9. </view>
  10. <view>
  11. <view class="money">{{ userInfo.integral | getMoneyStyle }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="navbar">
  16. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  17. </view>
  18. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'px' }" class="swiper-box" duration="300" @change="changeTab">
  19. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  20. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  21. <!-- 空白页 -->
  22. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  23. <!-- 订单列表 -->
  24. <view v-for="(item, index) in tabItem.orderList" :key="index" class="order-item flex">
  25. <view class="title-box">
  26. <view class="title">
  27. <text>{{ item.mark }}</text>
  28. </view>
  29. <view class="time">
  30. <text>{{ item.add_time }}</text>
  31. </view>
  32. </view>
  33. <view class="money">
  34. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  35. </view>
  36. </view>
  37. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  38. </scroll-view>
  39. </swiper-item>
  40. </swiper>
  41. </view>
  42. </template>
  43. <script>
  44. import { integrallist } from '@/api/wallet.js';
  45. // import { mapState } from 'vuex';
  46. import { getMoneyStyle } from '@/utils/rocessor.js';
  47. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  48. import { mapState, mapMutations } from 'vuex';
  49. import empty from '@/components/empty';
  50. // #ifdef H5
  51. import { weixindata } from '@/utils/wxAuthorized';
  52. // #endif
  53. export default {
  54. filters: {
  55. getMoneyStyle
  56. },
  57. components: {
  58. empty,
  59. uniLoadMore
  60. },
  61. computed: {
  62. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  63. },
  64. onReady() {
  65. let obj = this;
  66. // 初始化获取页面高度
  67. uni.createSelectorQuery()
  68. .select('.content')
  69. .fields(
  70. {
  71. size: true
  72. },
  73. data => {
  74. // 初始化获取头部高度
  75. uni.createSelectorQuery()
  76. .select('.content-money')
  77. .fields(
  78. {
  79. size: true
  80. },
  81. es => {
  82. // 保存头部高度
  83. obj.maxheight = data.height - es.height - 40;
  84. }
  85. )
  86. .exec();
  87. }
  88. )
  89. .exec();
  90. },
  91. data() {
  92. return {
  93. // 头部图高度
  94. maxheight: '',
  95. tabCurrentIndex: 0,
  96. navList: [
  97. {
  98. state: 0,
  99. text: '积分明细',
  100. loadingType: 'more',
  101. orderList: [],
  102. page: 1, //当前页数
  103. limit: 10 //每次信息条数
  104. }
  105. ],
  106. money: ''
  107. };
  108. },
  109. onLoad(options) {
  110. let bool = uni.getStorageSync('weichatBrowser');
  111. if (bool) {
  112. // 加载微信信息
  113. weixindata();
  114. }
  115. },
  116. onShow() {
  117. this.loadData();
  118. },
  119. methods: {
  120. // ToChangeInto() {
  121. // // #ifdef H5
  122. // this.weichatObj.scanQRCode({
  123. // needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  124. // scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  125. // success: function(res) {
  126. // let result = JSON.parse(res.resultStr);
  127. // rechargemoneys({
  128. // id: result.id,
  129. // money: result.money
  130. // })
  131. // .then(({ data }) => {
  132. // uni.showModal({
  133. // title: '标题',
  134. // content: '成功',
  135. // showCancel: false
  136. // });
  137. // })
  138. // .catch(e => {
  139. // console.log(e);
  140. // });
  141. // }
  142. // });
  143. // // #endif
  144. // },
  145. // 页面跳转
  146. navto(e) {
  147. uni.navigateTo({
  148. url: e
  149. });
  150. },
  151. //获取收入支出信息
  152. async loadData(source) {
  153. //这里是将订单挂载到tab列表下
  154. let index = this.tabCurrentIndex;
  155. let navItem = this.navList[index];
  156. let state = navItem.state;
  157. if (source === 'tabChange' && navItem.loaded === true) {
  158. //tab切换只有第一次需要加载数据
  159. return;
  160. }
  161. if (navItem.loadingType === 'loading' || navItem.loadingType === 'noMore') {
  162. //防止重复加载
  163. return;
  164. }
  165. // 修改当前对象状态为加载中
  166. navItem.loadingType = 'loading';
  167. integrallist({
  168. page: navItem.page,
  169. limit: navItem.limit
  170. })
  171. .then(({ data }) => {
  172. if (data.length > 0) {
  173. navItem.orderList = navItem.orderList.concat(data);
  174. console.log(navItem.orderList);
  175. navItem.page++;
  176. }
  177. if (navItem.limit == data.length) {
  178. //判断是否还有数据, 有改为 more, 没有改为noMore
  179. navItem.loadingType = 'more';
  180. return;
  181. } else {
  182. //判断是否还有数据, 有改为 more, 没有改为noMore
  183. navItem.loadingType = 'noMore';
  184. }
  185. uni.hideLoading();
  186. this.$set(navItem, 'loaded', true);
  187. })
  188. .catch(e => {
  189. console.log(e);
  190. });
  191. },
  192. //返回上一页面
  193. toBack() {
  194. console.log(111);
  195. uni.navigateBack({});
  196. },
  197. //swiper 切换
  198. changeTab(e) {
  199. this.tabCurrentIndex = e.target.current;
  200. this.loadData('tabChange');
  201. },
  202. //顶部tab点击
  203. tabClick(index) {
  204. this.tabCurrentIndex = index;
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss">
  210. page {
  211. background: #ffffff;
  212. height: 100%;
  213. padding: 0;
  214. }
  215. .content-money {
  216. padding-bottom: 30rpx;
  217. background: $page-color-base;
  218. }
  219. .money-box {
  220. background-color: $base-color;
  221. padding-top: var(--status-bar-height);
  222. height: 468rpx;
  223. color: #ffffff;
  224. text-align: center;
  225. justify-content: center;
  226. position: relative;
  227. .body-title {
  228. height: 80rpx;
  229. text-align: center;
  230. font-size: 35rpx;
  231. position: relative;
  232. .header {
  233. position: absolute;
  234. left: 0;
  235. top: 0;
  236. width: 100%;
  237. font-size: 36rpx;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. color: #fffeff;
  241. height: 80rpx;
  242. font-size: 32rpx;
  243. font-weight: 700;
  244. z-index: 9;
  245. display: flex;
  246. justify-content: center;
  247. align-items: center;
  248. }
  249. .goback-box {
  250. position: absolute;
  251. z-index: 10;
  252. left: 24rpx;
  253. top: 0;
  254. height: 80rpx;
  255. display: flex;
  256. align-items: center;
  257. }
  258. .goback {
  259. width: 30rpx;
  260. height: 36rpx;
  261. }
  262. }
  263. .bg {
  264. position: absolute;
  265. top: 0;
  266. left: 0;
  267. width: 100%;
  268. height: 100%;
  269. image {
  270. width: 100%;
  271. height: 100%;
  272. }
  273. }
  274. .money {
  275. position: relative;
  276. z-index: 10;
  277. font-size: 56rpx;
  278. height: 388rpx;
  279. line-height: 288rpx;
  280. }
  281. }
  282. .navbar {
  283. display: flex;
  284. height: 40px;
  285. padding: 0 5px;
  286. background: #fff;
  287. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  288. position: relative;
  289. z-index: 10;
  290. .nav-item {
  291. flex: 1;
  292. display: flex;
  293. justify-content: center;
  294. align-items: center;
  295. height: 100%;
  296. font-size: 15px;
  297. color: $font-color-dark;
  298. position: relative;
  299. &.current {
  300. color: $base-color;
  301. &:after {
  302. content: '';
  303. position: absolute;
  304. left: 50%;
  305. bottom: 0;
  306. transform: translateX(-50%);
  307. width: 44px;
  308. height: 0;
  309. border-bottom: 2px solid $base-color;
  310. }
  311. }
  312. }
  313. }
  314. // 列表
  315. .swiper-box {
  316. padding-top: 10rpx;
  317. .order-item {
  318. padding: 20rpx 30rpx;
  319. line-height: 1.5;
  320. .title-box {
  321. .title {
  322. font-size: $font-lg;
  323. color: $font-color-base;
  324. }
  325. .time {
  326. font-size: $font-base;
  327. color: $font-color-light;
  328. }
  329. }
  330. .money {
  331. color: #fd5b23;
  332. font-size: $font-lg;
  333. }
  334. }
  335. }
  336. .list-scroll-content {
  337. height: 100%;
  338. }
  339. .content {
  340. height: 100%;
  341. .empty-content {
  342. background-color: #ffffff;
  343. }
  344. }
  345. </style>