当前位置: 首页 > wzjs >正文

网站建设程序编制虚拟网站仿制教程

网站建设程序编制,虚拟网站仿制教程,电子商务网站建设 教案,业务推广公司文章目录 前言前端后端前面代码会出现的问题约束button的小插件连接mongodb来写登陆项目开源链接前言 真实应该要连接短信验证码服务,但是众所周知所有的服务和IT都是靠服务来挣钱的,所以我们目前只能模拟手机验证码登陆 考虑到账号的唯一值就想到了手机和验证码(基本上的网站…

文章目录

      • 前言
      • 前端
      • 后端
      • 前面代码会出现的问题
      • 约束button的小插件
      • 连接mongodb来写
      • 登陆
      • 项目开源链接

前言

真实应该要连接短信验证码服务,但是众所周知所有的服务和IT都是靠服务来挣钱的,所以我们目前只能模拟手机验证码登陆

考虑到账号的唯一值就想到了手机和验证码(基本上的网站都会使用)但是输入手机号后有"获取验证码"的操作,这个操作就是需要供应商支持(交钱)但是身无分文的我又没有像别人一样有收入来源所以我这里模拟的手机注册登陆的效果共大家做参考。

里面还有nuxt使用qrcode的方法,大家可以看看

前端

需要安装

yarn add nuxt-mongodb
yarn add --dev @types/mongodb
#生成二维码的依赖
yarn add qcode
<!--app.vue-->
<script setup lang="ts">
import Qrcode from 'qrcode.vue';
import ysn_kt from "./public/images/ysn_kt.png"
import type { Reactive } from 'vue';const qrcodeRef = ref(null)interface phoneInter {phone:string,//手机号can:string,//验证码
}const phoneReactive:Reactive<phoneInter> = reactive({phone:"",can:""
})//是否显示登陆页
const isLoginShow = ref(false)
//扫码配置
const qrcodeValue = ref("hello world") //扫码后里面的信息
const qrcodeSize = ref(200) //二维码的大小
const qrcodeColor = ref("#09fff7") //二维码的颜色
const qrcodeBack = ref("#ffffff")//二维码的背景颜色
const logoMargin = 5 // Logo 边距
const logoScale = 0.2 // Logo 缩放比例//打开登陆
function goToLogin(){isLoginShow.value = true// new Qrcode('')
}
//关闭登陆
function closeLogin(){isLoginShow.value = false
}//发送验证码
async function postSubCan(){fetch('/api/getPhone',{method: 'POST',body: JSON.stringify(phoneReactive),headers:{'Content-Type': 'application/json'}}).then(async res =>{return res.json()}).then(async(data:any) => {console.log(data)//弹出验证码alert(`你的验证码是:${data.message.can}`)}).catch(err=>console.log(err))
}//注册用户
function postRegisterUser(){fetch('/api/registerUser',{method:'POST',body:JSON.stringify(phoneReactive),headers:{'Context-Type':"application/json"}}).then(async res =>{return res.json()}).then(async(data:any) => {console.log(data)}).catch(err=>console.log(err))
}
</script><template><!-- 登陆页面 --><div ref="loginRef" v-if="isLoginShow" class="loginClass"><div class="masterBox"><div @click="closeLogin()" class="closeBtn">关闭</div><div class="scanNameTitle">扫码登陆</div><div class="qrcodeClass"><qrcode :value="qrcodeValue" :foreground="qrcodeColor":margin="1":logo-src="ysn_kt" :logo-scale="logoScale":logo-margin="logoMargin":size="qrcodeSize" class="qrcodeMaster" ref="qrcodeRef"/><div class="phoneRegNameTitle">手机注册</div><div class="phoneRegMaster"><input type="text" v-model="phoneReactive.phone" placeholder="手机号" /><input type="text" v-model="phoneReactive.can" placeholder="验证码" /><button @click="postSubCan">发送验证码</button><br /><button @click="postRegisterUser">注册</button></div></div></div></div><!-- 主页 --><div class=""><nuxt-link to="/" class="">首页</nuxt-link><nuxt-link to="/">测试</nuxt-link><span @click="goToLogin()" class="loginBtn">登录</span></div><div><nuxt-page></nuxt-page></div>
</template><style scoped>
/*样式,可以自定义*/
.loginClass{position: absolute;left: 0;top: 0;width: calc(100%);height: calc(100%);background: rgba(0, 0, 0, .3);z-index: 999;display: flex;align-items: center;justify-content: center;
}
.loginBtn{user-select: none;cursor: pointer;
}
.masterBox{width: 70%;height: 70%;background: rgba(255, 255, 255, 1);border-radius: 10px;
}
.closeBtn{position: absolute;right: calc(20%);top: calc(20%);user-select: none;cursor: pointer;
}
.qrcodeClass{position: relative;left: 100px;top: 200px;width: 200px;height: 200px;/* background: rgba(0, 255, 200, 1); */
}
.qrcodeMaster{border: 2px solid #09fff7; /* 添加边框 */padding: 10px; /* 添加内边距 */border-radius: 15px;
}
.scanNameTitle{position: absolute;left: 26%;top: 30%;font-size: calc(20px);
}
/* 注册样式 */
.phoneRegNameTitle{position: absolute;left: 190%;top: -40%;width: 40%;font-size: 20px;
}
.phoneRegMaster{position: absolute;left: 150%;top: -5%;width: 150%;height: 100%;/* background: rgba(255, 100, 100, 1); */display: flex;align-items: center;justify-content: center;
}
</style>

后端

/server/api/getPhone.ts

// server/api/getPhone.ts (模拟获取验证码服务)
//接口
interface phoneInter {phone:string,can:string,//验证码
}//随机浮点数
function getRandomFloatInRange(min: number, max: number): number {return Math.random() * (max - min) + min;
}
//随机四位整数
function getRandomFourDigitInt(): number {return Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
}//导出can信息
export let canMes:number = 0//只有注册账号才能使用(模拟手机短信发送(因为真正的短信发送要钱))
export default defineEventHandler(async(event:any)=><
http://www.dtcms.com/wzjs/829657.html

相关文章:

  • 网站改版升级方案如何让WordPress快起来
  • 盘龙网站建设公司小说网站开发的目的
  • 网站优化要做哪些南通网站优化找哪家
  • 二手房网站建设及推广方案成都有实力的网站建设
  • 上海网站建设招标大连专业网页设计
  • 南宁有多少家网站建设推广的公司wordpress在手机登录
  • 静态网站规范做美工需要知道的设计网站
  • 运城网站制作国内优秀企业网站欣赏
  • 怎么让别人找你做网站琼海网站建设公司
  • 创建网站基本流程电商系统的服务商
  • 网站建设费用明细报价北京注册公司政策
  • 门户网站官网有哪些做网站的资源有哪些
  • 12306网站开发时间秦皇岛网站团队
  • 怎么把网站做二维码长沙商城小程序开发
  • 企业品牌网站建设定制开发电子政务网站设计
  • 建设专业网站哪家更专业软件网站开发合同
  • 网站后台是做什么的零基础网站建设教程
  • 网站开发的初始密码电商网站建站报价
  • 郑州互助盘网站开发网站注册登录
  • 郑州高端网站定制建设2019做网站的出路
  • 专做废旧电子电路板配件回收的网站做企业云网站的企业
  • 好的 做网站的软件公司运城哪家做网站的公司好
  • dedecms 旅游网站模板下载阿里云主机怎么做两个网站吗
  • 北京专业制作网站公司哪家好怎么联系网站开发团队
  • 企业网站分为哪三种类型有关外贸的网站有哪些内容
  • 永久免费网站建设系统行业网站怎么做
  • 企业网站搜索优化外包wordpress cgi漏洞
  • 服务好的镇江网站优化搜索引擎最新排名
  • 郑州妇科医院哪家排名比较好放心网站推广优化咨询
  • 做网站如何组建域名免费网站下载app软件