SprinBoot+Vue宠物领养接济微信小步调的操持与实现

[复制链接]
发表于 2026-1-26 20:14:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×


1 项目先容

   博主个人先容:CSDN认证博客专家,CSDN平台Java范畴优质创作者,全网30w+粉丝,超300w访问量,专注于大弟子项目实战开发、解说和答疑辅导,对于专业性数据证明齐备!
重要项目:javaweb、ssm、springboot、vue、小步调、python、安卓、uniapp等操持与开发,万套源码制品可供选择学习。
  👇🏻👇🏻文末获取源码
SprinBoot+Vue宠物领养接济微信小步调的操持与实现(源码+数据库+文档)
项目形貌
本研究操持并实现了一个基于Springboot框架的小动物接济领养小步调。该小步调旨在为动物接济构造和爱心人士搭建一个平台,方便对流离动物举行接济和领养。本小步调的定位在于提供一个便捷快速的交换平台,在包管用户信息安全的同时,为动物接济古迹和流离动物探求更多机会和资源。
创新性方面,本小步调接纳了Springboot框架,实现了高效的开发和摆设,有效进步了小步调的性能和相应速率。同时,通过整合微信小步调接口和定制化开发,实现了用户的在线预约和动物信息的展示功能。别的,本小步调还引入了人工智能辨认技能,为用户提供更快速、正确的信息辨认和查询服务,大大进步了用户体验。
特色功能方面,本小步调提供了动物分类、领养预约、实时定位、在线付出等功能,用户可以根据自己的需求和喜好快速找到得当自己的动物并举行领养。同时,小步调还支持用户发布探求家的流离动物信息,资助更多动物找到温暖的故里。别的,小步调还提供动物康健档案管理和在线社区交换功能,促进用户之间的互动和交换。
本小步调的意义和代价在于提倡人与动物调和相处的理念,促进了社会公益古迹的发展和流离动物的掩护。同时,通过技能本领的运用,实现了动物接济信息的快速通报和动物领养过程的便捷化,进步了动物接济构造的服从和用户体验。将来,本研究将不绝美满和优化小步调功能,扩大用户覆盖范围,为更多的流离动物和有爱心的人士搭建桥梁,推动动物掩护古迹的发展。

2 项目截图


   springboot小动物接济领养小步调端演示录像


   springboot小动物接济领养小步调服务端演示录像

3 核心代码

