NameCardRemark.vue
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<template>
<div class="g-inherit m-article">
<x-header class="m-tab" :left-options="{backText: ' '}">
<h1 class="m-tab-top">[ 备注名 ]</h1>
<a slot="left"></a>
</x-header>
<group class="u-card">
<x-input
class="u-ipt-default"
type="text"
:required="false"
v-model="alias"
:max = "16"
placeholder="请输入备注名">
<span slot="label">备注:</span>
</x-input>
</group>
<div>
<x-button type="primary" action-type="button" @click.native="setAlias">设置备注名</x-button>
</div>
</div>
</template>
<script>
import util from '../utils'
export default {
data () {
return {
alias: ''
}
},
mounted(){
let info = this.$store.state.userInfos[this.account] || {}
this.alias = info.alias
},
computed: {
account () {
return this.$route.params.userId
}
},
methods: {
setAlias () {
this.alias = this.alias.replace(/\n/g, ' ').replace(/\r/g, '')
if (/^\s*$/.test(this.alias)) {
// ...
} else if (this.alias.length > 16) {
this.$vux.alert.show({
title: '备注不能超过16个字符'
})
return
}
this.$store.dispatch('updateFriend', {
account: this.account,
alias: this.alias
})
window.history.go(-1)
}
}
}
</script>