金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
6.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="积分" :showIcon="true" :spreadOut="false" bgColor="transparent" titleColor="#fff"></lf-nav>
  4. <view class="head">
  5. <view class="bg-left"></view>
  6. <view class="bg-right"></view>
  7. <view class="head-content">
  8. <view>
  9. <text class="lf-iconfont icon-jifen lf-font-50"></text>
  10. </view>
  11. <view class="point">{{point_data.point}}</view>
  12. <view class="head-menu">
  13. <view @click="$url('/pages/point/shoppingMall/shoppingMall')">
  14. <text class="lf-m-r-10">兑换礼品</text>
  15. <text class="lf-iconfont icon-xiangyou lf-font-20"></text>
  16. </view>
  17. <view @click="$url('/pages/point/rule/rule')">
  18. <text class="lf-m-r-10">积分规则</text>
  19. <text class="lf-iconfont icon-xiangyou lf-font-20"></text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="main">
  25. <view class="lf-row-between lf-m-b-30">
  26. <view class="lf-font-32 lf-color-black lf-font-bold">积分变动明细</view>
  27. <picker mode='date' :value="date" @change="dateChange">
  28. <view style="width: 440rpx; text-align: right;">
  29. <text>{{ date || nowDate }}</text>
  30. <text class="lf-iconfont icon-xiangyou lf-font-24 lf-m-l-10"></text>
  31. </view>
  32. </picker>
  33. </view>
  34. <scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
  35. @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  36. <view class="item" v-for="(item, index) in list" :key="index">
  37. <view class="lf-row-between">
  38. <text class="lf-font-36 lf-color-black lf-font-bold" :class="{'lf-color-price': item.ifNegative}">{{ item.value }}</text>
  39. <text class="lf-font-24 lf-color-777">{{item.created_at}}</text>
  40. </view>
  41. <view class="lf-m-t-20">
  42. <text class="lf-font-24 lf-color-555">{{item.note}}</text>
  43. </view>
  44. </view>
  45. <!-- 空数据的情况 -->
  46. <view class="loading-more">
  47. <text v-if="list.length != 0"
  48. :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  49. <lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data(){
  58. return {
  59. date: '',
  60. nowDate: '',
  61. point_data: '',
  62. list: [],
  63. page: 1,
  64. isPage: true,
  65. loadingClass: true,
  66. loadingText: '正在加载中',
  67. scrollH: 0,
  68. nav_height: 0,
  69. isRefresher: true,
  70. pageSize: 10
  71. }
  72. },
  73. computed: {
  74. autoHeight(){
  75. return `calc(${this.scrollH}px - ${this.nav_height}px - 660rpx)`;
  76. }
  77. },
  78. onLoad(){
  79. let info = uni.getSystemInfoSync();
  80. this.scrollH = info.screenHeight;
  81. var date1 = new Date();
  82. var date2 = new Date(date1);
  83. date2.setDate(date1.getDate());
  84. this.nowDate = this.$shared.recordTime(date2, '-', 'date')
  85. this.getPointNum();
  86. this.getPointList();
  87. },
  88. methods: {
  89. dateChange(event){
  90. this.date = event.detail.value;
  91. this.getPointList();
  92. },
  93. getPointNum(){
  94. this.$http.get({
  95. api: 'api/users/point',
  96. header: {
  97. Authorization: this.$cookieStorage.get('user_token')
  98. }
  99. }).then(res => {
  100. this.point_data = res.data.data
  101. console.log(this.point_data)
  102. })
  103. },
  104. // 页面触底,加载下一页
  105. onScrolltolower(){
  106. if(this.isPage){
  107. this.page = this.page + 1;
  108. this.getPointList();
  109. }
  110. },
  111. // 下拉刷新处理
  112. refreshFn(options){
  113. this.page = 1;
  114. this.isPage = true;
  115. this.loadingClass = true;
  116. this.list = []
  117. this.loadingText = '正在加载中';
  118. this.getPointList(options);
  119. },
  120. // scroll-view 下拉刷新
  121. onRefresherrefresh(){
  122. this.isRefresher = true;
  123. this.refreshFn({type: 'scrollRefresh'});
  124. },
  125. getPointList(options = {}){
  126. this.$http.get({
  127. api: 'api/users/point/list',
  128. data: {
  129. day: this.date || this.nowDate
  130. },
  131. header: {
  132. Authorization: this.$cookieStorage.get('user_token')
  133. }
  134. }).then(res => {
  135. console.log("----", res);
  136. let isPage = this.page < res.data.meta.pagination.total_pages?true:false;
  137. this.isPage = isPage;
  138. if(!isPage) {
  139. this.loadingClass = false;
  140. this.loadingText = '没有更多数据啦~';
  141. }
  142. if(options.type == 'pageRefresh') {
  143. uni.stopPullDownRefresh();
  144. }else if(options.type == 'scrollRefresh') {
  145. this.isRefresher = false;
  146. }
  147. if(this.page == 1) {
  148. let list = res.data.data;
  149. list.forEach((item,index) => {
  150. if(item.value.indexOf('-') != -1) {
  151. this.$set(item,'ifNegative',true)
  152. }else {
  153. this.$set(item,'ifNegative',false)
  154. }
  155. })
  156. this.list = list;
  157. }else {
  158. let list = res.data.data;
  159. list.forEach((item,index) => {
  160. if(item.value.indexOf('-') != -1) {
  161. this.$set(item,'ifNegative',true)
  162. }else {
  163. this.$set(item,'ifNegative',false)
  164. }
  165. })
  166. this.list.push(...list);
  167. }
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style>
  174. page{
  175. overflow-x: hidden;
  176. }
  177. </style>
  178. <style lang="scss" scoped="scoped">
  179. .head{
  180. width: 750rpx;
  181. height: 512rpx;
  182. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  183. position: relative;
  184. overflow: hidden;
  185. display: flex;
  186. align-items: flex-end;
  187. box-sizing: border-box;
  188. padding: 60rpx 32rpx;
  189. color: #FFFFFF;
  190. .bg-left{
  191. position: absolute;
  192. width: 196rpx;
  193. height: 196rpx;
  194. border-radius: 50%;
  195. background-color: rgba(255,255,255,0.04);
  196. left: -92rpx;
  197. bottom: 60rpx;
  198. }
  199. .bg-right{
  200. position: absolute;
  201. width: 520rpx;
  202. height: 520rpx;
  203. border-radius: 50%;
  204. background-color: rgba(255,255,255,0.04);
  205. right: -168rpx;
  206. top: -122rpx;
  207. }
  208. .head-content{
  209. width: 100%;
  210. display: flex;
  211. flex-direction: column;
  212. justify-content: center;
  213. align-items: center;
  214. &>view{
  215. width: 100%;
  216. text-align: center;
  217. }
  218. .head-menu{
  219. display: flex;
  220. justify-content: space-between;
  221. padding: 0 78rpx;
  222. font-size: 24rpx;
  223. margin-top: 50rpx;
  224. }
  225. .point{
  226. font-size: 72rpx;
  227. letter-spacing: 2rpx;
  228. font-weight: bold;
  229. word-break: break-all;
  230. line-height: 1;
  231. margin-top: 10rpx;
  232. }
  233. }
  234. }
  235. .main{
  236. padding: 30rpx 32rpx;
  237. width: 750rpx;
  238. height: max-content;
  239. box-sizing: border-box;
  240. .item{
  241. width: 686rpx;
  242. height: max-content;
  243. background: #F4F8F8;
  244. border-radius: 10rpx;
  245. margin-bottom: 26rpx;
  246. padding: 30rpx;
  247. box-sizing: border-box;
  248. line-height: 1;
  249. }
  250. }
  251. </style>