sen
1 天以前 7ed2a032d0724e68aec8af940f2ce0023a9f0eb7
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<template>
  <view>
    <view v-if="modelValue" class="popup-mask" @tap="close" />
    <view v-if="modelValue" class="popup-container" :class="{ show: modelValue }">
      <view class="popup-header">
        <text class="popup-title">实名信息确认</text>
        <view class="close-btn" @tap="close">
          <u-icon name="close" color="#999" size="20" />
        </view>
      </view>
 
      <view class="popup-body">
        <view class="signature-box">
          <Signature ref="signatureRef" v-model="localSignature" />
        </view>
        <button class="sign-btn" @tap="generateSignature" type="primary" plain size="mini">
          生成签名
        </button>
      </view>
 
      <view class="popup-footer">
        <button class="cancel-btn" @tap="close" :disabled="loading">取消</button>
        <button class="submit-btn" type="primary" :loading="loading" :disabled="!localSignature" @tap="submit">
          提交
        </button>
      </view>
    </view>
  </view>
</template>
 
<script>
import Signature from '@/components/sin-signature/index.vue'
 
export default {
  name: 'SignPopup',
  components: { Signature },
  props: {
    modelValue: {
      type: Boolean,
      default: false
    },
    signature: {
      type: String,
      default: ''
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      localSignature: ''
    }
  },
  watch: {
    modelValue(val) {
      if (val) this.localSignature = this.signature
    }
  },
  methods: {
    close() {
      if (this.loading) return
      this.$emit('update:modelValue', false)
    },
    async generateSignature() {
      try {
        const data = await this.$refs.signatureRef.getSyncSignature()
        this.localSignature = data
        this.$emit('update:signature', data)
        uni.showToast({ title: '签名已生成', icon: 'success' })
      } catch (err) {
        uni.showToast({ title: '签名生成失败', icon: 'none' })
      }
    },
    submit() {
      if (!this.localSignature) {
        return uni.showToast({ title: '请先生成签名', icon: 'none' })
      }
      this.$emit('update:signature', this.localSignature)
      this.$emit('submit')
    }
  }
}
</script>
 
<style scoped>
.popup-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
}
 
.popup-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ffffff;
  border-top-left-radius: 20rpx;
  border-top-right-radius: 20rpx;
  z-index: 999;
  padding: 30rpx;
  box-sizing: border-box;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
 
.popup-container.show {
  transform: translateY(0);
}
 
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30rpx;
  padding-bottom: 20rpx;
  border-bottom: 1rpx solid #f0f0f0;
}
 
.popup-title {
  flex: 1;
  font-size: 34rpx;
  color: #333;
  font-weight: 600;
  text-align: center;
}
 
.close-btn {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
.popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 10rpx 0;
}
 
.signature-box {
  width: 100%;
  height: 400rpx;
  border: 2rpx dashed #555;
  border-radius: 8rpx;
  overflow: hidden;
}
 
.sign-btn {
  margin-top: 20rpx;
  width: 200rpx;
}
 
.popup-footer {
  display: flex;
  gap: 20rpx;
  margin-top: 30rpx;
  padding-top: 20rpx;
  border-top: 1rpx solid #f0f0f0;
}
 
.popup-footer .cancel-btn,
.popup-footer .submit-btn {
  flex: 1;
  height: 90rpx;
  line-height: 90rpx;
  font-size: 32rpx;
  border-radius: 8rpx;
  border: none;
}
 
.popup-footer .cancel-btn {
  color: #666;
  background-color: #f5f5f5;
}
 
.popup-footer .submit-btn {
  color: #fff;
  background-color: #1677ff;
}
 
.popup-footer .submit-btn[disabled] {
  background-color: #c9d8e9;
  opacity: 0.7;
}
</style>