金诚优选前端代码
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.

144 lines
3.5 KiB

  1. <template>
  2. <view id="pusher">
  3. <block v-for="(items, idx) in twitterList" :key="idx" >
  4. <view class="vipManage-item" v-for="(item, index) in items" :key="index" >
  5. <image :src="item.user.avatar"></image>
  6. <view class="item-right">
  7. <view class="username">
  8. <span class="nickname">{{item.user.nick_name}}</span>
  9. <!--<span class="grade">Vitem.grade</span>-->
  10. </view>
  11. <view class="vipdate">
  12. <span class="vipnum">会员号{{item.user_id}}</span>
  13. <span>加入日期{{item.user.created_at}}</span>
  14. </view>
  15. </view>
  16. </view>
  17. </block>
  18. <block v-if="twitterList && twitterList[0] && twitterList[0].length == 0 && init">
  19. <view class="no-data">暂无数据</view>
  20. </block>
  21. </view>
  22. </template>
  23. <script>
  24. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  25. export default {
  26. data() {
  27. return {
  28. twitterList: [],
  29. //推客列表
  30. page: 1,
  31. more: true,
  32. init: false
  33. };
  34. },
  35. onReachBottom() {
  36. if (this.more) {
  37. var page = this.page + 1;
  38. this.queryTwitterList(page);
  39. } else {
  40. wx.showToast({
  41. image: '../../../static/error.png',
  42. title: '再拉也没有啦'
  43. });
  44. }
  45. },
  46. onLoad() {
  47. this.queryTwitterList(1);
  48. },
  49. components: {},
  50. props: {},
  51. methods: {
  52. //请求推客列表
  53. queryTwitterList(page) {
  54. wx.showLoading({
  55. title: "加载中",
  56. mask: true
  57. });
  58. var token = this.$cookieStorage.get('user_token');
  59. this.$http.get({
  60. api: 'api/distribution/twitter/list',
  61. header: {
  62. Authorization: token
  63. },
  64. data: {
  65. page: page
  66. }
  67. }).then(res => {
  68. if (res.statusCode == 200) {
  69. res = res.data;
  70. if (res.status) {
  71. var pages = res.meta.pagination;
  72. var current_page = pages.current_page;
  73. var total_pages = pages.total_pages;
  74. // this.setData({
  75. // [`twitterList[${page - 1}]`]: res.data,
  76. // more: current_page < total_pages,
  77. // page: current_page,
  78. // init: true
  79. // });
  80. this.$set(this.twitterList, page -1, res.data);
  81. this.init=true;
  82. this.page=current_page;
  83. this.more=current_page < total_pages;
  84. } else {
  85. wx.showModal({
  86. content: res.message || '请求失败',
  87. showCancel: false
  88. });
  89. }
  90. } else {
  91. wx.showModal({
  92. content: res.message || '请求失败',
  93. showCancel: false
  94. });
  95. }
  96. wx.hideLoading();
  97. }).catch(rej => {
  98. wx.hideLoading();
  99. wx.showModal({
  100. content: res.message || '请求失败',
  101. showCancel: false
  102. });
  103. });
  104. },
  105. setData: function (obj) {
  106. let that = this;
  107. let keys = [];
  108. let val, data;
  109. Object.keys(obj).forEach(function (key) {
  110. keys = key.split('.');
  111. val = obj[key];
  112. data = that.$data;
  113. keys.forEach(function (key2, index) {
  114. if (index + 1 == keys.length) {
  115. that.$set(data, key2, val);
  116. } else {
  117. if (!data[key2]) {
  118. that.$set(data, key2, {});
  119. }
  120. }
  121. data = data[key2];
  122. });
  123. });
  124. }
  125. },
  126. computed: {},
  127. watch: {}
  128. };
  129. </script>
  130. <style rel="stylesheet/less" lang="less">
  131. @import "pusher";
  132. </style>