UserInfoAiList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!-- 用户信息列表 -->
  2. <template>
  3. <s-layout :bgStyle="{ color: '#FFF' }" title="用户信息">
  4. <view>
  5. <s-userinfoai-item
  6. v-for="item in state.list"
  7. :key="item.id"
  8. :item="item"
  9. hasBorderBottom
  10. @tap="onSelect(item)"
  11. />
  12. </view>
  13. <su-fixed bottom placeholder>
  14. <view class="footer-box ss-flex ss-row-between ss-p-20">
  15. <button
  16. class="add-btn ss-reset-button ui-Shadow-Main"
  17. @tap="sheep.$router.go('/pages/member/UserInfoAiEdit')"
  18. >
  19. 新增用户信息
  20. </button>
  21. </view>
  22. </su-fixed>
  23. <s-empty
  24. v-if="state.list.length === 0 && !state.loading"
  25. icon="/static/data-empty.png"
  26. text="暂无用户信息"
  27. />
  28. </s-layout>
  29. </template>
  30. <script setup>
  31. import { onBeforeMount, reactive } from 'vue';
  32. import { onLoad, onShow } from '@dcloudio/uni-app';
  33. import sheep from '@/sheep';
  34. import AreaApi from '@/sheep/api/system/area';
  35. import UserInfoAiApi from '@/sheep/api/member/UserInfoAi';
  36. const state = reactive({
  37. list: [], // 地址列表
  38. loading: true,
  39. openType: '', // 页面打开类型
  40. });
  41. // 选择用户信息
  42. const onSelect = (userinfoaiInfo) => {
  43. if (state.openType !== 'select') {
  44. // 不作为选择组件时阻断操作
  45. return;
  46. }
  47. uni.$emit('SELECT_USERINFOAI', {
  48. userinfoaiInfo,
  49. });
  50. sheep.$router.back();
  51. };
  52. onLoad((option) => {
  53. if (option.type) {
  54. state.openType = option.type;
  55. }
  56. });
  57. onShow(async () => {
  58. state.list = (await UserInfoAiApi.getUserInfoAiList()).data;
  59. state.loading = false;
  60. });
  61. onBeforeMount(() => {
  62. if (!!uni.getStorageSync('areaData')) {
  63. return;
  64. }
  65. // 提前加载省市区数据
  66. AreaApi.getAreaTree().then((res) => {
  67. if (res.code === 0) {
  68. uni.setStorageSync('areaData', res.data);
  69. }
  70. });
  71. });
  72. </script>
  73. <style lang="scss" scoped>
  74. .footer-box {
  75. .add-btn {
  76. flex: 1;
  77. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  78. border-radius: 80rpx;
  79. font-size: 30rpx;
  80. font-weight: 500;
  81. line-height: 80rpx;
  82. color: $white;
  83. position: relative;
  84. z-index: 1;
  85. }
  86. .sync-wxuserinfoai {
  87. flex: 1;
  88. line-height: 80rpx;
  89. background: $white;
  90. border-radius: 80rpx;
  91. font-size: 30rpx;
  92. font-weight: 500;
  93. color: $dark-6;
  94. margin-right: 18rpx;
  95. }
  96. }
  97. </style>