diff --git a/.DS_Store b/.DS_Store
index 6857663..0451fa5 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
index a97fd25..4bbcf3c 100644
--- a/.hbuilderx/launch.json
+++ b/.hbuilderx/launch.json
@@ -14,6 +14,10 @@
{
"launchtype" : "local"
},
+ "mp-weixin" :
+ {
+ "launchtype" : "local"
+ },
"type" : "uniCloud"
}
]
diff --git a/App.vue b/App.vue
index 7b7b95a..002072b 100644
--- a/App.vue
+++ b/App.vue
@@ -1,11 +1,13 @@
+
diff --git a/manifest.json b/manifest.json
index 4b641da..c65cec7 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
"name" : "ZH-HEALTH",
"appid" : "__UNI__C29473D",
"description" : "ZH-HEALTH,您手上的健康管理专家",
- "versionName" : "1.0.7",
- "versionCode" : 107,
+ "versionName" : "1.0.8",
+ "versionCode" : 108,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
diff --git a/pages.json b/pages.json
index 6ace7f2..d662e57 100644
--- a/pages.json
+++ b/pages.json
@@ -35,9 +35,8 @@
"path": "pages/record/drink",
"name": "Drink",
"style": {
- "navigationBarTitleText": "记录喝水",
- "navigationBarBackgroundColor": "#34CE98",
- "navigationBarTextStyle": "white"
+ "navigationBarTitleText": "记录",
+ "navigationStyle": "custom"
}
},
{
@@ -53,9 +52,8 @@
"path": "pages/record/foods",
"name": "RecordFoods",
"style": {
- "navigationBarTitleText": "食物记录",
- "navigationBarBackgroundColor": "#34CE98",
- "navigationBarTextStyle": "white"
+ "navigationBarTitleText": "",
+ "navigationStyle": "custom"
}
},
{
@@ -80,7 +78,7 @@
"path": "pages/evaluation/list",
"name": "EvaluationList",
"style": {
- "navigationBarTitleText": "评测列表",
+ "navigationBarTitleText": "健康评测",
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
}
@@ -369,10 +367,18 @@
"path": "pages/im/index",
"name": "IM",
"style": {
- "navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
+ {
+ "path": "pages/im/private/chat",
+ "style": {
+ "disableScroll": true,
+ "navigationBarTitleText": "聊天",
+ "enablePullDownRefresh": false,
+ "navigationBarBackgroundColor": "#F3F6FB"
+ }
+ },
{
"path": "pages/im/private/call",
"name": "imPrivateCall",
@@ -402,40 +408,110 @@
"path": "pages/im/friends/pending",
"name": "imFriendsPending",
"style": {
- "navigationBarTitleText": "新朋友",
- "navigationBarBackgroundColor": "#F3F6FB"
+ "navigationBarTitleText": "新朋友"
}
},
{
"path": "pages/im/friends/search",
"name": "SearchFriend",
"style": {
- "navigationBarTitleText": "好友搜索",
- "navigationBarBackgroundColor": "#F3F6FB"
+ "navigationBarTitleText": "好友搜索"
}
},
{
"path": "pages/im/friends/info",
"name": "imFriendsInfo",
"style": {
- "navigationBarTitleText": "好友资料",
- "navigationBarBackgroundColor": "#FFFFFF"
+ "navigationBarTitleText": "用户资料"
}
},
{
"path": "pages/im/friends/mine",
"name": "imFriendsMine",
"style": {
- "navigationBarTitleText": "我的二维码",
- "navigationBarBackgroundColor": "#34CE98",
- "navigationBarTextStyle": "white"
+ "navigationBarTitleText": "我的资料"
}
},
{
"path": "pages/im/group/index",
- "name": "imGroup",
+ "name": "imGroups",
"style": {
- "navigationBarTitleText": "我的群聊"
+ "navigationBarTitleText": "我的群聊",
+ "app-plus": {
+ "titleNView": {
+ "type": "default",
+ "buttons": [{
+ "float": "right",
+ "fontSrc": "/static/iconfont.ttf",
+ "text": "\ue60a",
+ "fontSize": "20px"
+ }]
+ }
+ }
+ }
+ },
+ {
+ "path": "pages/im/group/chat",
+ "name": "imGroupChat",
+ "style": {
+ "navigationBarTitleText": "群聊",
+ "app-plus": {
+ "titleNView": {
+ "type": "default",
+ "buttons": [{
+ "float": "right",
+ "fontSrc": "/static/iconfont.ttf",
+ "text": "\ue607",
+ "fontSize": "20px"
+ }]
+ }
+ }
+ }
+ },
+ {
+ "path": "pages/im/group/apply",
+ "name": "imGroupApply",
+ "style": {
+ "navigationBarTitleText": "申请加群"
+ }
+ },
+ {
+ "path": "pages/im/group/info",
+ "name": "imGroupInfo",
+ "style": {
+ "navigationBarTitleText": "群信息"
+ }
+ },
+ {
+ "path": "pages/im/group/users",
+ "name": "imGroupUsers",
+ "style": {
+ "navigationBarTitleText": "群成员"
+ }
+ },
+ {
+ "path": "pages/im/group/announcement",
+ "name": "imGroupAnnouncement",
+ "style": {
+ "navigationBarTitleText": "群公告",
+ "app-plus": {
+ "titleNView": {
+ "type": "default",
+ "buttons": [{
+ "float": "right",
+ "fontSrc": "/static/iconfont.ttf",
+ "text": "\ue60a",
+ "fontSize": "20px"
+ }]
+ }
+ }
+ }
+ },
+ {
+ "path": "pages/im/group/announceCreate",
+ "name": "imGroupAnnouncementCreate",
+ "style": {
+ "navigationBarTitleText": "发布群公告"
}
},
{
@@ -548,14 +624,6 @@
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
}
- }, {
- "path": "pages/im/private/chat",
- "style": {
- "disableScroll": true,
- "navigationBarTitleText": "聊天",
- "enablePullDownRefresh": false,
- "navigationBarBackgroundColor": "#F3F6FB"
- }
}
],
"tabBar": {
diff --git a/pages/auth/auth.vue b/pages/auth/auth.vue
index 33a8231..05f59cf 100644
--- a/pages/auth/auth.vue
+++ b/pages/auth/auth.vue
@@ -1,267 +1,253 @@
-
-
-
-
-
-
-
- 一键登录
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 未注册的手机号码验证后自动创建账号,登录即表示同意接受平台
- 《隐私协议》
- 和
- 《服务协议》
-
-
-
-
-
-
-
diff --git a/pages/essentialInfo/index.vue b/pages/essentialInfo/index.vue
index 357dd56..a149002 100644
--- a/pages/essentialInfo/index.vue
+++ b/pages/essentialInfo/index.vue
@@ -11,21 +11,18 @@
- 基本信息
-
+ 基本信息
- 健康目标
-
+ 健康目标
- 行为习惯
-
+ 行为习惯
-
+
生理性别和激素会影响我们的身体代谢食物的方式
@@ -47,19 +44,7 @@
你的出生日期是?
{{ showBirthday }}
-
+
@@ -68,7 +53,6 @@
身高体重信息对健康信息有重要参考价值
您的身高是?
-
{{ heightU }}厘米
@@ -84,51 +68,18 @@
下一步
-
+
-
+
您的目标是?
-
-
- 减肥
-
-
-
- 保持体重
-
-
-
- 增肌
-
+ 减肥
+ 保持体重
+ 增肌
上一步
@@ -141,10 +92,7 @@
您的打算减脂多少?
-
- {{ weightTargetU }}
- 公斤
-
+ {{ weightTargetU }} 公斤
@@ -153,7 +101,7 @@
下一步
-
+
@@ -162,51 +110,19 @@
您的运动量是?
-
+
久坐不动
-
+
少量运动
-
+
中等运动量
-
+
超强度运动
@@ -274,7 +190,6 @@ export default {
},
computed: {
showBirthday() {
- console.log(moment(this.birthday).format('YYYY年MM月DD日'));
return moment(this.birthday).format('YYYY年MM月DD日');
}
},
@@ -297,6 +212,7 @@ export default {
this.percentplan1 = uni.$u.range(0, 100, this.percentplan1 + 33.33); // 增加进度
this.heightWeightShow = true; // 展示身高体重模块
},
+
// 年龄 ----- 取消选择年龄
camcelBirthday() {
this.birthdayShow = false; // // 年龄页面弹窗不显示
@@ -304,6 +220,7 @@ export default {
this.percentplan1 = 0; // 进度为0
this.sexShow = true; // 显示性别页面
},
+
//年龄------------- 过滤出生年月日
formatter(type, value) {
if (type === 'year') {return `${value}年`;}
@@ -311,6 +228,8 @@ export default {
if (type === 'day') {return `${value}日`;}
return value;
},
+
+
// 体重---------标尺滚动
scrollWeight(msg) {
this.weightU = msg;
@@ -332,6 +251,8 @@ export default {
this.targetShow = true; // 目标页面展示
}
},
+
+
// 目标 ------------点击 1上一页 2 下一页
targetClick(type) {
if (type === 1) {
@@ -368,6 +289,8 @@ export default {
this.behaviorShow = true; // 打开行为习惯页面
}
},
+
+
// 目标 运动量--------- 1上一页 2 下一页
targetBehaviorClick(type) {
if (type === 1) {
@@ -391,7 +314,6 @@ export default {
exercise: this.activedbehaviarTarget, // 运动量
days: 1
};
- console.log(params, 'params.....');
recordsHealth(params)
.then(res => {
uni.showModal({
@@ -406,10 +328,12 @@ export default {
});
})
.catch(err => {
- uni.showToast({
- title: err.message,
- icon: 'none'
- });
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
});
}
}
diff --git a/pages/evaluation/index.vue b/pages/evaluation/index.vue
index e97b152..b512745 100644
--- a/pages/evaluation/index.vue
+++ b/pages/evaluation/index.vue
@@ -6,172 +6,175 @@
* @LastEditTime: 2022-01-13 17:16:09
-->
-
-
-
-
-
- {{ percent }}%
-
-
- {{ page }}.{{ currentInfo.title }}
-
-
-
-
-
-
-
-
- 下一步
-
-
+
+
+
+
+
+ {{ percent }}%
+
+
+ {{ page }}.{{ currentInfo.title }}
+
+
+
+
+
+
+
+
+ 下一步
+
+
diff --git a/pages/evaluation/introduce.vue b/pages/evaluation/introduce.vue
index 8850f9d..37b52d7 100644
--- a/pages/evaluation/introduce.vue
+++ b/pages/evaluation/introduce.vue
@@ -6,129 +6,138 @@
* @LastEditTime: 2022-01-13 17:26:38
-->
-
- 测评记录
- 暂未测评
-
- {{ info.title }}
-
-
-
-
- 开始测评
-
-
-
+
+ 测评记录
+ 暂未测评
+
+ {{ info.title }}
+
+
+
+
+ 开始测评
+
+
+
diff --git a/pages/evaluation/list.vue b/pages/evaluation/list.vue
index c2a4daa..896493b 100644
--- a/pages/evaluation/list.vue
+++ b/pages/evaluation/list.vue
@@ -11,44 +11,20 @@
-
- {{ item.title }}
- {{ item.description || '--' }}
-
+ {{ item.title }} {{ item.description || '--' }}
-
- {{ item.answer.total }}
- 分
-
+ {{ item.answer.total }} 分
-
- ·
- {{ item.remark }}
-
+ · {{ item.remark }}
查看历史结果
-
- ·
- {{ item.remark }}
- 人已测 | 约4~8分钟
-
-
+ · {{ item.remark }} 人已测 | 约4~8分钟
+
@@ -72,7 +48,14 @@ export default {
getList() {
evaluations().then(res => {
this.evalList = res;
- });
+ }).catch(err => {
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ });
},
// nowEva
nowEva(item) {
diff --git a/pages/evaluation/result.vue b/pages/evaluation/result.vue
index 29fa042..6888e1e 100644
--- a/pages/evaluation/result.vue
+++ b/pages/evaluation/result.vue
@@ -53,9 +53,7 @@
营养建议
-
- {{ item }}. 低Gi
-
+ {{ item }}. 低Gi
饮食营养及生活方式对维持面部年轻态影响较大,建议注意食材选择,逐步清淡口味;规律作息,逐个改善不良生活习惯;帮助改善当前皮肤状态。
@@ -63,10 +61,7 @@
-
- 更多护肤知识
-
-
+ 更多护肤知识
@@ -109,7 +104,14 @@ export default {
]
};
this.loaded = true;
- });
+ }).catch(err => {
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ });
},
reEva() {
uni.navigateTo({
diff --git a/pages/im/components/conversationList.vue b/pages/im/components/conversationList.vue
new file mode 100644
index 0000000..cf3eeca
--- /dev/null
+++ b/pages/im/components/conversationList.vue
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+
+ {{item}}
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/components/friendApplyCell.vue b/pages/im/components/friendApplyCell.vue
new file mode 100644
index 0000000..94f3263
--- /dev/null
+++ b/pages/im/components/friendApplyCell.vue
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+ {{ user.name }}
+
+
+ {{ message.message }}
+
+
+
+
+ 通过
+ 拒绝
+
+
+
+
+
+
+
diff --git a/components/friend-apply-reject-agree/index.vue b/pages/im/components/friendApplyList.vue
similarity index 86%
rename from components/friend-apply-reject-agree/index.vue
rename to pages/im/components/friendApplyList.vue
index c05d136..10e2762 100644
--- a/components/friend-apply-reject-agree/index.vue
+++ b/pages/im/components/friendApplyList.vue
@@ -1,15 +1,14 @@
-
+
-
+
{{ item.name }}
- {{ item.address || '这家伙很懒,什么都没有添加~' }}
- {{ item.remark || '你好,听说你很优秀想认识~' }}
+ {{ item.latestMessage.message }}
通过
@@ -44,8 +43,8 @@ export default {
default: false
}
},
- data() {
- return {};
+ created() {
+ console.log(this.lists);
},
methods: {
action(type, item) {
diff --git a/pages/im/components/messageCell.vue b/pages/im/components/messageCell.vue
new file mode 100644
index 0000000..3c6563c
--- /dev/null
+++ b/pages/im/components/messageCell.vue
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/components/messagePreview.nvue b/pages/im/components/messagePreview.nvue
index ece6929..8a0efab 100644
--- a/pages/im/components/messagePreview.nvue
+++ b/pages/im/components/messagePreview.nvue
@@ -1,28 +1,28 @@
-
- {{ msg.content || '' }}
+
+ {{ user.name }}: {{ msg.content || '' }}
-
- [语音]
+
+ {{ user.name }}: [语音]
-
- [图片]
+
+ {{ user.name }}: [图片]
-
- [表情]
+
+ {{ user.name }}: [表情]
-
- [文件]
+
+ {{ user.name }}: [文件]
-
- [位置]
+
+ {{ user.name }}: [位置]
-
- [语音通话]
+
+ {{ user.name }}: [语音通话]
-
- [视频通话]
+
+ {{ user.name }}: [视频通话]
@@ -33,11 +33,33 @@
msg: {
type: Object,
default: {}
+ },
+ conversationType: {
+ type: Number,
+ default: 0
+ },
+ user: {
+ type: Object,
+ default: function() {
+ return {
+ name: ''
+ }
+ }
}
}
}
-
diff --git a/pages/im/components/sentMessageBar.nvue b/pages/im/components/sentMessageBar.nvue
new file mode 100644
index 0000000..b09be2e
--- /dev/null
+++ b/pages/im/components/sentMessageBar.nvue
@@ -0,0 +1,83 @@
+
+
+
+
+
+ {showPopups = false, onSuccess()}">
+
+
+
+
+
+
diff --git a/pages/im/components/sentPopups.nvue b/pages/im/components/sentPopups.nvue
index 2a3566d..6772875 100644
--- a/pages/im/components/sentPopups.nvue
+++ b/pages/im/components/sentPopups.nvue
@@ -63,6 +63,11 @@
default: ''
}
},
+ computed: {
+ user() {
+ return this.$store.getters.sender
+ }
+ },
methods: {
singleCall(e) {
uni.showToast({
@@ -81,10 +86,11 @@
count: 9,
sourceType: ['album'],
success: res => {
- im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
- res) => {
- this.success()
- })
+ im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
+ this.user, (
+ res) => {
+ this.success()
+ })
}
})
break;
@@ -92,10 +98,11 @@
uni.chooseImage({
sourceType: ['camera'],
success: res => {
- im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
- res) => {
- this.success()
- })
+ im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0],
+ this.user, (
+ res) => {
+ this.success()
+ })
}
})
break;
diff --git a/pages/im/components/sentText.nvue b/pages/im/components/sentText.nvue
index c787f6f..ee7ef6b 100644
--- a/pages/im/components/sentText.nvue
+++ b/pages/im/components/sentText.nvue
@@ -1,15 +1,7 @@
-
+
@@ -36,6 +28,9 @@
computed: {
disabled() {
return this.inputTxt.length === 0
+ },
+ user() {
+ return this.$store.getters.sender
}
},
created() {
@@ -55,50 +50,35 @@
sent() {
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, this.user, () => {
this.$emit('success')
this.inputTxt = ''
})
}
- },
- focus() {
- this.$emit('focus')
- },
- blur() {
- this.$emit('blur')
- }
+ },
+ focus() {
+ this.$emit('focus')
+ },
+ blur() {
+ this.$emit('blur')
+ }
}
}
-
diff --git a/pages/im/components/sentVoice.nvue b/pages/im/components/sentVoice.nvue
index 8ab1148..65ef4cf 100644
--- a/pages/im/components/sentVoice.nvue
+++ b/pages/im/components/sentVoice.nvue
@@ -35,6 +35,11 @@
recorderManager: null
}
},
+ computed: {
+ user() {
+ return this.$store.getters.sender
+ }
+ },
created() {
this.recorderManager = uni.getRecorderManager()
},
@@ -81,7 +86,7 @@
this.recorderManager.onStop(res => {
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
this
- .recordTime), () => {
+ .recordTime), this.user, () => {
setTimeout(() => {
this.$emit('success')
}, 500)
diff --git a/pages/im/components/showImage.nvue b/pages/im/components/showImage.nvue
index bdbb5be..af297cc 100644
--- a/pages/im/components/showImage.nvue
+++ b/pages/im/components/showImage.nvue
@@ -1,7 +1,10 @@
-
-
-
-
+
+
+ {{ name }}
+
+
+
+
-
diff --git a/pages/im/components/showVoice.nvue b/pages/im/components/showVoice.nvue
index 159e467..3963f55 100644
--- a/pages/im/components/showVoice.nvue
+++ b/pages/im/components/showVoice.nvue
@@ -1,8 +1,11 @@
-
-
- {{msg.duration}}"
-
+
+ {{ name }}
+
+
+ {{msg.duration}}"
+
+
@@ -21,6 +24,10 @@
}
}
},
+ name: {
+ type: String,
+ default: ''
+ },
guest: {
type: Boolean,
default: true
@@ -56,6 +63,12 @@
diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue
index a75aa3f..778a51f 100644
--- a/pages/im/friends/info.vue
+++ b/pages/im/friends/info.vue
@@ -2,10 +2,11 @@
-
+
- {{userInfo.name}}
- 地址:{{userInfo.address}}
+ {{ userInfo.name }}
+ 地址:{{ userInfo.address }}
@@ -105,10 +106,11 @@
}
},
onLoad(e) {
- console.log(e);
this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => {
this.userInfo = res
+ // 获取到用户信息之后,去检查一下要不要更新
+ this.$store.dispatch('updateContact', res)
uni.setNavigationBarTitle({
title: res.name
})
@@ -125,7 +127,7 @@
if (code == 0) {
this.isTop = conversation.isTop
}
- });
+ })
},
methods: {
copyAddress() {
@@ -141,7 +143,7 @@
},
toPrivate() {
uni.redirectTo({
- url: '/pages/im/private/chat?conversationType=1&targetId=' + this.targetId
+ url: '/pages/im/private/chat?targetId=' + this.targetId
});
},
setRemark() {
@@ -156,7 +158,8 @@
content: '确认删除后不可恢复',
success: e => {
if (e.confirm) {
- deleteFriend(this.targetId).then(res => {
+ deleteFriend(this.targetId).then(res => {
+ uni.$emit('onContactNotification')
// 删除聊天记录
RongIMLib.deleteMessages(1, this.targetId);
RongIMLib.removeConversation(1, this.targetId);
@@ -313,14 +316,16 @@
background: white;
margin: $margin;
border-radius: $radius;
- .u-border-bottom{
+
+ .u-border-bottom {
border-bottom: solid 1rpx #f9f9f9 !important;
}
+
.item {
line-height: 100rpx;
display: flex;
align-items: center;
- padding:10rpx $padding;
+ padding: 10rpx $padding;
justify-content: space-between;
font-size: $title-size-lg;
diff --git a/pages/im/friends/mine.vue b/pages/im/friends/mine.vue
index de6672a..a09eec1 100644
--- a/pages/im/friends/mine.vue
+++ b/pages/im/friends/mine.vue
@@ -17,13 +17,13 @@
女
-
- {{infoObj.hash}}
+
+ {{infoObj.address}}
-
+
ZH-HEALTH扫一扫上面的二维码
添加我的好友
@@ -51,12 +51,11 @@
qrContent: 'ADDFRIEND|'
}
},
- onLoad(e) {},
- mounted() {
- getUserInfo(this.$Route.query.targetId).then(res => {
- this.infoObj = res
- this.qrContent += res.userId
- })
+ onLoad(e) {
+ this.qrContent += e.targetId
+ getUserInfo(e.targetId).then(res => {
+ this.infoObj = res
+ })
},
methods: {
diff --git a/pages/im/friends/pending.vue b/pages/im/friends/pending.vue
index 9d784ba..c25b597 100644
--- a/pages/im/friends/pending.vue
+++ b/pages/im/friends/pending.vue
@@ -1,11 +1,3 @@
-
-
@@ -14,66 +6,36 @@
:disabled="true" :show-action="false" />
-
-
-
-
-
- 暂无申请记录~
+
+
+
+
diff --git a/pages/im/group/announcement.vue b/pages/im/group/announcement.vue
new file mode 100644
index 0000000..5edd2d7
--- /dev/null
+++ b/pages/im/group/announcement.vue
@@ -0,0 +1,125 @@
+
+
+
+
+
+ {{ item.content }}
+
+
+
+
+
+
+
+
diff --git a/pages/im/group/apply.vue b/pages/im/group/apply.vue
new file mode 100644
index 0000000..3f7aa3f
--- /dev/null
+++ b/pages/im/group/apply.vue
@@ -0,0 +1,91 @@
+
+
+
+
+ {{ group.name }}
+
+
+
+
+ 群已满员
+ 禁止申请
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/group/chat.nvue b/pages/im/group/chat.nvue
new file mode 100644
index 0000000..74bac82
--- /dev/null
+++ b/pages/im/group/chat.nvue
@@ -0,0 +1,197 @@
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/group/index.vue b/pages/im/group/index.vue
index 3d1727e..caf00ab 100644
--- a/pages/im/group/index.vue
+++ b/pages/im/group/index.vue
@@ -1,11 +1,109 @@
-
-
-
-
-
-
-
-
-
diff --git a/pages/im/group/info.vue b/pages/im/group/info.vue
new file mode 100644
index 0000000..6997e1a
--- /dev/null
+++ b/pages/im/group/info.vue
@@ -0,0 +1,399 @@
+
+
+
+
+
+
+ {{ item.name }}
+
+
+
+ 邀请好友
+
+
+
+ 查看更多群成员 >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 清空聊天记录
+ 解散群聊
+ 删除并退出
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/group/users.vue b/pages/im/group/users.vue
new file mode 100644
index 0000000..6daa258
--- /dev/null
+++ b/pages/im/group/users.vue
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+ 邀请好友
+
+
+
+ {{ item.name }}
+
+
+ 成员总数({{ members.length }})
+
+
+
+
+
+
+
+
+
diff --git a/pages/im/index.vue b/pages/im/index.vue
index c8db817..5cb1a75 100644
--- a/pages/im/index.vue
+++ b/pages/im/index.vue
@@ -5,60 +5,23 @@
diff --git a/pages/record/addExercises.vue b/pages/record/addExercises.vue
index 8390a35..5b4e857 100644
--- a/pages/record/addExercises.vue
+++ b/pages/record/addExercises.vue
@@ -60,11 +60,17 @@ export default {
healthSports(data).then(res => {
this.lists = this.lists.concat(res.data);
this.has_more = res.page.has_more;
- });
+ }).catch(err => {
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ });
},
// 显示弹窗内容
addSport(item) {
- console.log(item);
this.selectSports = item;
this.selectSports.duration = 60;
this.addSportsShow = true;
@@ -99,7 +105,6 @@ export default {
//#region 搜索相关方法 start
// 点击搜索左侧按钮
searchCustom(e) {
- console.log(e);
this.name = e;
this.reset();
},
diff --git a/pages/record/addFoods.vue b/pages/record/addFoods.vue
index cf476b8..97f95d3 100644
--- a/pages/record/addFoods.vue
+++ b/pages/record/addFoods.vue
@@ -8,186 +8,187 @@
-
- 低等热量
- 中等热量
- 高等热量
-
+ 低等热量 中等热量 高等热量
-
+
-
+
-
+
diff --git a/pages/record/drink.vue b/pages/record/drink.vue
index 9bfd096..f14219b 100644
--- a/pages/record/drink.vue
+++ b/pages/record/drink.vue
@@ -7,402 +7,543 @@
-->
-
-
-
-
- 再喝
- {{ water.lack.cup }}
- 杯
- (约{{ water.lack.value }}ml)
-
-
- 已喝
- {{ water.total }}ml
-
-
-
-
-
-
-
-
-
-
- 今日目标
-
-
-
- 水杯容量
-
-
-
-
-
-
-
-
-
-
-
- 一杯水
-
-
-
-
-
- 喝水记录
-
-
-
-
-
- 水
- {{ item.time }}
-
- {{ item.ml }}ml
-
-
-
- 今天一杯水还没有喝呢,来一杯吧~
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 再喝 {{ water.lack.cup }} 杯 (约{{ water.lack.value }}ml)
+
+ 已喝 {{ water.total }}ml
+
+
+
+
+
+
+
+
+
+ 今日目标
+
+
+ 水杯容量
+
+
+
+
+
+
+
+
+
+
+
+ 一杯水
+
+
+
+
+
+ 喝水记录
+
+
+
+
+
+
+ 水 {{ item.time }} {{ item.ml }}ml
+
+
+
+ 今天一杯水还没有喝呢,来一杯吧~
+
+
+
+
+
diff --git a/pages/record/foods.vue b/pages/record/foods.vue
index 8b1f581..7488c32 100644
--- a/pages/record/foods.vue
+++ b/pages/record/foods.vue
@@ -3,450 +3,551 @@
* @Author: Aimee·Zhang
* @Date: 2022-01-11 08:54:49
* @LastEditors: Aimee·Zhang
- * @LastEditTime: 2022-01-20 10:05:15
+ * @LastEditTime: 2022-02-08 10:41:15
-->
-
-
-
-
- 饮食摄入
- {{ calorys.intake_total }}
-
-
- {{ calorys.exceeds ? '多吃了' : '还可以吃' }}
- {{ calorys.amount }}
- 推荐预算{{ calorys.goal }}
-
-
- 运动消耗
- {{ calorys.exercise_total }}
-
- 摄入量推荐
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
- {{ it.name }}
- {{ it.remark || '' }}
-
-
- {{ it.total }}
- 千卡
-
-
-
-
-
-
-
-
-
- 运动
-
- {{ sportsTotal }}
- 千卡
-
-
-
+
+
+ 饮食摄入 {{ calorys.intake_total }}
+
+ {{ calorys.exceeds ? '多吃了' : '还可以吃' }}
+ {{ calorys.amount }}
+ 推荐预算{{ calorys.goal }}
+
+ 运动消耗 {{ calorys.exercise_total }}
+ 摄入量推荐
+
+
-
-
+
+
+
+
+ {{ it.name }} {{ it.remark || '' }}
+ {{ it.total }} 千卡
+
+
+
+
-
-
-
- 还没有添加今日饮食记录
- 请点击屏幕下方按钮来添加
-
+
+
+
+ 运动
+ {{ sportsTotal }} 千卡
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 还没有添加今日饮食记录
+ 请点击屏幕下方按钮来添加
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/record/index.vue b/pages/record/index.vue
index 17660b4..54b15aa 100644
--- a/pages/record/index.vue
+++ b/pages/record/index.vue
@@ -398,9 +398,6 @@ export default {
*/
logs() {
logs().then(res => {
-
- console.log(res.is_login)
-
this.weight = res.weight;
this.water = res.water;
this.intake_run = res.intake_run;
@@ -410,7 +407,14 @@ export default {
this.banner = res.banner;
this.user = res.user;
this.notifications_count = res.notifications_count;
- });
+ }).catch(err => {
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ });
},
/**
* @description:跳转登录页面
diff --git a/pages/record/weight.vue b/pages/record/weight.vue
index b75cfad..bad53fb 100644
--- a/pages/record/weight.vue
+++ b/pages/record/weight.vue
@@ -8,231 +8,303 @@
-
-
-
- 斤
- 公斤
-
-
- {{weightInfo.text}}
-
- 保持 / 塑性
-
- 记录体重
- 以最后一次记录为主且每日只能更新一次
-
-
-
-
-
-
- {{item.weight}}公斤
-
- 测量结果
+
+
+
+
+ 斤 公斤
+
+ {{weightInfo.text}}
+
+ 保持 / 塑性
-
- 开始保持 / 塑性
- {{item.created_at}}
+ 记录体重
+ 以最后一次记录为主且每日只能更新一次
+
+
+
+
+
+ {{weightInfo.begin}}公斤 初始体重
+ 开始保持 / 塑性 {{weightInfo.first_weight_time}}
+
+
+ {{item.weight}}公斤 测量结果
+ 开始保持 / 塑性 {{item.created_at}}
+ 还没有体重信息,记录下呗~
+
+
+
+
+
+
+
+
+ 体重 单位:公斤
+
+
+
+
+ 记录体重
+ 只显示最近七次测量记录
+
- 还没有体重信息,记录下呗~
+
+
-
+
今天
{{weight}}公斤
-
- 确认添加
+
+ 确认添加
+
+
+
+
+
+
+
\ No newline at end of file
+
diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue
index 7f9ba30..124931b 100644
--- a/pages/setting/setting.vue
+++ b/pages/setting/setting.vue
@@ -3,18 +3,14 @@
-
- 修改头像
-
+ 修改头像
-
- 修改昵称
-
+ 修改昵称
@@ -86,11 +82,13 @@
this.avatar.showPath = pathRes.url[0]
this.resetUserInfo('avatar',pathRes.url[0])
}).catch(err => {
- uni.showToast({
- title: err.message,
- icon: 'none'
- })
- })
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ })
}
})
},
@@ -114,11 +112,13 @@
})
this.getUserInfo()
}).catch(err => {
- uni.showToast({
- title: err.message,
- icon: 'none'
- })
- })
+ uni.showToast({
+ title: err.message,
+ icon: "none",
+ duration: 2000,
+ mask: true
+ })
+ })
}
}
}
diff --git a/pages/user/files.vue b/pages/user/files.vue
index 3a1dc8a..0271b33 100644
--- a/pages/user/files.vue
+++ b/pages/user/files.vue
@@ -1,282 +1,316 @@
-
-
-
- 性别
-
-
-
-
- { (this.recordsData.sex = e.id), (this.sexShow = false); } "
- @close="sexShow = false"
- />
-
+
+
+
+ 性别
+
+
+
+
+ { (this.recordsData.sex = e.id), (this.sexShow = false); } " @close="sexShow = false" />
+
-
-
- 生日
-
-
-
-
- { this.recordsData.birthday = e.value, this.birthdayShow = false } "
- @cancel=" () => { this.birthdayShow = false; } "
- />
-
+
+
+ 生日
+
+
+
+
+ { this.recordsData.birthday = e.value, this.birthdayShow = false } "
+ @cancel=" () => { this.birthdayShow = false; } " />
+
-
-
- 身高
-
-
-
-
- { heightShow = false }">
-
- 你的身高为?
- {{recordsData.height}} CM
-
-
-
-
+
+
+ 身高
+
+
+
+
+ { heightShow = false }">
+
+ 你的身高为?
+ {{recordsData.height}} CM
+
+
+
+
-
-
- 最新体重
-
-
-
-
- { weightShow = false }">
-
- 你的当前体重为?
- {{recordsData.weight}} KG
-
-
-
-
+
+
+ 最新体重
+
+
+
+
+ { weightShow = false }">
+
+ 你的当前体重为?
+ {{recordsData.weight}} KG
+
+
+
+
-
-
- 目标
-
-
-
-
- { (this.selectedTargetIndex = this.targetList.findIndex(item => e.id === item.id)), (this.targetShow = false); } "
- @close="targetShow = false"
- />
-
+
+
+ 目标
+
+
+
+
+ { (this.selectedTargetIndex = this.targetList.findIndex(item => e.id === item.id)), (this.targetShow = false); } "
+ @close="targetShow = false" />
+
-
-
- 目标体重
-
-
- { targetWeightShow = false }">
-
- 你的目标体重为?
- {{recordsData.goal_weight}} KG
-
-
-
-
+
+
+ 目标体重
+
+
+
+
+ { targetWeightShow = false }">
+
+ 你的目标体重为?
+ {{recordsData.goal_weight}} KG
+
+
+
+
-
-
- 运动量
-
-
-
-
- { (this.selectExerciseIndex = this.exerciseList.findIndex(item => e.id === item.id)), (this.exerciseShow = false); } "
- @close="exerciseShow = false"
- />
-
- 确认修改
- 修改资料后可更新并查看最新方案,预算热量可能会发生变化
-
+
+
+ 运动量
+
+
+
+
+ { (this.selectExerciseIndex = this.exerciseList.findIndex(item => e.id === item.id)), (this.exerciseShow = false); } "
+ @close="exerciseShow = false" />
+
+ 确认修改
+ 修改资料后可更新并查看最新方案,预算热量可能会发生变化
+
diff --git a/pages/user/index.vue b/pages/user/index.vue
index 91ff793..50cdd88 100644
--- a/pages/user/index.vue
+++ b/pages/user/index.vue
@@ -155,12 +155,10 @@
if (this.$store.state.token === '') return;
info()
.then(res => {
- console.log(res);
uni.setNavigationBarTitle({
title: res.nickname
});
this.userInfo = res;
- console.log(res);
})
.catch(err => {
uni.showToast({
@@ -318,7 +316,7 @@
.user-content {
padding-left: 158rpx;
- height: 128rpx;
+ height: 140rpx;
display: flex;
flex-direction: column;
justify-content: center;
diff --git a/router/index.js b/router/index.js
index b3b5465..c9daf3f 100644
--- a/router/index.js
+++ b/router/index.js
@@ -4,16 +4,16 @@ import {
} from 'uni-simple-router';
import store from '@/store/index'
-// #ifdef APP-NVUE
-// CALL 页面,必须是nvue,但是NVUE 不支持webpack的 ROUTES 注入
+// CALL 页面,必须是nvue,但是NVUE 不支持webpack的 ROUTES 注入
// https://github.com/SilurianYang/uni-read-pages/issues/20
+// #ifdef APP-NVUE
const ROUTES = [{
- 'path': '/pages/im/private/call',
- 'name': 'imPrivateCall'
-},{
- 'path': '/pages/im/private/chat',
- 'name': 'imPrivateChat'
-}]
+ "path": "/pages/im/private/call"
+}, {
+ "path": "/pages/im/private/chat"
+}, {
+ "path": "/pages/im/group/chat"
+}];
// #endif
const router = createRouter({
diff --git a/static/iconfont.css b/static/iconfont.css
index 28fbeec..288cce8 100644
--- a/static/iconfont.css
+++ b/static/iconfont.css
@@ -1,6 +1,6 @@
@font-face {
font-family: "iconfont"; /* Project id 2869797 */
- src: url('@/static/iconfont.ttf') format('truetype');
+ src: url('@/static/iconfont.ttf');
}
.iconfont {
@@ -11,6 +11,10 @@
-moz-osx-font-smoothing: grayscale;
}
+.icon-jia:before {
+ content: "\e60a";
+}
+
.icon-dui:before {
content: "\e609";
}
diff --git a/static/iconfont.ttf b/static/iconfont.ttf
index c983dbc..898c7f9 100644
Binary files a/static/iconfont.ttf and b/static/iconfont.ttf differ
diff --git a/static/imgs/curve-1.png b/static/imgs/curve-1.png
new file mode 100644
index 0000000..0f6413e
Binary files /dev/null and b/static/imgs/curve-1.png differ
diff --git a/static/imgs/curve-2.png b/static/imgs/curve-2.png
new file mode 100644
index 0000000..a768201
Binary files /dev/null and b/static/imgs/curve-2.png differ
diff --git a/static/imgs/no-weight.png b/static/imgs/no-weight.png
new file mode 100644
index 0000000..19a26c9
Binary files /dev/null and b/static/imgs/no-weight.png differ
diff --git a/static/imgs/speed-1.png b/static/imgs/speed-1.png
new file mode 100644
index 0000000..c4c31e5
Binary files /dev/null and b/static/imgs/speed-1.png differ
diff --git a/static/imgs/speed-2.png b/static/imgs/speed-2.png
new file mode 100644
index 0000000..56ac17d
Binary files /dev/null and b/static/imgs/speed-2.png differ
diff --git a/static/imgs/water-1.png b/static/imgs/water-1.png
new file mode 100644
index 0000000..d3d7ef9
Binary files /dev/null and b/static/imgs/water-1.png differ
diff --git a/static/imgs/water-2.png b/static/imgs/water-2.png
new file mode 100644
index 0000000..50cbdb4
Binary files /dev/null and b/static/imgs/water-2.png differ
diff --git a/store/modules/im.js b/store/modules/im.js
index e72b86e..7d482b6 100644
--- a/store/modules/im.js
+++ b/store/modules/im.js
@@ -2,98 +2,144 @@ import im from "@/utils/im/index.js"
export default {
state: {
- friends: {},
- sender: {},
+ contacts: {},
+ myInfo: {}
},
getters: {
- friends(state) {
- return state.friends
+ contacts(state) {
+ return state.contacts
},
- userInfo: (state) => (targetId) => {
- if (state.friends[targetId]) {
- return state.friends[targetId]
+ contactInfo: (state) => (targetId) => {
+ if (state.contacts[targetId]) {
+ const info = state.contacts[targetId]
+ return {
+ name: info.name,
+ hash: info.hash,
+ portraitUrl: info.localAvatar ? info.localAvatar : require('@/static/user/cover.png')
+ }
} else {
- console.log('没找到,死循环了,得处理 todo', targetId);
- // im.syncUserInfo(targetId)
return {
name: '',
- address: '',
hash: '',
portraitUrl: ''
}
}
},
- hasUser: (state) => (targetId) => {
- return Boolean(state.friends[targetId])
+ // 联系人是否存在
+ contactIsExist: (state) => (targetId) => {
+ return Boolean(state.contacts[targetId])
},
sender(state) {
- return state.sender
+ return state.myInfo
}
},
mutations: {
- updateFriends(state, userInfo) {
- Vue.set(state.friends, userInfo.userId, userInfo)
+ updateContactInfo(state, contactInfo) {
+ Vue.set(state.contacts, contactInfo.targetId, contactInfo)
},
- SET_state_sender(state, userInfo) {
- state.sender = userInfo
+ setSenderInfo(state, contactInfo) {
+ state.myInfo = {
+ userId: contactInfo.targetId,
+ name: contactInfo.name,
+ portraitUrl: contactInfo.portraitUrl
+ }
}
},
actions: {
setSenderInfo({
commit
- }, userInfo) {
- commit('SET_state_sender', userInfo)
+ }, contactInfo) {
+ commit('setSenderInfo', contactInfo)
},
- updateFriends({
+ // 载入好友信息
+ launchContact({
commit
- }, userInfo) {
- commit('updateFriends', userInfo)
- const model = uni.model.friendModel
- model.find('userId=' + userInfo.userId, (err, user) => {
- if (!err && user.length == 0) {
- saveAvatar(userInfo, (savedFilePath) => {
- model.insert({
- userId: userInfo.userId,
- name: userInfo.name,
- hash: userInfo.hash,
- address: userInfo.address,
- portraitUrl: savedFilePath,
- }, (err, result) => {})
- userInfo.portraitUrl = savedFilePath
- commit('updateFriends', userInfo)
- })
- } else if (!err && user[0].hash != userInfo.hash) {
- saveAvatar(userInfo, (savedFilePath) => {
- model.update('userId=' + userInfo.userId, {
- name: userInfo.name,
- hash: userInfo.hash,
- portraitUrl: savedFilePath,
- }, (err, result) => {})
- userInfo.portraitUrl = savedFilePath
- commit('updateFriends', userInfo)
- })
- } else if (!err && user[0].portraitUrl.length > 50) {
- saveAvatar(userInfo, (savedFilePath) => {
- model.update('userId=' + userInfo.userId, {
- name: userInfo.name,
- hash: userInfo.hash,
- portraitUrl: savedFilePath,
- }, (err, result) => {})
-
- userInfo.portraitUrl = savedFilePath
- commit('updateFriends', userInfo)
- })
+ }, data) {
+ commit('updateContactInfo', data)
+ },
+ // 更新好友信息,这个时候要校验hash值了
+ updateContact({
+ commit,
+ dispatch
+ }, contactInfo) {
+ const model = uni.model.contactModel
+ model.find('targetId="' + contactInfo.targetId + '"', (err, result) => {
+ if (result.length == 0) {
+ // 没有数据,直接新增一条
+ dispatch('initContact', contactInfo)
+ } else if (contactInfo.hash != result[0].hash) {
+ commit('updateContactInfo', contactInfo)
+ if (contactInfo.portraitUrl && contactInfo.portraitUrl != result[0].portraitUrl) {
+ saveAvatar(contactInfo, (savedFilePath) => {
+ const info = {
+ targetId: contactInfo.targetId,
+ name: contactInfo.name,
+ hash: contactInfo.hash,
+ portraitUrl: contactInfo.portraitUrl,
+ localAvatar: savedFilePath
+ }
+ model.update('targetId="' + contactInfo.targetId + '"', info, (err,
+ res) => {
+ console.log('UPDATE AVATAR, ERR', err);
+ })
+ commit('updateContactInfo', info)
+ })
+ } else {
+ const info = {
+ targetId: contactInfo.targetId,
+ name: contactInfo.name,
+ hash: contactInfo.hash,
+ portraitUrl: contactInfo.portraitUrl,
+ localAvatar: result[0].localAvatar
+ }
+ model.update('targetId="' + contactInfo.targetId + '"', info, (err, res) => {
+ console.log('UPDATE NAME, ERR', err);
+ })
+ }
} else {
- console.log('不用操作', user[0]);
+ console.log('updateContact, 无操作');
}
})
+ },
+ // 初始化好友信息
+ initContact({
+ commit
+ }, contactInfo) {
+ // 将好友信息保存到vuex的内存中,方便立即使用
+ commit('updateContactInfo', contactInfo)
+ const model = uni.model.contactModel
+ // 用户头像,是否需要下载到本地
+ if (contactInfo.portraitUrl) {
+ saveAvatar(contactInfo, (savedFilePath) => {
+ const info = {
+ targetId: contactInfo.targetId,
+ name: contactInfo.name,
+ hash: contactInfo.hash,
+ portraitUrl: contactInfo.portraitUrl,
+ localAvatar: savedFilePath
+ }
+ model.insert(info, (err, res) => {})
+ // 保存头像后,更新信息
+ commit('updateContactInfo', info)
+ })
+ } else {
+ // 直接将信息,写入数据库
+ const info = {
+ targetId: contactInfo.targetId,
+ name: contactInfo.name,
+ hash: contactInfo.hash,
+ portraitUrl: contactInfo.portraitUrl,
+ localAvatar: ''
+ }
+ model.insert(info, (err, res) => {})
+ }
}
}
}
-const saveAvatar = (userInfo, callback) => {
+const saveAvatar = (contactInfo, callback) => {
uni.downloadFile({
- url: userInfo.portraitUrl,
+ url: contactInfo.portraitUrl,
success: ({
tempFilePath
}) => {
@@ -106,8 +152,6 @@ const saveAvatar = (userInfo, callback) => {
}
})
},
- fail: (err) => {
- console.log('头像保存失败', err);
- }
+ fail: (err) => {}
})
}
diff --git a/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js b/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
index d36ecbc..46039c6 100644
--- a/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
+++ b/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
@@ -21,630 +21,639 @@ const color = ['#91CB74', '#1890FF', '#FAC858', '#EE6666', '#73C0DE', '#3CA272',
//事件转换函数,主要用作格式化x轴为时间轴,根据需求自行修改
const formatDateTime = (timeStamp, returnType) => {
- var date = new Date();
- date.setTime(timeStamp * 1000);
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? ('0' + m) : m;
- var d = date.getDate();
- d = d < 10 ? ('0' + d) : d;
- var h = date.getHours();
- h = h < 10 ? ('0' + h) : h;
- var minute = date.getMinutes();
- var second = date.getSeconds();
- minute = minute < 10 ? ('0' + minute) : minute;
- second = second < 10 ? ('0' + second) : second;
- if (returnType == 'full') { return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second; }
- if (returnType == 'y-m-d') { return y + '-' + m + '-' + d; }
- if (returnType == 'h:m') { return h + ':' + minute; }
- if (returnType == 'h:m:s') { return h + ':' + minute + ':' + second; }
- return [y, m, d, h, minute, second];
+ var date = new Date();
+ date.setTime(timeStamp * 1000);
+ var y = date.getFullYear();
+ var m = date.getMonth() + 1;
+ m = m < 10 ? ('0' + m) : m;
+ var d = date.getDate();
+ d = d < 10 ? ('0' + d) : d;
+ var h = date.getHours();
+ h = h < 10 ? ('0' + h) : h;
+ var minute = date.getMinutes();
+ var second = date.getSeconds();
+ minute = minute < 10 ? ('0' + minute) : minute;
+ second = second < 10 ? ('0' + second) : second;
+ if (returnType == 'full') {
+ return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
+ }
+ if (returnType == 'y-m-d') {
+ return y + '-' + m + '-' + d;
+ }
+ if (returnType == 'h:m') {
+ return h + ':' + minute;
+ }
+ if (returnType == 'h:m:s') {
+ return h + ':' + minute + ':' + second;
+ }
+ return [y, m, d, h, minute, second];
}
const cfu = {
- //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
- "type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "bar", "area", "radar", "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"],
- "range": ["饼状图", "圆环图", "玫瑰图", "词云图", "漏斗图", "地图", "圆弧进度条", "折线图", "柱状图", "条状图", "区域图", "雷达图", "仪表盘", "K线图", "混合图", "时间轴折线", "时间轴区域", "散点图", "气泡图", "自定义类型"],
- //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
- //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
- "categories": ["line", "column", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
- //instance为实例变量承载属性,不要删除
- "instance": {},
- //option为opts及eopts承载属性,不要删除
- "option": {},
- //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
- "formatter": {
- "yAxisDemo1": function (val) { return val + '元' },
- "yAxisDemo2": function (val) { return val.toFixed(2) },
- "xAxisDemo1": function (val) { return val + '年' },
- "xAxisDemo2": function (val) { return formatDateTime(val, 'h:m') },
- "seriesDemo1": function (val) { return val + '元' },
- "tooltipDemo1": function (item, category, index, opts) {
- if (index == 0) {
- return '随便用' + item.data + '年'
- } else {
- return '其他我没改' + item.data + '天'
- }
- },
- "pieDemo": function (val, index, series) {
- if (index !== undefined) {
- return series[index].name + ':' + series[index].data + '元'
- }
- },
- },
- //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
- "demotype": {
- //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true,
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- },
- "legend": {
- },
- "extra": {
- "line": {
- "type": "curve",
- "width": 2
- },
- }
- },
- //下面是自定义配置,请添加项目所需的通用配置
- "pie": {
- "type": "pie",
- "color": color,
- "padding": [5, 5, 5, 5],
- "extra": {
- "pie": {
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": true,
- "borderWidth": 3,
- "borderColor": "#FFFFFF"
- },
- }
- },
- "ring": {
- "type": "ring",
- "color": color,
- "padding": [5, 5, 5, 5],
- "rotate": false,
- "dataLabel": true,
- "legend": {
- "show": true,
- "position": "right",
- "lineHeight": 25,
- },
- "title": {
- "name": "收益率",
- "fontSize": 15,
- "color": "#666666"
- },
- "subtitle": {
- "name": "70%",
- "fontSize": 25,
- "color": "#7cb5ec"
- },
- "extra": {
- "ring": {
- "ringWidth": 30,
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": true,
- "borderWidth": 3,
- "borderColor": "#FFFFFF"
- },
- },
- },
- "rose": {
- "type": "rose",
- "color": color,
- "padding": [5, 5, 5, 5],
- "legend": {
- "show": true,
- "position": "left",
- "lineHeight": 25,
- },
- "extra": {
- "rose": {
- "type": "area",
- "minRadius": 50,
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": false,
- "borderWidth": 2,
- "borderColor": "#FFFFFF"
- },
- }
- },
- "word": {
- "type": "word",
- "color": color,
- "extra": {
- "word": {
- "type": "normal",
- "autoColors": false
- }
- }
- },
- "funnel": {
- "type": "funnel",
- "color": color,
- "padding": [15, 15, 0, 15],
- "extra": {
- "funnel": {
- "activeOpacity": 0.3,
- "activeWidth": 10,
- "border": true,
- "borderWidth": 2,
- "borderColor": "#FFFFFF",
- "fillOpacity": 1,
- "labelAlign": "right"
- },
- }
- },
- "map": {
- "type": "map",
- "color": color,
- "padding": [0, 0, 0, 0],
- "dataLabel": true,
- "extra": {
- "map": {
- "border": true,
- "borderWidth": 1,
- "borderColor": "#666666",
- "fillOpacity": 0.6,
- "activeBorderColor": "#F04864",
- "activeFillColor": "#FACC14",
- "activeFillOpacity": 1
- },
- }
- },
- "arcbar": {
- "type": "arcbar",
- "color": color,
- "title": {
- "name": "百分比",
- "fontSize": 25,
- "color": "#00FF00"
- },
- "subtitle": {
- "name": "默认标题",
- "fontSize": 15,
- "color": "#666666"
- },
- "extra": {
- "arcbar": {
- "type": "default",
- "width": 12,
- "backgroundColor": "#E9E9E9",
- "startAngle": 0.75,
- "endAngle": 0.25,
- "gap": 2
- }
- }
- },
- "line": {
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true,
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- },
- "legend": {
- },
- "extra": {
- "line": {
- "type": "straight",
- "width": 2
- },
- }
- },
- "tline": {
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": false,
- "boundaryGap": "justify",
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- "data": [
- {
- "min": 0,
- "max": 80
- }
- ]
- },
- "legend": {
- },
- "extra": {
- "line": {
- "type": "curve",
- "width": 2
- },
- }
- },
- "tarea": {
- "type": "area",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true,
- "boundaryGap": "justify",
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- "data": [
- {
- "min": 0,
- "max": 80
- }
- ]
- },
- "legend": {
- },
- "extra": {
- "area": {
- "type": "curve",
- "opacity": 0.2,
- "addLine": true,
- "width": 2,
- "gradient": true
- },
- }
- },
- "column": {
- "type": "column",
- "color": color,
- "padding": [15, 15, 0, 5],
- "xAxis": {
- "disableGrid": true,
- },
- "yAxis": {
- "data": [{ "min": 0 }]
- },
- "legend": {
- },
- "extra": {
- "column": {
- "type": "group",
- "width": 30,
- "meterBorde": 1,
- "meterFillColor": "#FFFFFF",
- "activeBgColor": "#000000",
- "activeBgOpacity": 0.08
- },
- }
- },
- "bar": {
- "type": "bar",
- "color": color,
- "padding": [15, 30, 0, 5],
- "xAxis": {
- "boundaryGap": "justify",
- "disableGrid": false,
- "min": 0,
- "axisLine": false
- },
- "yAxis": {
- },
- "legend": {
- },
- "extra": {
- "bar": {
- "type": "group",
- "width": 30,
- "meterBorde": 1,
- "meterFillColor": "#FFFFFF",
- "activeBgColor": "#000000",
- "activeBgOpacity": 0.08
- },
- }
- },
- "area": {
- "type": "area",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": true,
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- },
- "legend": {
- },
- "extra": {
- "area": {
- "type": "straight",
- "opacity": 0.2,
- "addLine": true,
- "width": 2,
- "gradient": false
- },
- }
- },
- "radar": {
- "type": "radar",
- "canvasId": "",
- "canvas2d": false,
- "background": "none",
- "animation": true,
- "timing": "easeOut",
- "duration": 1000,
- "color": [
- "#91CB74",
- "#1890FF",
- "#FAC858",
- "#EE6666",
- "#73C0DE",
- "#3CA272",
- "#FC8452",
- "#9A60B4",
- "#ea7ccc"
- ],
- "padding": [
- 5,
- 5,
- 5,
- 5
- ],
- "rotate": false,
- "errorReload": true,
- "fontSize": 10,
- "fontColor": "#666666",
- "enableScroll": false,
- "touchMoveLimit": 60,
- "enableMarkLine": false,
- "dataLabel": false,
- "dataPointShape": true,
- "dataPointShapeType": "solid",
- "tapLegend": true,
- "legend": {
- "show": false,
- "position": "bottom",
- "float": "center",
- "padding": 5,
- "margin": 5,
- "backgroundColor": "rgba(0,0,0,0)",
- "borderColor": "rgba(0,0,0,0)",
- "borderWidth": 0,
- "fontSize": 13,
- "fontColor": "#666666",
- "lineHeight": 25,
- "hiddenColor": "#CECECE",
- "itemGap": 10
- },
- "extra": {
- "radar": {
- "gridType": "radar",
- "gridColor": "#CCCCCC",
- "gridCount": 3,
- "labelColor": "#666666",
- "opacity": 0.2,
- "border": false,
- "borderWidth": 2,
- "max": 50
- },
- "tooltip": {
- "showBox": true,
- "showArrow": true,
- "showCategory": false,
- "borderWidth": 0,
- "borderRadius": 0,
- "borderColor": "#000000",
- "borderOpacity": 0.7,
- "bgColor": "#000000",
- "bgOpacity": 0.7,
- "gridType": "solid",
- "dashLength": 4,
- "gridColor": "#CCCCCC",
- "fontColor": "#FFFFFF",
- "splitLine": true,
- "horizentalLine": false,
- "xAxisLabel": false,
- "yAxisLabel": false,
- "labelBgColor": "#FFFFFF",
- "labelBgOpacity": 0.7,
- "labelFontColor": "#666666"
- }
- }
- },
- "gauge": {
- "type": "gauge",
- "color": color,
- "title": {
- "name": "66Km/H",
- "fontSize": 25,
- "color": "#2fc25b",
- "offsetY": 50
- },
- "subtitle": {
- "name": "实时速度",
- "fontSize": 15,
- "color": "#1890ff",
- "offsetY": -50
- },
- "extra": {
- "gauge": {
- "type": "default",
- "width": 30,
- "labelColor": "#666666",
- "startAngle": 0.75,
- "endAngle": 0.25,
- "startNumber": 0,
- "endNumber": 100,
- "labelFormat": "",
- "splitLine": {
- "fixRadius": 0,
- "splitNumber": 10,
- "width": 30,
- "color": "#FFFFFF",
- "childNumber": 5,
- "childWidth": 12
- },
- "pointer": {
- "width": 24,
- "color": "auto"
- }
- }
- }
- },
- "candle": {
- "type": "candle",
- "color": color,
- "padding": [15, 15, 0, 15],
- "enableScroll": true,
- "enableMarkLine": true,
- "dataLabel": false,
- "xAxis": {
- "labelCount": 4,
- "itemCount": 40,
- "disableGrid": true,
- "gridColor": "#CCCCCC",
- "gridType": "solid",
- "dashLength": 4,
- "scrollShow": true,
- "scrollAlign": "left",
- "scrollColor": "#A6A6A6",
- "scrollBackgroundColor": "#EFEBEF"
- },
- "yAxis": {
- },
- "legend": {
- },
- "extra": {
- "candle": {
- "color": {
- "upLine": "#f04864",
- "upFill": "#f04864",
- "downLine": "#2fc25b",
- "downFill": "#2fc25b"
- },
- "average": {
- "show": true,
- "name": ["MA5", "MA10", "MA30"],
- "day": [5, 10, 20],
- "color": ["#1890ff", "#2fc25b", "#facc14"]
- }
- },
- "markLine": {
- "type": "dash",
- "dashLength": 5,
- "data": [
- {
- "value": 2150,
- "lineColor": "#f04864",
- "showLabel": true
- },
- {
- "value": 2350,
- "lineColor": "#f04864",
- "showLabel": true
- }
- ]
- }
- }
- },
- "mix": {
- "type": "mix",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": true,
- },
- "yAxis": {
- "disabled": false,
- "disableGrid": false,
- "splitNumber": 5,
- "gridType": "dash",
- "dashLength": 4,
- "gridColor": "#CCCCCC",
- "padding": 10,
- "showTitle": true,
- "data": []
- },
- "legend": {
- },
- "extra": {
- "mix": {
- "column": {
- "width": 20
- }
- },
- }
- },
- "scatter": {
- "type": "scatter",
- "color": color,
- "padding": [15, 15, 0, 15],
- "dataLabel": false,
- "xAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "splitNumber": 5,
- "boundaryGap": "justify",
- "min": 0
- },
- "yAxis": {
- "disableGrid": false,
- "gridType": "dash",
- },
- "legend": {
- },
- "extra": {
- "scatter": {
- },
- }
- },
- "bubble": {
- "type": "bubble",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "splitNumber": 5,
- "boundaryGap": "justify",
- "min": 0,
- "max": 250
- },
- "yAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "data": [{
- "min": 0,
- "max": 150
- }]
- },
- "legend": {
- },
- "extra": {
- "bubble": {
- "border": 2,
- "opacity": 0.5,
- },
- }
- }
+ //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
+ "type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "bar", "area", "radar",
+ "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"
+ ],
+ "range": ["饼状图", "圆环图", "玫瑰图", "词云图", "漏斗图", "地图", "圆弧进度条", "折线图", "柱状图", "条状图", "区域图", "雷达图", "仪表盘", "K线图",
+ "混合图", "时间轴折线", "时间轴区域", "散点图", "气泡图", "自定义类型"
+ ],
+ //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
+ //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
+ "categories": ["line", "column", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
+ //instance为实例变量承载属性,不要删除
+ "instance": {},
+ //option为opts及eopts承载属性,不要删除
+ "option": {},
+ //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
+ "formatter": {
+ "yAxisDemo1": function(val) {
+ return val + '元'
+ },
+ "yAxisDemo2": function(val) {
+ return val.toFixed(2)
+ },
+ "xAxisDemo1": function(val) {
+ return val + '年'
+ },
+ "xAxisDemo2": function(val) {
+ return formatDateTime(val, 'h:m')
+ },
+ "seriesDemo1": function(val) {
+ return val + '元'
+ },
+ "tooltipDemo1": function(item, category, index, opts) {
+ if (index == 0) {
+ return '随便用' + item.data + '年'
+ } else {
+ return '其他我没改' + item.data + '天'
+ }
+ },
+ "pieDemo": function(val, index, series) {
+ if (index !== undefined) {
+ return series[index].name + ':' + series[index].data + '元'
+ }
+ },
+ },
+ //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
+ "demotype": {
+ //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
+ "type": "line",
+ "color": color,
+ "padding": [15, 10, 0, 15],
+ "xAxis": {
+ "disableGrid": true,
+ },
+ "yAxis": {
+ "gridType": "dash",
+ "dashLength": 2,
+ },
+ "legend": {},
+ "extra": {
+ "line": {
+ "type": "curve",
+ "width": 2
+ },
+ }
+ },
+ //下面是自定义配置,请添加项目所需的通用配置
+ "pie": {
+ "type": "pie",
+ "color": color,
+ "padding": [5, 5, 5, 5],
+ "extra": {
+ "pie": {
+ "activeOpacity": 0.5,
+ "activeRadius": 10,
+ "offsetAngle": 0,
+ "labelWidth": 15,
+ "border": true,
+ "borderWidth": 3,
+ "borderColor": "#FFFFFF"
+ },
+ }
+ },
+ "ring": {
+ "type": "ring",
+ "color": color,
+ "padding": [5, 5, 5, 5],
+ "rotate": false,
+ "dataLabel": true,
+ "legend": {
+ "show": true,
+ "position": "right",
+ "lineHeight": 25,
+ },
+ "title": {
+ "name": "收益率",
+ "fontSize": 15,
+ "color": "#666666"
+ },
+ "subtitle": {
+ "name": "70%",
+ "fontSize": 25,
+ "color": "#7cb5ec"
+ },
+ "extra": {
+ "ring": {
+ "ringWidth": 30,
+ "activeOpacity": 0.5,
+ "activeRadius": 10,
+ "offsetAngle": 0,
+ "labelWidth": 15,
+ "border": true,
+ "borderWidth": 3,
+ "borderColor": "#FFFFFF"
+ },
+ },
+ },
+ "rose": {
+ "type": "rose",
+ "color": color,
+ "padding": [5, 5, 5, 5],
+ "legend": {
+ "show": true,
+ "position": "left",
+ "lineHeight": 25,
+ },
+ "extra": {
+ "rose": {
+ "type": "area",
+ "minRadius": 50,
+ "activeOpacity": 0.5,
+ "activeRadius": 10,
+ "offsetAngle": 0,
+ "labelWidth": 15,
+ "border": false,
+ "borderWidth": 2,
+ "borderColor": "#FFFFFF"
+ },
+ }
+ },
+ "word": {
+ "type": "word",
+ "color": color,
+ "extra": {
+ "word": {
+ "type": "normal",
+ "autoColors": false
+ }
+ }
+ },
+ "funnel": {
+ "type": "funnel",
+ "color": color,
+ "padding": [15, 15, 0, 15],
+ "extra": {
+ "funnel": {
+ "activeOpacity": 0.3,
+ "activeWidth": 10,
+ "border": true,
+ "borderWidth": 2,
+ "borderColor": "#FFFFFF",
+ "fillOpacity": 1,
+ "labelAlign": "right"
+ },
+ }
+ },
+ "map": {
+ "type": "map",
+ "color": color,
+ "padding": [0, 0, 0, 0],
+ "dataLabel": true,
+ "extra": {
+ "map": {
+ "border": true,
+ "borderWidth": 1,
+ "borderColor": "#666666",
+ "fillOpacity": 0.6,
+ "activeBorderColor": "#F04864",
+ "activeFillColor": "#FACC14",
+ "activeFillOpacity": 1
+ },
+ }
+ },
+ "arcbar": {
+ "type": "arcbar",
+ "color": color,
+ "title": {
+ "name": "百分比",
+ "fontSize": 25,
+ "color": "#00FF00"
+ },
+ "subtitle": {
+ "name": "默认标题",
+ "fontSize": 15,
+ "color": "#666666"
+ },
+ "extra": {
+ "arcbar": {
+ "type": "default",
+ "width": 12,
+ "backgroundColor": "#E9E9E9",
+ "startAngle": 0.75,
+ "endAngle": 0.25,
+ "gap": 2
+ }
+ }
+ },
+ "line": {
+ "type": "line",
+ "color": color,
+ "padding": [15, 10, 0, 15],
+ "xAxis": {
+ "disableGrid": true,
+ },
+ "yAxis": {
+ "gridType": "dash",
+ "dashLength": 2,
+ },
+ "legend": {},
+ "extra": {
+ "line": {
+ "type": "straight",
+ "width": 2
+ },
+ }
+ },
+ "tline": {
+ "type": "line",
+ "color": color,
+ "padding": [15, 10, 0, 15],
+ "xAxis": {
+ "disableGrid": false,
+ "boundaryGap": "justify",
+ },
+ "yAxis": {
+ "gridType": "dash",
+ "dashLength": 2,
+ "data": [{
+ "min": 0,
+ "max": 80
+ }]
+ },
+ "legend": {},
+ "extra": {
+ "line": {
+ "type": "curve",
+ "width": 2
+ },
+ }
+ },
+ "tarea": {
+ "type": "area",
+ "color": color,
+ "padding": [15, 10, 0, 15],
+ "xAxis": {
+ "disableGrid": true,
+ "boundaryGap": "justify",
+ },
+ "yAxis": {
+ "gridType": "dash",
+ "dashLength": 2,
+ "data": [{
+ "min": 0,
+ "max": 80
+ }]
+ },
+ "legend": {},
+ "extra": {
+ "area": {
+ "type": "curve",
+ "opacity": 0.2,
+ "addLine": true,
+ "width": 2,
+ "gradient": true
+ },
+ }
+ },
+ "column": {
+ "type": "column",
+ "color": color,
+ "padding": [15, 15, 0, 5],
+ "xAxis": {
+ "disableGrid": true,
+ },
+ "yAxis": {
+ "data": [{
+ "min": 0
+ }]
+ },
+ "legend": {},
+ "extra": {
+ "column": {
+ "type": "group",
+ "width": 30,
+ "meterBorde": 1,
+ "meterFillColor": "#FFFFFF",
+ "activeBgColor": "#000000",
+ "activeBgOpacity": 0.08
+ },
+ }
+ },
+ "bar": {
+ "type": "bar",
+ "color": color,
+ "padding": [15, 30, 0, 5],
+ "xAxis": {
+ "boundaryGap": "justify",
+ "disableGrid": false,
+ "min": 0,
+ "axisLine": false
+ },
+ "yAxis": {},
+ "legend": {},
+ "extra": {
+ "bar": {
+ "type": "group",
+ "width": 30,
+ "meterBorde": 1,
+ "meterFillColor": "#FFFFFF",
+ "activeBgColor": "#000000",
+ "activeBgOpacity": 0.08
+ },
+ }
+ },
+ "area": {
+ "type": "area",
+ "color": [
+ "#34ce98",
+ ],
+ "padding": [15, 15, 0, 15],
+ "xAxis": {
+ "disableGrid": true,
+ },
+ "yAxis": {
+ "gridType": "dash",
+ "dashLength": 2,
+ },
+ "fontColor": "#999",
+ "fontSize":"12",
+ "legend": {},
+ "extra": {
+ "area": {
+ "type": "straight",
+ "opacity": 0.2,
+ "addLine": true,
+ "width": 2,
+ "gradient": false
+ },
+ }
+ },
+ "radar": {
+ "type": "radar",
+ "canvasId": "",
+ "canvas2d": false,
+ "background": "none",
+ "animation": true,
+ "timing": "easeOut",
+ "duration": 1000,
+ "color": [
+ "#91CB74",
+ "#1890FF",
+ "#FAC858",
+ "#EE6666",
+ "#73C0DE",
+ "#3CA272",
+ "#FC8452",
+ "#9A60B4",
+ "#ea7ccc"
+ ],
+ "padding": [
+ 5,
+ 5,
+ 5,
+ 5
+ ],
+ "rotate": false,
+ "errorReload": true,
+ "fontSize": 10,
+ "fontColor": "#666666",
+ "enableScroll": false,
+ "touchMoveLimit": 60,
+ "enableMarkLine": false,
+ "dataLabel": false,
+ "dataPointShape": true,
+ "dataPointShapeType": "solid",
+ "tapLegend": true,
+ "legend": {
+ "show": false,
+ "position": "bottom",
+ "float": "center",
+ "padding": 5,
+ "margin": 5,
+ "backgroundColor": "rgba(0,0,0,0)",
+ "borderColor": "rgba(0,0,0,0)",
+ "borderWidth": 0,
+ "fontSize": 13,
+ "fontColor": "#666666",
+ "lineHeight": 25,
+ "hiddenColor": "#CECECE",
+ "itemGap": 10
+ },
+ "extra": {
+ "radar": {
+ "gridType": "radar",
+ "gridColor": "#CCCCCC",
+ "gridCount": 3,
+ "labelColor": "#666666",
+ "opacity": 0.2,
+ "border": false,
+ "borderWidth": 2,
+ "max": 50
+ },
+ "tooltip": {
+ "showBox": true,
+ "showArrow": true,
+ "showCategory": false,
+ "borderWidth": 0,
+ "borderRadius": 0,
+ "borderColor": "#000000",
+ "borderOpacity": 0.7,
+ "bgColor": "#000000",
+ "bgOpacity": 0.7,
+ "gridType": "solid",
+ "dashLength": 4,
+ "gridColor": "#CCCCCC",
+ "fontColor": "#FFFFFF",
+ "splitLine": true,
+ "horizentalLine": false,
+ "xAxisLabel": false,
+ "yAxisLabel": false,
+ "labelBgColor": "#FFFFFF",
+ "labelBgOpacity": 0.7,
+ "labelFontColor": "#666666"
+ }
+ }
+ },
+ "gauge": {
+ "type": "gauge",
+ "color": color,
+ "title": {
+ "name": "66Km/H",
+ "fontSize": 25,
+ "color": "#2fc25b",
+ "offsetY": 50
+ },
+ "subtitle": {
+ "name": "实时速度",
+ "fontSize": 15,
+ "color": "#1890ff",
+ "offsetY": -50
+ },
+ "extra": {
+ "gauge": {
+ "type": "default",
+ "width": 30,
+ "labelColor": "#666666",
+ "startAngle": 0.75,
+ "endAngle": 0.25,
+ "startNumber": 0,
+ "endNumber": 100,
+ "labelFormat": "",
+ "splitLine": {
+ "fixRadius": 0,
+ "splitNumber": 10,
+ "width": 30,
+ "color": "#FFFFFF",
+ "childNumber": 5,
+ "childWidth": 12
+ },
+ "pointer": {
+ "width": 24,
+ "color": "auto"
+ }
+ }
+ }
+ },
+ "candle": {
+ "type": "candle",
+ "color": color,
+ "padding": [15, 15, 0, 15],
+ "enableScroll": true,
+ "enableMarkLine": true,
+ "dataLabel": false,
+ "xAxis": {
+ "labelCount": 4,
+ "itemCount": 40,
+ "disableGrid": true,
+ "gridColor": "#CCCCCC",
+ "gridType": "solid",
+ "dashLength": 4,
+ "scrollShow": true,
+ "scrollAlign": "left",
+ "scrollColor": "#A6A6A6",
+ "scrollBackgroundColor": "#EFEBEF"
+ },
+ "yAxis": {},
+ "legend": {},
+ "extra": {
+ "candle": {
+ "color": {
+ "upLine": "#f04864",
+ "upFill": "#f04864",
+ "downLine": "#2fc25b",
+ "downFill": "#2fc25b"
+ },
+ "average": {
+ "show": true,
+ "name": ["MA5", "MA10", "MA30"],
+ "day": [5, 10, 20],
+ "color": ["#1890ff", "#2fc25b", "#facc14"]
+ }
+ },
+ "markLine": {
+ "type": "dash",
+ "dashLength": 5,
+ "data": [{
+ "value": 2150,
+ "lineColor": "#f04864",
+ "showLabel": true
+ },
+ {
+ "value": 2350,
+ "lineColor": "#f04864",
+ "showLabel": true
+ }
+ ]
+ }
+ }
+ },
+ "mix": {
+ "type": "mix",
+ "color": color,
+ "padding": [15, 15, 0, 15],
+ "xAxis": {
+ "disableGrid": true,
+ },
+ "yAxis": {
+ "disabled": false,
+ "disableGrid": false,
+ "splitNumber": 5,
+ "gridType": "dash",
+ "dashLength": 4,
+ "gridColor": "#CCCCCC",
+ "padding": 10,
+ "showTitle": true,
+ "data": []
+ },
+ "legend": {},
+ "extra": {
+ "mix": {
+ "column": {
+ "width": 20
+ }
+ },
+ }
+ },
+ "scatter": {
+ "type": "scatter",
+ "color": color,
+ "padding": [15, 15, 0, 15],
+ "dataLabel": false,
+ "xAxis": {
+ "disableGrid": false,
+ "gridType": "dash",
+ "splitNumber": 5,
+ "boundaryGap": "justify",
+ "min": 0
+ },
+ "yAxis": {
+ "disableGrid": false,
+ "gridType": "dash",
+ },
+ "legend": {},
+ "extra": {
+ "scatter": {},
+ }
+ },
+ "bubble": {
+ "type": "bubble",
+ "color": color,
+ "padding": [15, 15, 0, 15],
+ "xAxis": {
+ "disableGrid": false,
+ "gridType": "dash",
+ "splitNumber": 5,
+ "boundaryGap": "justify",
+ "min": 0,
+ "max": 250
+ },
+ "yAxis": {
+ "disableGrid": false,
+ "gridType": "dash",
+ "data": [{
+ "min": 0,
+ "max": 150
+ }]
+ },
+ "legend": {},
+ "extra": {
+ "bubble": {
+ "border": 2,
+ "opacity": 0.5,
+ },
+ }
+ }
}
-export default cfu;
\ No newline at end of file
+export default cfu;
diff --git a/utils/im/data.js b/utils/im/data.js
new file mode 100644
index 0000000..495c149
--- /dev/null
+++ b/utils/im/data.js
@@ -0,0 +1,16 @@
+// 获取新好友申请数量
+const getPendingCount = (callback) => {
+ RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 100, 0, (res) => {
+ if (res.code === 0) {
+ const pendingCount = res.conversations.filter((item) => {
+ return item.objectName == RongIMLib.ObjectName.ContactNotification
+ }).length
+
+ callback(pendingCount)
+ }
+ })
+}
+
+export default {
+ getPendingCount
+}
diff --git a/utils/im/historyMessages.json b/utils/im/historyMessages.json
deleted file mode 100644
index 97f2e47..0000000
--- a/utils/im/historyMessages.json
+++ /dev/null
@@ -1,23 +0,0 @@
-[{
- "objectName": "RC:TxtMsg",
- "receivedTime": 1643080237399,
- "extra": "",
- "messageUId": "BUFC-3FSU-OLE4-I31K",
- "conversationType": 1,
- "messageDirection": 2,
- "senderUserId": "10041",
- "content": {
- "content": "你好,这是 1710 条消息条消息条消息条消息条消息条消息条消息条消息条消息0.97796900 1642741562",
- "objectName": "RC:TxtMsg",
- "userInfo": {
- "userId": "10041",
- "name": "我是eth",
- "portraitUrl": "http://storage.zh.shangkelian.cn/images/2022/01/12/3d2a103386df6822db7e5290272e8bc2.png"
- }
- },
- "targetId": "10041",
- "sentTime": 1642741563003,
- "messageId": 2,
- "receivedStatus": 1,
- "sentStatus": 30
-}]
diff --git a/utils/im/index.js b/utils/im/index.js
index 60714db..4c22b53 100644
--- a/utils/im/index.js
+++ b/utils/im/index.js
@@ -2,6 +2,7 @@ import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
import store from '@/store/index.js'
import message from './message.js'
+import listeners from './listeners.js'
import {
getFriends,
getUserInfo,
@@ -10,7 +11,7 @@ import {
const initIm = (KEY) => {
RongIMLib.init(KEY)
- CallLib.init()
+ // CallLib.init()
addListeners()
// 初始化的时候 自动链接
if (store.getters.getToken !== '') {
@@ -47,25 +48,37 @@ const setNotifyBadge = () => {
/**
* 连接IM服务
* @param {string} token token
- * @param {object} userInfo {userId: string, name: string, portraitUrl: string}
+ * @param {object} userInfo {targetId: string, name: string, portraitUrl: string}
*/
const connect = (token, userInfo, callback) => {
RongIMLib.connect(token, res => {
- console.log('连接结果', res);
-
callback(res)
- })
+ // 更新个人信息
+ store.dispatch('setSenderInfo', userInfo)
+ // 设置未读消息数量
+ setNotifyBadge()
+ // 首次运行获取好友列表
+ const FK = 'IFT_' + userInfo.targetId
- store.dispatch('setSenderInfo', userInfo)
-
- setNotifyBadge()
-
- const model = uni.model.friendModel
-
- model.find((err, results) => {
- console.log('好友列表', results);
- results.map(item => {
- store.dispatch('updateFriends', item)
+ uni.getStorage({
+ key: FK,
+ success: () => {
+ const model = uni.model.contactModel
+ model.find((err, results) => {
+ results.map(item => {
+ store.dispatch('launchContact', item)
+ })
+ })
+ },
+ fail: () => {
+ // 程序是首次运行,初始化加载好友信息
+ getFriends().then(res => {
+ res.map(item => {
+ store.dispatch('initContact', item)
+ })
+ uni.setStorageSync(FK, userInfo.targetId)
+ })
+ }
})
})
}
@@ -102,71 +115,88 @@ const notifyMsgTypes = [
function inArray(search, array) {
for (var i in array) {
if (array[i] == search) {
- return true;
+ return true
}
}
- return false;
+ return false
}
const addListeners = () => {
// 添加连接状态监听函数
RongIMLib.addConnectionStatusListener((res) => {
- console.log('连接状态监听', res.data.status);
+ console.log('连接状态监听', res.data.status)
uni.$emit('onConnectionStatusChange', res.data.status)
})
// 添加消息监听函数
RongIMLib.addReceiveMessageListener((res) => {
- console.log('收到消息', res.data.message);
const message = res.data.message
+ console.log('收到消息', message)
if (inArray(message.objectName, notifyMsgTypes)) {
- console.log('new Message');
+ if (!store.getters.contactIsExist(message.targetId)) {
+ getUserInfo(message.targetId).then(res => {
+ store.dispatch('initContact', res)
+ }).catch(err => {
+ console.log('ERR', err)
+ })
+ }
newMessage(message)
+ } else if (message.objectName === RongIMLib.ObjectName.ProfileNotification) {
+ store.dispatch('updateContact', JSON.parse(message.content.data))
+ // 调用完更新之后,删除这条消息
+ RongIMLib.deleteMessagesByIds([message.messageId], ({
+ code
+ }) => {
+ console.log('消息删除结果', code)
+ })
+ } else if (message.objectName === RongIMLib.ObjectName.ContactNotification) {
+ // 触发一个新好友的通知事件
+ uni.$emit('onContactNotification', message.content)
}
- })
-
- // 监听消息回执
- RongIMLib.addReadReceiptReceivedListener(({
- data
- }) => {
- uni.$emit('onReadReceiptReceived', data)
- })
-
- // 音视频通话相关的
- // 监听通话呼入
- CallLib.onCallReceived(({
+ })
+
+ // 监听消息回执
+ RongIMLib.addReadReceiptReceivedListener(({
data
}) => {
- uni.navigateTo({
- url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
- data.mediaType
- })
- })
- // 通话建立成功
- CallLib.onCallConnected(() => {
- uni.$emit('onCallConnected');
- })
- // 外呼
- CallLib.onCallOutgoing((res) => {
- uni.$emit('onCallOutgoing');
- })
- // 远端响铃
- CallLib.onRemoteUserRinging((res) => {
- uni.$emit('onRemoteUserRinging');
- })
- // 远端加入
- CallLib.onRemoteUserJoined((res) => {
- uni.$emit('onRemoteUserJoined');
- })
- // 断开链接
- CallLib.onCallDisconnected((res) => {
- console.log('断开链接', res);
- uni.$emit('onCallDisconnected');
- })
- // 远端挂断
- CallLib.onRemoteUserLeft((res) => {
- console.log('远端离开', res);
- uni.$emit('onRemoteUserLeft');
+ uni.$emit('onReadReceiptReceived', data)
})
+
+ // 音视频通话相关的
+ // 监听通话呼入
+ // CallLib.onCallReceived(({
+ // data
+ // }) => {
+ // uni.navigateTo({
+ // url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
+ // data.mediaType
+ // })
+ // })
+ // // 通话建立成功
+ // CallLib.onCallConnected(() => {
+ // uni.$emit('onCallConnected')
+ // })
+ // // 外呼
+ // CallLib.onCallOutgoing((res) => {
+ // uni.$emit('onCallOutgoing')
+ // })
+ // // 远端响铃
+ // CallLib.onRemoteUserRinging((res) => {
+ // uni.$emit('onRemoteUserRinging')
+ // })
+ // // 远端加入
+ // CallLib.onRemoteUserJoined((res) => {
+ // uni.$emit('onRemoteUserJoined')
+ // })
+ // // 断开链接
+ // CallLib.onCallDisconnected((res) => {
+ // console.log('断开链接', res)
+ // uni.$emit('onCallDisconnected')
+ // })
+ // // 远端挂断
+ // CallLib.onRemoteUserLeft((res) => {
+ // console.log('远端离开', res)
+ // uni.$emit('onRemoteUserLeft')
+ // })
}
// 维护消息列表,检查是否需要通知声音,设置新消息提醒的数量
@@ -176,25 +206,14 @@ const newMessage = (msg) => {
status
}) => {
if (code === 0) {
- if (status) {
+ if (status) {
+ uni.vibrateLong()
triTone()
}
}
- });
-
- setNotifyBadge()
-
- if (!store.getters.hasUser(msg.targetId)) {
- syncUserInfo(msg.targetId)
- }
-
- uni.$emit('onReceiveMessage', msg);
-}
-
-function syncUserInfo(targetId) {
- getUserInfo(targetId).then(res => {
- store.dispatch('updateFriends', res)
})
+ setNotifyBadge()
+ uni.$emit('onReceiveMessage', msg)
}
// 播放状态
@@ -209,29 +228,15 @@ const triTone = () => {
tipState = true
})
innerAudioContext.onEnded(() => {
- tipState = false
+ tipState = false
innerAudioContext.destroy()
})
}
}
-/**
- * 同步好友信息,保存头像地址等
- */
-const syncFriends = () => {
- getFriends().then(res => {
- res.map(item => {
- console.log('item', item);
- store.dispatch('updateFriends', item)
- })
- })
-}
-
export default {
initIm,
connect,
setNotifyBadge,
- syncFriends,
- syncUserInfo,
...message
}
diff --git a/utils/im/listeners.js b/utils/im/listeners.js
new file mode 100644
index 0000000..e69de29
diff --git a/utils/im/message.js b/utils/im/message.js
index e9edbee..15dc586 100644
--- a/utils/im/message.js
+++ b/utils/im/message.js
@@ -1,8 +1,9 @@
import store from '@/store/index.js'
+
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
const getMessageList = (conversationType, targetId, timeStamp, count, isForward, callback) => {
- // 获取消息列表
+ // 获取消息列表 https://doc.rongcloud.cn/imserver/server/v1/message/objectname#objectName
const objectNames = [
'RC:TxtMsg',
'RC:VcMsg',
@@ -40,6 +41,21 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
)
}
+// 获取好友申请列表
+const getPendingList = (callback, total) => {
+ total = total || 100
+ RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
+ if (res.code === 0) {
+ const pendings = res.conversations.filter((item) => {
+ return item.objectName == RongIMLib.ObjectName.ContactNotification &&
+ item.latestMessage.operation === 'Request'
+ })
+
+ callback(pendings)
+ }
+ })
+}
+
/**
* 发送文本消息
* @param {number} conversationType 消息类型
@@ -47,17 +63,17 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
* @param {string} content 消息内容
* @param {function} callback 回调函数
*/
-const sentText = (conversationType, targetId, content, callback) => {
- console.log('发送');
+const sentText = (conversationType, targetId, content, user, callback) => {
const msg = {
conversationType: conversationType,
targetId: String(targetId),
content: {
objectName: 'RC:TxtMsg',
content: content,
- user: store.getters.sender
+ userInfo: user
}
}
+
RongIMLib.sendMessage(msg, ({
code,
messageId
@@ -65,9 +81,10 @@ const sentText = (conversationType, targetId, content, callback) => {
if (code === 0) {
callback(messageId)
} else {
+ console.log('发送失败', msg);
uni.showToast({
icon: 'none',
- title: '发送失败'
+ title: '发送失败' + code
})
}
})
@@ -81,14 +98,15 @@ const sentText = (conversationType, targetId, content, callback) => {
* @param {integer} time 录音时长
* @param {function} callback 录音时长
*/
-const sentVoice = (conversationType, targetId, voiceUrl, time, callback) => {
+const sentVoice = (conversationType, targetId, voiceUrl, time, user, callback) => {
const msg = {
conversationType: conversationType,
targetId: String(targetId),
content: {
objectName: 'RC:HQVCMsg',
local: 'file:///' + plus.io.convertLocalFileSystemURL(voiceUrl),
- duration: time
+ duration: time,
+ userInfo: user
}
}
RongIMLib.sendMediaMessage(msg, {
@@ -107,13 +125,14 @@ const sentVoice = (conversationType, targetId, voiceUrl, time, callback) => {
})
}
-const sentImage = (conversationType, targetId, imageUrl, callback) => {
+const sentImage = (conversationType, targetId, imageUrl, user, callback) => {
const msg = {
conversationType: conversationType,
targetId: String(targetId),
content: {
objectName: 'RC:ImgMsg',
- local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl)
+ local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl),
+ userInfo: user
}
}
RongIMLib.sendMediaMessage(msg, {
@@ -185,7 +204,8 @@ const sendFile = (conversationType, targetId, fileUrl, time, callback) => {
}
export default {
- getMessageList,
+ getMessageList,
+ getPendingList,
sentText,
sentVoice,
sentImage,
diff --git a/utils/im/models.js b/utils/im/models.js
index a36e1bd..a7c6ef0 100644
--- a/utils/im/models.js
+++ b/utils/im/models.js
@@ -2,21 +2,21 @@ import {
usqlite
} from '@/uni_modules/onemue-USQLite/js_sdk/usqlite.js'
-const friendModel = usqlite.model('friends', {
- userId: {
+const contactModel = usqlite.model('contacts', {
+ targetId: {
type: String,
primaryKey: true,
unique: true
},
name: String,
- address: String,
hash: {
type: String,
unique: true
},
- portraitUrl: String
-})
+ portraitUrl: String,
+ localAvatar: String
+})
export default {
- friendModel
+ contactModel
}
diff --git a/utils/im/视频呼入.json b/utils/im/视频呼入.json
deleted file mode 100644
index 97a4087..0000000
--- a/utils/im/视频呼入.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "type": "Engine:OnCallReceived",
- "module": "RongCloud-Call-RCUniCall",
- "data": {
- "endTime": 0,
- "users": [{
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420111350",
- "mediaType": 1,
- "userType": 0,
- "enableMicrophone": false
- }, {
- "userId": "10047",
- "enableCamera": false,
- "mediaType": 1,
- "userType": 0,
- "enableMicrophone": false
- }],
- "inviter": {
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420111350",
- "mediaType": 1,
- "userType": 0,
- "enableMicrophone": false
- },
- "caller": {
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420111350",
- "mediaType": 1,
- "userType": 0,
- "enableMicrophone": false
- },
- "connectedTime": 0,
- "extra": "",
- "startTime": 0,
- "mediaType": 1,
- "callId": "c28cb9d8-6581-474c-bfa5-9872a4824b65",
- "targetId": "10051",
- "callType": 0,
- "mine": {
- "userId": "10047",
- "enableCamera": false,
- "mediaType": 1,
- "userType": 0,
- "enableMicrophone": false
- }
- }
-}
diff --git a/utils/im/语音呼入.json b/utils/im/语音呼入.json
deleted file mode 100644
index 3c24ca0..0000000
--- a/utils/im/语音呼入.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "type": "Engine:OnCallReceived",
- "module": "RongCloud-Call-RCUniCall",
- "data": {
- "endTime": 0,
- "users": [{
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420068630",
- "mediaType": 0,
- "userType": 0,
- "enableMicrophone": false
- }, {
- "userId": "10047",
- "enableCamera": true,
- "mediaType": 0,
- "userType": 0,
- "enableMicrophone": false
- }],
- "inviter": {
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420068630",
- "mediaType": 0,
- "userType": 0,
- "enableMicrophone": false
- },
- "caller": {
- "userId": "10051",
- "enableCamera": false,
- "mediaId": "420068630",
- "mediaType": 0,
- "userType": 0,
- "enableMicrophone": false
- },
- "connectedTime": 0,
- "extra": "",
- "startTime": 0,
- "mediaType": 0,
- "callId": "1a1462b8-b63b-40a9-bf95-963e810ac49a",
- "targetId": "10051",
- "callType": 0,
- "mine": {
- "userId": "10047",
- "enableCamera": true,
- "mediaType": 0,
- "userType": 0,
- "enableMicrophone": false
- }
- }
-}