integralList.vue 6.2 KB

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