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
| /**
| * CFormAgreement - 表单套装组件,同意协议勾选项
| * @author Tevin
| */
|
| <template>
| <view class="c-form-agreement">
| <view
| class="title"
| @tap="evt=>handleCheck()"
| >
| <view :class="['icon', checked?'checked':'']">
| <text class="at-icon at-icon-check"></text>
| </view>
| <text class="tips">我已阅读并同意</text>
| </view>
| <view
| class="protocol"
| @tap="evt=>openProtocol()"
| >{{protocol}}</view>
| <AtFloatLayout
| :title="protocol"
| :isOpened="protocolShow"
| :onClose="evt=>closeProtocol()"
| >
| <slot />
| </AtFloatLayout>
| </view>
| </template>
|
| <script>
| import { AtFloatLayout } from 'taro-ui-vue';
|
| export default {
| name: 'CFormAgreement',
| components: {
| AtFloatLayout,
| },
| props: {
| // 表单数据资源(表单组件内部机制专用)
| formRes: Object,
| // 需要同意的协议内容
| protocol: String,
| },
| data() {
| return {
| name: '$agreement',
| protocolShow: false,
| checked: false,
| };
| },
| methods: {
| handleCheck() {
| this.checked = !this.checked;
| },
| openProtocol() {
| this.protocolShow = true;
| },
| closeProtocol() {
| this.protocolShow = false;
| },
| },
| mounted() {
| this.$nextTick(() => {
| this.formRes.$regItemValidator(this.name, () => {
| if (this.checked) {
| return Promise.resolve({
| name: this.name,
| passed: true,
| });
| } else {
| return {
| name: this.name,
| passed: false,
| msg: '请同意' + this.protocol,
| };
| }
| });
| });
| },
| };
| </script>
|
|