您现在的位置: 微信小程序 > 微信小程序DEMO >

一个上传车牌到后台自动识别车牌号的demo(LUA后台)

来源:微信小程序 编辑:易用通 发布时间:04-08热度:
里面有备注,看看就懂了,
 

代码示例:
[AppleScript] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Page({ //上传图片到服务器
    chooseImg: function () {
        var that = this;//this赋值给thata
        wx.chooseImage({
            count: 1,
            sizeType: ['original', 'compressed'],
            sourceType: ['album', 'camera'],
            success: function (res) {
                var tempFilePaths = res.tempFilePaths
                wx.uploadFile({
                    url: '',//获取服务器地址。这里和lua后台输入就可以直接运行。
                    filePath: tempFilePaths[0],
                    name: 'file',
                    formData: {
                        'user': 'test'
                    },
                    success: function (res) {
 
                        var mydata = JSON.parse(res.data)//if判断
                        if (mydata.resultcode == 0) {//0是服务器返回的正确数据
                            var mydata1 = JSON.parse(mydata.response.data);//字符串转对象
                            var chepai = mydata1.words_result[0].words;//对象里的某个值赋值给chepai
                            that.setData({ cp: chepai });//给data里面的某个变量赋值
                            console.log(res.data)//打印res.data
                        } else {
                            console.log("错误", "上传失败")
                        }
                    }
                })
            }
        })
    }
})