微信小程序 用thinkphp的验证码类库captcha来做图形验证
亲测可用!上代码
code.js
const app = getApp()
Page({
data: {
imgUrl: '',
result: ''
},
onLoad() {
this.initCaptcha();
},
initCaptcha() {
let url = 'https:wei.cn/order/index.php/Home/Index/nindex.html'; // 空请求 为了拿到sessionId
wx.request({
header: app.globalData.header,
url,
data: {},
success: (res) => {
console.log('res', res);
this.setSessionId(res);
this.downloadCaptcha();
}
})
},
downloadCaptcha() {
var time = new Date().getTime();
console.log(time);
let url = '