var app = getApp()
Page({
data: {
globalData:{
StatusBar:'',
Custom:'',
CustomBar:'',
},
newsList:[],
openid:'换日线',
animation:false,
voice:false,
sendout:false,
camera:false,
news:'',
pression:[],
emojis:false,
curra:0,
feature:[
{ src: '/images/album.png', name: '相册' }
],
alcur:false,
vision:'',
time:'',
duration:'',
playing:false,
cuindex:'',
},
fanhui:function(e){
wx.navigateBack({
delta: 1
})
},
cuinbut:function(e){
let that = this
setTimeout(function () {
wx.createSelectorQuery().select('#chat-height').boundingClientRect(function (rect) {
that.setData({
chatheight: parseFloat(rect.height) + parseFloat(that.data.curra),
curr: 'jump' + JSON.stringify(that.data.newsList.length - 1)
})
}).exec()
}, 100)
},
onShow:function(e){
this.setData({
curr: 'jump' + JSON.stringify(this.data.newsList.length-1)
})
},
onLoad: function (options) {
let that = this
wx.getSystemInfo({
success: e => {
that.data.globalData.StatusBar = e.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
that.data.globalData.Custom = capsule;
that.data.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
} else {
that.data.globalData.CustomBar = e.statusBarHeight + 50;
}
}
})
that.setData({
openid:options.openid,
globalData: that.data.globalData,
newsList: wx.getStorageSync('newsList'),
pression: app.emoji.pression,
vision: wx.getRecorderManager(),
})
},
getkey:function(e){
this.setData({
curra: e.detail.height,
})
this.cuinbut();
},
getblur:function(e){
this.setData({
curra: 0,
})
this.cuinbut();
},
onReady: function (e) {
this.cuinbut();
},
moninput:function(e){
let that = this
that.cuinbut();
this.setData({
sendout: e.detail.value?true:false,
news: e.detail.value,
})
},
scrollstart:function(e){
this.setData({
emojis: false,
camera: false,
})
this.cuinbut();
},
speak:function(e){
this.setData({
voice: !this.data.voice,
emojis:false,
camera:false,
})
this.cuinbut();
},
emoji:function(e){
this.setData({
emojis: !this.data.emojis,
voice:false,
camera:false,
})
this.cuinbut();
},
camerax:function(e){
this.setData({
camera: !this.data.camera,
voice: false,
emojis: false,
})
this.cuinbut();
},
upload:function(e){
const that = this
wx.chooseImage({
count: 1,
success: function (res) {
const src = res.tempFilePaths[0]
wx.getImageInfo({
src,
success: function (res) {
const { width, height } = res
const newChatList = [...that.data.newsList,{
news_type: 'image',
news_centent: { src, width, height },
openid: that.data.openid,
}]
that.setData({
animation: true,
newsList: newChatList,
})
wx.setStorageSync('newsList', newChatList);
that.cuinbut();
}
})
}
})
},
picture:function(e){
let src = e.currentTarget.dataset.src
wx.previewImage({
current: src,
urls: [src]
})
},
message:function(e){
let that = this
const newChatList = [...that.data.newsList, {
news_type: 'text',
news_centent: that.data.news,
openid: that.data.openid,
}]
that.setData({
animation: true,
newsList: newChatList,
sendout:false,
news: '',
})
wx.setStorageSync('newsList', newChatList);
that.cuinbut();
},
expression:function(e){
let item = e.currentTarget.dataset.item
this.setData({
sendout: true,
news: this.data.news+=item,
})
},
featch:function(e){
let that = this
let index = e.currentTarget.dataset.index
if(index == 0){
that.upload();
}
},
touchdown: function (e) {
let that = this
wx.stopVoice();
that.setData({
alcur: true,
playing: false,
cuindex: ''
})
that.data.duration = 0
that.data.time = setInterval(function () {
that.setData({
duration: that.data.duration+1
})
},1000)
wx.startRecord({
success: function (res) {
const newChatList = [...that.data.newsList, {
news_type: 'voice',
news_centent: { voice: res.tempFilePath, dimen: that.data.duration},
openid: that.data.openid,
}]
that.setData({
newsList: newChatList,
})
wx.setStorageSync('newsList', newChatList);
that.cuinbut();
},
fail:function(e){
that.touchup();
}
})
},
touchup: function (e) {
let that = this
wx.stopRecord()
clearInterval(that.data.time)
that.setData({
alcur:false
})
},
play: function (e) {
let that = this
let voice = e.currentTarget.dataset.voice
var index = e.currentTarget.dataset.index
if (!that.data.playing){
that.setData({
playing:true,
cuindex:index
})
wx.playVoice({
filePath: voice,
success: function () {
that.setData({
playing: false,
cuindex:''
})
},
})
}
},
suspend:function(e){
wx.stopVoice();
this.setData({
playing: false,
cuindex: ''
})
},
})
微信小程序聊天(仿微信).zip
需积分: 49 163 浏览量
2020-05-09
17:30:14
上传
评论 9
收藏 654KB ZIP 举报
换日线°
- 粉丝: 355
- 资源: 18
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