index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <text>{{user.integral||0}}</text><text>分</text>
  7. </view>
  8. <view class="one_2" style="display: none;">
  9. <button type="default" size="mini">礼品兑换记录</button>
  10. </view>
  11. </view>
  12. <view class="two">
  13. <view class="two_1" v-if="list&&list.length>0">
  14. scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  15. <view class="list-scroll-view">
  16. <view class="list" v-for="(item, index) in list" :key="index">
  17. </view>
  18. </view>
  19. </scroll-view>
  20. </view>
  21. <view class="two_2" v-else>
  22. 已加载完全部
  23. </view>
  24. </view>
  25. </view>
  26. </mobile-frame>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. user: {},
  33. list: [],
  34. total: 0,
  35. skip: 0,
  36. limit: 6,
  37. page: 0,
  38. // 状态
  39. statusList: [],
  40. // 来源
  41. sourceList: [],
  42. };
  43. },
  44. onShow: async function() {
  45. const that = this;
  46. await that.searchOther();
  47. await that.watchLogin();
  48. },
  49. methods: {
  50. watchLogin() {
  51. const that = this;
  52. uni.getStorage({
  53. key: 'token',
  54. success: function(res) {
  55. let user = that.$jwt(res.data);
  56. that.$set(that, `user`, user)
  57. that.search()
  58. }
  59. })
  60. },
  61. // 查询列表
  62. async search() {
  63. const that = this;
  64. let user = that.user;
  65. if (user._id) {
  66. let info = {
  67. skip: that.skip,
  68. limit: that.limit,
  69. customer: user._id,
  70. }
  71. let res = await that.$api(`/point`, 'GET', {
  72. ...info,
  73. })
  74. if (res.errcode == '0') {
  75. let list = [...that.list, ...res.data];
  76. that.$set(that, `list`, list);
  77. that.$set(that, `total`, res.total)
  78. }
  79. }
  80. },
  81. // 查询其他信息
  82. async searchOther() {
  83. const that = this;
  84. let res;
  85. res = await that.$api(`/dictData`, 'GET', {
  86. code: "point_status"
  87. });
  88. if (res.errcode == '0') {
  89. that.$set(that, `statusList`, res.data)
  90. }
  91. res = await that.$api(`/dictData`, 'GET', {
  92. code: "point_source"
  93. });
  94. if (res.errcode == '0') {
  95. that.$set(that, `sourceList`, res.data)
  96. }
  97. },
  98. // 分页
  99. toPage(e) {
  100. const that = this;
  101. let list = that.list;
  102. let limit = that.limit;
  103. if (that.total > list.length) {
  104. uni.showLoading({
  105. title: '加载中',
  106. mask: true
  107. })
  108. let page = that.page + 1;
  109. that.$set(that, `page`, page)
  110. let skip = page * limit;
  111. that.$set(that, `skip`, skip)
  112. that.search();
  113. uni.hideLoading();
  114. } else uni.showToast({
  115. title: '没有更多数据了',
  116. icon: 'none'
  117. });
  118. },
  119. // 清空列表
  120. clearPage() {
  121. const that = this;
  122. that.$set(that, `list`, [])
  123. that.$set(that, `skip`, 0)
  124. that.$set(that, `limit`, 6)
  125. that.$set(that, `page`, 0)
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. .main {
  132. display: flex;
  133. flex-direction: column;
  134. width: 100vw;
  135. height: 100vh;
  136. .one {
  137. background-color: var(--fFB1Color);
  138. padding: 5vw 2vw;
  139. display: flex;
  140. justify-content: space-between;
  141. .one_1 {
  142. color: #fff;
  143. font-size: 25px;
  144. font-weight: bold;
  145. text:last-child {
  146. padding: 0 0 0 2vw;
  147. font-size: 15px;
  148. }
  149. }
  150. .one_2 {
  151. button {
  152. background: #fff;
  153. color: #ff0000;
  154. border-radius: 25px;
  155. font-size: 14px;
  156. }
  157. }
  158. }
  159. .two {
  160. .two_2 {
  161. text-align: center;
  162. color: #858585;
  163. font-size: 14px;
  164. margin: 5vw 0;
  165. }
  166. }
  167. }
  168. .scroll-view {
  169. position: absolute;
  170. top: 0;
  171. left: 0;
  172. right: 0;
  173. bottom: 0;
  174. .list-scroll-view {
  175. display: flex;
  176. flex-direction: column;
  177. }
  178. }
  179. </style>