ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:18.90KB ,
资源ID:4055059      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4055059.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(微信小程序开发六.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

微信小程序开发六.docx

1、微信小程序开发六微信小程序开发(六)第六章 APIAPI框架总览(绘图API专列章学习,暂略)1Wx.navigateTo7Wx.hideKeyBoard2Wx.navigateBack8Wx.stopPulldownFresh3Wx.directTo9Wx.setNavigationBarTitle4Wx.createAnimation10wx.showNavigationBarLoading5Wx.createContext11wx.hideNavigationBarLoading6Wx.drawCanvas第1节 网络API1. 发送请求:wx.request(object)+数据请求W

2、x.request( url:url, data:object, method:get|post, dataType:json, header:content-type:application/json, success:function(res)var data=res.data, fail:function(), complate:function()2. 上传下载:wx.upload(object)|wx.download(object)+下载一段音乐播放Wx.downloadFile( url:url, type:audio, success:function(res) wx.play

3、Voice(filePath:res.tmpFilePath)3. 嵌套字:+连接Wx.connectSocket(url:url,data:data,header:,method:get|post)+打开Wx.onSocketOpen(function(res)+出错Wx.onSocketError(function(res)+发数据Wx.sendSocketMessage(data:msg)+发消息(回调)Wx.onSocketMessage(function(res)+关闭Wx.closeSocket(url:url)+关闭(回调)Wx.onSocketClose(function(re

4、s)第2节 媒体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()3. 音频控制:+播放Wx.playVoice(filePath:xxxx,comlete:function()+暂停Wx.pauseVoice()+停止Wx.stopVoice()4

5、. 音乐控制:+获状态Wx.getBackgroundAudioPlayState(success:function(res)res.status|dataUrl|currentPosition|duration)+播放Wx.playBackgroundAudio(dataUrl:xx,title:xx,coverImgUrl:xx)+暂停Wx.pauseBackgroundAudio()+定位Wx.seekBackgroundAudio(position:60)+停止Wx.stopBackgroundAudion()5. 视频:+逻辑层Page( Data:src:xxx, getVideo

6、:function() var that=this; wx.chooseVideo( sourceType:, success:function(res) that.setData( src:res.tempfilePath)6. 音频组件控制:+创建上下文Var ctx=wx.createAudioContext(audioId)+播放Ctx.paly()+暂停Ctx.pause()+进到Ctx.seek(n)+从头Ctx.seek(0)+停止Ctx.stop()7. 视频组件控制:+创建上下文Var ctx=wx.createVedioContext(videoId)+发送弹幕Ctx.se

7、ndDanmu(text:xxxx,color:#xxxxxx)8. 文件:+保存文件Wx.saveFile(tempFilePath:xxx,success:function(res)+获已保存文件列表Wx.getSavedFileList(success:function(res)var list=res.fileList)+获已保存文件信息Wx.getSavedFileInfo(filePath:xxx,success:function(res)+移除已保存文件Wx.removeSavedFile(filePath:xxx,complete:function(res)+打开文件Wx.op

8、enDocument(filePath:xxx,success:function(res)第3节 数据API+设置数据Wx.setStorage(key:xxx,value:xxx)+获取数据Wx.getStorage(key:xxx,success:function(res)+清空数据Wx.clearStorage()+设;置数据(异步)Wx.setStorageSync(key:xxx,value:xxx)+获取数据(异步)Wx.getStorageSync(key:xxx,success:function(res)+清空数据(异步)Wx.clearStorageSync()第4节 位置A

9、PI1. 位置:+获取位置Wx.getLocation(type:xxx,success:function(res)+打开位置Wx.openLocation(latitude:xx,longItude:xx,scale:xx)+选择位置Wx.chooseLocation(success:function(res)2. 地图组件:+创建上下文Var ctx=wx.createMapContext(mapId)+中心打开Ctx.openCenterLocation(success:function(res)+移动位置Ctx.moveToLocation(success:function(res)第

10、5节 设备API1. 系统信息:+同步获取信息wx.getSystemInfo( success: function(res) console.log(res.model) console.log(res.pixelRatio) console.log(res.windowWidth) console.log(res.windowHeight) console.log(res.language) console.log(res.version) console.log(res.platform) )+异步获取信息wx.getSystemInfo(success:function(res)2.

11、网络类型:+网络类型wx.getNetworkType( success: function(res) var networkType = workType / 返回网络类型2g,3g,4g,wifi, none, unknown )3. 重力感应:+重力感应wx.onAccelerometerChange(function(res) console.log(res.x) console.log(res.y) console.log(res.z)4. 罗盘指南:+罗盘指南wx.onCompassChange(function (res) console.log(res.direction)5.

12、 拨打电话:+拨打电话wx.makePhoneCall( phoneNumber: )6. 扫码:+扫码wx.scanCode( success: function(res) console.log(res) )7. 剪贴板:+加入剪贴板Wx.setClipboadData(data:xx,success:function(res)+读取剪贴板Wx.getClipboardData(success:function(res)var data=res.data)8. 篮牙:+篮牙wx.openBluetoothAdapter( success: function (res) console.lo

13、g(res) )第6节 窗口API1. 互动操作:+自消窗口Wx.showToast(title:xx,icon:xx,duration:xx)+对话框Wx.showDialog(title:xx)+对话框(模态)Wx.showModal(title:xx,content:xx,success:function(res)+活动页签Wx.showActionSheet(itemList:,success:function(res)2. 导航设置:+设标题Wx.setNavigationBarTitle(title:xxx)+显动画Wx.showNavigationBarLoading()+隐动画

14、Wx.hideVavigationBarLoading()3. 导航操控:+转到Wx.vavigatorTo(url:xx,success:function(res)+重定向Wx.redirectTo(url:xx;success:funtion(res)+重载Wx.reLaunch(url:xx,success:function(res)+切页Wx.switchTab(url:xxx)+返回Wx.navigatorBack(delta:xx)4. 动画操作:+创建动画Var ani=wx.createAnimation( transformOrign:xx, duration:xx, tim

15、ingFunction:xx)+具体方法(略)第7节 绘图API详述于第七章.第8节 开放接口API1. 小程序登录API=登录微信:+登录微信Wx.login(success:function()+检查会话Wx.checkSession(success:function(),fail:function()=签名验证|加密解密为了确保开放接口返回用户数据的安全性,微信会对明文数据进行签名。开发者可以根据业务需要对数据包进行签名校验,确保数据的完整性。签名校验算法涉及用户的session_key,通过 wx.login 登录流程获取用户session_key,并自行维护与应用自身登录态的对应关系

16、。通过调用接口(如 wx.getUserInfo)获取数据时,接口会同时返回 rawData、signature,其中 signature = sha1( rawData + session_key )开发者将 signature、rawData 发送到开发者服务器进行校验。服务器利用用户对应的 session_key 使用相同的算法计算出签名 signature2 ,比对 signature 与 signature2 即可校验数据的完整性。2. 用户信息wx.getUserInfo( success: function(res) var userInfo = res.userInfo var

17、 nickName = userInfo.nickName var avatarUrl = userInfo.avatarUrl var gender = userInfo.gender /性别 0:未知、1:男、2:女 var province = userInfo.province var city = userInfo.city var country = userInfo.country )3. 微信支付wx.requestPayment( timeStamp: , nonceStr: , package: , signType: MD5, paySign: , success:fun

18、ction(res) , fail:function(res) )4. 模板信息不作讲解5. 客服操作API=接收消息和事件-进入客服:-客服消息转发server:response-消息类型:文本,图片,事件-格式类型:xml,json-公共字段:ToUserName,FromUserName,CreateTime,MsgType,-专有字段:文本:Content,MsgId图片:PicUrl,MsgId事件:Event,SessionFrom=发送客服消息http请求方式: POST.com/cgi-bin/message/custom/send?access_token=ACCESS_TO

19、KEN=临时素材接口 -新增临时素材Curl -F media=test.jpg .com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE -获取临时素材.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID=接入指导(消息服务器接入) Step1:埴写服务器配置: Step2:服务器验证(PHP)private function checkSignature() $signature = $_GETsignature; $timestamp = $_

20、GETtimestamp; $nonce = $_GETnonce; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr, SORT_STRING); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr = $signature ) return true; else return false; Step3:实现服务功能6. 分享功能+设定分享Page( onShareAppMessage:function() r

21、eturn: title:xx,path:xx, success:function(res)/end return/end function)+显示分享Wx.showShareMenu()+隐藏分享Wx.hideShareMenu()7. 二维码通过后台接口可以获取小程序任意页面的二维码,扫描该二维码可以直接进入小程序对应的页面接口地址:.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN8. 收货地址wx.chooseAddress( success: function (res) console.log(res.user

22、Name) console.log(res.postalCode) console.log(res.provinceName) console.log(res.cityName) console.log(res.countyName) console.log(res.detailInfo) console.log(res.nationalCode) console.log(res.telNumber) )9. 卡券+加载卡券Wx.addCard(cardList:,success:function(res)+打开卡券Wx.openCard(cardList:,success:function(res)+card结构code:xx,openId:xx,timeStamp:xx,signature:xx10. 设置+打开设置Wx.openSetting(success:function(res)第9节 拓展接口API数据转换1 数据缓冲转为BASE64:Wx.arrayBufferToBase64(arrayBuffer)2 BASE64转为数据缓冲:Wx.base64ToArrayBuffer(base64)说明此章中没有列举绘图API,在第七章中专门学习.

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1