|
@@ -59,8 +59,15 @@ export default {
|
|
|
data: function() {
|
|
data: function() {
|
|
|
return {
|
|
return {
|
|
|
showInviteModal: false,
|
|
showInviteModal: false,
|
|
|
- relationshipTypeList: [],
|
|
|
|
|
|
|
+ relationshipTypeList: [
|
|
|
|
|
+ { typeName: '家人', typeKey: 'family' },
|
|
|
|
|
+ { typeName: '朋友', typeKey: 'friend' },
|
|
|
|
|
+ { typeName: '伴侣', typeKey: 'partner' },
|
|
|
|
|
+ { typeName: '同事', typeKey: 'colleague' },
|
|
|
|
|
+ { typeName: '其他', typeKey: 'other' }
|
|
|
|
|
+ ],
|
|
|
selectedRelationshipName: '',
|
|
selectedRelationshipName: '',
|
|
|
|
|
+ selectedRelationshipKey: '',
|
|
|
generationLevelList: ['父母(+1)', '子女(-1)', '配偶(0)', '兄弟姐妹(0)', '祖父母(+2)', '孙子女(-2)'],
|
|
generationLevelList: ['父母(+1)', '子女(-1)', '配偶(0)', '兄弟姐妹(0)', '祖父母(+2)', '孙子女(-2)'],
|
|
|
selectedGeneration: ''
|
|
selectedGeneration: ''
|
|
|
}
|
|
}
|
|
@@ -92,28 +99,22 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
handleInvite: function() {
|
|
handleInvite: function() {
|
|
|
this.showInviteModal = true
|
|
this.showInviteModal = true
|
|
|
- this.loadRelationshipTypes()
|
|
|
|
|
- },
|
|
|
|
|
- loadRelationshipTypes: function() {
|
|
|
|
|
- var that = this
|
|
|
|
|
- var app = getApp()
|
|
|
|
|
- if (!app || !app.globalData || !app.globalData.baseUrl) return
|
|
|
|
|
- uni.request({
|
|
|
|
|
- url: app.globalData.baseUrl + '/api/family/member/relationship-types',
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- header: { 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
|
|
|
|
|
- success: function(res) {
|
|
|
|
|
- if (res.data && res.data.data) {
|
|
|
|
|
- that.relationshipTypeList = res.data.data
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 预填联系人已有的关系类型
|
|
|
|
|
+ var self = this
|
|
|
|
|
+ this.selectedRelationshipKey = this.contact.relationshipType || 'other'
|
|
|
|
|
+ for (var i = 0; i < this.relationshipTypeList.length; i++) {
|
|
|
|
|
+ if (this.relationshipTypeList[i].typeKey === this.selectedRelationshipKey) {
|
|
|
|
|
+ this.selectedRelationshipName = this.relationshipTypeList[i].typeName
|
|
|
|
|
+ break
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
onRelationshipChange: function(e) {
|
|
onRelationshipChange: function(e) {
|
|
|
var idx = e.detail.value
|
|
var idx = e.detail.value
|
|
|
var item = this.relationshipTypeList[idx]
|
|
var item = this.relationshipTypeList[idx]
|
|
|
if (item) {
|
|
if (item) {
|
|
|
this.selectedRelationshipName = item.typeName
|
|
this.selectedRelationshipName = item.typeName
|
|
|
|
|
+ this.selectedRelationshipKey = item.typeKey
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onGenerationChange: function(e) {
|
|
onGenerationChange: function(e) {
|
|
@@ -134,9 +135,6 @@ export default {
|
|
|
'孙子女(-2)': 'grandchild'
|
|
'孙子女(-2)': 'grandchild'
|
|
|
}
|
|
}
|
|
|
var generationLevel = generationMap[this.selectedGeneration] || 'child'
|
|
var generationLevel = generationMap[this.selectedGeneration] || 'child'
|
|
|
- var selectedItem = this.relationshipTypeList.filter(function(item) {
|
|
|
|
|
- return item.typeName === that.selectedRelationshipName
|
|
|
|
|
- })[0]
|
|
|
|
|
var app = getApp()
|
|
var app = getApp()
|
|
|
if (!app || !app.globalData || !app.globalData.baseUrl) return
|
|
if (!app || !app.globalData || !app.globalData.baseUrl) return
|
|
|
uni.request({
|
|
uni.request({
|
|
@@ -145,7 +143,7 @@ export default {
|
|
|
header: { 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
|
|
header: { 'Authorization': 'Bearer ' + uni.getStorageSync('token') },
|
|
|
data: {
|
|
data: {
|
|
|
contactId: this.contact.id,
|
|
contactId: this.contact.id,
|
|
|
- relationshipType: selectedItem ? selectedItem.typeKey : 'child',
|
|
|
|
|
|
|
+ relationshipType: this.selectedRelationshipKey || 'other',
|
|
|
generationLevel: generationLevel
|
|
generationLevel: generationLevel
|
|
|
},
|
|
},
|
|
|
success: function(res) {
|
|
success: function(res) {
|