myIntegral.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="container">
  3. <view class="fixed_top_status_bar"></view>
  4. <view class="integral_top" :style="{backgroundImage:'url('+ top_bg +')'}">
  5. <image :src="imgUrl+'go_back.png'" mode="" class="go_back_icon" @click="goBack"></image>
  6. <text class="points_num">{{my_points}}</text>
  7. </view>
  8. <view class="integral_main">
  9. <view class="integral_title">
  10. <view :class="is_default?'active':'integral_title_item'" @click="changeStyle(1)">收入</view>
  11. <view :class="!is_default?'active':'integral_title_item'" @click="changeStyle(2)">支出</view>
  12. </view>
  13. <view class="integral_item_wrap">
  14. <view class="integral_item" v-for="(item,index) in info_list" :key="index">
  15. <view class="integral_item_title">
  16. <text>{{item.typeDesc}}</text>
  17. <text>{{is_default? '+':'-'}}{{item.value}}</text>
  18. </view>
  19. <view class="integral_item_content">{{item.description}}</view>
  20. <view class="integral_item_date">{{item.createTime}}</view>
  21. </view>
  22. <loadingState :state='loadingState' v-if="!is_show_empty"/>
  23. </view>
  24. <view class="empty_page" v-if="is_show_empty">
  25. <image :src="imgUrl+'empty_goods.png'" mode="" class="empty_img"></image>
  26. <view class="empty_text">{{$L('暂无数据')}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import loadingState from "@/components/loading-state.vue";
  33. export default{
  34. components:{
  35. loadingState
  36. },
  37. data(){
  38. return {
  39. top_bg:getApp().globalData.imgUrl+'points_bg.png',
  40. is_default:true, //是否默认选择收入
  41. my_points:'', //我的积分
  42. info_list:[], //收支列表
  43. current:1,
  44. pageSize:10,
  45. loadingState:'first_loading',
  46. type:1, //收入:1,支出:2
  47. imgUrl:getApp().globalData.imgUrl,
  48. is_show_empty:false,
  49. hasMore:false,
  50. }
  51. },
  52. onLoad(){
  53. this.getUserPoints()
  54. this.getPointsList(this.type)
  55. },
  56. onReachBottom(){
  57. if(this.hasMore){
  58. this.getPointsList(this.type)
  59. }
  60. },
  61. methods:{
  62. getUserPoints(){
  63. let param = {}
  64. param.url = 'v3/member/front/integralLog/getMemberIntegral'
  65. param.method = 'GET'
  66. this.$request(param).then(res=>{
  67. if(res.state == 200){
  68. this.my_points = res.data.memberIntegral
  69. }
  70. })
  71. },
  72. getPointsList(type){
  73. let param = {}
  74. param.url = 'v3/member/front/integralLog/list'
  75. param.method = 'POST'
  76. param.data = {
  77. type,
  78. current:this.current,
  79. pageSize:this.pageSize
  80. }
  81. this.$request(param).then(res=>{
  82. if(this.current == 1){
  83. this.info_list = res.data.list
  84. }else{
  85. this.info_list = this.info_list.concat(res.data.list);
  86. }
  87. this.hasMore = this.$checkPaginationHasMore(res.data.pagination); //是否还有数据
  88. if (this.hasMore) {
  89. this.current++;
  90. this.loadingState = 'allow_loading_more';
  91. } else {
  92. this.loadingState = 'no_more_data';
  93. }
  94. if(this.info_list.length == 0){
  95. this.is_show_empty = true;
  96. this.$forceUpdate();
  97. }else{
  98. this.is_show_empty = false;
  99. }
  100. })
  101. },
  102. // 切换收入支出
  103. changeStyle(type){
  104. this.is_default = type==1;
  105. this.type = type;
  106. this.current = 1;
  107. this.getPointsList(this.type)
  108. },
  109. // 返回上一页
  110. goBack(){
  111. // #ifdef H5
  112. const pages = getCurrentPages();
  113. //有返回的页面则直接返回,uni.navigateBack默认返回失败之后会自动刷新页面,无法继续返回
  114. if(pages.length > 1){
  115. uni.navigateBack(1)
  116. return;
  117. }
  118. //vue router 可以返回uni.navigateBack失败的页面,但是会重新加载
  119. let a = this.$router.go(-1);
  120. //router.go失败之后则重定向到个人中心
  121. if(a == undefined){
  122. uni.reLaunch({
  123. url:'/pages/user/user'
  124. })
  125. }
  126. return;
  127. // #endif
  128. uni.navigateBack({
  129. delta:1
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss">
  136. .fixed_top_status_bar {
  137. position: fixed;
  138. /* #ifdef APP-PLUS */
  139. height: var(--status-bar-height);
  140. /* #endif */
  141. /* #ifndef APP-PLUS */
  142. height: 0;
  143. /* #endif */
  144. /* #ifdef MP-WEIXIN */
  145. height: var(--status-bar-height);
  146. /* #endif */
  147. top: 0;
  148. left: 0;
  149. right: 0;
  150. z-index: 99;
  151. background: #fff;
  152. }
  153. .container{
  154. width: 750rpx;
  155. margin:0 auto;
  156. overflow-x: hidden;
  157. .integral_top{
  158. /* #ifdef APP-PLUS */
  159. margin-top: var(--status-bar-height);
  160. /* #endif */
  161. height:396rpx;
  162. background-size: 100% 100%;
  163. position: relative;
  164. .go_back_icon{
  165. width:50rpx;
  166. height:50rpx;
  167. position: absolute;
  168. left:25rpx;
  169. top:25rpx;
  170. /* #ifdef MP */
  171. top:70rpx;
  172. /* #endif */
  173. }
  174. .points_num{
  175. position: absolute;
  176. top:50%;
  177. left:50%;
  178. transform: translate(-50%,-50%);
  179. font-size:54rpx;
  180. color: #AD703A;
  181. background: linear-gradient(-90deg, #FFF6E1 0%, #FFD27A 100%);
  182. -webkit-background-clip: text;
  183. -webkit-text-fill-color: transparent;
  184. }
  185. }
  186. .integral_main{
  187. .integral_title{
  188. height:87rpx;
  189. font-size:32rpx;
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. padding:0 200rpx;
  194. border-bottom: 1rpx solid #F2F2F2;
  195. }
  196. .integral_item_wrap{
  197. padding-left:30rpx;
  198. box-sizing: border-box;
  199. .integral_item{
  200. padding:30rpx 30rpx 30rpx 0;
  201. border-bottom:1rpx solid #f2f2f2;
  202. .integral_item_title{
  203. font-weight: bold;
  204. display: flex;
  205. justify-content: space-between;
  206. }
  207. .integral_item_title text:nth-child(1){
  208. font-size:28rpx;
  209. color:#2d2d2d;
  210. }
  211. .integral_item_title text:nth-child(2){
  212. font-size:32rpx;
  213. color:#F30300;
  214. }
  215. .integral_item_content{
  216. font-size:28rpx;
  217. color:#666;
  218. margin-top:10rpx;
  219. }
  220. .integral_item_date{
  221. font-size:24rpx;
  222. color:#999;
  223. margin-top:10rpx;
  224. }
  225. }
  226. }
  227. .integral_item_wrap>view:nth-last-child(1){
  228. border-bottom: none;
  229. }
  230. }
  231. }
  232. .active{
  233. height:100%;
  234. display: flex;
  235. align-items: center;
  236. color:#FC1C1C;
  237. font-weight: bold;
  238. border-bottom: 6rpx solid #FC1C1C;
  239. box-sizing:border-box;
  240. }
  241. .empty_page{
  242. display: flex;
  243. flex-direction: column;
  244. justify-content: center;
  245. align-items: center;
  246. margin-top:150rpx;
  247. .empty_img{
  248. width:210rpx;
  249. height: 210rpx;
  250. margin-bottom:20rpx;
  251. }
  252. .empty_text{
  253. font-size:26rpx;
  254. color:#666;
  255. }
  256. }
  257. </style>