integralList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. methods: {
  78. // 切换tab
  79. changeTabs(index) {
  80. this.tabIndex = index;
  81. },
  82. // 懒加载
  83. handleLoadMore() {
  84. if (this.tabIndex == 0) {
  85. if (!this.isOver1) {
  86. this.pageIndex1++
  87. this.getIntegraList(1)
  88. }
  89. } else {
  90. if (!this.isOver2) {
  91. this.pageIndex2++
  92. this.getIntegraList(2)
  93. }
  94. }
  95. },
  96. // 获取全部商品
  97. getIntegraList(type) {
  98. NET.request(API.getIntegralList, {
  99. behavior: type,
  100. pageIndex: this['pageIndex' + type],
  101. pageSize: 10,
  102. }, 'POST').then(res => {
  103. this['isOver' + type] = res.data.integralList.length != 10
  104. this['integralList' + type] = this['integralList' + type].concat(res.data.integralList)
  105. }).catch(res => {
  106. this.$refs.uTips.show({
  107. title: '获取商品列表失败',
  108. type: 'warning',
  109. })
  110. })
  111. },
  112. },
  113. }
  114. </script>
  115. <style lang="less" scoped>
  116. page {
  117. width: 100%;
  118. height: 100%;
  119. }
  120. .container {
  121. width: 100%;
  122. height: 100%;
  123. float: left;
  124. background-color: #f7f7f7;
  125. .integral-mine-info {
  126. width: 100%;
  127. height: 180px;
  128. float: left;
  129. background-size: 100% 180px;
  130. background-position: center;
  131. background-repeat: no-repeat;
  132. background-image: url(@/static/images/integralBg.png);
  133. .integral-info-round {
  134. width: 118px;
  135. height: 118px;
  136. float: left;
  137. position: relative;
  138. left: 50%;
  139. transform: translateX(-50%);
  140. margin-top: 22px;
  141. background: #FFFFFF;
  142. border: 4px solid rgba(18, 148, 88, 0.38);
  143. border-radius: 50%;
  144. .integral-number {
  145. width: 100%;
  146. height: 40px;
  147. float: left;
  148. margin: 26px 0 4px 0;
  149. font-size: 36px;
  150. font-family: PingFang SC;
  151. color: #52A63A;
  152. line-height: 40px;
  153. text-align: center;
  154. }
  155. .integral-text {
  156. width: 100%;
  157. height: 16px;
  158. float: left;
  159. font-size: 12px;
  160. font-family: PingFang SC;
  161. color: #52A63A;
  162. line-height: 16px;
  163. text-align: center;
  164. }
  165. }
  166. }
  167. .integral-list-box {
  168. width: calc(100% - 30px);
  169. height: calc(100% - 150px);
  170. float: left;
  171. margin: -30px 15px 0 15px;
  172. background-color: #FFFFFF;
  173. .integral-tab {
  174. width: 100%;
  175. height: 45px;
  176. float: left;
  177. border-bottom: 1px solid #EFEFEF;
  178. }
  179. .integral-list {
  180. width: 100%;
  181. height: calc(100% - 46px);
  182. float: left;
  183. .integral-row {
  184. width: 100%;
  185. height: 70px;
  186. float: left;
  187. box-sizing: border-box;
  188. border-bottom: 1px solid #EFEFEF;
  189. .integral-icon {
  190. width: 8px;
  191. height: 8px;
  192. float: left;
  193. margin: 22px 10px 0 10px;
  194. background: #52A63A;
  195. border-radius: 50%;
  196. }
  197. .integral-info {
  198. width: calc(100% - 120px);
  199. height: 100%;
  200. float: left;
  201. .integral-title {
  202. width: 100%;
  203. height: 18px;
  204. float: left;
  205. font-size: 15px;
  206. font-family: PingFang SC;
  207. color: #222222;
  208. line-height: 18px;
  209. margin: 16px 0 6px 0;
  210. }
  211. .integral-date {
  212. width: 100%;
  213. height: 16px;
  214. float: left;
  215. font-size: 12px;
  216. font-family: PingFang SC;
  217. color: #888888;
  218. line-height: 16px;
  219. }
  220. }
  221. .integral-number {
  222. width: 80px;
  223. height: 100%;
  224. float: right;
  225. margin-right: 12px;
  226. font-size: 15px;
  227. font-family: PingFang SC;
  228. font-weight: bold;
  229. color: #52A63A;
  230. line-height: 70px;
  231. text-align: right;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>