list.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="authorization-list">
  3. <view class="rf-list" v-if="thirdPartyAuthList.length > 0">
  4. <view
  5. class="rf-list-item"
  6. v-for="(item, index) in thirdPartyAuthList"
  7. :key="index"
  8. >
  9. <view class="left">
  10. <image class="head_portrait" :src="item.head_portrait"></image>
  11. </view>
  12. <view class="mid">
  13. <view class="title">
  14. <text class="iconfont icon iconweixinzhifu"></text>
  15. <text class="address">{{
  16. item.oauth_client | oauthClientFilter
  17. }}</text>
  18. </view>
  19. <view class="time">
  20. <text>授权时间: {{ item.updated_at | time }}</text>
  21. </view>
  22. </view>
  23. <view class="right">
  24. <text class="rf-button" :class="'bg-' + themeColor.name" @tap.stop="unBind(item.id)">解除绑定</text>
  25. </view>
  26. </view>
  27. <rf-load-more
  28. :status="loadingType"
  29. v-if="thirdPartyAuthList.length > 0"
  30. />
  31. </view>
  32. <rf-empty
  33. :info="'您暂未授权第三方平台~'"
  34. v-if="thirdPartyAuthList.length === 0 && !loading"
  35. ></rf-empty>
  36. <!--加载动画-->
  37. <rfLoading isFullScreen :active="loading"></rfLoading>
  38. </view>
  39. </template>
  40. <script>
  41. import { thirdPartyAuthDelete, thirdPartyAuthList } from '@/api/userInfo';
  42. import moment from '@/common/moment';
  43. import rfLoadMore from '@/components/rf-load-more/rf-load-more';
  44. export default {
  45. components: {
  46. rfLoadMore
  47. },
  48. data() {
  49. return {
  50. page: 1,
  51. loadingType: 'more',
  52. thirdPartyAuthList: [],
  53. loading: true
  54. };
  55. },
  56. filters: {
  57. time(val) {
  58. return moment(val * 1000).format('YYYY-MM-DD HH:mm:ss');
  59. },
  60. oauthClientFilter(val) {
  61. switch (val) {
  62. case 'wechat':
  63. return '微信';
  64. case 'wechatMp':
  65. return '微信小程序';
  66. case 'qq':
  67. return 'QQ小程序';
  68. case 'sina':
  69. return '新浪';
  70. case 'wechatOP':
  71. return '微信开放平台';
  72. }
  73. }
  74. },
  75. // 加载更多
  76. onReachBottom() {
  77. if (this.loadingType === 'nomore') return;
  78. if (this.loadingType === 'nomore') return;
  79. this.page++;
  80. this.getThirdPartyAuthList();
  81. },
  82. onLoad() {
  83. this.initData();
  84. },
  85. methods: {
  86. // 数据初始化
  87. initData() {
  88. this.page = 1;
  89. this.thirdPartyAuthList.length = 0;
  90. this.getThirdPartyAuthList();
  91. },
  92. // 获取收货地址列表
  93. async getThirdPartyAuthList(type) {
  94. await this.$http
  95. .get(`${thirdPartyAuthList}`)
  96. .then(r => {
  97. this.loading = false;
  98. if (type === 'refresh') {
  99. uni.stopPullDownRefresh();
  100. }
  101. this.loadingType = r.data.length === 10 ? 'more' : 'nomore';
  102. this.thirdPartyAuthList = [...this.thirdPartyAuthList, ...r.data];
  103. })
  104. .catch(() => {
  105. this.loading = false;
  106. if (type === 'refresh') {
  107. uni.stopPullDownRefresh();
  108. }
  109. });
  110. },
  111. // 解绑第三方授权登录
  112. async unBind(id) {
  113. await this.$http.delete(`${thirdPartyAuthDelete}?id=${id}`).then(r => {
  114. this.page = 1;
  115. this.thirdPartyAuthList = [];
  116. this.getThirdPartyAuthList();
  117. });
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss">
  123. page {
  124. background-color: $page-color-base;
  125. }
  126. .authorization-list {
  127. .rf-list {
  128. .left {
  129. .head_portrait {
  130. width: 80upx;
  131. height: 80upx;
  132. margin: $spacing-lg $spacing-lg $spacing-lg 0;
  133. border-radius: 50%;
  134. }
  135. }
  136. .mid {
  137. flex: 1;
  138. .title {
  139. font-size: $font-lg;
  140. .iconweixinzhifu {
  141. margin-right: 10upx;
  142. color: #36cb59;
  143. }
  144. }
  145. .time {
  146. font-size: $font-sm;
  147. color: $font-color-light;
  148. }
  149. }
  150. .right {
  151. .rf-button {
  152. font-size: $font-sm;
  153. padding: 10upx 20upx;
  154. }
  155. }
  156. }
  157. }
  158. </style>