leaseAdd.vue
6.93 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<template>
<view class="page">
<view>
<u-form labelPosition="left" :model="model1" ref="uForm" :labelWidth="250">
<view class="add-list">
<u-form-item label="经营者姓名" prop="name" borderBottom>
<u-input v-model="model1.name"></u-input>
</u-form-item>
<!-- <u-form-item label="手机号" prop="phone" borderBottom>
<u-input v-model="model1.phone"></u-input>
</u-form-item> -->
<!-- <u-form-item label="证件类型" prop="idCardType" borderBottom>
<u-input v-model="model1.idCardType" type="select" @click="IdtypeShow = true"
placeholder='请选择类型' />
</u-form-item> -->
<u-form-item label="身份证号码" prop="idCardNumber" borderBottom>
<u-input v-model="model1.idCardNumber"></u-input>
</u-form-item>
</view>
<view class="add-list">
<view class="deom-box">
<view class="img-deom">
<u-upload :action="url" @on-choose-complete="onsuccess1" :auto-upload="false"
:custom-btn="true" :max-count="1" ref="idPhotoFront">
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover"
hover-stay-time="150">
<u-image width="304rpx" height="182rpx" :src="$imgUrl('/uploadID1.png')"></u-image>
</view>
</u-upload>
<text>点击上传证件人像面</text>
</view>
<view class="img-deom">
<u-upload :action="url" @on-choose-complete="onsuccess2" :auto-upload="false"
:custom-btn="true" :max-count="1" ref="idPhotoBack">
<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover"
hover-stay-time="150">
<u-image width="304rpx" height="182rpx" :src="$imgUrl('/uploadID2.png')"></u-image>
</view>
</u-upload>
<text>点击上传证件国徽面</text>
</view>
</view>
</view>
<view class="add-list">
<view style="line-height: 60rpx;">上传示例</view>
<view class="deom-box">
<view class="img-deom">
<u-image width="304rpx" height="182rpx" :src="$imgUrl('/front-icon.png')"></u-image>
<text>人脸示例图</text>
</view>
<view class="img-deom">
<u-image width="304rpx" height="182rpx" :src="$imgUrl('/back-icon.png')"></u-image>
<text>国徽面示例图</text>
</view>
</view>
</view>
<text
style="display: inline-block; font-size: 24rpx; line-height: 30px; margin: 24rpx 30rpx 0;">请拍摄证件原件,保证照片拍摄清晰,取图完整,不反光。</text>
</u-form>
</view>
<u-select v-model="IdtypeShow" :list="idType" @confirm="IdtypeChange"></u-select>
<!-- 保存按钮 -->
<view class="page-footer">
<u-button type="success" style="flex: 1; margin: 0 10px;" @click="go">提交申请</u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
url: 'http://8.130.38.56:9003/file/upload',
model1: {
name: '',
phone: '',
idCardType: '身份证',
idCardNumber: '',
idCardFrontImage: '',
idCardBackImage: '',
checkState: '1',
applyTime: ''
},
idType: [{
value: 1,
label: '身份证'
}, ],
IdtypeShow: false,
fileList1: [],
fileList2: [],
};
},
onLoad() {
},
onShow() {
},
methods: {
getCurrentTime() {
const now = new Date();
const year = now.getFullYear();
const month = ('0' + (now.getMonth() + 1)).slice(-2);
const day = ('0' + now.getDate()).slice(-2);
const hours = ('0' + now.getHours()).slice(-2);
const minutes = ('0' + now.getMinutes()).slice(-2);
const seconds = ('0' + now.getSeconds()).slice(-2);
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
go() {
if (!this.model1.idCardNumber) {
uni.showToast({
icon: 'none',
title: '请输入身份证号码'
});
return false;
}
this.model1.applyTime = this.getCurrentTime()
this.model1.idCardFrontImage = this.fileList1.join(',')
this.model1.idCardBackImage = this.fileList2.join(',')
if (!this.model1.idCardFrontImage) {
uni.showToast({
icon: 'none',
title: '请上传身份证照片'
});
return false;
}
if (!this.model1.idCardBackImage) {
uni.showToast({
icon: 'none',
title: '请上传身份证照片'
});
return false;
}
this.model1.username = this.model1.name
this.model1.phone = uni.getStorageSync('user').phone
console.error({
...this.model1
})
let info = {
"content": JSON.stringify({
type: '1',
title: '商家入驻审核申请',
content: '您的商家入驻申请已提交(申请时间:' + this.model1.applyTime +
'),正在审核中,审核通过后,我们将通过系统消息通知您,请保持关注;'
}), // 消息内容
"messageClass": 1, // 消息类型(1:指定用户发送)
"messageType": '通知消息', // 消息类型描述
"cereMessageReceipts": [ // 接收人列表
{
"phone": uni.getStorageSync('user').phone, // 用户ID
"messageType": '通知消息', // 消息类型
"content": JSON.stringify({
type: '1',
title: '商家入驻审核申请',
content: '您的商家入驻申请已提交(申请时间:' + this.model1.applyTime +
'),正在审核中,审核通过后,我们将通过系统消息通知您,请保持关注;'
}) // 消息内容
}
]
}
// return
this.$http.sendRequest('/cerePlatformMerchant/add', 'POST', this.model1, 2).then(res => {
console.error(res)
if (res.data.code) {
uni.showToast({
icon: 'none',
title: '提交申请成功'
})
this.$http.sendRequest('/cereMessage/sendToUser', 'POST', info, 1).then(res => {
console.error(res)
})
setTimeout(() => {
uni.navigateBack()
}, 1000);
} else {
uni.showToast({
icon: 'none',
title: '提交申请失败'
})
}
})
},
onup(e, e1) {
uni.uploadFile({
url: this.$upload, // 仅为示例,请替换为您的服务器上传接口
filePath: e,
name: 'file', // 后端接收的文件参数名
formData: {
filePath: 'xcx', // 其他表单数据
},
success: (uploadFileRes) => {
console.log('上传成功', uploadFileRes);
uni.showToast({
title: '上传成功',
icon: 'success',
});
this[e1].push(JSON.parse(uploadFileRes.data).data)
},
fail: (err) => {
console.error('上传失败', err);
uni.showToast({
title: '上传失败',
icon: 'none',
});
},
});
},
onsuccess1(e) {
console.error(e)
this.fileList1 = []
this.onup(e[0].url, 'fileList1')
},
onsuccess2(e) {
console.error(e)
this.fileList2 = []
this.onup(e[0].url, 'fileList2')
},
IdtypeChange(e) {
this.model1.idCardType = e[0].label;
},
}
}
</script>
<style scoped lang="scss">
@import 'leaseAdd.scss';
</style>