草稿处理
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="text">
|
<view class="text">
|
||||||
<input class="input" type="text" v-model="inputTxt" confirm-type="send" @confirm="send" cursor-spacing="10" />
|
<input class="input" type="text" v-model="inputTxt" confirm-type="send" @confirm="sent" cursor-spacing="10" />
|
||||||
<text class="button" size="mini" @click="send">发送</text>
|
<button class="button" size="mini" :disabled="disabled" @click="sent">发送</button>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import im from '@/utils/im/index.js'
|
import im from '@/utils/im/index.js'
|
||||||
|
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -20,20 +21,39 @@
|
|||||||
},
|
},
|
||||||
inputTxt: {
|
inputTxt: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '1234567890'
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
disabled() {
|
||||||
|
return this.inputTxt.length === 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
RongIMLib.getTextMessageDraft(this.conversationType, this.targetId, ({
|
||||||
|
draft
|
||||||
|
}) => {
|
||||||
|
draft ? this.inputTxt = draft : ''
|
||||||
|
})
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
RongIMLib.saveTextMessageDraft(this.conversationType, this.targetId, this.inputTxt, (res) => {
|
||||||
|
console.log('销毁组件之前,保存草稿信息,但是没有执行', res);
|
||||||
|
})
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 发送文本消息
|
// 发送文本消息
|
||||||
send() {
|
sent() {
|
||||||
if (this.inputTxt === '') return
|
if (!this.disabled) {
|
||||||
|
RongIMLib.clearTextMessageDraft(this.conversationType, this.targetId)
|
||||||
im.sentText(this.conversationType, this.targetId, this.inputTxt, () => {
|
im.sentText(this.conversationType, this.targetId, this.inputTxt, () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$emit('success')
|
this.$emit('success')
|
||||||
}, 500)
|
}, 500)
|
||||||
this.inputTxt = ''
|
this.inputTxt = ''
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -55,6 +75,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
border: none;
|
||||||
background: #34CE98;
|
background: #34CE98;
|
||||||
color: white;
|
color: white;
|
||||||
width: 120rpx;
|
width: 120rpx;
|
||||||
@@ -64,4 +85,8 @@
|
|||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button[disabled] {
|
||||||
|
background-color: #555555;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user