uni-app 185iOS端兼容处理
生活随笔
收集整理的這篇文章主要介紹了
uni-app 185iOS端兼容处理
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
朋友圈樣式問(wèn)題
/pages.json
{"pages": [ //pages數(shù)組中第一項(xiàng)表示應(yīng)用啟動(dòng)頁(yè),參考:https://uniapp.dcloud.io/collocation/pages{"path" : "pages/common/login/login","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path": "pages/tabbar/index/index","style": {"navigationBarTitleText": "uni-app","disableScroll": true // 不嵌套 scroller}},{"path" : "pages/tabbar/find/find","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/tabbar/my/my","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/tabbar/mail/mail","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/chat/chat","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/video/video","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/chat-set/chat-set","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/user-base/user-base","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/user-tag-set/user-tag-set","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/user-remark-tag/user-remark-tag","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/user-moments-auth/user-moments-auth","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/send-card/send-card","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/user-report/user-report","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/find/moments/moments","style" : {"navigationBarTitleText": "","enablePullDownRefresh": true,"app-plus":{"pullToRefresh":{"support":true,"style":"circle"}}}},{"path" : "pages/my/userinfo/userinfo","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/my/code/code","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/my/fava/fava","style" : {"navigationBarTitleText": "","enablePullDownRefresh": true}},{"path" : "pages/common/search/search","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/find/add-moment/add-moment","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/my/setting/setting","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/add-friend/add-friend","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/apply-list/apply-list","style" : {"enablePullDownRefresh": true}},{"path" : "pages/mail/mail/mail","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/group-list/group-list","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/group-remark/group-remark","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/chat-list/chat-list","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/chat-history/chat-history","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/chat/group-user/group-user","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}},{"path" : "pages/mail/tag-list/tag-list","style" : {"navigationBarTitleText": "","enablePullDownRefresh": true}},{"path" : "pages/mail/tag-read/tag-read","style" : {"navigationBarTitleText": "","enablePullDownRefresh": false}}],"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "uni-app","navigationBarBackgroundColor": "#F8F8F8","backgroundColor": "#F8F8F8"},"globalStyle":{"navigationBarTextStyle":"black","navigationBarTitleText":"微信","navigationBarBackgroundColor":"#F8F8F8","backgroundColor":"#F8F8F8","app-plus":{"titleNView":false,"scrollIndicator":"none"}},"tabBar":{"borderStyle":"black","backgroundColor":"#F7F7F7","color":"#000000","selectedColor":"#08C261","list":[{"iconPath":"./static/tabbar/index.png","selectedIconPath":"./static/tabbar/index-select.png","pagePath":"pages/tabbar/index/index","text":"首頁(yè)"},{"iconPath":"./static/tabbar/mail.png","selectedIconPath":"./static/tabbar/mail-select.png","pagePath":"pages/tabbar/mail/mail","text":"通訊錄"},{"iconPath":"./static/tabbar/find.png","selectedIconPath":"./static/tabbar/find-select.png","pagePath":"pages/tabbar/find/find","text":"發(fā)現(xiàn)"},{"iconPath":"./static/tabbar/my.png","selectedIconPath":"./static/tabbar/my-select.png","pagePath":"pages/tabbar/my/my","text":"我的"}]},"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch --minimize","condition" : { //模式配置,僅開(kāi)發(fā)期間生效"current": 0, //當(dāng)前激活的模式(list 的索引項(xiàng))"list": [{"name": "", //模式名稱(chēng)"path": "", //啟動(dòng)頁(yè)面,必選"query": "" //啟動(dòng)參數(shù),在頁(yè)面的onLoad函數(shù)里面得到}]} }彈出層問(wèn)題
/components/free-ui/free-popup.vue
<template><div style="z-index:9999;overflow:hidden;" v-if="status"><!-- 蒙版 --><view v-if="mask" class="position-fixed top-0 left-0 right-0 bottom-0 z-index" :style="getMaskColor" @click="hide"></view><!-- 彈出框內(nèi)容 --><div ref="popup" class="position-fixed free-animated z-index" :class="getBodyClass" :style="getBodyStyle"><slot></slot></div></div> </template><script>// #ifdef APP-PLUS-NVUEconst animation = weex.requireModule('animation')// #endifexport default {props: {// 是否開(kāi)啟蒙版顏色maskColor: {type: Boolean,default: false},// 是否開(kāi)啟蒙版mask:{type:Boolean,default:true},// 是否居中center:{type:Boolean,default:false},// 是否處于底部bottom:{type:Boolean,default:false},// 彈出層內(nèi)容寬度bodyWidth:{type:Number,default:0},// 彈出層內(nèi)容高度bodyHeight:{type:Number,default:0},bodyBgColor:{type:String,default:"bg-white"},transformOrigin:{type:String,default:"left top"},// tabbar高度tabbarHeight:{type:Number,default:0}},data() {return {status: false,x:-1,y:1,maxX:0,maxY:0}},mounted() {try {const res = uni.getSystemInfoSync();this.maxX = res.windowWidth - uni.upx2px(this.bodyWidth)this.maxY = res.windowHeight - uni.upx2px(this.bodyHeight) - uni.upx2px(this.tabbarHeight)} catch (e) {// error}},computed: {getMaskColor() {let i = this.maskColor ? 0.5 : 0return `background-color: rgba(0,0,0,${i});` },getBodyClass(){if(this.center){return 'left-0 right-0 bottom-0 top-0 flex align-center justify-center'}let bottom = this.bottom ? 'left-0 right-0 bottom-0' : 'rounded border'return `${this.bodyBgColor} ${bottom}`},getBodyStyle(){let left = this.x > -1 ? `left:${this.x}px;` : ''let top = this.y > -1 ? `top:${this.y}px;` : ''return left + top}},methods:{show(x = -1 ,y = -1){if (this.status) {return;}this.x = (x > this.maxX) ? this.maxX : xthis.y = (y > this.maxY) ? this.maxY : ythis.status = true// #ifdef APP-PLUS-NVUE// this.$nextTick(()=>{// animation.transition(this.$refs.popup, {// styles: {// transform: 'scale(1,1)',// transformOrigin:this.transformOrigin,// opacity:1// },// duration: 100, //ms// timingFunction: 'ease',// }, function () {// console.log('動(dòng)畫(huà)執(zhí)行結(jié)束');// })// })// #endif},hide(){this.$emit('hide')// #ifdef APP-PLUS-NVUE// animation.transition(this.$refs.popup, {// styles: {// transform: 'scale(0,0)',// transformOrigin:this.transformOrigin,// opacity:0// },// duration: 100, //ms// timingFunction: 'ease',// }, ()=> {// this.status = false// console.log('動(dòng)畫(huà)執(zhí)行結(jié)束');// })// #endifthis.status = false}}} </script><style scoped>.free-animated{/* #ifdef APP-PLUS-NVUE *//* transform: scale(0,0);opacity: 0; *//* #endif */}.z-index{/* #ifndef APP-NVUE */z-index: 9999;/* #endif */} </style>底部聊天框問(wèn)題
/pages/chat/chat/chat.nvue
<template><view><!-- 導(dǎo)航欄 --><free-nav-bar :title="detail.name" :noreadnum="totalNoreadnum" showBack><free-icon-button slot="right" @click="openChatSet"><text class="iconfont font-lg"></text></free-icon-button></free-nav-bar><!-- 聊天內(nèi)容區(qū)域 --><scroll-view scroll-y class="bg-light position-fixed left-0 right-0 px-3"style="bottom: 105rpx;box-sizing: border-box;" :style="chatBodyBottom" :show-scrollbar="false":scroll-into-view="scrollIntoView" :scroll-with-animation="true" @click="clickPage"><!-- 聊天信息列表組件 --><view v-for="(item,index) in list" :key="index" :id="'chatItem_'+index"><free-chat-item :item="item" :index="index" ref="chatItem":pretime=" index > 0 ? list[index-1].create_time : 0" @long="long" @preview="previewImage":shownickname="currentChatItem.shownickname"></free-chat-item></view></scroll-view><!-- #ifdef APP-PLUS-NVUE --><div v-if="mode === 'action' || mode === 'emoticon'" class="position-fixed top-0 right-0 left-0":style="'bottom:'+maskBottom+'px;'" @click="clickPage"></div><!-- #endif --><!-- 底部輸入框 --><view class="position-fixed left-0 right-0 border-top ":style="'bottom:'+KeyboardHeight+'px;'"><view class="flex align-center" style="background-color: #F7F7F6;height: 105rpx;"><free-icon-button v-if="mode === 'audio'" @click="changeVoiceOrText"><textclass="iconfont font-lg"></text></free-icon-button><free-icon-button v-else @click="changeVoiceOrText"><text class="iconfont font-lg"></text></free-icon-button><view class="flex-1"><view v-if="mode === 'audio'" class="rounded flex align-center justify-center" style="height: 80rpx;":class="isRecording?'bg-hover-light':'bg-white'" @touchstart="voiceTouchStart"@touchend="voiceTouchEnd" @touchcancel="voiceTouchCancel" @touchmove="voiceTouchMove"><text class="font">{{isRecording ? '松開(kāi) 結(jié)束':'按住 說(shuō)話'}}</text></view><textarea v-else fixed class="bg-white rounded p-2 font-md" style="height: 80rpx;max-width: 450rpx;":adjust-position="false" v-model="text" @focus="focus" @blur="blur" /></view><!-- 表情 --><free-icon-button @click="openActionOrEmoticon('emoticon')"><text class="iconfont font-lg"></text></free-icon-button><template v-if="text.length === 0"><!-- 擴(kuò)展菜單 --><free-icon-button @click="openActionOrEmoticon('action')"><text class="iconfont font-lg"></text></free-icon-button></template><view v-else class="flex-shrink"><!-- 發(fā)送按鈕 --><free-main-button name="發(fā)送" @click="send('text')"></free-main-button></view></view><view v-if="mode==='emoticon' || mode ==='action'" style="height: 580rpx;" class="border-top border-light-secondary bg-light"><swiper :indicator-dots="emoticonOrActionList.length > 1" style="height: 510rpx;"><swiper-item class="row" v-for="(item,index) in emoticonOrActionList" :key="index"><view class="col-3 flex flex-column align-center justify-center" style="height: 255rpx;"v-for="(item2,index2) in item" :key="index2" @click="actionEvent(item2)"><image :src="item2.icon" mode="widthFix" style="width: 100rpx;height: 100rpx;"></image><text class="font-sm text-muted mt-2">{{item2.name}}</text></view></swiper-item></swiper></view></view><!-- 擴(kuò)展菜單 --><!-- <free-popup ref="action" bottom transformOrigin="center bottom" @hide="KeyboardHeight = 0" :mask="false"><view style="height: 580rpx;" class="border-top border-light-secondary bg-light"><swiper :indicator-dots="emoticonOrActionList.length > 1" style="height: 510rpx;"><swiper-item class="row" v-for="(item,index) in emoticonOrActionList" :key="index"><view class="col-3 flex flex-column align-center justify-center" style="height: 255rpx;"v-for="(item2,index2) in item" :key="index2" @click="actionEvent(item2)"><image :src="item2.icon" mode="widthFix" style="width: 100rpx;height: 100rpx;"></image><text class="font-sm text-muted mt-2">{{item2.name}}</text></view></swiper-item></swiper></view></free-popup> --><!-- 彈出層 --><free-popup ref="extend" :bodyWidth="240" :bodyHeight="450" :tabbarHeight="105"><view class="flex flex-column" style="width: 240rpx;" :style="getMenusStyle"><view class="flex-1 flex align-center" hover-class="bg-light" v-for="(item,index) in menusList":key="index" @click="clickEvent(item.event)"><text class="font-md pl-3">{{item.name}}</text></view></view></free-popup><!-- 錄音提示 --><view v-if="isRecording" class="position-fixed top-0 left-0 right-0 flex align-center justify-center"style="bottom: 105rpx;"><view style="width: 360rpx;height: 360rpx;background-color: rgba(0,0,0,0.5);"class="rounded flex flex-column align-center justify-center"><image src="/static/images/audio/audio/recording.gif" style="width: 150rpx;height: 150rpx;"></image><text class="font text-white mt-3">{{unRecord ? '松開(kāi)手指,取消發(fā)送':'手指上滑,取消發(fā)送'}}</text></view></view></view> </template><script>// #ifdef APP-PLUS-NVUEconst dom = weex.requireModule('dom')// #endifimport freeNavBar from "@/components/free-ui/free-nav-bar.vue"import freeIconButton from "@/components/free-ui/free-icon-button.vue"import freeChatItem from '@/components/free-ui/free-chat-item.vue';import freePopup from "@/components/free-ui/free-popup.vue"import freeMainButton from '@/components/free-ui/free-main-button.vue';import {mapState,mapMutations} from 'vuex'import auth from '@/common/mixin/auth.js';import $U from '@/common/free-lib/util.js';import $H from '@/common/free-lib/request.js';import $C from '@/common/free-lib/config.js';export default {mixins: [auth],components: {freeNavBar,freeIconButton,freeChatItem,freePopup,freeMainButton},data() {return {scrollIntoView: "",// 模式 text輸入文字,emoticon表情,action操作,audio音頻mode: "text",// 擴(kuò)展菜單列表actionList: [[{name: "相冊(cè)",icon: "/static/images/extends/pic.png",event: "uploadImage"}, {name: "拍攝",icon: "/static/images/extends/video.png",event: "uploadVideo"}, {name: "收藏",icon: "/static/images/extends/shoucan.png",event: "openFava"}, {name: "名片",icon: "/static/images/extends/man.png",event: "sendCard"}, {name: "語(yǔ)音通話",icon: "/static/images/extends/phone.png",event: ""}, {name: "位置",icon: "/static/images/extends/path.png",event: ""}]],emoticonList: [],// 鍵盤(pán)高度KeyboardHeight: 0,menusList: [],navBarHeight: 0,list: [],// 當(dāng)前操作的氣泡索引propIndex: -1,// 輸入文字text: "",// 音頻錄制狀態(tài)isRecording: false,RecordingStartY: 0,// 取消錄音unRecord: false,detail: {id: 0,name: "",avatar: "",chat_type: "user"},isfocus:false}},mounted() {var statusBarHeight = 0// #ifdef APP-PLUS-NVUEstatusBarHeight = plus.navigator.getStatusbarHeight()// #endifthis.navBarHeight = statusBarHeight + uni.upx2px(90)// // 監(jiān)聽(tīng)鍵盤(pán)高度變化// uni.onKeyboardHeightChange(res => {// if (this.mode !== 'action' && this.mode !== 'emoticon') {// this.KeyboardHeight = res.height// }// if (this.KeyboardHeight > 0) {// this.pageToBottom()// }// })// 注冊(cè)發(fā)送音頻事件this.regSendVoiceEvent((url) => {if (!this.unRecord) {this.send('audio', url, {time: this.RecordTime})}})this.pageToBottom()},computed: {...mapState({chatList: state => state.user.chatList,RECORD: state => state.audio.RECORD,RecordTime: state => state.audio.RecordTime,chat: state => state.user.chat,totalNoreadnum: state => state.user.totalNoreadnum,user: state => state.user.user}),// 當(dāng)前會(huì)話配置信息currentChatItem() {let index = this.chatList.findIndex(item => item.id === this.detail.id && item.chat_type === this.detail.chat_type)if (index !== -1) {return this.chatList[index]}return {}},// 獲取蒙版的位置maskBottom() {let h = this.mode !== 'emoticon' || this.mode === 'action' ? uni.upx2px(685) : uni.upx2px(105)if(this.isfocus){h = this.KeyboardHeight + uni.upx2px(105)}return this.KeyboardHeight + h},// 動(dòng)態(tài)獲取菜單高度getMenusHeight() {let H = 100return this.menusList.length * H},// 獲取菜單的樣式getMenusStyle() {return `height: ${this.getMenusHeight}rpx;`},// 判斷是否操作本人信息isdoSelf() {// 獲取本人id(假設(shè)拿到了)let id = 1let user_id = this.propIndex > -1 ? this.list[this.propIndex].user_id : 0return user_id === id},// 聊天區(qū)域bottomchatBodyBottom() {let h = this.mode !== 'emoticon' || this.mode === 'action' ? uni.upx2px(685) : uni.upx2px(105)if(this.isfocus){h = this.KeyboardHeight + uni.upx2px(105)}return `bottom:${h}px;top:${this.navBarHeight}px;`},// 獲取操作或者表情列表emoticonOrActionList() {return (this.mode === 'emoticon' || this.mode === 'action') ? this[this.mode + 'List'] : []},// 所有信息的圖片地址imageList() {let arr = []this.list.forEach((item) => {if (item.type === 'emoticon' || item.type === 'image') {arr.push(item.data)}})return arr}},watch: {mode(newValue, oldValue) {if (newValue !== 'text') {this.KeyboardHeight = 0;this.isfocus = false;uni.hideKeyboard()}}},onLoad(e) {if (!e.params) {return this.backToast()}this.detail = JSON.parse(decodeURIComponent(e.params))//console.log(this.detail);// 初始化this.__init()// 創(chuàng)建聊天對(duì)象this.chat.createChatObject(this.detail)// 獲取歷史記錄this.list = this.chat.getChatDetail()// 監(jiān)聽(tīng)接收聊天信息uni.$on('onMessage', this.onMessage)uni.$on('updateHistory', this.updateHistory)// 監(jiān)聽(tīng)發(fā)送收藏和名片uni.$on('sendItem', this.onSendItem)},destroyed() {// 銷(xiāo)毀聊天對(duì)象this.chat.destoryChatObject()// 銷(xiāo)毀監(jiān)聽(tīng)接收聊天消息uni.$off('onMessage', this.onMessage)uni.$off('updateHistory', this.updateHistory)uni.$off('sendItem', this.onSendItem)},methods: {...mapMutations(['regSendVoiceEvent']),onSendItem(e) {if (e.sendType === 'fava' || e.sendType === 'card') {this.send(e.type, e.data, e.options)}},updateHistory(isclear = true) {if (isclear) {this.list = []} else {this.list = this.chat.getChatDetail()}},onMessage(message) {//console.log('[聊天頁(yè)] 監(jiān)聽(tīng)接收聊天信息', message);if ((message.from_id === this.detail.id && message.chat_type === 'user') || (message.chat_type ==='group' && message.to_id === this.detail.id)) {if (message.isremove !== 1) {this.list.push(message)// 置于底部return this.pageToBottom()}// 撤回消息let index = this.list.findIndex(item => item.id === message.id)if (index !== -1) {this.list[index].isremove = 1}}},__init() {var total = 24;var page = Math.ceil(total / 8);var arr = [];for (var i = 0; i < page; i++) {var start = i * 8;arr[i] = [];for (var j = 0; j <= 8; j++) {arr[i].push({name: '表情' + (start + j),icon: '/static/images/emoticon/5497/' + (start + j) + '.gif',event: 'sendEmoticon'})}}this.emoticonList = arr;// var total = 20// var page = Math.ceil(total/8)// var arr = []// for (var i = 0; i < page; i++) {// var start = i*8// arr[i] = []// for (var j = 0; j < 8; j++) {// var no = start + j// if ((no+1) > total) {// continue;// }// arr[i].push({// name:"表情"+no,// icon: $C.emoticonUrl + no +'.gif',// event:"sendEmoticon"// })// }// }// this.emoticonList = arr// 初始化會(huì)話列表this.chat.initChatListItem({chat_type: this.detail.chat_type,to_id: this.detail.id,to_name: this.detail.name,to_avatar: this.detail.avatar,data: this.detail.chat_type === 'user' ? '你們已經(jīng)是好友,可以開(kāi)始聊天了' : '你已經(jīng)加入群聊,可以開(kāi)始聊天了'})},// 打開(kāi)擴(kuò)展菜單或者表情包openActionOrEmoticon(mode = 'action') {this.mode = modethis.$refs.action.show()uni.hideKeyboard()this.KeyboardHeight = uni.upx2px(580)},// 發(fā)送send(type, data = '', options = {}) {// 組織數(shù)據(jù)格式switch (type) {case 'text':data = data || this.textbreak;}let message = this.chat.formatSendData({type,data,options})// 渲染到頁(yè)面let index = this.list.lengththis.list.push(message)// 監(jiān)聽(tīng)上傳進(jìn)度let onProgress = falseif (message.type !== 'text' && message.type !== 'emoticon' && message.type !== 'card' && !message.data.startsWith('http')) {onProgress = (progress) => {// //console.log('上傳進(jìn)度:', progress);}}// 發(fā)送到服務(wù)端this.chat.send(message, onProgress).then(res => {//console.log(res);// 發(fā)送成功this.list[index].id = res.idthis.list[index].data = res.data;this.list[index].sendStatus = 'success'}).catch(err => {// 發(fā)送失敗this.list[index].sendStatus = 'fail'//console.log(err);})// 發(fā)送文字成功,清空輸入框if (type === 'text') {this.text = ''}// 置于底部this.pageToBottom()},// 回到底部pageToBottom() {setTimeout(() => {// #ifdef APP-PLUS-NVUElet chatItem = this.$refs.chatItemif(chatItem){let lastIndex = chatItem.length > 0 ? chatItem.length - 1 : 0if (chatItem[lastIndex]) {dom.scrollToElement(chatItem[lastIndex], {})}}// #endif// #ifndef APP-NVUElet lastIndex = this.list.length - 1this.scrollIntoView = 'chatItem_' + lastIndex// #endif}, 300)},// 長(zhǎng)按消息氣泡long({x,y,index}) {// 初始化 索引this.propIndex = index// 組裝菜單let menus = [{name: "發(fā)送給朋友",event: 'sendToChatItem'}, {name: "收藏",event: 'fava'}, {name: "刪除",event: 'delete'}]let item = this.list[this.propIndex]let isSelf = this.user.id === item.from_idif (isSelf) {menus.push({name: "撤回",event: 'removeChatItem'})}// #ifndef H5if (item.type === 'text') {menus.unshift({name: "復(fù)制",event: 'copy',})}// #endifthis.menusList = menus// 顯示擴(kuò)展菜單this.$refs.extend.show(x, y)},// 操作菜單方法分發(fā)clickEvent(event) {let item = this.list[this.propIndex]let isSelf = this.user.id === item.from_idswitch (event) {case 'removeChatItem': // 撤回消息// 拿到當(dāng)前被操作的信息this.chat.recall(item).then(res => {item.isremove = 1})break;case 'sendToChatItem':uni.navigateTo({url: '../chat-list/chat-list?params=' + encodeURIComponent(JSON.stringify(item)),});break;case 'copy': // 復(fù)制uni.setClipboardData({data: item.data,success: () => {uni.showToast({title: '復(fù)制成功',icon: 'none'});}});break;case 'delete':uni.showModal({content: '是否要?jiǎng)h除該記錄?',success: (res) => {if (!res.confirm) return;this.chat.deleteChatDetailItem(item, isSelf)this.list.splice(this.propIndex, 1)// 刪除最后一條消息if (this.list.length === this.propIndex) {this.chat.updateChatItem({id: this.detail.id,chat_type: this.detail.chat_type}, (v) => {let o = this.list[this.propIndex - 1]let data = ''if (o) {data = this.chat.formatChatItemData(o, isSelf)}v.data = datareturn v})}}});break;case 'fava': // 加入收藏uni.showModal({content: '是否要加入收藏?',success: (res) => {if (res.confirm) {$H.post('/fava/create', {type: item.type,data: item.data,options: JSON.stringify(item.options)}).then(res => {uni.showToast({title: '加入收藏成功',icon: 'none'});})}}});break;}// 關(guān)閉菜單this.$refs.extend.hide()},// 擴(kuò)展菜單actionEvent(e) {switch (e.event) {case 'uploadImage': // 選擇相冊(cè)uni.chooseImage({count: 9,success: (res) => {// 發(fā)送到服務(wù)器// 渲染到頁(yè)面res.tempFilePaths.forEach((item) => {this.send('image', item)})}})break;case 'uploadVideo': // 發(fā)送短視頻uni.chooseVideo({maxDuration: 10,success: (res) => {this.send('video', res.tempFilePath)// 渲染頁(yè)面// 發(fā)送到服務(wù)端(獲取視頻封面,返回url)// 修改本地的發(fā)送狀態(tài)}})break;case 'sendEmoticon': // 發(fā)送表情包this.send('emoticon', e.icon)break;case 'openFava': // 發(fā)送收藏uni.navigateTo({url: '../../my/fava/fava?type=send',});break;case 'sendCard': // 發(fā)送名片uni.navigateTo({url: '../../mail/mail/mail?type=sendCard&limit=1',});break;}},// 點(diǎn)擊頁(yè)面clickPage() {this.mode = ''},// 預(yù)覽圖片previewImage(url) {uni.previewImage({current: url,urls: this.imageList,indicator: "default"})},// 切換音頻錄制和文本輸入changeVoiceOrText() {this.mode = this.mode !== 'audio' ? 'audio' : 'text'},// 錄音相關(guān)// 錄音開(kāi)始voiceTouchStart(e) {// 初始化this.isRecording = truethis.RecordingStartY = e.changedTouches[0].screenYthis.unRecord = false// 開(kāi)始錄音this.RECORD.start({format: "mp3"})},// 錄音結(jié)束voiceTouchEnd() {this.isRecording = false// 停止錄音this.RECORD.stop()},// 錄音被打斷voiceTouchCancel() {this.isRecording = falsethis.unRecord = true// 停止錄音this.RECORD.stop()},voiceTouchMove(e) {let Y = Math.abs(e.changedTouches[0].screenY - this.RecordingStartY)this.unRecord = (Y >= 50)},// 打開(kāi)聊天信息設(shè)置openChatSet() {uni.navigateTo({url: '../chat-set/chat-set?params=' + JSON.stringify({id: this.detail.id,chat_type: this.detail.chat_type}),});},focus(e){this.mode = 'text';this.isfocus = true;this.KeyboardHeight = e.detail.height;},blur(){this.KeyboardHeight = 0;this.isfocus = false;}}} </script><style></style>感謝大家觀看,我們下次見(jiàn)
總結(jié)
以上是生活随笔為你收集整理的uni-app 185iOS端兼容处理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Docker快速上手指南
- 下一篇: 2016互联网女皇报告中文版