test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // pages/test/test.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. },
  8. saoma:function(e){
  9. wx.scanCode({
  10. onlyFromCamera:true,
  11. success(res){
  12. console.log(res)
  13. }
  14. })
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. },
  21. start:function(){
  22. let that=this
  23. var plugin = requirePlugin("WechatSI")
  24. let manager = plugin.getRecordRecognitionManager()
  25. manager.onRecognize = function (res) {
  26. console.log("current result", res.result)
  27. that.setData({
  28. text: res.result
  29. })
  30. }
  31. manager.onStop = function (res) {
  32. console.log("record file path", res.tempFilePath)
  33. console.log("result", res.result)
  34. }
  35. manager.onStart = function (res) {
  36. console.log("成功开始录音识别", res)
  37. }
  38. manager.onError = function (res) {
  39. console.error("error msg", res.msg)
  40. }
  41. manager.start({ duration: 30000, lang: "zh_CN" })
  42. },
  43. stop:function(){
  44. var plugin = requirePlugin("WechatSI")
  45. let manager = plugin.getRecordRecognitionManager()
  46. manager.stop()
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function () {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function () {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function () {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage: function () {
  82. }
  83. })