index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <text>{{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 class="other">
  18. <view class="other_1">积分: <text class="integral">{{item.point}}</text></view>
  19. <view class="other_1">状态: <text>{{item.zhStatus}}</text></view>
  20. <view class="other_1">来源: <text>{{item.zhSource}}</text></view>
  21. <view class="other_1">时间: <text>{{item.time}}</text></view>
  22. </view>
  23. </view>
  24. </view>
  25. </scroll-view>
  26. </view>
  27. <view class="two_2" v-else>
  28. 已加载完全部
  29. </view>
  30. </view>
  31. </view>
  32. </mobile-frame>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. user: {},
  39. integral: '',
  40. list: [],
  41. total: 0,
  42. skip: 0,
  43. limit: 6,
  44. page: 0,
  45. // 状态
  46. statusList: [],
  47. // 来源
  48. sourceList: [],
  49. };
  50. },
  51. onShow: async function() {
  52. const that = this;
  53. await that.searchOther();
  54. await that.watchLogin();
  55. },
  56. methods: {
  57. watchLogin() {
  58. const that = this;
  59. uni.getStorage({
  60. key: 'token',
  61. success: function(res) {
  62. let user = that.$jwt(res.data);
  63. that.$set(that, `user`, user)
  64. that.search()
  65. }
  66. })
  67. },
  68. // 查询列表
  69. async search() {
  70. const that = this;
  71. let user = that.user;
  72. if (user._id) {
  73. let info = {
  74. skip: that.skip,
  75. limit: that.limit,
  76. customer: user._id,
  77. }
  78. let res = await that.$api(`/point`, 'GET', {
  79. ...info,
  80. })
  81. if (res.errcode == '0') {
  82. let list = [...that.list, ...res.data];
  83. for (let val of list) {
  84. let status = that.statusList.find(i => i.value == val.status)
  85. if (status) val.zhStatus = status.label;
  86. let source = that.sourceList.find(i => i.value == val.source)
  87. if (source) val.zhSource = source.label;
  88. }
  89. that.$set(that, `list`, list);
  90. that.$set(that, `total`, res.total)
  91. }
  92. let arr = await that.$api(`/point/computedTotal`, 'GET', {
  93. customer: user._id
  94. })
  95. if (arr.errcode == '0') that.$set(that, `integral`, arr.data);
  96. }
  97. },
  98. // 查询其他信息
  99. async searchOther() {
  100. const that = this;
  101. let res;
  102. res = await that.$api(`/dictData`, 'GET', {
  103. code: "point_status"
  104. });
  105. if (res.errcode == '0') {
  106. that.$set(that, `statusList`, res.data)
  107. }
  108. res = await that.$api(`/dictData`, 'GET', {
  109. code: "point_source"
  110. });
  111. if (res.errcode == '0') {
  112. that.$set(that, `sourceList`, res.data)
  113. }
  114. },
  115. // 分页
  116. toPage(e) {
  117. const that = this;
  118. let list = that.list;
  119. let limit = that.limit;
  120. if (that.total > list.length) {
  121. uni.showLoading({
  122. title: '加载中',
  123. mask: true
  124. })
  125. let page = that.page + 1;
  126. that.$set(that, `page`, page)
  127. let skip = page * limit;
  128. that.$set(that, `skip`, skip)
  129. that.search();
  130. uni.hideLoading();
  131. } else uni.showToast({
  132. title: '没有更多数据了',
  133. icon: 'none'
  134. });
  135. },
  136. // 清空列表
  137. clearPage() {
  138. const that = this;
  139. that.$set(that, `list`, [])
  140. that.$set(that, `skip`, 0)
  141. that.$set(that, `limit`, 6)
  142. that.$set(that, `page`, 0)
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .main {
  149. display: flex;
  150. flex-direction: column;
  151. width: 100vw;
  152. height: 100vh;
  153. .one {
  154. background-color: var(--fFB1Color);
  155. padding: 5vw 2vw;
  156. display: flex;
  157. justify-content: space-between;
  158. .one_1 {
  159. color: #fff;
  160. font-size: 25px;
  161. font-weight: bold;
  162. text:last-child {
  163. padding: 0 0 0 2vw;
  164. font-size: 15px;
  165. }
  166. }
  167. .one_2 {
  168. button {
  169. background: #fff;
  170. color: #ff0000;
  171. border-radius: 25px;
  172. font-size: 14px;
  173. }
  174. }
  175. }
  176. .two {
  177. position: relative;
  178. flex-grow: 1;
  179. padding: 2vw 0 0 0;
  180. .two_1 {
  181. .list {
  182. width: 92vw;
  183. border: 0.5vw solid var(--f1Color);
  184. margin: 2vw 2vw 0 1.5vw;
  185. padding: 2vw;
  186. border-radius: 5px;
  187. .other {
  188. .other_1 {
  189. font-size: var(--font16Size);
  190. margin: 0 0 1vw 0;
  191. .integral {
  192. color: #ff0000;
  193. }
  194. text {
  195. margin: 0 0 0 2vw;
  196. color: var(--f85Color);
  197. font-size: var(--font14Size);
  198. }
  199. }
  200. }
  201. }
  202. }
  203. .two_2 {
  204. text-align: center;
  205. color: #858585;
  206. font-size: 14px;
  207. margin: 5vw 0;
  208. }
  209. }
  210. }
  211. .scroll-view {
  212. position: absolute;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. bottom: 0;
  217. .list-scroll-view {
  218. display: flex;
  219. flex-direction: column;
  220. }
  221. }
  222. </style>