资源描述:
《微信小程序开发(六)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、微信小程序开发(六)第六章APIAPI框架总览(绘图API专列章学习,暂略)网络API媒体API数据API位置API窗口API绘图API开放API设备API1Wx.request2Wx.uploadFile3Wx.downloadFile4Wx.connectSocket7onSocketOpen
2、onSocketError5Wx.sendSocketMessage8onSocketMessage6closeSockeonSocketClose1Wx.closeImage2Wx.previewImage3Wx.startRecord4Wx.stopRecord5
3、Wx.play[background][voice,audio]10onBackgroundAudioPlay6Wx.pause[background][voice,audio]11onBackgroundAudioPause7Wx.stop[background][voice,audio]12onBackgroundAudioStop8Wx.chooseVideo9Wx.saveFile1Wx.getStorage2Wx.setStorage3Wx.clearStoage1Wx.getLocation2Wx.openLocation1Wx.getNetWork
4、Type3onAccelerometerChange2Wx.getSystemInfo4onCompassChange1Wx.login2Wx.getUserInfo3Wx.requestPayment1Wx.navigateTo7Wx.hideKeyBoard2Wx.navigateBack8Wx.stopPulldownFresh3Wx.directTo9Wx.setNavigationBarTitle4Wx.createAnimation10wx.showNavigationBarLoading5Wx.createContext11wx.hideNavig
5、ationBarLoading6Wx.drawCanvas第1节网络API1.发送请求:wx.request(object)+数据请求Wx.request({url:url,data:{object},method:get
6、post,dataType:json,header:{content-type:application/json},success:function(res){vardata=res.data},fail:function(){},complate:function(){}})2.上传下载:wx.upload(object)
7、wx.downl
8、oad(object)+选取一个图片上传Wx.chooseImage({Success:function(res){Vartmp=res.tempFilePathsWx.uploadFile({url:url,filePath:tmp[0],name:”file”,formData:{user:test}})}})+下载一段音乐播放Wx.downloadFile({url:url,type:audio,success:function(res){wx.playVoice({filePath:res.tmpFilePath})}})1.嵌套字:+连接Wx.conn
9、ectSocket({url:url,data:{data},header:{},method:get
10、post})+打开Wx.onSocketOpen(function(res){…})+出错Wx.onSocketError(function(res){…})+发数据Wx.sendSocketMessage({data:msg})+发消息(回调)Wx.onSocketMessage(function(res){…})+关闭Wx.closeSocket({url:url})+关闭(回调)Wx.onSocketClose(function(res){…})第1节媒
11、体API1.图片:+选图Wx.chooseImage({count:1,sizetype:[],sourceType:[album,camera],success:function(res){…}})+预览Wx.previewImage({current:’’,urls:[]})2.录音:+录音Wx.startRecord({success:function(){},fail:function(){}})+停止Wx.stopRecord()1.音频控制:+播放Wx.playVoice({filePath:xxxx,comlete:function(){…}})+
12、暂停Wx.pauseVo