integralList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="container">
  3. <view class="integral-mine-info">
  4. <view class="integral-info-round">
  5. <view class="integral-number" :style="{fontSize: integralData.usableIntegral >= 1000000 ? '26px' : (integralData.usableIntegral >= 100000 ? '31px' :'')}">
  6. {{integralData.usableIntegral}}
  7. </view>
  8. <view class="integral-text">可用积分</view>
  9. <view class="integral-text">累计{{integralData.totalIntegral}}</view>
  10. </view>
  11. </view>
  12. <view class="integral-list-box">
  13. <view class="integral-tab">
  14. <u-tabs :list="tabList" :is-scroll="false" :current="tabIndex" @change="changeTabs" font-size="30" active-color="#52A63A"
  15. inactive-color="#666666" :bold="false" height="90" bar-width="120"></u-tabs>
  16. </view>
  17. <scroll-view class="integral-list" scroll-y="true" @scrolltolower="handleLoadMore" v-if="!tabIndex">
  18. <view class="integral-row" v-for="(item, index) in integralList1" :key="index">
  19. <view class="integral-icon"></view>
  20. <view class="integral-info">
  21. <view class="integral-title">{{item.behaviorType == 1 ? '购物赠送' : (item.behaviorType == 2 ? '消费扣减' : '消费扣减')}}</view>
  22. <view class="integral-date">{{item.addTime}}</view>
  23. </view>
  24. <view class="integral-number">+{{item.integralValue}}</view>
  25. </view>
  26. </scroll-view>
  27. <scroll-view class="integral-list" scroll-y="true" @scrolltolower="handleLoadMore" v-else>
  28. <view class="integral-row" v-for="(item, index) in integralList2" :key="index">
  29. <view class="integral-icon"></view>
  30. <view class="integral-info">
  31. <view class="integral-title">{{item.behaviorType == 1 ? '购物赠送' : (item.behaviorType == 2 ? '消费扣减' : '消费扣减')}}</view>
  32. <view class="integral-date">{{item.reduceTime}}</view>
  33. </view>
  34. <view class="integral-number">-{{item.integralValue}}</view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. <u-top-tips ref="uTips"></u-top-tips>
  39. </view>
  40. </template>
  41. <script>
  42. const NET = require('@/utils/request')
  43. const API = require('@/config/api')
  44. export default {
  45. data() {
  46. return {
  47. integralData: {
  48. usableIntegral: 0,
  49. totalIntegral: 0,
  50. },
  51. tabIndex: 0,
  52. tabList: [{
  53. name: '收入积分'
  54. },
  55. {
  56. name: '支出积分'
  57. },
  58. ],
  59. pageIndex1: 1,
  60. isOver1: false,
  61. integralList1: [],
  62. pageIndex2: 1,
  63. isOver2: false,
  64. integralList2: [],
  65. }
  66. },
  67. onLoad() {
  68. NET.request(API.getIntegral, {}, 'POST').then(res => {
  69. this.integralData = res.data
  70. }).catch(res => {
  71. this.$refs.uTips.show({
  72. title: '获取个人积分失败',
  73. type: 'warning',
  74. })
  75. })
  76. this.getIntegraList(1)
  77. this.getIntegraList(2)
  78. },
  79. onPullDownRefresh() {
  80. this.pageIndex1 = 1
  81. this.integralList1 = []
  82. this.pageIndex2 = 1
  83. this.integralList2 = []
  84. this.getIntegraList(1, 'refresh')
  85. this.getIntegraList(2, 'refresh')
  86. },
  87. methods: {
  88. // 切换tab
  89. changeTabs(index) {
  90. this.tabIndex = index;
  91. },
  92. // 懒加载
  93. handleLoadMore() {
  94. if (this.tabIndex == 0) {
  95. if (!this.isOver1) {
  96. this.pageIndex1++
  97. this.getIntegraList(1)
  98. }
  99. } else {
  100. if (!this.isOver2) {
  101. this.pageIndex2++
  102. this.getIntegraList(2)
  103. }
  104. }
  105. },
  106. // 获取全部商品
  107. getIntegraList(type, refresh) {
  108. NET.request(API.getIntegralList, {
  109. behavior: type,
  110. pageIndex: this['pageIndex' + type],
  111. pageSize: 10,
  112. }, 'POST').then(res => {
  113. if (refresh == 'refresh') {
  114. uni.stopPullDownRefresh();
  115. }
  116. this['isOver' + type] = res.data.integralList.length != 10
  117. this['integralList' + type] = this['integralList' + type].concat(res.data.integralList)
  118. }).catch(res => {
  119. this.$refs.uTips.show({
  120. title: '获取商品列表失败',
  121. type: 'warning',
  122. })
  123. })
  124. },
  125. },
  126. }
  127. </script>
  128. <style>
  129. page {
  130. background-color: #f7f7f7;
  131. }
  132. </style>
  133. <style lang="less" scoped>
  134. page {
  135. width: 100%;
  136. height: 100%;
  137. }
  138. .container {
  139. width: 100%;
  140. height: 100%;
  141. float: left;
  142. background-color: #f7f7f7;
  143. .integral-mine-info {
  144. width: 100%;
  145. height: 180px;
  146. float: left;
  147. background-size: 100% 180px;
  148. background-position: center;
  149. background-repeat: no-repeat;
  150. background-image: url(@/static/images/integralBg.jpg);
  151. .integral-info-round {
  152. width: 118px;
  153. height: 118px;
  154. float: left;
  155. position: relative;
  156. left: 50%;
  157. transform: translateX(-50%);
  158. margin-top: 22px;
  159. background: #FFFFFF;
  160. border: 4px solid rgba(18, 148, 88, 0.38);
  161. border-radius: 50%;
  162. .integral-number {
  163. width: 100%;
  164. height: 40px;
  165. float: left;
  166. margin: 26px 0 4px 0;
  167. font-size: 36px;
  168. font-family: PingFang SC;
  169. color: #52A63A;
  170. line-height: 40px;
  171. text-align: center;
  172. }
  173. .integral-text {
  174. width: 100%;
  175. height: 16px;
  176. float: left;
  177. font-size: 12px;
  178. font-family: PingFang SC;
  179. color: #52A63A;
  180. line-height: 16px;
  181. text-align: center;
  182. }
  183. }
  184. }
  185. .integral-list-box {
  186. width: calc(100% - 30px);
  187. height: calc(100% - 150px);
  188. float: left;
  189. margin: -30px 15px 0 15px;
  190. background-color: #FFFFFF;
  191. .integral-tab {
  192. width: 100%;
  193. height: 45px;
  194. float: left;
  195. border-bottom: 1px solid #EFEFEF;
  196. }
  197. .integral-list {
  198. width: 100%;
  199. height: calc(100% - 46px);
  200. float: left;
  201. .integral-row {
  202. width: 100%;
  203. height: 70px;
  204. float: left;
  205. box-sizing: border-box;
  206. border-bottom: 1px solid #EFEFEF;
  207. .integral-icon {
  208. width: 8px;
  209. height: 8px;
  210. float: left;
  211. margin: 22px 10px 0 10px;
  212. background: #52A63A;
  213. border-radius: 50%;
  214. }
  215. .integral-info {
  216. width: calc(100% - 120px);
  217. height: 100%;
  218. float: left;
  219. .integral-title {
  220. width: 100%;
  221. height: 18px;
  222. float: left;
  223. font-size: 15px;
  224. font-family: PingFang SC;
  225. color: #222222;
  226. line-height: 18px;
  227. margin: 16px 0 6px 0;
  228. }
  229. .integral-date {
  230. width: 100%;
  231. height: 16px;
  232. float: left;
  233. font-size: 12px;
  234. font-family: PingFang SC;
  235. color: #888888;
  236. line-height: 16px;
  237. }
  238. }
  239. .integral-number {
  240. width: 80px;
  241. height: 100%;
  242. float: right;
  243. margin-right: 12px;
  244. font-size: 15px;
  245. font-family: PingFang SC;
  246. font-weight: bold;
  247. color: #52A63A;
  248. line-height: 70px;
  249. text-align: right;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. </style>