• 前端uniapp提交表单调用接口方法最新


    源码1

    <template>
    	<view class="my-add-bank-card">
    		
    		<form @submit="formSubmit" @reset="formReset">
    			<view class="my-add-bank-card-box">
    				<view class="add-card-tit">
    					添加银行卡信息
    				view>
    				<view class="add-card-list1">
    					<view class="add-card-list-name1">
    						开户人姓名
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_user_name" type="text"
    							v-model="address.bank_user_name" placeholder="请填写银行卡开户人姓名" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						所属银行
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_name" type="text" v-model="address.bank_name"
    							placeholder="请填写所属银行" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						开户支行
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_account" type="number"
    							v-model="address.bank_account" placeholder="请填写开户支行" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						银行卡号
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_card" type="number" v-model="address.bank_card"
    							placeholder="请填写正确的银行卡号" />
    					view>
    				view>
    			view>
    			<view class="bankCardSub">
    				<button form-type="submit">提交银行卡信息button>
    			view>
    		form>
    		
    		
    	view>
    template>
    
    <script>
    	export default {
    		data() {
    			return {
    				address: {},
    			}
    		},
    		methods: {
    			formSubmit(e) {
    				let self = this;
    				var formdata = e.detail.value;
    				// formdata.province_id = self.province_id;//有特殊表单的单独加参数
    
    				// console.log(e, 'formdata');
    
    				// 校验里面formdata就是赋值给formdata对象里面了,然后传参就可以传了
    
    				if (formdata.bank_user_name == '') {
    					uni.showToast({
    						title: '请输入开户人姓名',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_name == '') {
    					uni.showToast({
    						title: '请输入所属银行',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_account == '') {
    					uni.showToast({
    						title: '请输入开户支行',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_card == '') {
    					uni.showToast({
    						title: '请输入银行卡号',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    
    				// if (formdata.phone == '') {
    				// 	uni.showToast({
    				// 		title: '请输入手机号码',
    				// 		duration: 1000,
    				// 		icon: 'none'
    				// 	});
    				// 	return false;
    				// }
    
    				// if (formdata.province_id == 0 || formdata.city_id == 0 || formdata.region_id) {
    				// 	if (formdata.detail == '') {
    				// 		uni.showToast({
    				// 			title: '请选择完整省市区',
    				// 			duration: 1000,
    				// 			icon: 'none'
    				// 		});
    				// 		return false;
    				// 	}
    				// }
    
    				self._post('user.user/bindUserBankData', formdata, function(res) {
    
    					// self.showSuccess(res.msg, function() {
    					// console.log(self.delta);
    					// #ifdef  H5
    					// uni.navigateBack({
    					// 	delta: parseInt(self.delta)
    					// });
    					//#endif
    					// #ifndef  H5
    					// uni.navigateBack({
    					// 	delta: 1
    					// });
    					//#endif
    					// });
    					
    					// console.log(res, '添加成功');
    					// 跳到添加成功
    					if (res.msg == '添加成功') {
    						uni.navigateTo({
    							url: '/pages/user/my-bank-card/my-successfully-added-bank-card/my-successfully-added-bank-card'
    						})
    					} else {
    						uni.showToast({
    							title: '添加失败',
    							duration: 1000,
    							icon: 'none'
    						});
    					}
    				});
    			},
    			/*清空数据*/
    			formReset: function(e) {
    				console.log('清空数据');
    			},
    		}
    	}
    script>
    
    <style scoped>
    	page {
    		background: #F8F9FA;
    	}
    
    	.my-add-bank-card {
    		display: flex;
    		flex-direction: column;
    	}
    
    	.my-add-bank-card-box {
    		width: 686rpx;
    		background: #FFFFFF;
    		border-radius: 16rpx 16rpx 16rpx 16rpx;
    		opacity: 1;
    		margin: 20rpx 32rpx 80rpx 32rpx;
    		padding: 24rpx 30rpx 0rpx 30rpx;
    		box-sizing: border-box;
    	}
    
    	.add-card-tit {
    		font-size: 36rpx;
    		font-family: Source Han Sans-Medium, Source Han Sans;
    		font-weight: 500;
    		color: #333333;
    		line-height: 50rpx;
    		font-weight: bold;
    	}
    
    	.add-card-list1 {
    		padding-top: 12rpx;
    		padding-bottom: 30rpx;
    		box-sizing: border-box;
    		display: flex;
    		align-items: center;
    	}
    
    	.add-card-list-name1 {
    		font-size: 32rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #3D3D3D;
    		line-height: 52rpx;
    	}
    
    	.add-card-list1-ipt {
    		margin-left: 24rpx;
    	}
    
    	.add-card-list {
    		padding-bottom: 30rpx;
    		box-sizing: border-box;
    		display: flex;
    		align-items: center;
    	}
    
    	.bankCardSub {
    		width: 554rpx;
    		height: 84rpx;
    		background: #891F50;
    		border-radius: 137rpx 137rpx 137rpx 137rpx;
    		opacity: 1;
    		margin: 0 auto;
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		font-size: 36rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #FFFFFF;
    		line-height: 36rpx;
    	}
    
    	.bankCardSub button {
    		width: 554rpx;
    		height: 84rpx;
    		background: #891F50;
    		border-radius: 137rpx 137rpx 137rpx 137rpx;
    		opacity: 1;
    		margin: 0 auto;
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		font-size: 36rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #FFFFFF;
    		line-height: 36rpx;
    	}
    style>
    
    • 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
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257

    源码2

    <template>
    	<view class="my-add-bank-card">
    		
    		<form @submit="formSubmit" @reset="formReset">
    			<view class="my-add-bank-card-box">
    				<view class="add-card-tit">
    					编辑银行卡信息
    				view>
    				<view class="add-card-list1">
    					<view class="add-card-list-name1">
    						开户人姓名
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_user_name" type="text"
    							v-model="address.bank_user_name" placeholder="请填写银行卡开户人姓名" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						所属银行
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_name" type="text" v-model="address.bank_name"
    							placeholder="请填写所属银行" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						开户支行
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_account" type="number"
    							v-model="address.bank_account" placeholder="请填写开户支行" />
    					view>
    				view>
    				<view class="add-card-list">
    					<view class="add-card-list-name1">
    						银行卡号
    					view>
    					<view class="add-card-list1-ipt">
    						<input class="popup-input-field" name="bank_card" type="number" v-model="address.bank_card"
    							placeholder="请填写正确的银行卡号" />
    					view>
    				view>
    			view>
    			<view class="bankCardSub">
    				<button form-type="submit">提交银行卡信息button>
    			view>
    		form>
    		
    		
    	view>
    template>
    
    <script>
    	export default {
    		data() {
    			return {
    				address: {
    					bank_user_name: '',
    					bank_name: '',
    					bank_account: '',
    					bank_card: '',
    					bank_id: ''
    				},
    			}
    		},
    		onLoad(onptions) {
    			// console.log(onptions.bank_user_name, '接受bank_user_name');
    			// console.log(onptions.bank_name, '接受bank_name');
    			// console.log(onptions.bank_account, '接受bank_account');
    			// console.log(onptions.bank_card, '接受bank_card');
    			this.address.bank_user_name = onptions.bank_user_name;
    			this.address.bank_name = onptions.bank_name;
    			this.address.bank_account = onptions.bank_account;
    			this.address.bank_card = onptions.bank_card;
    			this.bank_id = onptions.bank_id;
    		},
    		methods: {
    			formSubmit(e) {
    				let self = this;
    				var formdata = e.detail.value;
    				// formdata.province_id = self.province_id;//有特殊表单的单独加参数
    
    				// console.log(e, 'formdata');
    
    				// 校验里面formdata就是赋值给formdata对象里面了,然后传参就可以传了
    
    				this.bank_id = onptions.bank_id;
    				
    				formdata.bank_id = self.bank_id;	// 这个就是特殊的上一个页面传过来的参数id
    
    				if (formdata.bank_user_name == '') {
    					uni.showToast({
    						title: '请输入开户人姓名',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_name == '') {
    					uni.showToast({
    						title: '请输入所属银行',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_account == '') {
    					uni.showToast({
    						title: '请输入开户支行',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    				if (formdata.bank_card == '') {
    					uni.showToast({
    						title: '请输入银行卡号',
    						duration: 1000,
    						icon: 'none'
    					});
    					return false;
    				}
    
    
    				// if (formdata.phone == '') {
    				// 	uni.showToast({
    				// 		title: '请输入手机号码',
    				// 		duration: 1000,
    				// 		icon: 'none'
    				// 	});
    				// 	return false;
    				// }
    
    				// if (formdata.province_id == 0 || formdata.city_id == 0 || formdata.region_id) {
    				// 	if (formdata.detail == '') {
    				// 		uni.showToast({
    				// 			title: '请选择完整省市区',
    				// 			duration: 1000,
    				// 			icon: 'none'
    				// 		});
    				// 		return false;
    				// 	}
    				// }
    
    				self._post('user.user/editBankData', formdata, function(res) {
    
    					// self.showSuccess(res.msg, function() {
    					// console.log(self.delta);
    					// #ifdef  H5
    					// uni.navigateBack({
    					// 	delta: parseInt(self.delta)
    					// });
    					//#endif
    					// #ifndef  H5
    					// uni.navigateBack({
    					// 	delta: 1
    					// });
    					//#endif
    					// });
    
    					// console.log(res, '添加成功');
    					// 跳到添加成功
    					if (res.msg == '添加成功') {
    						uni.navigateTo({
    							url: '/pages/user/my-bank-card/my-successfully-edit-bank-card/my-successfully-edit-bank-card'
    						})
    					} else {
    						uni.showToast({
    							title: '添加失败',
    							duration: 1000,
    							icon: 'none'
    						});
    					}
    				});
    			},
    			/*清空数据*/
    			formReset: function(e) {
    				console.log('清空数据');
    			},
    		}
    	}
    script>
    
    <style scoped>
    	page {
    		background: #F8F9FA;
    	}
    
    	.my-add-bank-card {
    		display: flex;
    		flex-direction: column;
    	}
    
    	.my-add-bank-card-box {
    		width: 686rpx;
    		background: #FFFFFF;
    		border-radius: 16rpx 16rpx 16rpx 16rpx;
    		opacity: 1;
    		margin: 20rpx 32rpx 80rpx 32rpx;
    		padding: 24rpx 30rpx 0rpx 30rpx;
    		box-sizing: border-box;
    	}
    
    	.add-card-tit {
    		font-size: 36rpx;
    		font-family: Source Han Sans-Medium, Source Han Sans;
    		font-weight: 500;
    		color: #333333;
    		line-height: 50rpx;
    		font-weight: bold;
    	}
    
    	.add-card-list1 {
    		padding-top: 12rpx;
    		padding-bottom: 30rpx;
    		box-sizing: border-box;
    		display: flex;
    		align-items: center;
    	}
    
    	.add-card-list-name1 {
    		font-size: 32rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #3D3D3D;
    		line-height: 52rpx;
    	}
    
    	.add-card-list1-ipt {
    		margin-left: 24rpx;
    	}
    
    	.add-card-list {
    		padding-bottom: 30rpx;
    		box-sizing: border-box;
    		display: flex;
    		align-items: center;
    	}
    
    	.bankCardSub {
    		width: 554rpx;
    		height: 84rpx;
    		background: #891F50;
    		border-radius: 137rpx 137rpx 137rpx 137rpx;
    		opacity: 1;
    		margin: 0 auto;
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		font-size: 36rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #FFFFFF;
    		line-height: 36rpx;
    	}
    
    	.bankCardSub button {
    		width: 554rpx;
    		height: 84rpx;
    		background: #891F50;
    		border-radius: 137rpx 137rpx 137rpx 137rpx;
    		opacity: 1;
    		margin: 0 auto;
    		display: flex;
    		justify-content: center;
    		align-items: center;
    		font-size: 36rpx;
    		font-family: Source Han Sans-Regular, Source Han Sans;
    		font-weight: 400;
    		color: #FFFFFF;
    		line-height: 36rpx;
    	}
    style>
    
    • 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
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278

    最后

    感觉文章好的话记得点个心心和关注和收藏,有错的地方麻烦指正一下,如果需要转载,请标明出处,多谢!!!

  • 相关阅读:
    Java接口Json数组入参转换为指定List<Entity>
    理论与实践:如何写好一个方法
    GFP-GAN环境搭建&推理测试
    树莓派——5、Ubuntu18-04虚拟机搭建VMware版本
    图解http
    深入分析以太坊合并后的监管和应用层问题
    Cisco.Packet.Tracer思科模拟器浮动路由讲解(含实例步骤)
    第七章:最新版零基础学习 PYTHON 教程—Python 列表(第四节 -如何在 Python 中查找列表的长度)
    Dubbo线程池
    创建.NET程序Dump的几种姿势
  • 原文地址:https://blog.csdn.net/m0_49714202/article/details/134210654