@@ -16,6 +16,12 @@ | |||||
"navigationBarTitleText": "Weixin", | "navigationBarTitleText": "Weixin", | ||||
"navigationBarTextStyle": "black" | "navigationBarTextStyle": "black" | ||||
}, | }, | ||||
"plugins": { | |||||
"WechatSI": { | |||||
"version": "0.3.5", | |||||
"provider": "wx069ba97219f66d99" | |||||
} | |||||
}, | |||||
"style": "v2", | "style": "v2", | ||||
"sitemapLocation": "sitemap.json", | "sitemapLocation": "sitemap.json", | ||||
"usingComponents": { | "usingComponents": { | ||||
@@ -1,8 +1,11 @@ | |||||
const app = getApp() | const app = getApp() | ||||
import request from '../../utils/request' | import request from '../../utils/request' | ||||
import { scrollToID, keyWordsEnum } from '../../utils/util' | import { scrollToID, keyWordsEnum } from '../../utils/util' | ||||
Page({ | |||||
var plugin = requirePlugin("WechatSI") | |||||
let manager = plugin.getRecordRecognitionManager() | |||||
const record = wx.getRecorderManager() | |||||
Page({ | |||||
/** | /** | ||||
* 页面的初始数据 | * 页面的初始数据 | ||||
*/ | */ | ||||
@@ -22,7 +25,8 @@ Page({ | |||||
interval: null, | interval: null, | ||||
promotContentCount: 0, | promotContentCount: 0, | ||||
completionContentCount: 0, | completionContentCount: 0, | ||||
noticeText: '' | |||||
noticeText: '', | |||||
inputMode: true | |||||
}, | }, | ||||
/** | /** | ||||
@@ -397,6 +401,57 @@ Page({ | |||||
}) | }) | ||||
}, | }, | ||||
voiceMode() { | |||||
manager.start({ duration: 100, lang: "zh_CN" }) | |||||
manager.onStop(res => { | |||||
console.log('已获取麦克风调用权限!'); | |||||
}) | |||||
const inputMode = this.data.inputMode | |||||
this.setData({ | |||||
inputMode: !inputMode | |||||
}) | |||||
}, | |||||
speakStart() { | |||||
console.log('按下'); | |||||
wx.showLoading({ | |||||
title: '请说话' | |||||
}) | |||||
manager.start({ duration: 30000, lang: "zh_CN" }) | |||||
manager.onStart = function (res) { | |||||
console.log("成功开始录音识别", res) | |||||
} | |||||
}, | |||||
speakEnd() { | |||||
console.log('抬起'); | |||||
wx.hideLoading() | |||||
// wx.showLoading({ | |||||
// title: '正在识别', | |||||
// mask: true | |||||
// }) | |||||
manager.stop() | |||||
}, | |||||
initVoiceManager() { | |||||
manager.onRecognize = function (res) { | |||||
console.log("current result", res.result) | |||||
} | |||||
manager.onStop = function (res) { | |||||
console.log(res.tempFilePath, 'res'); | |||||
console.log(res.result, 'result'); | |||||
wx.hideLoading() | |||||
} | |||||
manager.onError = function (res) { | |||||
console.error("error msg", res.msg) | |||||
wx.showToast({ | |||||
title: '太短了,请描述长一点', | |||||
icon: 'none' | |||||
}) | |||||
} | |||||
}, | |||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
@@ -409,7 +464,7 @@ Page({ | |||||
* 生命周期函数--监听页面显示 | * 生命周期函数--监听页面显示 | ||||
*/ | */ | ||||
onShow() { | onShow() { | ||||
this.initVoiceManager() | |||||
}, | }, | ||||
/** | /** | ||||
@@ -212,9 +212,23 @@ page { | |||||
.boxOutside { | .boxOutside { | ||||
margin-bottom: 20rpx; | margin-bottom: 20rpx; | ||||
.voiceBtn { | |||||
height: 70rpx; | |||||
margin-right: 20rpx; | |||||
} | |||||
.pushBtn { | |||||
display: inline-block; | |||||
width: 530rpx; | |||||
height: 70rpx; | |||||
line-height: 60rpx; | |||||
padding: 5rpx 0; | |||||
margin-left: 35rpx; | |||||
} | |||||
.inputBox { | .inputBox { | ||||
display: inline-block; | display: inline-block; | ||||
width: 480rpx; | |||||
width: 410rpx; | |||||
height: 70rpx; | height: 70rpx; | ||||
line-height: 70rpx; | line-height: 70rpx; | ||||
border-radius: 10rpx; | border-radius: 10rpx; | ||||
@@ -40,8 +40,14 @@ | |||||
</view> | </view> | ||||
<view class="chatBox"> | <view class="chatBox"> | ||||
<view class="boxOutside"> | |||||
<view wx:if="{{ inputMode }}" class="boxOutside"> | |||||
<image class="voiceBtn" mode="heightFix" src="../../asset/icon/voice.png" bindtap="voiceMode"></image> | |||||
<input class="inputBox" type="text" bindinput="input" value="{{message}}" placeholder="单次最多可输入{{saysContentLength}}字" cursor-spacing="20" confirm-type="send" bindconfirm="send" /> | <input class="inputBox" type="text" bindinput="input" value="{{message}}" placeholder="单次最多可输入{{saysContentLength}}字" cursor-spacing="20" confirm-type="send" bindconfirm="send" /> | ||||
<button class="sendBtn" type="primary" bindtap="send">发送</button> | <button class="sendBtn" type="primary" bindtap="send">发送</button> | ||||
</view> | </view> | ||||
<view wx:if="{{ !inputMode }}" class="boxOutside"> | |||||
<image class="voiceBtn" mode="heightFix" src="../../asset/icon/keyboard.png" bindtap="voiceMode"></image> | |||||
<button class="pushBtn" type="primary" bindtouchstart="speakStart" bindtouchend="speakEnd">按住 说话</button> | |||||
</view> | |||||
</view> | </view> |
@@ -53,7 +53,7 @@ | |||||
<text bindtap="checkUserProtocol" style="margin-right: 20rpx;">用户协议</text> | <text bindtap="checkUserProtocol" style="margin-right: 20rpx;">用户协议</text> | ||||
<text bindtap="checkPayHistory">延续历史</text> | <text bindtap="checkPayHistory">延续历史</text> | ||||
</view> | </view> | ||||
<button type="primary" bindtap="goToBuy">延续使用</button> | |||||
<button type="primary" bindtap="goToChat">延续使用</button> | |||||
</block> | </block> | ||||
<!-- <block wx:if="{{userInfo.phone && userInfo.isMember == 0 && userInfo.isValid == 0}}"> | <!-- <block wx:if="{{userInfo.phone && userInfo.isMember == 0 && userInfo.isValid == 0}}"> | ||||