UserInfoAiList.vue 2.2 KB

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