Browse Source

9-24-upapply

lhl 3 years ago
parent
commit
3601b99aea
2 changed files with 48 additions and 3 deletions
  1. 8 0
      api/apply.js
  2. 40 3
      pages/upload/upload.vue

+ 8 - 0
api/apply.js

@@ -33,4 +33,12 @@ export function cancelApply(data,id) {
 		method:'get',
 		data
 	})
+}
+//上传凭证uploadApply
+export function uploadApply(data,id) {
+	return request({
+		url: '/api/activity/upload/' + id,
+		method:'post',
+		data
+	})
 }

+ 40 - 3
pages/upload/upload.vue

@@ -26,14 +26,20 @@
 	</view>
 </template>
 <script>
-
+	import {
+		uploadApply
+	} from '../../api/apply.js'
 	import { uploads } from '@/api/user.js';
 	export default {
 		data() {
 			return {
 				imgone: '',
-				imgtow: '',
+				imgtow: '',
+				apply_id: '',
 			}
+		},
+		onLoad(opt) {
+			this.apply_id = opt.id
 		},
 		methods: {
 			upimg(name) {
@@ -45,7 +51,38 @@
 				})
 			},
 			sub() {
-				
+				let obj = this
+				if(obj.imgone == '' && obj.imgtow == '') {
+					return obj.$api.msg('请上传凭证')
+				}
+				uni.showLoading({
+					title: '提交中...',
+					mask: true
+				})
+				let arr = []
+				if(obj.imgone) {
+					arr.push(obj.imgone)
+				}
+				if(obj.imgtow) {
+					arr.push(obj.imgtow)
+				}
+				console.log(arr,'arr')
+				uploadApply({
+					images:arr
+				},obj.apply_id).then( res => {
+					uni.hideLoading()
+					uni.showToast({
+						title:'提交成功',
+						duration:2000
+					});
+					setTimeout(function() {
+						uni.navigateBack();
+					}, 800);
+					console.log(res,'+++++++++++++++++')
+				}).catch( err => {
+					uni.hideLoading()
+					console.log(err)
+				})
 			}
 		}
 	}