index.vue 5.4 KB

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