index.js
2.84 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import {
mineApi,
} from '~/api/api'
Component({
/**
* 组件的属性列表
*/
properties: {
show: Boolean,
userName:{
type:String,
observer(name){
this.handleName(name)
}
},
verifyId:Number
},
/**
* 组件的初始数据
*/
data: {
textList: [],
disable: true,
status: 0
},
/**
* 组件的方法列表
*/
methods: {
handleName(str) {
if (!str) return
const len = str.length
const arr = str.split('')
let temp = []
arr.forEach(el => {
let obj = {
text: el,
needFill: false,
verify: ''
}
temp.push(obj)
})
// 姓名为两个或三个字:展示第一和第三个字,第二个字需输入,
// 姓名为四个字:展示第一和第四个字,第二和第三个字需输入,
// 姓名为五个字或大于五个字,展示第一、第二、第五及以后的字,第三和第四个字需输入
if (len < 4) {
temp[1].needFill = true
} else if (len == 4) {
temp[1].needFill = true
temp[2].needFill = true
} else if (len > 4) {
temp[2].needFill = true
temp[3].needFill = true
}
this.setData({
textList: temp
})
},
intText(e) {
const { index } = e.currentTarget.dataset
const value = e.detail.value
const name = `textList[${index}].verify`
this.setData({
[name]: value
}, () => {
const { textList } = this.data
let flag = false
textList.forEach(el => {
if (el.needFill) {
if (!el.verify) {
flag = true
}
}
})
this.setData({
disable: flag
})
})
},
confirmText() {
const { textList, disable } = this.data
let success = true
if (disable) return
textList.forEach(el => {
if (el.needFill && el.verify != el.text) {
if (el.verify != el.text) {
success = false
}
}
})
if (!success) return this.setData({ status: 2 })
if (success) {
this.setData({ status: 1 })
this.toJumpMineJF()
setTimeout(() => {
this.setData({ status: 0 })
this.cancel()
}, 1500)
}
},
cancel() {
this.setData({
show: false
})
},
confirmCancel() {
this.setData({
status: 0,
disable: true
})
},
// 获取需要匹配账户的名称
async toJumpMineJF() {
const id = this.data.verifyId
const res = await mineApi.getUserForGR({id})
if(res){
wx.$router.go(`/packageShopmall/packageMine/pages/integral/index/index`,{source:'mine'})
}
}
},
lifetimes: {
// attached() {
// this.getMatchAcconut()
// },
}
})