|
|
@@ -8,7 +8,9 @@ import {
|
|
|
|
|
|
import ImApi from './apis/im'
|
|
|
import AppIMDelegate from "./delegate/app-im-delegate";
|
|
|
-import { fotmatDate } from './utils/date'
|
|
|
+import {
|
|
|
+ fotmatDate
|
|
|
+} from './utils/date'
|
|
|
|
|
|
var QQMapWX = require('/utils/qqmap-wx-jssdk.min.js')
|
|
|
var timer = null
|
|
|
@@ -38,11 +40,11 @@ App({
|
|
|
}))
|
|
|
}
|
|
|
wx.getSystemInfo({
|
|
|
- success (res) {
|
|
|
+ success(res) {
|
|
|
console.log(res, '系统信息')
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 当小程序启动,或从后台进入前台显示,会触发 onShow
|
|
|
@@ -105,37 +107,39 @@ App({
|
|
|
getIMHandler() {
|
|
|
return this.appIMDelegate.getIMHandlerDelegate();
|
|
|
},
|
|
|
- async getNewMessage (msg) {
|
|
|
- const { conversations } = this.globalData
|
|
|
+ async getNewMessage(msg) {
|
|
|
+ const {
|
|
|
+ conversations
|
|
|
+ } = this.globalData
|
|
|
let item = conversations.find(item => item.id === msg.fromId)
|
|
|
if (item) {
|
|
|
- item.latestMsgContent = msg.content
|
|
|
- item.latestMsgTime = msg.sendTime
|
|
|
- item.unReadNum ? item.unReadNum++ : item.unReadNum = 1
|
|
|
- this.globalData.conversations = this.dealConversations(conversations)
|
|
|
+ item.latestMsgContent = msg.content
|
|
|
+ item.latestMsgTime = msg.sendTime
|
|
|
+ item.unReadNum ? item.unReadNum++ : item.unReadNum = 1
|
|
|
+ this.globalData.conversations = this.dealConversations(conversations)
|
|
|
} else {
|
|
|
- await this.getContact()
|
|
|
+ await this.getContact()
|
|
|
}
|
|
|
-},
|
|
|
-getContact(isNewMsg) {
|
|
|
- return ImApi.getContacts().then(res => {
|
|
|
- const friends = res.data.friends
|
|
|
- const {
|
|
|
- conversations
|
|
|
- } = this.globalData
|
|
|
- this.globalData.unViewMsg = 0
|
|
|
- this.globalData.conversations = this.dealConversations(friends.map(item => {
|
|
|
- const con = conversations.find(con => con.id === item.id)
|
|
|
- if (con) {
|
|
|
- item = Object.assign(con, item)
|
|
|
- } else if (isNewMsg){
|
|
|
- item.unReadNum = 1
|
|
|
- }
|
|
|
- this.globalData.unViewMsg += item.unReadNum
|
|
|
- return item
|
|
|
- }))
|
|
|
- })
|
|
|
-},
|
|
|
+ },
|
|
|
+ getContact(isNewMsg) {
|
|
|
+ return ImApi.getContacts().then(res => {
|
|
|
+ const friends = res.data.friends
|
|
|
+ const {
|
|
|
+ conversations
|
|
|
+ } = this.globalData
|
|
|
+ this.globalData.unViewMsg = 0
|
|
|
+ this.globalData.conversations = this.dealConversations(friends.map(item => {
|
|
|
+ const con = conversations.find(con => con.id === item.id)
|
|
|
+ if (con) {
|
|
|
+ item = Object.assign(con, item)
|
|
|
+ } else if (isNewMsg) {
|
|
|
+ item.unReadNum = 1
|
|
|
+ }
|
|
|
+ this.globalData.unViewMsg += item.unReadNum
|
|
|
+ return item
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ },
|
|
|
dealConversations(conversations) {
|
|
|
return conversations.map(item => {
|
|
|
let content = item.latestMsgContent
|
|
|
@@ -157,7 +161,7 @@ getContact(isNewMsg) {
|
|
|
} else {
|
|
|
item.timeStr = fotmatDate(item.latestMsgTime, 'MM/dd')
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return item
|
|
|
}).sort((a, b) => new Date(b.latestMsgTime) - new Date(a.latestMsgTime))
|
|
|
},
|
|
|
@@ -165,17 +169,21 @@ getContact(isNewMsg) {
|
|
|
token: loadToken(),
|
|
|
raw_city: true,
|
|
|
// city: '定位中...', // 默认进入首页的地址
|
|
|
- city: '洛杉矶', // 默认进入首页的地址
|
|
|
+ // city: '洛杉矶', // 默认进入首页的地址
|
|
|
+ // city: '洛杉矶', // 默认进入首页的地址
|
|
|
+ city: 'Los Angeles',
|
|
|
+ // 默认进入首页的地址
|
|
|
+ // cityId: '3392', // 默认进入首页的地址
|
|
|
// province: '广东省',
|
|
|
province: '',
|
|
|
district: '',
|
|
|
userinfo: loadUserInfo() || {},
|
|
|
- user_code:loadUserCode() ||'',
|
|
|
+ user_code: loadUserCode() || '',
|
|
|
io: '',
|
|
|
messageList: [],
|
|
|
unViewMsg: 0,
|
|
|
conversations: [],
|
|
|
type: 'user',
|
|
|
- historyCity:loadHistoryCity() ||[],
|
|
|
+ historyCity: loadHistoryCity() || [],
|
|
|
}
|
|
|
});
|