Blame view

addons/exam/uniapp/common/api/common.js 1.05 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
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
  import utils from "../js/utils.js";

  

  /**

   * 公共接口

   */

  module.exports = {

  

  	/**

  	 * 上传文件

  	 * @returns {Promise<*>}

  	 */

  	uploadFile(handler, filePath, data = {}, fileType = 'image') {

  		

  		uni.uploadFile({

  			url: fun.SITE + 'api/wx/wxpayApplyImage',

  			header: {

  				'token': uni.getStorageSync('token'),

  				"Content-Type": "multipart/form-data"

  			},

  			fileType: fileType,

  			filePath: filePath,

  			formData: data,

  			name: 'file',

  			success: (res) => {

  				if (res.statusCode == 413) {

  					this.modalDo(true, '图片太大了,请压缩后再重新上传')

  					return

  				}

  

  				let data = JSON.parse(res.data)

  				if (data.status == 1) {

  					let result = data.result

  					this.ocrResult(type, result, lists)

  					return

  				} else {

  					this.modalDo(true, '识别有误,提交可能影响审核,建议重新上传更清晰的图片')

  					return

  				}

  			},

  			fail: (res) => {

  				console.log('fail res', res)

  			},

  			complete: (uploadFileRes) => {

  				this.showPopup = false

  			},

  		})

  	}

  }