3.1 Controller

  1. package com.controller;
  2. import java.util.Arrays;
  3. import java.util.Calendar;
  4. import java.util.Date;
  5. import java.util.Map;
  6. import javax.servlet.http.HttpServletRequest;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PathVariable;
  11. import org.springframework.web.bind.annotation.PostMapping;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import com.annotation.IgnoreAuth;
  18. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  19. import com.entity.TokenEntity;
  20. import com.entity.UserEntity;
  21. import com.service.TokenService;
  22. import com.service.UserService;
  23. import com.utils.CommonUtil;
  24. import com.utils.MPUtil;
  25. import com.utils.PageUtils;
  26. import com.utils.R;
  27. import com.utils.ValidatorUtils;
  28. /**
  29. * 登录相关
  30. */
  31. @RequestMapping("users")
  32. @RestController
  33. public class UserController{
  34.        
  35.         @Autowired
  36.         private UserService userService;
  37.        
  38.         @Autowired
  39.         private TokenService tokenService;
  40.         /**
  41.          * 登录
  42.          */
  43.         @IgnoreAuth
  44.         @PostMapping(value = "/login")
  45.         public R login(String username, String password, String captcha, HttpServletRequest request) {
  46.                 UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
  47.                 if(user==null || !user.getPassword().equals(password)) {
  48.                         return R.error("账号或密码不正确");
  49.                 }
  50.                 String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
  51.                 return R.ok().put("token", token);
  52.         }
  53.        
  54.         /**
  55.          * 注册
  56.          */
  57.         @IgnoreAuth
  58.         @PostMapping(value = "/register")
  59.         public R register(@RequestBody UserEntity user){
  60. //            ValidatorUtils.validateEntity(user);
  61.             if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
  62.                     return R.error("用户已存在");
  63.             }
  64.         userService.insert(user);
  65.         return R.ok();
  66.     }
  67.         /**
  68.          * 退出
  69.          */
  70.         @GetMapping(value = "logout")
  71.         public R logout(HttpServletRequest request) {
  72.                 request.getSession().invalidate();
  73.                 return R.ok("退出成功");
  74.         }
  75.        
  76.         /**
  77.      * 密码重置
  78.      */
  79.     @IgnoreAuth
  80.         @RequestMapping(value = "/resetPass")
  81.     public R resetPass(String username, HttpServletRequest request){
  82.             UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
  83.             if(user==null) {
  84.                     return R.error("账号不存在");
  85.             }
  86.             user.setPassword("123456");
  87.         userService.update(user,null);
  88.         return R.ok("密码已重置为:123456");
  89.     }
  90.        
  91.         /**
  92.      * 列表
  93.      */
  94.     @RequestMapping("/page")
  95.     public R page(@RequestParam Map<String, Object> params,UserEntity user){
  96.         EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
  97.             PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
  98.         return R.ok().put("data", page);
  99.     }
  100.         /**
  101.      * 列表
  102.      */
  103.     @RequestMapping("/list")
  104.     public R list( UserEntity user){
  105.                EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
  106.               ew.allEq(MPUtil.allEQMapPre( user, "user"));
  107.         return R.ok().put("data", userService.selectListView(ew));
  108.     }
  109.     /**
  110.      * 信息
  111.      */
  112.     @RequestMapping("/info/{id}")
  113.     public R info(@PathVariable("id") String id){
  114.         UserEntity user = userService.selectById(id);
  115.         return R.ok().put("data", user);
  116.     }
  117.    
  118.     /**
  119.      * 获取用户的session用户信息
  120.      */
  121.     @RequestMapping("/session")
  122.     public R getCurrUser(HttpServletRequest request){
  123.             Integer id = (Integer)request.getSession().getAttribute("userId");
  124.         UserEntity user = userService.selectById(id);
  125.         return R.ok().put("data", user);
  126.     }
  127.     /**
  128.      * 保存
  129.      */
  130.     @PostMapping("/save")
  131.     public R save(@RequestBody UserEntity user){
  132. //            ValidatorUtils.validateEntity(user);
  133.             if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
  134.                     return R.error("用户已存在");
  135.             }
  136.         userService.insert(user);
  137.         return R.ok();
  138.     }
  139.     /**
  140.      * 修改
  141.      */
  142.     @RequestMapping("/update")
  143.     public R update(@RequestBody UserEntity user){
  144. //        ValidatorUtils.validateEntity(user);
  145.             UserEntity u = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername()));
  146.             if(u!=null && u.getId()!=user.getId() && u.getUsername().equals(user.getUsername())) {
  147.                     return R.error("用户名已存在。");
  148.             }
  149.         userService.updateById(user);//全部更新
  150.         return R.ok();
  151.     }
  152.     /**
  153.      * 删除
  154.      */
  155.     @RequestMapping("/delete")
  156.     public R delete(@RequestBody Long[] ids){
  157.         userService.deleteBatchIds(Arrays.asList(ids));
  158.         return R.ok();
  159.     }
  160. }
复制代码
3.2 Service

  1. /**
  2. * 系统用户
  3. */
  4. public interface UserService extends IService<UserEntity> {
  5.         PageUtils queryPage(Map<String, Object> params);
  6.    
  7.            List<UserEntity> selectListView(Wrapper<UserEntity> wrapper);
  8.           
  9.            PageUtils queryPage(Map<String, Object> params,Wrapper<UserEntity> wrapper);
  10.                   
  11. }
复制代码
3.3 Dao

  1. /**
  2. * 用户
  3. */
  4. public interface UserDao extends BaseMapper<UserEntity> {
  5.        
  6.         List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);
  7.         List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);
  8.        
  9. }
