Blame view

lvdao-miniapp/pagesA/leaseAdd/leaseAdd.vue 5.44 KB
4373acf5   wesley88   1
1
2
3
4
5
6
7
8
  <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>
d64cd58f   wesley88   上传验收小程序
9
  			<!-- 		<u-form-item label="手机号" prop="phone" borderBottom>
4373acf5   wesley88   1
10
  						<u-input v-model="model1.phone"></u-input>
d64cd58f   wesley88   上传验收小程序
11
  					</u-form-item> -->
4373acf5   wesley88   1
12
13
14
15
16
17
18
19
20
21
22
  					<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">
8984a1f4   wesley88   1
23
24
  							<u-upload :action="url" @on-choose-complete="onsuccess1" :auto-upload="false"
  								:custom-btn="true" :max-count="1" ref="idPhotoFront">
4373acf5   wesley88   1
25
26
27
28
29
30
31
32
  								<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">
d64cd58f   wesley88   上传验收小程序
33
  							<u-upload :action="url" @on-choose-complete="onsuccess2" :auto-upload="false" :custom-btn="true" :max-count="1"
4373acf5   wesley88   1
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
  								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() {
  				console.error(this.fileList1)
  				console.error(this.fileList2)
d64cd58f   wesley88   上传验收小程序
115
  				
4373acf5   wesley88   1
116
117
118
  				this.model1.applyTime = this.getCurrentTime()
  				this.model1.idCardFrontImage = this.fileList1.join(',')
  				this.model1.idCardBackImage = this.fileList2.join(',')
d64cd58f   wesley88   上传验收小程序
119
120
121
122
123
124
  				this.model1.username = this.model1.name
  				this.model1.phone = uni.getStorageSync('user').phone
  				console.error({
  					...this.model1
  				})
  				// return
4373acf5   wesley88   1
125
126
127
128
129
130
131
132
133
134
  				this.$http.sendRequest('/cerePlatformMerchant/add', 'POST', this.model1, 2).then(res => {
  					console.error(res)
  					if (res.data.code) {
  						uni.showToast({
  							icon: 'none',
  							title: '提交申请成功'
  						})
  						setTimeout(() => {
  							uni.navigateBack()
  						}, 1000);
8984a1f4   wesley88   1
135
  					} else {
4373acf5   wesley88   1
136
137
138
139
140
141
142
  						uni.showToast({
  							icon: 'none',
  							title: '提交申请失败'
  						})
  					}
  				})
  			},
d64cd58f   wesley88   上传验收小程序
143
  			onup(e,e1) {
8984a1f4   wesley88   1
144
  				uni.uploadFile({
1ab21b43   杨鑫   '策略'
145
  					url: this.$upload, // 仅为示例,请替换为您的服务器上传接口
d64cd58f   wesley88   上传验收小程序
146
  					filePath: e,
8984a1f4   wesley88   1
147
148
  					name: 'file', // 后端接收的文件参数名
  					formData: {
1ab21b43   杨鑫   '策略'
149
  						filePath: 'xcx', // 其他表单数据
8984a1f4   wesley88   1
150
151
152
153
154
155
156
  					},
  					success: (uploadFileRes) => {
  						console.log('上传成功', uploadFileRes);
  						uni.showToast({
  							title: '上传成功',
  							icon: 'success',
  						});
d64cd58f   wesley88   上传验收小程序
157
  						this[e1].push(JSON.parse(uploadFileRes.data).data)
8984a1f4   wesley88   1
158
159
160
161
162
163
164
165
166
  					},
  					fail: (err) => {
  						console.error('上传失败', err);
  						uni.showToast({
  							title: '上传失败',
  							icon: 'none',
  						});
  					},
  				});
4373acf5   wesley88   1
167
  			},
d64cd58f   wesley88   上传验收小程序
168
169
170
171
172
  			onsuccess1(e) {
  				console.error(e)
  				this.fileList1 = []
  				this.onup(e[0].url,'fileList1')
  			},
4373acf5   wesley88   1
173
174
  			onsuccess2(e) {
  				console.error(e)
d64cd58f   wesley88   上传验收小程序
175
176
177
  				this.fileList2 = []
  				this.onup(e[0].url,'fileList2')
  				
4373acf5   wesley88   1
178
179
180
181
182
183
184
185
186
187
188
  			},
  			IdtypeChange(e) {
  				this.model1.idCardType = e[0].label;
  			},
  		}
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'leaseAdd.scss';
  </style>