image-check.js
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import udid from '../../common/udid';
import config from '../../common/config';
Component({
/**
* 组件的初始数据
*/
data: {
imageSrc: '',
degrees: [0, 0, 0, 0],
imageClass: [0, 0, 0, 0]
},
attached: function() {
this.setData({
imageSrc: this.getVerifyImage()
});
},
/**
* 组件的方法列表
*/
methods: {
/**
* 获取图片
*/
getVerifyImage: function() {
let timestamp = Date.parse(new Date());
let url = `${config.domains.api}/passport/img-check?business_line=${config.apiParams.business_line}&app_version=0.0.1&udid=${udid.get()}&client_type=${config.apiParams.client_type}&fromPage=${config.apiParams.client_type}&t=${timestamp}`; // eslint-disable-line
return url;
},
/**
* 更新图片
*/
refreshImage: function() {
this.setData({
imageSrc: this.getVerifyImage()
});
},
/**
* 改变图片的方向
*/
changeDirection: function(event) {
let indexNum = event.currentTarget.id.replace('image-', '');
let degrees = this.data.degrees;
let imageClass = this.data.imageClass;
degrees[indexNum] = (degrees[indexNum] + 1) % 4;
imageClass[indexNum] = (imageClass[indexNum] + 140) % 560;
this.setData({
degrees: degrees,
imageClass: imageClass
});
this.triggerEvent('refreshCode', {
degrees: this.data.degrees
});
}
}
});