复制代码
3.4 application.yml

  1. # Tomcat
  2. server:
  3.     tomcat:
  4.         uri-encoding: UTF-8
  5.     port: 8080
  6.     servlet:
  7.         context-path: /springbootpkh49
  8. spring:
  9.     datasource:
  10.         driverClassName: com.mysql.jdbc.Driver
  11.         url: jdbc:mysql://127.0.0.1:3306/springbootpkh49?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
  12.         username: root
  13.         password: root
  14. #        driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
  15. #        url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=springbootpkh49
  16. #        username: sa
  17. #        password: 123456
  18.     servlet:
  19.       multipart:
  20.         max-file-size: 10MB
  21.         max-request-size: 10MB
  22.     resources:
  23.       static-locations: classpath:static/,file:static/
  24. #mybatis
  25. mybatis-plus:
  26.   mapper-locations: classpath*:mapper/*.xml
  27.   #实体扫描,多个package用逗号或者分号分隔
  28.   typeAliasesPackage: com.entity
  29.   global-config:
  30.     #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
  31.     id-type: 1
  32.     #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
  33.     field-strategy: 2
  34.     #驼峰下划线转换
  35.     db-column-underline: true
  36.     #刷新mapper 调试神器
  37.     refresh-mapper: true
  38.     #逻辑删除配置
  39.     logic-delete-value: -1
  40.     logic-not-delete-value: 0
  41.     #自定义SQL注入器
  42.     sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
  43.   configuration:
  44.     map-underscore-to-camel-case: true
  45.     cache-enabled: false
  46.     call-setters-on-nulls: true
  47.     #springboot 项目mybatis plus 设置 jdbcTypeForNull (oracle数据库需配置JdbcType.NULL, 默认是Other)
  48.     jdbc-type-for-null: 'null'
复制代码
3.5 SpringbootApplication

  1. @SpringBootApplication
  2. @MapperScan(basePackages = {"com.dao"})
  3. public class SpringbootSchemaApplication extends SpringBootServletInitializer{
  4.         public static void main(String[] args) {
  5.                 SpringApplication.run(SpringbootSchemaApplication.class, args);
  6.         }
  7.        
  8.         @Override
  9.     protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
  10.         return applicationBuilder.sources(SpringbootSchemaApplication.class);
  11.     }
  12. }
复制代码
3.5 Vue

  1. <template>
  2.   <div>
  3.     <div class="container loginIn" style="backgroundImage: url(http://codegen.caihongy.cn/20201206/eaa69c2b4fa742f2b5acefd921a772fc.jpg)">
  4.       <div :class="2 == 1 ? 'left' : 2 == 2 ? 'left center' : 'left right'" style="backgroundColor: rgba(255, 255, 255, 0.71)">
  5.         <el-form class="login-form" label-position="left" :label-width="1 == 3 ? '56px' : '0px'">
  6.           <div class="title-container"><h3 class="title" style="color: rgba(84, 88, 179, 1)">在线文档管理系统登录</h3></div>
  7.           <el-form-item :label="1 == 3 ? '用户名' : ''" :class="'style'+1">
  8.             <span v-if="1 != 3" class="svg-container" style="color:rgba(89, 97, 102, 1);line-height:44px"><svg-icon icon-class="user" /></span>
  9.             <el-input placeholder="请输入用户名" name="username" type="text" v-model="rulesForm.username" />
  10.           </el-form-item>
  11.           <el-form-item :label="1 == 3 ? '密码' : ''" :class="'style'+1">
  12.             <span v-if="1 != 3" class="svg-container" style="color:rgba(89, 97, 102, 1);line-height:44px"><svg-icon icon-class="password" /></span>
  13.             <el-input placeholder="请输入密码" name="password" type="password" v-model="rulesForm.password" />
  14.           </el-form-item>
  15.           <el-form-item v-if="0 == '1'" class="code" :label="1 == 3 ? '验证码' : ''" :class="'style'+1">
  16.             <span v-if="1 != 3" class="svg-container" style="color:rgba(89, 97, 102, 1);line-height:44px"><svg-icon icon-class="code" /></span>
  17.             <el-input placeholder="请输入验证码" name="code" type="text" v-model="rulesForm.code" />
  18.             <div class="getCodeBt" @click="getRandCode(4)" style="height:44px;line-height:44px">
  19.               <span v-for="(item, index) in codes" :key="index" :style="{color:item.color,transform:item.rotate,fontSize:item.size}">{{ item.num }}</span>
  20.             </div>
  21.           </el-form-item>
  22.           <el-form-item label="角色" prop="loginInRole" class="role">
  23.             <el-radio
  24.               v-for="item in menus"
  25.               v-if="item.hasBackLogin=='是'"
  26.               v-bind:key="item.roleName"
  27.               v-model="rulesForm.role"
  28.               :label="item.roleName"
  29.             >{{item.roleName}}</el-radio>
  30.           </el-form-item>
  31.           <el-button type="primary" @click="login()" class="loginInBt" style="padding:0;font-size:16px;border-radius:4px;height:44px;line-height:44px;width:100%;backgroundColor:rgba(84, 88, 179, 1); borderColor:rgba(84, 88, 179, 1); color:rgba(255, 255, 255, 1)">{{'1' == '1' ? '登录' : 'login'}}</el-button>
  32.           <el-form-item class="setting">
  33.             <!-- <div style="color:rgba(255, 255, 255, 1)" class="reset">修改密码</div> -->
  34.           </el-form-item>
  35.         </el-form>
  36.       </div>
  37.     </div>
  38.   </div>
  39. </template>
  40. <script>
  41. import menu from "@/utils/menu";
  42. export default {
  43.   data() {
  44.     return {
  45.       rulesForm: {
  46.         username: "",
  47.         password: "",
  48.         role: "",
  49.         code: '',
  50.       },
  51.       menus: [],
  52.       tableName: "",
  53.       codes: [{
  54.         num: 1,
  55.         color: '#000',
  56.         rotate: '10deg',
  57.         size: '16px'
  58.       },{
  59.         num: 2,
  60.         color: '#000',
  61.         rotate: '10deg',
  62.         size: '16px'
  63.       },{
  64.         num: 3,
  65.         color: '#000',
  66.         rotate: '10deg',
  67.         size: '16px'
  68.       },{
  69.         num: 4,
  70.         color: '#000',
  71.         rotate: '10deg',
  72.         size: '16px'
  73.       }],
  74.     };
  75.   },
  76.   mounted() {
  77.     let menus = menu.list();
  78.     this.menus = menus;
  79.   },
  80.   created() {
  81.     this.setInputColor()
  82.     this.getRandCode()
  83.   },
  84.   methods: {
  85.     setInputColor(){
  86.       this.$nextTick(()=>{
  87.         document.querySelectorAll('.loginIn .el-input__inner').forEach(el=>{
  88.           el.style.backgroundColor = "rgba(255, 255, 255, 1)"
  89.           el.style.color = "rgba(0, 0, 0, 1)"
  90.           el.style.height = "44px"
  91.           el.style.lineHeight = "44px"
  92.           el.style.borderRadius = "2px"
  93.         })
  94.         document.querySelectorAll('.loginIn .style3 .el-form-item__label').forEach(el=>{
  95.           el.style.height = "44px"
  96.           el.style.lineHeight = "44px"
  97.         })
  98.         document.querySelectorAll('.loginIn .el-form-item__label').forEach(el=>{
  99.           el.style.color = "rgba(89, 97, 102, 1)"
  100.         })
  101.         setTimeout(()=>{
  102.           document.querySelectorAll('.loginIn .role .el-radio__label').forEach(el=>{
  103.             el.style.color = "rgba(84, 88, 179, 1)"
  104.           })
  105.         },350)
  106.       })
  107.     },
  108.     register(tableName){
  109.       this.$storage.set("loginTable", tableName);
  110.       this.$router.push({path:'/register'})
  111.     },
  112.     // 登陆
  113.     login() {
  114.       let code = ''
  115.       for(let i in this.codes) {
  116.         code += this.codes[i].num
  117.       }
  118.           if ('0' == '1' && !this.rulesForm.code) {
  119.              this.$message.error("请输入验证码");
  120.             return;
  121.           }
  122.       if ('0' == '1' && this.rulesForm.code.toLowerCase() != code.toLowerCase()) {
  123.          this.$message.error("验证码输入有误");
  124.                 this.getRandCode()
  125.         return;
  126.       }
  127.       if (!this.rulesForm.username) {
  128.          this.$message.error("请输入用户名");
  129.         return;
  130.       }
  131.       if (!this.rulesForm.password) {
  132.          this.$message.error("请输入密码");
  133.         return;
  134.       }
  135.       if (!this.rulesForm.role) {
  136.          this.$message.error("请选择角色");
  137.         return;
  138.       }
  139.       let menus = this.menus;
  140.       for (let i = 0; i < menus.length; i++) {
  141.         if (menus[i].roleName == this.rulesForm.role) {
  142.           this.tableName = menus[i].tableName;
  143.         }
  144.       }
  145.       this.$http({
  146.         url: `${this.tableName}/login?username=${this.rulesForm.username}&password=${this.rulesForm.password}`,
  147.         method: "post"
  148.       }).then(({ data }) => {
  149.         if (data && data.code === 0) {
  150.           this.$storage.set("Token", data.token);
  151.           this.$storage.set("role", this.rulesForm.role);
  152.           this.$storage.set("sessionTable", this.tableName);
  153.           this.$storage.set("adminName", this.rulesForm.username);
  154.           this.$router.replace({ path: "/index/" });
  155.         } else {
  156.           this.$message.error(data.msg);
  157.         }
  158.       });
  159.     },
  160.     getRandCode(len = 4){
  161.       this.randomString(len)
  162.     },
  163.     randomString(len = 4) {
  164.       let chars = [
  165.           "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
  166.           "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
  167.           "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
  168.           "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
  169.           "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
  170.           "3", "4", "5", "6", "7", "8", "9"
  171.       ]
  172.       let colors = ["0", "1", "2","3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]
  173.       let sizes = ['14', '15', '16', '17', '18']
  174.       let output = [];
  175.       for (let i = 0; i < len; i++) {
  176.         // 随机验证码
  177.         let key = Math.floor(Math.random()*chars.length)
  178.         this.codes[i].num = chars[key]
  179.         // 随机验证码颜色
  180.         let code = '#'
  181.         for (let j = 0; j < 6; j++) {
  182.           let key = Math.floor(Math.random()*colors.length)
  183.           code += colors[key]
  184.         }
  185.         this.codes[i].color = code
  186.         // 随机验证码方向
  187.         let rotate = Math.floor(Math.random()*60)
  188.         let plus = Math.floor(Math.random()*2)
  189.         if(plus == 1) rotate = '-'+rotate
  190.         this.codes[i].rotate = 'rotate('+rotate+'deg)'
  191.         // 随机验证码字体大小
  192.         let size = Math.floor(Math.random()*sizes.length)
  193.         this.codes[i].size = sizes[size]+'px'
  194.       }
  195.     },
  196.   }
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. .loginIn {
  201.   min-height: 100vh;
  202.   position: relative;
  203.   background-repeat: no-repeat;
  204.   background-position: center center;
  205.   background-size: cover;
  206.   .left {
  207.     position: absolute;
  208.     left: 0;
  209.     top: 0;
  210.     width: 360px;
  211.     height: 100%;
  212.     .login-form {
  213.       background-color: transparent;
  214.       width: 100%;
  215.       right: inherit;
  216.       padding: 0 12px;
  217.       box-sizing: border-box;
  218.       display: flex;
  219.       justify-content: center;
  220.       flex-direction: column;
  221.     }
  222.     .title-container {
  223.       text-align: center;
  224.       font-size: 24px;
  225.       .title {
  226.         margin: 20px 0;
  227.       }
  228.     }
  229.     .el-form-item {
  230.       position: relative;
  231.       .svg-container {
  232.         padding: 6px 5px 6px 15px;
  233.         color: #889aa4;
  234.         vertical-align: middle;
  235.         display: inline-block;
  236.         position: absolute;
  237.         left: 0;
  238.         top: 0;
  239.         z-index: 1;
  240.         padding: 0;
  241.         line-height: 40px;
  242.         width: 30px;
  243.         text-align: center;
  244.       }
  245.       .el-input {
  246.         display: inline-block;
  247.         height: 40px;
  248.         width: 100%;
  249.         & /deep/ input {
  250.           background: transparent;
  251.           border: 0px;
  252.           -webkit-appearance: none;
  253.           padding: 0 15px 0 30px;
  254.           color: #fff;
  255.           height: 40px;
  256.         }
  257.       }
  258.     }
  259.   }
  260.   .center {
  261.     position: absolute;
  262.     left: 50%;
  263.     top: 50%;
  264.     width: 360px;
  265.     transform: translate3d(-50%,-50%,0);
  266.     height: 446px;
  267.     border-radius: 8px;
  268.   }
  269.   .right {
  270.     position: absolute;
  271.     left: inherit;
  272.     right: 0;
  273.     top: 0;
  274.     width: 360px;
  275.     height: 100%;
  276.   }
  277.   .code {
  278.     .el-form-item__content {
  279.       position: relative;
  280.       .getCodeBt {
  281.         position: absolute;
  282.         right: 0;
  283.         top: 0;
  284.         line-height: 40px;
  285.         width: 100px;
  286.         background-color: rgba(51,51,51,0.4);
  287.         color: #fff;
  288.         text-align: center;
  289.         border-radius: 0 4px 4px 0;
  290.         height: 40px;
  291.         overflow: hidden;
  292.         span {
  293.           padding: 0 5px;
  294.           display: inline-block;
  295.           font-size: 16px;
  296.           font-weight: 600;
  297.         }
  298.       }
  299.       .el-input {
  300.         & /deep/ input {
  301.           padding: 0 130px 0 30px;
  302.         }
  303.       }
  304.     }
  305.   }
  306.   .setting {
  307.     & /deep/ .el-form-item__content {
  308.       padding: 0 15px;
  309.       box-sizing: border-box;
  310.       line-height: 32px;
  311.       height: 32px;
  312.       font-size: 14px;
  313.       color: #999;
  314.       margin: 0 !important;
  315.       .register {
  316.         float: left;
  317.         width: 50%;
  318.       }
  319.       .reset {
  320.         float: right;
  321.         width: 50%;
  322.         text-align: right;
  323.       }
  324.     }
  325.   }
  326.   .style2 {
  327.     padding-left: 30px;
  328.     .svg-container {
  329.       left: -30px !important;
  330.     }
  331.     .el-input {
  332.       & /deep/ input {
  333.         padding: 0 15px !important;
  334.       }
  335.     }
  336.   }
  337.   .code.style2, .code.style3 {
  338.     .el-input {
  339.       & /deep/ input {
  340.         padding: 0 115px 0 15px;
  341.       }
  342.     }
  343.   }
  344.   .style3 {
  345.     & /deep/ .el-form-item__label {
  346.       padding-right: 6px;
  347.     }
  348.     .el-input {
  349.       & /deep/ input {
  350.         padding: 0 15px !important;
  351.       }
  352.     }
  353.   }
  354.   .role {
  355.     & /deep/ .el-form-item__label {
  356.       width: 56px !important;
  357.     }
  358.     & /deep/ .el-radio {
  359.       margin-right: 12px;
  360.     }
  361.   }
  362. }
  363. </style>
复制代码
3.6 uniapp代码

  1. <template>
  2.         <view class="content">
  3.                 <view class="box" :style='{"padding":"24rpx","background":"url(http://codegen.caihongy.cn/20231129/b245d02724c846eb81ec48ed8ffd3ba3.png)","width":"100%","backgroundSize":"cover","backgroundPosition":"center center","backgroundRepeat":"no-repeat","height":"100%"}'>
  4.                         <view :style='{"width":"100%","padding":"24rpx 24rpx","position":"relative","flexWrap":"wrap","display":"flex","height":"auto"}'>
  5.                                 <image :style='{"width":"120rpx","margin":"0 auto 24rpx","borderRadius":"50%","display":"block","height":"120rpx","order":"1"}' src="https://img-blog.csdnimg.cn/img_convert/51919a48762d28dc6336b713589210e9.webp?x-oss-process=image/format,png" mode="aspectFill"></image>
  6.                                 <view v-if="loginType==1" :style='{"width":"100%","margin":"0 0 0","flexWrap":"wrap","display":"flex","height":"auto","order":"2"}' class="uni-form-item uni-column">
  7.                                         <view :style='{"width":"100%","lineHeight":"88rpx","fontSize":"26rpx","color":"#000","textAlign":"left","fontWeight":"bold"}' class="label">账号:</view>
  8.                                         <input v-model="username" :style='{"border":"2rpx solid #aaa","padding":"0px 24rpx","margin":"0px","color":"rgb(0, 0, 0)","borderRadius":"0","flex":"1","background":"none","borderWidth":"0 0 2rpx","fontSize":"28rpx","height":"88rpx"}' type="text" class="uni-input" name="" placeholder="请输入账号" />
  9.                                 </view>
  10.                                 <view v-if="loginType==1" :style='{"width":"100%","margin":"0 0 0","flexWrap":"wrap","display":"flex","height":"auto","order":"2"}' class="uni-form-item uni-column">
  11.                                         <view :style='{"width":"100%","lineHeight":"88rpx","fontSize":"26rpx","color":"#000","textAlign":"left","fontWeight":"bold"}' class="label">密码:</view>
  12.                                         <input v-model="password" :style='{"border":"2rpx solid #aaa","padding":"0px 24rpx","margin":"0px","color":"rgb(0, 0, 0)","borderRadius":"0","flex":"1","background":"none","borderWidth":"0 0 2rpx","fontSize":"28rpx","height":"88rpx"}' type="password" class="uni-input" name="" placeholder="请输入密码" />
  13.                                 </view>
  14.                                 <view v-if="roleNum>1" :style='{"width":"100%","margin":"0 0 24rpx 0","display":"block","height":"auto","order":"4"}'>
  15.                                         <view :style='{"width":"100%","lineHeight":"88rpx","fontSize":"26rpx","color":"#000","textAlign":"left","fontWeight":"bold"}' class="label">用户类型:</view>
  16.                                         <picker @change="optionsChange" :value="index" :range="options" :style='{"width":"100%","lineHeight":"48rpx","fontSize":"24rpx","textDecoration":"underline","color":"#424EF0","textAlign":"left"}'>
  17.                                                 <view class="uni-picker-type">{{options[index]}}</view>
  18.                                         </picker>
  19.                                 </view>
  20.                                
  21.                                
  22.                                 <button v-if="loginType==1" class="btn-submit" @tap="onLoginTap" type="primary" :style='{"border":"0","padding":"0px","margin":"24rpx auto ","color":"rgb(255, 255, 255)","borderRadius":"8rpx","background":"url(http://codegen.caihongy.cn/20231129/e83626e1e97e489099693ee9348afd12.png)","width":"120rpx","lineHeight":"120rpx","fontSize":"0","backgroundSize":"cover","backgroundPosition":"center center","backgroundRepeat":"no-repeat","fontWeight":"bold","height":"120rpx","order":"7"}'>→</button>
  23.                                 <button v-if="loginType==2" class="btn-submit" @tap="onFaceLoginTap" type="primary" :style='{"border":"0","padding":"0px","margin":"24rpx auto ","color":"rgb(255, 255, 255)","borderRadius":"8rpx","background":"url(http://codegen.caihongy.cn/20231129/e83626e1e97e489099693ee9348afd12.png)","width":"120rpx","lineHeight":"120rpx","fontSize":"0","backgroundSize":"cover","backgroundPosition":"center center","backgroundRepeat":"no-repeat","fontWeight":"bold","height":"120rpx","order":"7"}'>人脸识别登录</button>
  24.                                 <view class="links" :style='{"margin":"0 0 24rpx 0","flexWrap":"wrap","display":"flex","width":"100%","justifyContent":"flex-end","height":"auto","order":"6"}'>
  25.                                         <view class="link-highlight" @tap="onRegisterTap('xuesheng')" :style='{"color":"#9E9E9E","padding":"0 12rpx","fontSize":"24rpx"}'>注册学生</view>
  26.                                         <view class="link-highlight" @tap="onRegisterTap('jiaoshi')" :style='{"color":"#9E9E9E","padding":"0 12rpx","fontSize":"24rpx"}'>注册教师</view>
  27.                                 </view>
  28.                                
  29.                                 <view class="idea1" :style='{"width":"100%","background":"red","display":"none","height":"80rpx"}'>idea1</view>
  30.                                 <view class="idea2" :style='{"width":"100%","background":"red","display":"none","height":"80rpx"}'>idea2</view>
  31.                                 <view class="idea3" :style='{"width":"100%","background":"red","display":"none","height":"80rpx"}'>idea3</view>
  32.                         </view>
  33.                 </view>
  34.         </view>
  35. </template>
  36. <script>
  37.         import menu from '@/utils/menu'
  38.         export default {
  39.                 data() {
  40.                         return {
  41.                                 username: '',
  42.                                 password: '',
  43.                 loginType:1,
  44.                                 codes: [{
  45.                                   num: 1,
  46.                                   color: '#000',
  47.                                   rotate: '10deg',
  48.                                   size: '16px'
  49.                                 }, {
  50.                                   num: 2,
  51.                                   color: '#000',
  52.                                   rotate: '10deg',
  53.                                   size: '16px'
  54.                                 }, {
  55.                                   num: 3,
  56.                                   color: '#000',
  57.                                   rotate: '10deg',
  58.                                   size: '16px'
  59.                                 }, {
  60.                                   num: 4,
  61.                                   color: '#000',
  62.                                   rotate: '10deg',
  63.                                   size: '16px'
  64.                                 }],
  65.                                 options: [
  66.                                         '请选择登录用户类型',
  67.                                 ],
  68.                 optionsValues: [
  69.                                         '',
  70.                     'xuesheng',
  71.                     'jiaoshi',
  72.                                 ],
  73.                                 index: 0,
  74.                                 roleNum:0,
  75.                         }
  76.                 },
  77.                 onLoad() {
  78.                         let options = ['请选择登录用户类型'];
  79.                         let menus = menu.list();
  80.                         this.menuList = menus;
  81.                         for(let i=0;i<this.menuList.length;i++){
  82.                                 if(this.menuList[i].hasFrontLogin=='是'){
  83.                                         options.push(this.menuList[i].roleName);
  84.                                         this.roleNum++;
  85.                                 }
  86.                         }
  87.                         if(this.roleNum==1) {
  88.                                 this.index = 1;
  89.                         }       
  90.                         this.options = options;
  91.                         this.styleChange()
  92.                 },
  93.                 onShow() {
  94.                 },
  95.                 mounted() {
  96.                 },
  97.                 methods: {
  98.                         styleChange() {
  99.                                 this.$nextTick(()=>{
  100.                                         // document.querySelectorAll('.uni-input .uni-input-input').forEach(el=>{
  101.                                         //   el.style.backgroundColor = this.loginFrom.content.input.backgroundColor
  102.                                         // })
  103.                                 })
  104.                         },
  105.                         onRegisterTap(tableName) {
  106.                 uni.setStorageSync("loginTable", tableName);
  107.                                 this.$utils.jump('../register/register')
  108.                         },
  109.                         async onLoginTap() {
  110.                 if (!this.username) {
  111.                                         this.$utils.msg('请输入用户名')
  112.                                         return
  113.                                 }
  114.                 if (!this.password) {
  115.                                         this.$utils.msg('请输入用户密码')
  116.                                         return
  117.                                 }
  118.                 if (!this.optionsValues[this.index]) {
  119.                                         this.$utils.msg('请选择登录用户类型')
  120.                                         return
  121.                                 }
  122.                                 this.loginPost()
  123.                         },
  124.                         async loginPost() {
  125.                                
  126.                                 let res = await this.$api.login(`${this.optionsValues[this.index]}`, {
  127.                                         username: this.username,
  128.                                         password: this.password
  129.                                 });
  130.                                 uni.removeStorageSync("useridTag");
  131.                                 uni.setStorageSync("appToken", res.token);
  132.                                 uni.setStorageSync("nickname",this.username);
  133.                                 uni.setStorageSync("nowTable", `${this.optionsValues[this.index]}`);
  134.                                 res = await this.$api.session(`${this.optionsValues[this.index]}`);
  135.                                 if(res.data.touxiang) {
  136.                                     uni.setStorageSync('headportrait', res.data.touxiang);
  137.                                 } else if(res.data.headportrait) {
  138.                                     uni.setStorageSync('headportrait', res.data.headportrait);
  139.                                 }
  140.                                 uni.setStorageSync('userSession',JSON.stringify(res.data))
  141.                                 // 保存用户id
  142.                                 uni.setStorageSync("appUserid", res.data.id);
  143.                                 if(res.data.vip) {
  144.                                         uni.setStorageSync("vip", res.data.vip);
  145.                                 }
  146.                                 uni.setStorageSync("appRole", `${this.options[this.index]}`);
  147.                                 this.$utils.tab('../index/index');
  148.                         },
  149.                         optionsChange(e) {
  150.                                 this.index = e.target.value
  151.                         }
  152.                 }
  153.         }
  154. </script>
  155. <style lang="scss" scoped>
  156.         page {
  157.                 height: 100%;
  158.         }
  159.        
  160.         .content {
  161.                 height: 100%;
  162.                 box-sizing: border-box;
  163.         }
  164.        
  165. </style>
复制代码
4 数据库表操持

用户注册实体图如图所示:

数据库表的操持,如下表:

5 文档参考


6 盘算机毕设选题保举

最新盘算机软件毕业操持选题大全:整理中…
7 源码获取

👇🏻获取接洽方式在文章末端 如果想入行提升技能的可以看我专栏其他内容:

回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表