takephoto: function(n){
var that = this //保存当前上下文的引用
var i = n.currentTarget.id;//将事件触发的元素的id赋值给变量i
var history = app.globalData.history;
wx.chooseImage({
count: 1, //count表示选择图片的数量
sizeType:["original","compressed"],//选择图片的类型(原图或压缩图)
sourceType:[i], //图片来源(相册或相机)
success (res){
const tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'https://nongzuowu.xyz/log/login', //将图片文件上传到指定的服务器地址
filePath: tempFilePaths [0],
name:'file',
success(res){
var result=JSON.parse(res.data);
console.log(result);
app.globalDate.chl = result.CHL;
app.globalDate.lai = result.LAI;
app.globalDate.agb = result.AGB;
微信小程序前端实现与后台服务器之间的通信的主要函数——“takephoto”
最新推荐文章于 2024-07-24 11:19:16 发布