Commit bdf99b77 by 肖康

拖动验证码

parent 9391a1b4
import Vue from 'vue' import Vue from 'vue'
import {Toast} from 'vant'; import {Toast} from 'vant';
import {services as Services} from '../../../api/index' import {services as Services} from '../../../api/index'
import TCaptcha from '../../../util/tcaptcha';
var qs = require('qs'); var qs = require('qs');
Vue.use(Toast); Vue.use(Toast);
const state = { const state = {
loading: false loading: false,
randstr:"",//验证码客户端验证回调的随机串,
ticket:"",//验证码客户端验证回调的票据,
imgShowIsSuccess:false,//是否拖动图片验证成功
tcstate:false//传票验证 是否 验证成功
} }
const mutations = { const mutations = {
index(state, payload) { index(state, payload) {
state.index = payload.data; state.index = payload.data;
...@@ -40,21 +42,33 @@ const actions = { ...@@ -40,21 +42,33 @@ const actions = {
}, },
customSmsVerify({commit}, payload) { customSmsVerify({commit}, payload) {
state.loading = true; state.loading = true;
state.tcstate=false;
state.imgShowIsSuccess=false;
var params = { var params = {
pf: 2, pf: 2,
verify: '', mobile: payload.mobile,
mobile: payload.mobile randstr:payload.randstr,//验证码客户端验证回调的随机串,
ticket:payload.ticket//验证码客户端验证回调的票据
} }
Services.customSmsVerify(qs.stringify(params)).then((res) => { Services.customSmsVerify(qs.stringify(params)).then((res) => {
let data = res.data; let data = res.data;
state.loading = false; state.loading = false;
if (data.err_code == 0) { if (data.err_code == 0) {
state.tcstate=true;
Toast({ Toast({
message: data.err_msg, message: data.err_msg,
duration: 2000 duration: 2000
}); });
} else { } else if(data.err_code==23019||data.err_code==11008||data.err_code==11011){
TCaptcha.imgShow(function(res){
state.randstr=res.randstr;
state.ticket=res.ticket;
state.imgShowIsSuccess=false;
if(res.ret==0){
state.imgShowIsSuccess=true;
}
})
}else {
Toast({ Toast({
message: data.err_msg, message: data.err_msg,
duration: 3000 duration: 3000
......
import '../assets/js/TCaptcha';
/**腾讯验证码**/
export default {
imgShow:function(callback){
let randstr="";
let ticket="";
// 直接生成一个验证码对象
var captcha1 = new TencentCaptcha('2020469075', function(res) {
randstr=res.randstr;
ticket=res.ticket;
if(res.ret==0){
callback(res)
}
});
captcha1.show();
}
}
\ No newline at end of file
...@@ -278,7 +278,11 @@ ...@@ -278,7 +278,11 @@
}, },
computed: { computed: {
...mapState({ ...mapState({
loading: state => state.smt.loading loading: state => state.smt.loading,
randstr: state => state.smt.randstr,
ticket: state => state.smt.ticket,
tcstate:state => state.smt.tcstate,
imgShowIsSuccess:state => state.smt.imgShowIsSuccess
}), }),
linkName(){ linkName(){
return this.form.linkName; return this.form.linkName;
...@@ -307,6 +311,16 @@ ...@@ -307,6 +311,16 @@
account: this.form.mobile account: this.form.mobile
}) })
} }
},
tcstate(val){
if(val){
this.timeNum();
}
},
imgShowIsSuccess(val){
if(val){
this.getCode();
}
} }
}, },
methods: { methods: {
...@@ -332,7 +346,7 @@ ...@@ -332,7 +346,7 @@
} }
}, },
getCode() { getCode() {
this.timeNum();
this.$store.dispatch({ this.$store.dispatch({
type: 'customSmsVerify', type: 'customSmsVerify',
mobile: this.form.mobile mobile: this.form.mobile
......
...@@ -246,6 +246,7 @@ ...@@ -246,6 +246,7 @@
import {Swipe, SwipeItem, Loading} from 'vant'; import {Swipe, SwipeItem, Loading} from 'vant';
import Menu from '@/views/common/Menu.vue'; import Menu from '@/views/common/Menu.vue';
Vue.use(Swipe).use(SwipeItem).use(Loading); Vue.use(Swipe).use(SwipeItem).use(Loading);
export default { export default {
...@@ -280,7 +281,11 @@ ...@@ -280,7 +281,11 @@
}, },
computed: { computed: {
...mapState({ ...mapState({
loading: state => state.smt.loading loading: state => state.smt.loading,
randstr: state => state.smt.randstr,
ticket: state => state.smt.ticket,
tcstate:state => state.smt.tcstate,
imgShowIsSuccess:state => state.smt.imgShowIsSuccess
}), }),
comName() { comName() {
return this.form.com_name; return this.form.com_name;
...@@ -340,6 +345,16 @@ ...@@ -340,6 +345,16 @@
account: this.form.mobile account: this.form.mobile
}) })
} }
},
tcstate(val){
if(val){
this.timeNum();
}
},
imgShowIsSuccess(val){
if(val){
this.getCode();
}
} }
}, },
methods: { methods: {
...@@ -407,10 +422,11 @@ ...@@ -407,10 +422,11 @@
}, },
getCode() { getCode() {
this.timeNum();
this.$store.dispatch({ this.$store.dispatch({
type: 'customSmsVerify', type: 'customSmsVerify',
mobile: this.form.mobile mobile: this.form.mobile,
randstr:this.randstr,
ticket:this.ticket
}) })
}, },
timeNum() { timeNum() {
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js" type="text/javascript" charset="utf-8"></script> <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js" type="text/javascript" charset="utf-8"></script>
<script src="//szh5static.ichunt.com/static/js/flexible.min.js" type="text/javascript" charset="utf-8"></script> <script src="//szh5static.ichunt.com/static/js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
<script src="//szh5static.ichunt.com/static/js/shence.min.js" type="text/javascript" charset="utf-8"></script> <script src="//szh5static.ichunt.com/static/js/shence.min.js" type="text/javascript" charset="utf-8"></script>
<link href="//szh5static.ichunt.com/0.js" rel="prefetch"><link href="//szh5static.ichunt.com/1.js" rel="prefetch"><link href="//szh5static.ichunt.com/2.js" rel="prefetch"><link href="//szh5static.ichunt.com/3.js" rel="prefetch"><link href="//szh5static.ichunt.com/4.js" rel="prefetch"><link href="//szh5static.ichunt.com/5.js" rel="prefetch"><link href="//szh5static.ichunt.com/6.js" rel="prefetch"><link href="//szh5static.ichunt.com/7.js" rel="prefetch"><link href="//szh5static.ichunt.com/app.js" rel="preload" as="script"></head> <link href="//szh5static.ichunt.com/0.js" rel="prefetch"><link href="//szh5static.ichunt.com/1.js" rel="prefetch"><link href="//szh5static.ichunt.com/2.js" rel="prefetch"><link href="//szh5static.ichunt.com/3.js" rel="prefetch"><link href="//szh5static.ichunt.com/4.js" rel="prefetch"><link href="//szh5static.ichunt.com/5.js" rel="prefetch"><link href="//szh5static.ichunt.com/6.js" rel="prefetch"><link href="//szh5static.ichunt.com/app.js" rel="preload" as="script"></head>
<body class="boxsiz"> <body class="boxsiz">
<noscript> <noscript>
<strong>网站出现了一点小问题,正在紧急修复中.......</strong> <strong>网站出现了一点小问题,正在紧急修复中.......</strong>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment