zrd 3 hónapja
szülő
commit
efeeba576b

+ 29 - 0
pages.json

@@ -385,6 +385,35 @@
         }
       ]
     },
+    {
+      "root": "pages/member",
+      "pages": [
+        {
+          "path": "UserInfoAiList",
+          "style": {
+            "navigationBarTitleText": "我的信息"
+          },
+          "meta": {
+            "auth": true,
+            "sync": true,
+            "title": "用户信息",
+            "group": "用户AI中心"
+          }
+        },
+        {
+          "path": "UserInfoAiEdit",
+          "style": {
+            "navigationBarTitleText": "新增我的信息"
+          },
+          "meta": {
+            "auth": true,
+            "sync": true,
+            "title": "新增用户信息",
+            "group": "用户AI中心"
+          }
+        }
+      ]
+    },
     {
       "root": "pages/user",
       "pages": [

+ 209 - 0
pages/member/UserInfoAiEdit.vue

@@ -0,0 +1,209 @@
+<!-- 用户信息的新增/编辑 -->
+<template>
+  <s-layout :title="state.model.id ? '编辑地址' : '新增用户信息'">
+    <uni-forms
+      ref="userinfoaiFormRef"
+      v-model="state.model"
+      :labelStyle="{ fontWeight: 'bold' }"
+      :rules="rules"
+      border
+      labelAlign="left"
+      labelWidth="160"
+      validateTrigger="bind"
+    >
+      <view class="bg-white form-box ss-p-x-30">
+        <uni-forms-item class="form-item" label="用户编号" name="userId">
+          <uni-easyinput
+            v-model="state.model.userId"
+            :inputBorder="false"
+            placeholder="请填写用户编号"
+            placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
+          />
+        </uni-forms-item>
+        <uni-forms-item
+          :formItemStyle="{ alignItems: 'flex-start' }"
+          :labelStyle="{ lineHeight: '5em' }"
+          class="textarea-item"
+          label="提取有效信息"
+          name="textInformation"
+        >
+          <uni-easyinput
+            v-model="state.model.textInformation"
+            :inputBorder="false"
+            clearable
+            placeholder="请输入提取有效信息"
+            placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
+            type="textarea"
+          />
+        </uni-forms-item>
+
+        <uni-forms-item
+          :formItemStyle="{ alignItems: 'flex-start' }"
+          :labelStyle="{ lineHeight: '5em' }"
+          class="textarea-item"
+          label="补充信息"
+          name="additionalInfo"
+        >
+          <uni-easyinput
+            v-model="state.model.additionalInfo"
+            :inputBorder="false"
+            clearable
+            placeholder="请输入补充信息"
+            placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
+            type="textarea"
+          />
+        </uni-forms-item>
+      </view>
+    </uni-forms>
+    <su-fixed :index="10" :noFixed="false" :opacity="false" bg="" bottom placeholder>
+      <view class="footer-box ss-flex-col ss-row-between ss-p-20">
+        <view class="ss-m-b-20">
+          <button class="ss-reset-button save-btn ui-Shadow-Main" @tap="onSave">保存</button>
+        </view>
+        <button v-if="state.model.id" class="ss-reset-button cancel-btn" @tap="onDelete">
+          删除
+        </button>
+      </view>
+    </su-fixed>
+  </s-layout>
+</template>
+
+<script setup>
+  import { reactive, ref, unref } from 'vue';
+  import sheep from '@/sheep';
+  import { onLoad } from '@dcloudio/uni-app';
+  import UserInfoAiApi from '@/sheep/api/member/UserInfoAi';
+
+  const userinfoaiFormRef = ref(null);
+  const state = reactive({
+    showRegion: false,
+    model: {
+      name: '',
+      mobile: '',
+      detailUserInfoAi: '',
+      defaultStatus: false,
+      areaName: '',
+    },
+    rules: {},
+  });
+
+  const rules = {
+    userId: {
+      rules: [
+        {
+          required: true,
+          errorMessage: '请输入用户编号',
+        },
+      ],
+    },
+  };
+
+  // 保存用户信息
+  const onSave = async () => {
+    // 参数校验
+    const validate = await unref(userinfoaiFormRef)
+      .validate()
+      .catch((error) => {
+        console.log('error: ', error);
+      });
+    if (!validate) {
+      return;
+    }
+
+    // 提交请求
+    const formData = {
+      ...state.model,
+    };
+    const { code } =
+      state.model.id > 0
+        ? await UserInfoAiApi.updateUserInfoAi(formData)
+        : await UserInfoAiApi.createUserInfoAi(formData);
+    if (code === 0) {
+      sheep.$router.back();
+    }
+  };
+
+  // 删除用户信息
+  const onDelete = () => {
+    uni.showModal({
+      title: '提示',
+      content: '确认删除此用户信息吗?',
+      success: async function (res) {
+        if (!res.confirm) {
+          return;
+        }
+        const { code } = await UserInfoAiApi.deleteUserInfoAi(state.model.id);
+        if (code === 0) {
+          sheep.$router.back();
+        }
+      },
+    });
+  };
+
+  onLoad(async (options) => {});
+</script>
+
+<style lang="scss" scoped>
+  :deep() {
+    .uni-forms-item__label .label-text {
+      font-size: 28rpx !important;
+      color: #333333 !important;
+      line-height: normal !important;
+    }
+
+    .uni-easyinput__content-input {
+      font-size: 28rpx !important;
+      color: #333333 !important;
+      line-height: normal !important;
+      padding-left: 0 !important;
+    }
+
+    .uni-easyinput__content-textarea {
+      font-size: 28rpx !important;
+      color: #333333 !important;
+      line-height: normal !important;
+      margin-top: 8rpx !important;
+    }
+
+    .uni-icons {
+      font-size: 40rpx !important;
+    }
+
+    .is-textarea-icon {
+      margin-top: 22rpx;
+    }
+
+    .is-disabled {
+      color: #333333;
+    }
+  }
+
+  .default-box {
+    width: 100%;
+    box-sizing: border-box;
+    height: 100rpx;
+
+    .default-box-title {
+      font-size: 28rpx;
+      color: #333333;
+      line-height: normal;
+    }
+  }
+
+  .footer-box {
+    .save-btn {
+      width: 710rpx;
+      height: 80rpx;
+      border-radius: 40rpx;
+      background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
+      color: $white;
+    }
+
+    .cancel-btn {
+      width: 710rpx;
+      height: 80rpx;
+      border-radius: 40rpx;
+      background: var(--ui-BG);
+    }
+  }
+</style>

+ 106 - 0
pages/member/UserInfoAiList.vue

@@ -0,0 +1,106 @@
+<!-- 用户信息列表 -->
+<template>
+  <s-layout :bgStyle="{ color: '#FFF' }" title="用户信息">
+    <view>
+      <s-userinfoai-item
+        v-for="item in state.list"
+        :key="item.id"
+        :item="item"
+        hasBorderBottom
+        @tap="onSelect(item)"
+      />
+    </view>
+
+    <su-fixed bottom placeholder>
+      <view class="footer-box ss-flex ss-row-between ss-p-20">
+        <button
+          class="add-btn ss-reset-button ui-Shadow-Main"
+          @tap="sheep.$router.go('/pages/member/UserInfoAiEdit')"
+        >
+          新增用户信息
+        </button>
+      </view>
+    </su-fixed>
+    <s-empty
+      v-if="state.list.length === 0 && !state.loading"
+      icon="/static/data-empty.png"
+      text="暂无用户信息"
+    />
+  </s-layout>
+</template>
+
+<script setup>
+  import { onBeforeMount, reactive } from 'vue';
+  import { onLoad, onShow } from '@dcloudio/uni-app';
+  import sheep from '@/sheep';
+  import AreaApi from '@/sheep/api/system/area';
+  import UserInfoAiApi from '@/sheep/api/member/UserInfoAi';
+
+  const state = reactive({
+    list: [], // 地址列表
+    loading: true,
+    openType: '', // 页面打开类型
+  });
+
+  // 选择用户信息
+  const onSelect = (userinfoaiInfo) => {
+    if (state.openType !== 'select') {
+      // 不作为选择组件时阻断操作
+      return;
+    }
+    uni.$emit('SELECT_USERINFOAI', {
+      userinfoaiInfo,
+    });
+    sheep.$router.back();
+  };
+
+  onLoad((option) => {
+    if (option.type) {
+      state.openType = option.type;
+    }
+  });
+
+  onShow(async () => {
+    state.list = (await UserInfoAiApi.getUserInfoAiList()).data;
+    state.loading = false;
+  });
+
+  onBeforeMount(() => {
+    if (!!uni.getStorageSync('areaData')) {
+      return;
+    }
+    // 提前加载省市区数据
+    AreaApi.getAreaTree().then((res) => {
+      if (res.code === 0) {
+        uni.setStorageSync('areaData', res.data);
+      }
+    });
+  });
+</script>
+
+<style lang="scss" scoped>
+  .footer-box {
+    .add-btn {
+      flex: 1;
+      background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
+      border-radius: 80rpx;
+      font-size: 30rpx;
+      font-weight: 500;
+      line-height: 80rpx;
+      color: $white;
+      position: relative;
+      z-index: 1;
+    }
+
+    .sync-wxuserinfoai {
+      flex: 1;
+      line-height: 80rpx;
+      background: $white;
+      border-radius: 80rpx;
+      font-size: 30rpx;
+      font-weight: 500;
+      color: $dark-6;
+      margin-right: 18rpx;
+    }
+  }
+</style>

+ 53 - 0
sheep/api/member/UserInfoAi.js

@@ -0,0 +1,53 @@
+import request from '@/sheep/request';
+
+const UserInfoAiApi = {
+  // 获得用户信息列表
+  getUserInfoAiList: () => {
+    return request({
+      url: '/member/user-info-ai/list',
+      method: 'GET'
+    });
+  },
+  // 创建用户信息
+  createUserInfoAi: (data) => {
+    return request({
+      url: '/member/user-info-ai/create',
+      method: 'POST',
+      data,
+      custom: {
+        showSuccess: true,
+        successMsg: '保存成功'
+      },
+    });
+  },
+  // 更新用户信息
+  updateUserInfoAi: (data) => {
+    return request({
+      url: '/member/user-info-ai/update',
+      method: 'PUT',
+      data,
+      custom: {
+        showSuccess: true,
+        successMsg: '更新成功'
+      },
+    });
+  },
+  // 获得用户信息
+  getUserInfoAi: (id) => {
+    return request({
+      url: '/member/user-info-ai/get',
+      method: 'GET',
+      params: { id }
+    });
+  },
+  // 删除用户信息
+  deleteUserInfoAi: (id) => {
+    return request({
+      url: '/member/user-info-ai/delete',
+      method: 'DELETE',
+      params: { id }
+    });
+  }
+};
+
+export default UserInfoAiApi;

+ 108 - 0
sheep/components/s-userinfoai-item/s-userinfoai-item.vue

@@ -0,0 +1,108 @@
+<!-- 用户信息卡片 -->
+<template>
+  <view
+    :class="[{ 'border-bottom': props.hasBorderBottom }]"
+    class="userinfoai-item ss-flex ss-row-between ss-col-center"
+  >
+    <view v-if="!isEmpty(props.item)" class="item-left">
+      <view class="area-text ss-flex ss-col-center">
+        <uni-tag
+          v-if="props.item.defaultStatus"
+          class="ss-m-r-10"
+          custom-style="background-color: var(--ui-BG-Main); border-color: var(--ui-BG-Main); color: #fff;"
+          size="small"
+          text="默认"
+        />
+        {{ props.item.areaName }}
+      </view>
+    </view>
+    <view v-else>
+      <view class="userinfoai-text ss-m-b-10">请选择用户信息</view>
+    </view>
+    <slot>
+      <button class="ss-reset-button edit-btn" @tap.stop="onEdit">
+        <view class="edit-icon ss-flex ss-row-center ss-col-center">
+          <image :src="sheep.$url.static('/static/img/shop/member/userinfoai/edit.png')" />
+        </view>
+      </button>
+    </slot>
+  </view>
+</template>
+
+<script setup>
+  /**
+   * 基础组件 - 用户信息卡片
+   *
+   * @param {String}  icon = _icon-edit    - icon
+   *
+   * @event {Function()} click       - 点击
+   * @event {Function()} actionClick     - 点击工具栏
+   *
+   * @slot                 - 默认插槽
+   */
+  import sheep from '@/sheep';
+  import { isEmpty } from 'lodash-es';
+
+  const props = defineProps({
+    item: {
+      type: Object,
+      default() {},
+    },
+    hasBorderBottom: {
+      type: Boolean,
+      defult: true,
+    },
+  });
+
+  const onEdit = () => {
+    sheep.$router.go('/pages/member/userinfoai/edit', {
+      id: props.item.id,
+    });
+  };
+</script>
+
+<style lang="scss" scoped>
+  .userinfoai-item {
+    padding: 24rpx 30rpx;
+
+    .item-left {
+      width: 600rpx;
+    }
+
+    .area-text {
+      font-size: 26rpx;
+      font-weight: 400;
+      color: $dark-9;
+    }
+
+    .userinfoai-text {
+      font-size: 32rpx;
+      font-weight: 500;
+      color: #333333;
+      line-height: 48rpx;
+    }
+
+    .person-text {
+      font-size: 28rpx;
+      font-weight: 400;
+      color: $dark-9;
+    }
+  }
+
+  .edit-btn {
+    width: 44rpx;
+    height: 44rpx;
+    background: $gray-f;
+    border-radius: 50%;
+
+    .edit-icon {
+      width: 24rpx;
+      height: 24rpx;
+    }
+  }
+
+  image {
+    width: 100%;
+    height: 100%;
+  }
+</style>