integralRecord.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="integralRecord">
  3. <!-- 分段器 -->
  4. <view class="segmented">
  5. <view class="tab_nav">
  6. <view class="navTitle" v-for="(item,index) in items" :key="index">
  7. <view :class="{'active':isActive == index}" @click="checked(index)">
  8. {{item}}
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. <!-- 占位 -->
  14. <view style="width: 100%; height: 112rpx; "></view>
  15. <view class="msg-null" v-if="incomeList.length == 0 && isActive == 0 ">
  16. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  17. <view class="msg-null-text">
  18. <text>暂无数据</text>
  19. </view>
  20. </view>
  21. <!-- 收入 -->
  22. <view class="List" v-if="isActive == 0 && incomeList.length > 0 ">
  23. <view class="ListItem" v-for="(item,index) in incomeList" :key="index">
  24. <view style="display: flex; justify-content: space-between;">
  25. <view class="title"><text>{{item.change_integral}}积分</text> </view>
  26. <view class='data'><text>{{item.created_at}}</text></view>
  27. </view>
  28. <view class="content" v-if="item.type==1"><text>投票奖励获得</text></view>
  29. <view class="content" v-if="item.type==2"><text>抽奖奖励获得</text></view>
  30. </view>
  31. </view>
  32. <view class="msg-null" v-if="spendingList.length == 0 && isActive == 1 ">
  33. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  34. <view class="msg-null-text">
  35. <text>暂无数据</text>
  36. </view>
  37. </view>
  38. <!-- 支出 -->
  39. <view class="List" :style="{'--height':ListHeight+'rpx'}" v-if="isActive == 1 && spendingList.length > 0" >
  40. <view class="ListItem" v-for="(item,index) in spendingList" :key="index" >
  41. <view style="display: flex; justify-content: space-between;">
  42. <view class="title"><text>{{item.change_integral}}积分</text> </view>
  43. <view class='data'><text>{{item.created_at}}</text></view>
  44. </view>
  45. <view class="content" v-if="item.type==3"><text>兑换商品消耗</text></view>
  46. <view class="content" v-if="item.type==4"><text>后台增加/减少</text></view>
  47. </view>
  48. </view>
  49. <!-- 已经到底啦 -->
  50. <view class="home-bottom" style="margin-top: 88rpx;padding-bottom: 60rpx;" v-if="isActive == 0 && incomeList.length > 0 ">
  51. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
  52. </view>
  53. <view class="home-bottom" style="margin-top: 88rpx;padding-bottom: 60rpx;" v-if="isActive == 1 && spendingList.length > 0 ">
  54. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default{
  60. data(){
  61. return{
  62. // 分段器
  63. items: ['收入', '支出',],
  64. isActive: 0,
  65. // list高度
  66. ListHeight: 800,
  67. contentText: {
  68. contentdown: '查看更多',
  69. contentrefresh: '加载中',
  70. contentnomore: '—— 已经到底啦 ——'
  71. },
  72. // 收入列表
  73. incomeList:[],
  74. // 支出列表
  75. spendingList:[],
  76. // 分页
  77. page: 1,
  78. pagesize: 15,
  79. totalElements: '',
  80. allListItem: '',
  81. // 组件uni-load-more
  82. status: 'noMore',
  83. }
  84. },
  85. onLoad() {
  86. // 收入
  87. this.getIntegralList(1)
  88. // 支出
  89. this.getIntegralList(2)
  90. },
  91. // 触底加载
  92. onReachBottom() {
  93. // 触底的时候请求数据,即为上拉加载更多
  94. var allTotal = this.page * this.pagesize
  95. console.log(allTotal, '----allTotal');
  96. //this.page为加载次数,this.pagesize为每一次加载的数据条数
  97. if(this.isActive + 1 == 1){
  98. if (allTotal < this.totalElements) {
  99. //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
  100. this.allListItem = false;
  101. this.page++;
  102. //加载次数递加
  103. this.status = "loading"
  104. this.$api.integral.getIntegralLog({ //请求更多数据列表
  105. page: this.page,
  106. type:this.isActive + 1
  107. }).then(res => {
  108. let ret = [...this.incomeList, ...res.data.data]
  109. this.incomeList = ret
  110. console.log(ret)
  111. })
  112. } else {
  113. this.allListItem = true;
  114. console.log('已加载全部数据')
  115. this.status = "noMore"
  116. }
  117. }else if(this.isActive + 1 == 2){
  118. if (allTotal < this.totalElements) {
  119. //this.totalElements为请求数据的总条数。只要现有条数小于总条数就就执行一下代码
  120. this.allListItem = false;
  121. this.page++;
  122. //加载次数递加
  123. this.status = "loading"
  124. this.$api.integral.getIntegralLog({ //请求更多数据列表
  125. page: this.page,
  126. type:this.isActive + 1
  127. }).then(res => {
  128. let ret = [...this.spendingList, ...res.data.data]
  129. this.spendingList = ret
  130. console.log(ret)
  131. })
  132. } else {
  133. this.allListItem = true;
  134. console.log('已加载全部数据')
  135. this.status = "noMore"
  136. }
  137. }
  138. },
  139. methods:{
  140. //菜单index切换
  141. checked(index) {
  142. this.isActive = index
  143. this.page = 1
  144. this.getIntegralList(this.isActive + 1)
  145. },
  146. // 获取积分日志
  147. getIntegralList(type){
  148. if(type==1){
  149. this.$api.integral.getIntegralLog({
  150. page:1,
  151. type:1
  152. }).then(res=>{
  153. console.log(res,'收入积分日志')
  154. if(res.code==0){
  155. this.incomeList=res.data.data
  156. this.totalElements = res.data.total
  157. this.pagesize = res.data.per_page
  158. }
  159. })
  160. } else if (type==2){
  161. this.$api.integral.getIntegralLog({
  162. page:1,
  163. type:2
  164. }).then(res=>{
  165. console.log(res,'支出积分日志')
  166. if(res.code==0){
  167. this.spendingList=res.data.data
  168. this.totalElements = res.data.total
  169. this.pagesize = res.data.per_page
  170. }
  171. })
  172. }else{
  173. uni.showToast({
  174. title:'请传入正确type值!',
  175. icon:'none'
  176. })
  177. }
  178. },
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. $pageColor:#F9F9F9;
  184. $bgColor:#FFFFFF;
  185. // flex布局居中对齐
  186. @mixin flexlayout {
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. }
  191. .integralRecord{
  192. height: 100%;
  193. background: $pageColor;
  194. }
  195. .msg-null{
  196. padding-top: 60rpx;
  197. display: flex;
  198. flex-direction: column;
  199. align-items: center;
  200. justify-content: center;
  201. .msg-null-text{
  202. margin-top: 40rpx;
  203. font-size: 28rpx;
  204. color: #333;
  205. }
  206. }
  207. .segmented{
  208. position: fixed;
  209. top: 0;
  210. z-index: 99;
  211. height: 112rpx;
  212. width: 100%;
  213. background: $bgColor;
  214. box-shadow: 0px 4rpx 8rpx 0px rgba(0,0,0,0.04);
  215. border-radius: 0px 0px 16rpx 16rpx;
  216. //菜单切换
  217. .tab_nav {
  218. width: 690rpx;
  219. margin-left: 30rpx;
  220. padding:0 80rpx;
  221. display: flex;
  222. justify-content: space-between;
  223. align-items: center;
  224. font-family: PingFang-SC-Heavy, PingFang-SC;
  225. margin-top: 14rpx;
  226. }
  227. .tab_nav .navTitle {
  228. @include flexlayout()
  229. margin-top: 20rpx;
  230. width: 128rpx;
  231. flex: none;
  232. height: 28rpx;
  233. font-size: 32rpx;
  234. color: #666;
  235. position: relative;
  236. }
  237. .active {
  238. color: #D9A94D;
  239. font-weight: bold;
  240. &::after {
  241. display: inline-block;
  242. content: '';
  243. width: 48rpx;
  244. height: 12rpx;
  245. background: linear-gradient(90deg, #F3D69F 0%, #D9A94D 100%);
  246. border-radius: 6px;
  247. position: absolute;
  248. bottom: -24rpx;
  249. left: 40rpx;
  250. }
  251. }
  252. }
  253. ::v-deep .segmented-control__text {
  254. font-size: 32rpx !important;
  255. font-family: PingFang-SC-Heavy, PingFang-SC;
  256. color: #666666 !important;
  257. }
  258. ::v-deep .segmented-control__item--text {
  259. font-size: 32rpx;
  260. font-family: PingFang-SC-Heavy, PingFang-SC;
  261. font-weight: 800 !important;
  262. padding: 10rpx 0 !important;
  263. border-radius: 4rpx !important;
  264. color: #D9A94D !important;
  265. }
  266. .List {
  267. width: 750rpx;
  268. background: $bgColor;
  269. box-shadow: 0px 4rpx 24rpx -10rpx rgba(101, 95, 90, 0.3);
  270. border-radius: 12rpx;
  271. margin-top: 24rpx;
  272. padding: 0rpx 28rpx 0 32rpx;
  273. box-sizing: border-box;
  274. .ListItem {
  275. width: 690rpx;
  276. border-bottom: #F0F0F0 solid 0.5rpx;
  277. position: relative;
  278. padding-top: 40rpx;
  279. padding-bottom: 40rpx;
  280. box-sizing: border-box;
  281. &:first-child{
  282. padding-top: 48rpx;
  283. }
  284. &:last-child{
  285. border-bottom: none;
  286. }
  287. .title {
  288. margin-bottom: 10rpx;
  289. text {
  290. font-size: 32rpx;
  291. font-family: PingFang-SC-Bold, PingFang-SC;
  292. font-weight: bold;
  293. color: #333333;
  294. }
  295. }
  296. .data {
  297. text {
  298. font-size: 26rpx;
  299. font-family: PingFang-SC-Medium, PingFang-SC;
  300. color: #999999;
  301. }
  302. }
  303. .content {
  304. text {
  305. font-size: 28rpx;
  306. font-family: PingFang-SC-Medium, PingFang-SC;
  307. color: #333333;
  308. }
  309. }
  310. }
  311. // 消除最后一个下划线
  312. .ListItem:last-child {
  313. width: 690rpx;
  314. height: 160rpx;
  315. border-bottom: #F0F0F0 solid 0rpx;
  316. position: relative;
  317. padding-top: 35rpx;
  318. box-sizing: border-box;
  319. .title {
  320. margin-bottom: 10rpx;
  321. text {
  322. font-size: 32rpx;
  323. font-family: PingFang-SC-Bold, PingFang-SC;
  324. font-weight: bold;
  325. color: #333333;
  326. }
  327. }
  328. .data {
  329. text {
  330. font-size: 26rpx;
  331. font-family: PingFang-SC-Medium, PingFang-SC;
  332. color: #999999;
  333. }
  334. }
  335. .content {
  336. text {
  337. font-size: 28rpx;
  338. font-family: PingFang-SC-Medium, PingFang-SC;
  339. color: #333333;
  340. }
  341. }
  342. }
  343. }
  344. </style>