From 780a48b484191d878b98eaf031fdc5d7a37234b5 Mon Sep 17 00:00:00 2001
From: Dragon <13925835632@139.com>
Date: Mon, 28 Nov 2022 18:07:28 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90h5=E6=B3=A8=E5=86=8C=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
view/peko/modules/register/index.html | 45 +++++++
view/peko/modules/register/js/des.js | 9 ++
view/peko/modules/register/js/index.js | 161 +++++++++++++++++++++++++
3 files changed, 215 insertions(+)
create mode 100644 view/peko/modules/register/index.html
create mode 100644 view/peko/modules/register/js/des.js
create mode 100644 view/peko/modules/register/js/index.js
diff --git a/view/peko/modules/register/index.html b/view/peko/modules/register/index.html
new file mode 100644
index 0000000..197acd8
--- /dev/null
+++ b/view/peko/modules/register/index.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+ 注册
+
+
+
+
+
+
+
+
+
+

+
提交成功
+
申請結果會通過短信通知,請耐心等候
+
我知道了
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/view/peko/modules/register/js/des.js b/view/peko/modules/register/js/des.js
new file mode 100644
index 0000000..a095725
--- /dev/null
+++ b/view/peko/modules/register/js/des.js
@@ -0,0 +1,9 @@
+//DES加密
+const encryptDes = (message, key) => {
+ var keyHex = CryptoJS.enc.Utf8.parse(key);
+ var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
+ mode: CryptoJS.mode.ECB,
+ padding: CryptoJS.pad.Pkcs7
+ });
+ return encrypted.toString();
+}
\ No newline at end of file
diff --git a/view/peko/modules/register/js/index.js b/view/peko/modules/register/js/index.js
new file mode 100644
index 0000000..b5cde1b
--- /dev/null
+++ b/view/peko/modules/register/js/index.js
@@ -0,0 +1,161 @@
+// 封装layer消息提醒框
+let layerIndex
+const showLoading = (content = '加载中...') => {
+ layer.open({
+ type: 2,
+ shadeClose: false,
+ content,
+ success (e) {
+ layerIndex = $(e).attr('index')
+ }
+ })
+}
+const hideLoading = (index) => {
+ layer.close(index)
+}
+const toastMsg = (content = '操作完成', time = 2) => {
+ layer.open({
+ content,
+ time,
+ skin: 'msg'
+ })
+}
+var browser = checkVersion();
+const urlPrefix = getUrlPrefix();
+var getUrl = getQueryString();
+var time = 59;
+var isClick = true;
+if (EnvCheck() == 'test') {//degBug
+ new VConsole();
+}
+$(function () {
+ getInfoFromClient();//请求依赖
+})
+function request (phone, num) {
+ showLoading()
+ networkRequest({
+ type: 'POST',
+ url: urlPrefix + '/phone/auth/apply',
+ data: {
+ phone: `${phone}`,
+ phoneAreaCode: num
+ },
+ success: function (res) {
+ if (res.code == 200) {
+ $('.box .phone input').val('');
+ $('.box .code input').val('');
+ $('.pop_up').show();
+ hideLoading(layerIndex)
+ } else {
+ hideLoading(layerIndex)
+ toastMsg(res.message)
+ }
+ },
+ error () {
+ hideLoading(layerIndex)
+ toastMsg('網絡錯誤');
+ }
+ });
+}
+function getCode (num, phone, code) {
+ showLoading()
+ networkRequest({
+ type: 'POST',
+ url: urlPrefix + '/sms/getCode',
+ data: {
+ mobile: encryptDes(`${num}${phone}`, "1ea53d260ecf11e7b56e00163e046a26"),
+ type: 15,
+ phoneAreaCode: num
+ },
+ success: function (res) {
+ if (res.code == 200) {
+ timerFun()
+ hideLoading(layerIndex)
+ toastMsg(res.message)
+ } else {
+ hideLoading(layerIndex)
+ toastMsg(res.message)
+ }
+ },
+ error () {
+ hideLoading(layerIndex)
+ toastMsg('網絡錯誤');
+ }
+ });
+}
+function verify (num, phone, code) {
+ $.ajax({
+ type: 'POST',
+ url: urlPrefix + '/sms/verify',
+ data: {
+ mobile: `${num}${phone}`,
+ phoneAreaCode: num,
+ code,
+ },
+ beforeSend: function (request) {
+ },
+ success: function (res) {
+ if (res.code == 200) {
+ request(phone, num)
+ } else {
+ hideLoading(layerIndex)
+ toastMsg(res.message)
+ }
+ },
+ error: function (data) {
+ hideLoading(layerIndex)
+ toastMsg('網絡錯誤');
+ }
+ })
+}
+// 提交按钮
+$('.box .but').click(function () {
+ var num = Number($('.box .phone .num').text().match(/\d+/)[0]);
+ var phone = Number($('.box .phone input').val());
+ var code = Number($('.box .code input').val());
+ if (code == '') {
+ toastMsg('請輸入驗證碼');
+ } else {
+ verify(num, phone, code)
+ }
+})
+// 获取验证码按钮
+$('.box .code .num').click(function () {
+ var num = Number($('.box .phone .num').text().match(/\d+/)[0]);
+ var phone = Number($('.box .phone input').val());
+ var code = Number($('.box .code input').val());
+ if (isClick) {
+ if (phone == '') {
+ toastMsg('請輸入手機號');
+ } else {
+ getCode(num, phone, code);
+ }
+ } else {
+ console.log('倒计时中');
+ }
+})
+// 关闭弹窗
+$('.pop_up .pop_up_in img').click(function () {
+ $('.pop_up').hide();
+})
+// 关闭弹窗
+$('.pop_up .pop_up_in .but').click(function () {
+ $('.pop_up').hide();
+})
+
+function timerFun () {
+ // 开启定时器
+ var timer = setInterval(function () {
+ // 判断剩余秒数
+ if (time == 0) {
+ // 清除定时器和复原按钮
+ clearInterval(timer);
+ $('.box .code .num').text('獲取驗證碼');
+ isClick = true;
+ } else {
+ $('.box .code .num').text(`${time}秒後重新獲取`);
+ time--;
+ isClick = false;
+ }
+ }, 1000);
+}
\ No newline at end of file