RemarkPopup.js
2.62 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
// components/RemarkPopup/RemarkPopup.js
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
value: false,
observer: function (n) {
// if (n) this.getLetter()
console.log(n)
}
},
placeholder: String,
maxlength: Number,
value: {
type: String
},
// isFormComponent: {
// type: Boolean,
// value: false
// },
title: {
type: String,
value: '备注'
},
btnName: {
type: String
},
isLimitNum: {
type: Boolean,
value: false
},
isInt: {
type: Boolean,
value: false
},
required: {
type: Boolean,
value: false
}
},
/**
* 组件的初始数据
*/
data: {
inputValue: '',
isEdit: false
},
/**
* 组件的方法列表
*/
methods: {
noScroll() {},
blur(e) {
this.setData({
inputValue: e.detail.value,
isEdit: true
})
},
showPopup(e) {
// console.log()
let { name, btnName } = e.currentTarget.dataset
// if (btnName == 'cancel') {
// this.setData({
// value: ''
// })
// }
// console.log(name)
// 判断是不是来自组件 不是调用页面的数据修改
// 是用方法回传关闭
// let { isFormComponent } = this.data
// if (!isFormComponent) {
let thisPage = wx.$router.getPageInstance()
// console.log(thisPage)
console.log(thisPage)
thisPage.setData({
[name]: false
})
// 组件中使用
this.triggerEvent('cancel')
this.setData({
isEdit: false
})
// } else {
// // console.log('tri')
// this.triggerEvent('closePop')
// }
},
remarkConfirm() {
// console.log('confirm')
let { isInt, value, inputValue, isEdit, required } = this.data
let confirmValue = isEdit ? inputValue : value
console.log('1', confirmValue)
console.log('confirmValue', confirmValue.length)
if (isInt && !confirmValue.toString().length) {
return wx.showToast({
title: '修改值不能为空',
icon: 'none'
})
}
if (required && !confirmValue.length) {
return wx.showToast({
title: '内容不能为空',
icon: 'none'
})
}
// let { isFormComponent } = this.data
this.triggerEvent('confirm', confirmValue)
// if (!isFormComponent) {
this.showPopup({
currentTarget: {
dataset: {
name: 'showRemark'
}
}
})
// }
}
}
})