Browse Source

add 加密算法

master
453530270@qq.com 2 years ago
parent
commit
d438fa0e00
  1. 21
      core/app.js
  2. 3
      main.js
  3. 8
      pages.json
  4. 6
      pages/login/index.vue
  5. 7
      pages/login/loginsms.vue
  6. 203
      pages/login/smscode.vue

21
core/app.js

@ -1,6 +1,7 @@
import store from '@/store'
import * as util from '@/utils/util'
import { paginate } from '@/common/constant'
import exp from 'constants'
/**
* 显示成功提示框
@ -209,3 +210,23 @@ export const getMoreListData = (resList, oldList, pageNo) => {
// 合并新数据
return oldList.data.concat(resList.data)
}
export const tohex=(str)=>{
let hexStr = "";
for(let i = 0; i< str.length; i++) {
let code = str.charCodeAt(i).toString(16);
hexStr += code;
}
return hexStr;
}
function aesEncrypt(text, key) {
var encrypted = CryptoJS.AES.encrypt(text, key);
return encrypted.toString();
}
function aesDecrypt(text, key) {
var decrypted = CryptoJS.AES.decrypt(text, key);
return decrypted.toString(CryptoJS.enc.Utf8);
}

3
main.js

@ -6,7 +6,7 @@ import bootstrap from './core/bootstrap'
import mixin from './core/mixins/app'
import './js_sdk/ican-H5Api/ican-H5Api'
import {
navTo,
navTo,tohex,
showToast,
showSuccess,
showError,
@ -29,6 +29,7 @@ Vue.prototype.$success = showSuccess
Vue.prototype.$error = showError
Vue.prototype.$navTo = navTo
Vue.prototype.$getShareUrlParams = getShareUrlParams
Vue.prototype.$tohex = tohex
// 实例化应用
const app = new Vue({

8
pages.json

@ -135,6 +135,14 @@
"navigationBarTitleText" : "",
"enablePullDownRefresh" : false
}
},
{
"path" : "pages/login/smscode",
"style" :
{
"navigationStyle": "custom",
"enablePullDownRefresh" : false
}
}
],
"globalStyle": {

6
pages/login/index.vue

@ -31,7 +31,7 @@
</view>
<!-- 验证码登录 -->
<view class="vfcode" @tap="go">验证码登录</view>
<view class="vfcode" @click="gtsms('smscode')" >验证码登录</view>
<!-- logo -->
<view class="vbottom">
@ -79,6 +79,10 @@
},
methods: {
//goto smslogin
gtsms(){
this.$navTo("pages/login/loginsms")
},
//
handleLogin() {

7
pages/login/loginsms.vue

@ -48,8 +48,10 @@
<script>
import * as LoginApi from '@/api/login'
import * as Verify from '@/utils/verify'
import store from '@/store'
export default {
components: {
// nothing
@ -70,7 +72,10 @@ import store from '@/store'
handleLogin() {
const app = this
if (!app.isLoading && app.formValidationMobile(app.mobile)) {
app.submitLogin()
//app.submitLogin()
console.log(this.$tohex("sss"))
//
// app.$navTo("pages/login/smscode?rt="+app.mobile)
}
},

203
pages/login/smscode.vue

@ -0,0 +1,203 @@
<template>
<view class="phone_code">
<text class="phone_code_label">验证码已发送至</text>
<view class="phone_code_count">
<text class="phone_code_count_new">{{ newPhone }}</text>
<view v-if="isReget" class="phone_code_count_reget">
<button plain="true" type="warn" size="mini" @click="getCode">重新获取</button>
</view>
<text v-else class="phone_code_count_down">获取验证码<text>{{count}}</text>s</text>
</view>
<view class="phone_code_single">
<input class="phone_code_single_cinput" adjust-position="false" auto-blur="true" @blur="codeNumBlurFun"
@input="codeNumInputFun" :focus="focus" v-model="code" type="number" maxlength="6" />
<view class="phone_code_single_codeinput">
<view v-for="(item,index) in 6" :key="index" @click="codefocusFun(index)"
:style="(index == code.length? 'background-color:#FEF2F2;':'color: #313131;background-color:#eee')">
{{code[index]}}
</view>
</view>
</view>
<button :disabled="isCode" class="btn" type="warn" @click="submitFun()">确定</button>
</view>
</template>
<script>
export default {
data() {
return {
newPhone: "167****8898", //
isReget: false, //
timer: null, //
count: 60, //
code:"", //
focus:true, //
isCode:true //
}
},
onLoad(options) {
console.log(options)
this.getTimer() //
this.getCode() //
},
watch: {
count(val) {
if (val == 0) {
this.isReget = true
clearInterval(this.timer)
}
},
},
methods: {
/**
* AUTHOR: 单乘风
* DESC: 定时器
* */
getTimer() {
this.timer = setInterval(() => {
if (this.count == 0) {
clearInterval(this.timer)
uni.navigateBack({
delta: 1
})
return
}
this.count--
}, 1000)
},
/**
* AUTHOR: 单乘风
* DESC: 获取验证码
* */
getCode() {
console.log("获取验证码", this.newPhone)
if (this.count == 0) {
this.count = 60
this.isReget = false
this.getTimer()
}
},
/**
* AUTHOR: 单乘风
* DESC: 输入框输入事件
* */
codeNumInputFun(e) {
let val = e.detail.value
this.code = val
if (val.length == 6) this.isCode = false
else this.isCode = true
},
/**
* AUTHOR: 单乘风
* DESC: 输入框失去焦点事件
* */
codeNumBlurFun(e) {
let val = e.detail.value
this.focus = false
if (val.length == 6) this.isCode = false
else this.isCode = true
},
/**
* AUTHOR: 单乘风
* DESC: 输入框点击事件
* @param {Number} index 当前点击框索引
* */
codefocusFun(index) {
this.focus = true
},
/**
* AUTHOR: 单乘风
* DESC: 按钮点击事件
* */
submitFun() {
console.log("确认更换手机号")
},
}
}
</script>
<style lang="scss" scoped>
.phone {
background-color: #FFF;
width: 100vw;
height: 100vh;
&_code {
padding: 30rpx;
&_label {
font-size: 30rpx;
color: #999;
}
&_count {
margin-top: 30rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 100rpx;
&_new {
color: #FEF2F2;
font-size: 38rpx;
font-weight: bold;
}
&_down {
border: 1rpx solid #eee;
border-radius: 10rpx;
color: #999;
height: 60rpx;
line-height: 60rpx;
padding: 0 20rpx;
text {
margin-left: 10rpx;
}
}
}
&_single {
margin-top: 30rpx;
&_cinput {
position: fixed;
left: -100rpx;
width: 50rpx;
height: 50rpx;
}
&_codeinput {
margin: auto;
width: 650rpx;
height: 100rpx;
display: flex;
}
&_codeinput>view {
margin-top: 5rpx;
margin-left: 15rpx;
width: 86rpx;
height: 86rpx;
line-height: 86rpx;
font-size: 60rpx;
font-weight: bold;
color: #313131;
text-align: center;
border-radius: 10rpx;
}
&_codeinput>view:nth-child(1) {
margin-left: 0rpx;
}
}
}
}
.btn{
background-color: #FEF2F2;
}
</style>
Loading…
Cancel
Save