diff --git a/App.vue b/App.vue index c9578d3..8a45324 100644 --- a/App.vue +++ b/App.vue @@ -1,68 +1,74 @@ - - - diff --git a/apis/interfaces/im.js b/apis/interfaces/im.js new file mode 100644 index 0000000..e8fa10c --- /dev/null +++ b/apis/interfaces/im.js @@ -0,0 +1,20 @@ +import { + request +} from '../index' + +const getFriends = () => { + return request({ + url: 'im/friends', + }) +} + +const getUserInfo = async (targetId) => { + const [err, res] = await request({ + url: 'im/userInfo/' + targetId, + }) + return res +} + +export { + getFriends +} diff --git a/main.js b/main.js index f7bb7cf..b52960e 100644 --- a/main.js +++ b/main.js @@ -1,34 +1,33 @@ -/* - * @Description: - * @Author: Aimee·Zhang - * @Date: 2022-01-05 09:01:12 - * @LastEditors: Aimee·Zhang - * @LastEditTime: 2022-01-12 16:35:13 - */ -import App from './App' - -// #ifndef VUE3 -import Vue from 'vue' -import store from './store' -import uView from 'uview-ui'; -import { router, RouterMount } from 'router' -Vue.use(uView); -Vue.use(router) -Vue.config.productionTip = false -Vue.prototype.$store = store -App.mpType = 'app' -const app = new Vue({ - ...App -}) +/* + * @Description: + * @Author: Aimee·Zhang + * @Date: 2022-01-05 09:01:12 + * @LastEditors: Aimee·Zhang + * @LastEditTime: 2022-01-12 16:35:13 + */ +import App from './App' +import Vue from 'vue' +import store from './store' +import uView from 'uview-ui' +import filters from './utils/filters.js' +import { + router, + RouterMount +} from 'router' + +Object.keys(filters).forEach(key => { + Vue.filter(key, filters[key]) +}) + +Vue.use(uView); +Vue.use(router) + +Vue.config.productionTip = false +Vue.prototype.$store = store + +App.mpType = 'app' +const app = new Vue({ + store, + ...App +}) app.$mount() -// #endif - -// #ifdef VUE3 -import { createSSRApp } from 'vue' -export function createApp() { - const app = createSSRApp(App) - return { - app - } -} -// #endif \ No newline at end of file diff --git a/manifest.json b/manifest.json index 80ab562..86ea5fc 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,8 @@ "modules" : { "OAuth" : {}, "Payment" : {}, - "Share" : {} + "Share" : {}, + "SQLite" : {} }, /* 应用发布信息 */ "distribute" : { @@ -29,6 +30,7 @@ "permissions" : [ "", "", + "", "", "", "", @@ -36,12 +38,15 @@ "", "", "", + "", "", "", "", "", + "", "", "", + "", "" ], "autoSdkPermissions" : true @@ -63,8 +68,14 @@ "__platform__" : [ "android" ] } }, - "share" : {}, - "ad" : {} + "share" : { + "weixin" : { + "appid" : "wxb7e3c263a2a37ab9", + "UniversalLinks" : "" + } + }, + "ad" : {}, + "push" : {} }, "icons" : { "android" : { diff --git a/package.json b/package.json index 429be0a..ef47374 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,26 @@ -{ - "name": "zhhealth", - "version": "1.0.0", - "description": "ZH健康", - "main": "main.js", - "dependencies": { - "@rongcloud/imlib-uni": "^5.1.3-release.3", - "bitcore-lib": "^8.25.25", - "bitcore-mnemonic": "^8.25.25", - "moment": "^2.29.1", - "uni-read-pages": "^1.0.5", - "uni-simple-router": "^2.0.7", - "uview-ui": "^2.0.19", - "vuex": "^3.6.2" - }, - "devDependencies": {}, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "https://git.yuzhankeji.cn/TmOct5/ZhHealth.git" - }, - "author": "唐明明", - "license": "ISC" +{ + "name": "zhhealth", + "version": "1.0.0", + "description": "ZH健康", + "main": "main.js", + "dependencies": { + "@rongcloud/imlib-uni": "^5.1.3-release.3", + "bitcore-lib": "^8.25.25", + "bitcore-mnemonic": "^8.25.25", + "moment": "^2.29.1", + "uni-read-pages": "^1.0.5", + "uni-simple-router": "^2.0.7", + "uview-ui": "^2.0.19", + "vuex": "^3.6.2" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://git.yuzhankeji.cn/TmOct5/ZhHealth.git" + }, + "author": "唐明明", + "license": "ISC" } diff --git a/pages.json b/pages.json index b2c6759..8b8bd93 100644 --- a/pages.json +++ b/pages.json @@ -1,541 +1,557 @@ { - "pages": [{ - "path": "pages/index/index", - "name": "Index", - "style": { - "navigationBarTitleText": "发现", - "navigationStyle": "custom" - } - }, - { - "path": "pages/index/guide", - "name": "indexGuide", - "style": { - "navigationBarTitleText": "", - "navigationStyle": "custom" - } - }, - { - "path": "pages/index/search", - "name": "indexSearch", - "style": { - "navigationBarTitleText": "", - "navigationStyle": "custom" - } - }, - { - "path": "pages/record/index", - "name": "Record", - "style": { - "navigationBarTitleText": "记录", - "navigationStyle": "custom" - } - }, - { - "path": "pages/record/drink", - "name": "Drink", - "style": { - "navigationBarTitleText": "记录喝水", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/record/weight", - "name": "Weight", - "style": { - "navigationBarTitleText": "记录体重", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/record/foods", - "name": "RecordFoods", - "style": { - "navigationBarTitleText": "食物记录", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/record/addFoods", - "name": "AddFoods", - "style": { - "navigationBarTitleText": "添加食物", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/evaluation/list", - "name": "EvaluationList", - "style": { - "navigationBarTitleText": "评测列表", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/evaluation/index", - "name": "Evaluation", - "style": { - "navigationBarTitleText": "评测", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/evaluation/introduce", - "name": "EvaluationIntroduce", - "style": { - "navigationBarTitleText": "评测题目", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/evaluation/result", - "name": "EvaluationResult", - "style": { - "navigationBarTitleText": "评测结果", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/vip/foods", - "name": "VipFoods", - "style": { - "navigationBarTitleText": "会员专享食谱", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/vip/nutritionHelper", - "name": "NutritionHelper", - "style": { - "navigationBarTitleText": "营养小助手", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/essentialInfo/index", - "name": "EssentialInfo", - "style": { - "navigationBarTitleText": "完善信息", - "navigationBarBackgroundColor": "#34CE98", - "navigationBarTextStyle": "white" - } - }, - { - "path": "pages/store/index", - "name": "Store", - "style": { - "navigationBarTitleText": "健康生活", - "enablePullDownRefresh": true, - "app-plus": { - "titleNView": { - "backgroundColor": "#FFFFFF", - "buttons": [{ - "float": "right", - "text": "\ue603", - "fontSrc": "/static/iconfont.ttf", - "color": "#000", - "fontSize": "20px" - }] - } - } - } - }, - { - "path": "pages/user/index", - "name": "User", - "style": { - "navigationBarTitleText": "我的", - "navigationStyle": "custom" - } - }, - { - "path": "pages/auth/auth", - "name": "Auth", - "style": { - "navigationBarTitleText": "登录", - "navigationStyle": "custom" - } - }, - { - "path": "pages/store/goods", - "name": "StoreGoods", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "详情", - "app-plus": { - "titleNView": { - "backgroundColor": "#FFFFFF", - "type": "transparent" - } - } - } - }, - { - "path": "pages/store/buy", - "name": "StoreBuy", - "style": { - "navigationBarTitleText": "确认订单", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/order/index", - "name": "Order", - "style": { - "navigationBarTitleText": "订单", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/order/details", - "name": "OrderDetails", - "style": { - "navigationBarTitleText": "订单详情", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/address/index", - "name": "Address", - "style": { - "navigationBarTitleText": "收货地址" - } - }, - { - "path": "pages/address/edit", - "name": "AddressEdit", - "style": { - "navigationBarTitleText": "编辑", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/pay/pay", - "name": "Pay", - "style": { - "navigationBarTitleText": "收银台", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/store/list", - "name": "StoreList", - "style": { - "navigationBarTitleText": "商品", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": true - } - }, - { - "path": "pages/store/meals", - "name": "StoreMeals", - "style": { - "navigationBarTitleText": "套餐", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": true - } - }, - { - "path": "pages/sign/index", - "name": "signIndex", - "style": { - "navigationBarTitleText": "每日签到", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/menu/index", - "name": "menuIndex", - "style": { - "navigationBarTitleText": "食谱推荐", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/menu/classify", - "name": "menuClassify", - "style": { - "navigationBarTitleText": "食谱推荐", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/menu/details", - "name": "menuDetails", - "style": { - "navigationBarTitleText": "食谱详情", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/topic/index", - "name": "topicIndex", - "style": { - "navigationBarTitleText": "话题广场", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/topic/details", - "name": "topicDetails", - "style": { - "navigationStyle": "custom", - "navigationBarBackgroundColor": "#FFFFFF", - "app-plus": { - "titleNView": { - "type": "transparent" - } - } - } - }, - { - "path": "pages/ranking/index", - "name": "rankingIndex", - "style": { - "navigationBarTitleText": "食物排行", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/ranking/list", - "name": "rankingList", - "style": { - "navigationBarTitleText": "食物榜单", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/ranking/details", - "name": "rankingDetails", - "style": { - "navigationBarTitleText": "食物详情", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/notice/index", - "name": "noticeIndex", - "style": { - "navigationBarTitleText": "消息", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/notice/list", - "name": "noticeList", - "style": { - "navigationBarTitleText": "消息", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/notice/details", - "name": "noticeDetails", - "style": { - "navigationBarTitleText": "消息", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/im/index", - "name": "IM", - "style": { - "navigationBarTitleText": "聊聊", - "navigationBarBackgroundColor": "#FFFFFF", - "app-plus": { - "titleNView": { - "buttons": [{ - "float": "right", - "text": "\ue605", - "fontSrc": "/static/iconfont.ttf", - "color": "#000", - "fontSize": "20px" - }, - { - "float": "left", - "text": "\ue606", - "fontSrc": "/static/iconfont.ttf", - "color": "#000", - "fontSize": "20px" - } - ] - } - } - } - }, - { - "path": "pages/im/chum", - "name": "ImChum", - "style": { - "navigationBarTitleText": "好友", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/add", - "name": "WalletAdd", - "style": { - "navigationBarTitleText": "创建钱包", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/create", - "name": "WalletCreate", - "style": { - "navigationBarTitleText": "设置密码", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/mnemonic", - "name": "WalletMnemonic", - "style": { - "navigationBarTitleText": "导出助记词", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/validation", - "name": "WalletValidation", - "style": { - "navigationBarTitleText": "验证助记词", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/property", - "name": "WalletProperty", - "style": { - "navigationBarTitleText": "ZH钱包", - "navigationBarTextStyle": "white", - "app-plus": { - "titleNView": { - "backgroundImage": "linear-gradient(to right, #34ce98, #22aa98)", - "type": "transparent", - "buttons": [{ - "float": "right", - "text": "\ue607", - "fontSrc": "/static/iconfont.ttf", - "color": "#FFF", - "fontSize": "20px", - "background": "rgba(0,0,0,0)" - }], - "backButton": { - "background": "rgba(0,0,0,0)" - } - } - } - } - }, - { - "path": "pages/service/index", - "name": "serviceIndex", - "style": { - "navigationBarTitleText": "", - "navigationStyle": "custom" - } - }, - { - "path": "pages/service/details", - "name": "serviceDetails", - "style": { - "navigationBarTitleText": "" - } - }, - { - "path": "pages/wallet/privatekey", - "name": "WalletPrivatekey", - "style": { - "navigationBarTitleText": "钱包私钥", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/wallet/resetPassword", - "name": "ResetPassword", - "style": { - "navigationBarTitleText": "修改钱包密码", - "navigationBarBackgroundColor": "#FFFFFF", - "enablePullDownRefresh": false - } - }, - { - "path": "pages/store/search", - "name": "StoreSearch", - "style": { - "navigationBarTitleText": "搜索", - "navigationBarBackgroundColor": "#FFFFFF" - } - }, - { - "path": "pages/user/files", - "name": "UserFiles", - "style": { - "navigationBarTitleText": "健康档案", - "navigationBarBackgroundColor": "#FFFFFF" - } - } - ], - "tabBar": { - "borderStyle": "white", - "selectedColor": "#34CE98", - "list": [{ - "iconPath": "static/tabBar/tabBar_00.png", - "selectedIconPath": "static/tabBar/tabBar_show_00.png", - "pagePath": "pages/index/index", - "text": "健康" - }, - { - "iconPath": "static/tabBar/tabBar_02.png", - "selectedIconPath": "static/tabBar/tabBar_show_02.png", - "pagePath": "pages/store/index", - "text": "好物" - }, - { - "iconPath": "static/tabBar/tabBar_01.png", - "selectedIconPath": "static/tabBar/tabBar_show_01.png", - "pagePath": "pages/service/index", - "text": "生活" - }, - { - "iconPath": "static/tabBar/tabBar_04.png", - "selectedIconPath": "static/tabBar/tabBar_show_04.png", - "pagePath": "pages/im/index", - "text": "聊聊" - }, - { - "iconPath": "static/tabBar/tabBar_03.png", - "selectedIconPath": "static/tabBar/tabBar_show_03.png", - "pagePath": "pages/user/index", - "text": "我的" - } - ] - }, - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "ZH健康", - "navigationBarBackgroundColor": "#F3F6FB", - "backgroundColorTop": "#F3F6FB", - "backgroundColorBottom": "#F3F6FB" - }, - "easycom": { - "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue" - } + "pages": [{ + "path": "pages/index/index", + "name": "Index", + "style": { + "navigationBarTitleText": "发现", + "navigationStyle": "custom" + } + }, + { + "path": "pages/index/guide", + "name": "indexGuide", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "pages/index/search", + "name": "indexSearch", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "pages/record/index", + "name": "Record", + "style": { + "navigationBarTitleText": "记录", + "navigationStyle": "custom" + } + }, + { + "path": "pages/record/drink", + "name": "Drink", + "style": { + "navigationBarTitleText": "记录喝水", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/record/weight", + "name": "Weight", + "style": { + "navigationBarTitleText": "记录体重", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/record/foods", + "name": "RecordFoods", + "style": { + "navigationBarTitleText": "食物记录", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/record/addFoods", + "name": "AddFoods", + "style": { + "navigationBarTitleText": "添加食物", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/evaluation/list", + "name": "EvaluationList", + "style": { + "navigationBarTitleText": "评测列表", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/evaluation/index", + "name": "Evaluation", + "style": { + "navigationBarTitleText": "评测", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/evaluation/introduce", + "name": "EvaluationIntroduce", + "style": { + "navigationBarTitleText": "评测题目", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/evaluation/result", + "name": "EvaluationResult", + "style": { + "navigationBarTitleText": "评测结果", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/vip/foods", + "name": "VipFoods", + "style": { + "navigationBarTitleText": "会员专享食谱", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/vip/nutritionHelper", + "name": "NutritionHelper", + "style": { + "navigationBarTitleText": "营养小助手", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/essentialInfo/index", + "name": "EssentialInfo", + "style": { + "navigationBarTitleText": "完善信息", + "navigationBarBackgroundColor": "#34CE98", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/store/index", + "name": "Store", + "style": { + "navigationBarTitleText": "健康生活", + "enablePullDownRefresh": true, + "app-plus": { + "titleNView": { + "backgroundColor": "#FFFFFF", + "buttons": [{ + "float": "right", + "text": "\ue603", + "fontSrc": "/static/iconfont.ttf", + "color": "#000", + "fontSize": "20px" + }] + } + } + } + }, + { + "path": "pages/user/index", + "name": "User", + "style": { + "navigationBarTitleText": "我的", + "navigationStyle": "custom" + } + }, + { + "path": "pages/auth/auth", + "name": "Auth", + "style": { + "navigationBarTitleText": "登录", + "navigationStyle": "custom" + } + }, + { + "path": "pages/store/goods", + "name": "StoreGoods", + "style": { + "navigationStyle": "custom", + "navigationBarTitleText": "详情", + "app-plus": { + "titleNView": { + "backgroundColor": "#FFFFFF", + "type": "transparent" + } + } + } + }, + { + "path": "pages/store/buy", + "name": "StoreBuy", + "style": { + "navigationBarTitleText": "确认订单", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/order/index", + "name": "Order", + "style": { + "navigationBarTitleText": "订单", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/order/details", + "name": "OrderDetails", + "style": { + "navigationBarTitleText": "订单详情", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/address/index", + "name": "Address", + "style": { + "navigationBarTitleText": "收货地址" + } + }, + { + "path": "pages/address/edit", + "name": "AddressEdit", + "style": { + "navigationBarTitleText": "编辑", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/pay/pay", + "name": "Pay", + "style": { + "navigationBarTitleText": "收银台", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/store/list", + "name": "StoreList", + "style": { + "navigationBarTitleText": "商品", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/store/meals", + "name": "StoreMeals", + "style": { + "navigationBarTitleText": "套餐", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": true + } + }, + { + "path": "pages/sign/index", + "name": "signIndex", + "style": { + "navigationBarTitleText": "每日签到", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/menu/index", + "name": "menuIndex", + "style": { + "navigationBarTitleText": "食谱推荐", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/menu/classify", + "name": "menuClassify", + "style": { + "navigationBarTitleText": "食谱推荐", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/menu/details", + "name": "menuDetails", + "style": { + "navigationBarTitleText": "食谱详情", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/topic/index", + "name": "topicIndex", + "style": { + "navigationBarTitleText": "话题广场", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/topic/details", + "name": "topicDetails", + "style": { + "navigationStyle": "custom", + "navigationBarBackgroundColor": "#FFFFFF", + "app-plus": { + "titleNView": { + "type": "transparent" + } + } + } + }, + { + "path": "pages/ranking/index", + "name": "rankingIndex", + "style": { + "navigationBarTitleText": "食物排行", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/ranking/list", + "name": "rankingList", + "style": { + "navigationBarTitleText": "食物榜单", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/ranking/details", + "name": "rankingDetails", + "style": { + "navigationBarTitleText": "食物详情", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/notice/index", + "name": "noticeIndex", + "style": { + "navigationBarTitleText": "消息", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/notice/list", + "name": "noticeList", + "style": { + "navigationBarTitleText": "消息", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/notice/details", + "name": "noticeDetails", + "style": { + "navigationBarTitleText": "消息", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/im/index", + "name": "IM", + "style": { + "navigationBarTitleText": "聊聊", + "navigationBarBackgroundColor": "#FFFFFF", + "app-plus": { + "titleNView": { + "buttons": [{ + "float": "right", + "text": "\ue605", + "fontSrc": "/static/iconfont.ttf", + "color": "#000", + "fontSize": "20px" + }, + { + "float": "left", + "text": "\ue606", + "fontSrc": "/static/iconfont.ttf", + "color": "#000", + "fontSize": "20px" + } + ] + } + } + } + }, + { + "path": "pages/im/detail", + "style": { + "navigationBarTitleText": "", + "app-plus": { + "titleNView": { + "type": "default", + "buttons": [{ + "float": "right", + "fontSrc": "/static/uniicons.ttf", + "text": "\ue64d" + }] + } + } + } + }, + { + "path": "pages/im/chum", + "name": "ImChum", + "style": { + "navigationBarTitleText": "好友", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/add", + "name": "WalletAdd", + "style": { + "navigationBarTitleText": "创建钱包", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/create", + "name": "WalletCreate", + "style": { + "navigationBarTitleText": "设置密码", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/mnemonic", + "name": "WalletMnemonic", + "style": { + "navigationBarTitleText": "导出助记词", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/validation", + "name": "WalletValidation", + "style": { + "navigationBarTitleText": "验证助记词", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/property", + "name": "WalletProperty", + "style": { + "navigationBarTitleText": "ZH钱包", + "navigationBarTextStyle": "white", + "app-plus": { + "titleNView": { + "backgroundImage": "linear-gradient(to right, #34ce98, #22aa98)", + "type": "transparent", + "buttons": [{ + "float": "right", + "text": "\ue607", + "fontSrc": "/static/iconfont.ttf", + "color": "#FFF", + "fontSize": "20px", + "background": "rgba(0,0,0,0)" + }], + "backButton": { + "background": "rgba(0,0,0,0)" + } + } + } + } + }, + { + "path": "pages/service/index", + "name": "serviceIndex", + "style": { + "navigationBarTitleText": "", + "navigationStyle": "custom" + } + }, + { + "path": "pages/service/details", + "name": "serviceDetails", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "pages/wallet/privatekey", + "name": "WalletPrivatekey", + "style": { + "navigationBarTitleText": "钱包私钥", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/wallet/resetPassword", + "name": "ResetPassword", + "style": { + "navigationBarTitleText": "修改钱包密码", + "navigationBarBackgroundColor": "#FFFFFF", + "enablePullDownRefresh": false + } + }, + { + "path": "pages/store/search", + "name": "StoreSearch", + "style": { + "navigationBarTitleText": "搜索", + "navigationBarBackgroundColor": "#FFFFFF" + } + }, + { + "path": "pages/user/files", + "name": "UserFiles", + "style": { + "navigationBarTitleText": "健康档案", + "navigationBarBackgroundColor": "#FFFFFF" + } + } + ], + "tabBar": { + "borderStyle": "white", + "selectedColor": "#34CE98", + "list": [{ + "iconPath": "static/tabBar/tabBar_00.png", + "selectedIconPath": "static/tabBar/tabBar_show_00.png", + "pagePath": "pages/index/index", + "text": "健康" + }, + { + "iconPath": "static/tabBar/tabBar_02.png", + "selectedIconPath": "static/tabBar/tabBar_show_02.png", + "pagePath": "pages/store/index", + "text": "好物" + }, + { + "iconPath": "static/tabBar/tabBar_01.png", + "selectedIconPath": "static/tabBar/tabBar_show_01.png", + "pagePath": "pages/service/index", + "text": "生活" + }, + { + "iconPath": "static/tabBar/tabBar_04.png", + "selectedIconPath": "static/tabBar/tabBar_show_04.png", + "pagePath": "pages/im/index", + "text": "聊聊" + }, + { + "iconPath": "static/tabBar/tabBar_03.png", + "selectedIconPath": "static/tabBar/tabBar_show_03.png", + "pagePath": "pages/user/index", + "text": "我的" + } + ] + }, + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "ZH健康", + "navigationBarBackgroundColor": "#F3F6FB", + "backgroundColorTop": "#F3F6FB", + "backgroundColorBottom": "#F3F6FB" + }, + "easycom": { + "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue" + } } diff --git a/pages/im/detail.vue b/pages/im/detail.vue new file mode 100644 index 0000000..7376366 --- /dev/null +++ b/pages/im/detail.vue @@ -0,0 +1,276 @@ + + + + + + + + + + {{ item.content.content }} + + + 未读 + + + + + + + + {{ item.sentTime|timeCustomCN }} + + + + + + + + + + diff --git a/pages/im/index.vue b/pages/im/index.vue index 0014616..9009d66 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -1,188 +1,131 @@ - - - - - - - 开启聊天 - - - - - - - - - - - - - - - - {{item.name}} - {{item.time}} - - {{item.message}} - - - - - - - - - - diff --git a/public/im.js b/public/im.js deleted file mode 100644 index 8304f70..0000000 --- a/public/im.js +++ /dev/null @@ -1,37 +0,0 @@ - -/** - * Web唐明明 - * 匆匆数载恍如梦,岁月迢迢华发增。 - * 碌碌无为枉半生,一朝惊醒万事空。 - * moduleName: 融云im - */ - - -import { - init, - connect, - addConnectionStatusListener, - addReceiveMessageListener -} from '@rongcloud/imlib-uni' - -export default { - // 初始化 - imInit(){ - init('lmxuhwaglu76d') - connect('token', res => { - console.log(res) - }) - this.imMonitor() - }, - // 监听器 - imMonitor(){ - // 添加连接状态监听函数 - addConnectionStatusListener(res => { - console.log(res.data) - }) - // 添加消息监听函数 - addReceiveMessageListener(res => { - console.log(res) - }) - } -} diff --git a/store/index.js b/store/index.js index fadb080..b30a2fe 100644 --- a/store/index.js +++ b/store/index.js @@ -1,42 +1,45 @@ - -/** - * Web唐明明 - * 匆匆数载恍如梦,岁月迢迢华发增。 - * 碌碌无为枉半生,一朝惊醒万事空。 - */ - -import Vue from 'vue' -import Vuex from 'vuex' - -Vue.use(Vuex) - -export default new Vuex.Store({ - state: { - token : uni.getStorageSync('token') || '', - address : {}, - refresh : 0 - }, - getters: { - getToken: state => { - return state.token - }, - getAddress: state => { - return state.address - }, - getRefresh: state => { - return state.refresh - } - }, - mutations: { - setToken(state, tokenString) { - state.token = tokenString - uni.setStorageSync('token', tokenString) - }, - setAddress(state, value) { - state.address = value - }, - setRefresh(state, value) { - state.refresh = value - } - } +/** + * Web唐明明 + * 匆匆数载恍如梦,岁月迢迢华发增。 + * 碌碌无为枉半生,一朝惊醒万事空。 + */ + +import Vue from 'vue' +import Vuex from 'vuex' +import im from './modules/im.js' + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + token: uni.getStorageSync('token') || '', + address: {}, + refresh: 0 + }, + getters: { + getToken: state => { + return state.token + }, + getAddress: state => { + return state.address + }, + getRefresh: state => { + return state.refresh + } + }, + mutations: { + setToken(state, tokenString) { + state.token = tokenString + uni.setStorageSync('token', tokenString) + }, + setAddress(state, value) { + state.address = value + }, + setRefresh(state, value) { + state.refresh = value + } + }, + modules: { + im + } }) diff --git a/store/modules/im.js b/store/modules/im.js new file mode 100644 index 0000000..afea9d0 --- /dev/null +++ b/store/modules/im.js @@ -0,0 +1,57 @@ +import { + getUserInfo +} from "@/apis/interfaces/im.js" + +export default { + state: { + newMsg: {}, + friends: [], + sender: {} + }, + getters: { + newMessage(state) { + return state.newMsg + }, + friends(state) { + return state.friends + }, + userInfo: (state) => (targetId) => { + if (state.friends.filter((item) => item.userId == targetId)[0]) { + return state.friends.filter((item) => String(item.userId) == targetId)[0] + } else { + return getUserInfo() + } + }, + sender(state) { + return state.sender + } + }, + mutations: { + newMessage(state, msg) { + Vue.set(state, 'newMsg', msg) + }, + updateFriends(state, list) { + state.friends = list + }, + SET_state_sender(state, userInfo) { + state.sender = userInfo + } + }, + actions: { + newMessage({ + commit + }, msg) { + commit('newMessage', msg) + }, + updateFriends({ + commit + }, list) { + commit('updateFriends', list) + }, + setSenderInfo({ + commit + }, userInfo) { + commit('SET_state_sender', userInfo) + } + } +} diff --git a/utils/filters.js b/utils/filters.js new file mode 100644 index 0000000..e4a983c --- /dev/null +++ b/utils/filters.js @@ -0,0 +1,89 @@ +import store from '@/store/index.js' + +/* + * 截断hash + */ +const filterHash = (str, num) => { + let length = num || 16 + return String(str).substr(0, length) + '...' + String(str).substr(-4) +} + +const timeCustomCN = (val) => { + val = timeStamp(val, 'Y-m-d H:i:s') + let currentDate = new Date(); + let currentD = currentDate.getDate(); + let currentYear = currentDate.getFullYear(); + let currentMonth = currentDate.getMonth() + 1; + let date = val.substring(0, 19); + date = date.replace(/-/g, '/'); + let valDate = new Date(date); + let valD = valDate.getDate(); + let valYear = valDate.getFullYear(); + let valMonth = valDate.getMonth() + 1; + // 判断是否属于今天,计算时分 + let difftime = (currentDate - valDate) / 1000; + if (currentYear === valYear && currentMonth === valMonth && currentD === valD) { + let minute = parseInt(difftime % 3600 / 60); + if (minute <= 60) { + return minute === 0 ? '刚刚' : minute + '分钟前'; + } else { + return (minute * 60).toFixed(0) + '小时前'; + } + } else { + // 计算天 + if (currentYear === valYear && currentMonth === valMonth && currentD - 1 === valD) { + return '昨天'; + } else { + let days = Math.abs(currentDate.getTime() - valDate.getTime()) / (1000 * 60 * 60 * 24); + return Math.ceil(days) + '天前'; + } + + } +} + +const timeStamp = (timestamp, formats) => { + /* + ** 时间戳转换成指定格式日期 + ** eg. + ** dateFormat(11111111111111, 'Y年m月d日 H时i分') + ** → "2322年02月06日 03时45分" + */ + // formats格式包括 + // 1. Y-m-d + // 2. Y-m-d H:i:s + // 3. Y年m月d日 + // 4. Y年m月d日 H时i分 + formats = formats || 'Y-m-d'; + + var zero = function(value) { + if (value < 10) { + return '0' + value; + } + return value; + }; + var myDate = timestamp ? new Date(timestamp) : new Date(); + + var year = myDate.getFullYear(); + var month = zero(myDate.getMonth() + 1); + var day = zero(myDate.getDate()); + + var hour = zero(myDate.getHours()); + var minite = zero(myDate.getMinutes()); + var second = zero(myDate.getSeconds()); + + return formats.replace(/Y|m|d|H|i|s/ig, function(matches) { + return ({ + Y: year, + m: month, + d: day, + H: hour, + i: minite, + s: second + })[matches]; + }); +} + +export default { + filterHash, + timeCustomCN +} diff --git a/utils/im/api.js b/utils/im/api.js new file mode 100644 index 0000000..259fdfb --- /dev/null +++ b/utils/im/api.js @@ -0,0 +1,44 @@ +const api_url = 'http://api.zh.shangkelian.cn/api/im' + +/** + * 获取币种余额 + */ +export const getToken = (uid) => { + return new Promise((resolve, reject) => { + uni.request({ + method: 'GET', + url: api_url + '/token/' + uid, + success: (res) => { + if (res.statusCode === 200) { + resolve(res.data.data) + } else { + reject(res.message) + } + } + }) + }) +} + +/** + * 获取好友列表 + */ +export const getFriends = () => { + return new Promise((resolve, reject) => { + uni.request({ + method: 'GET', + url: api_url + '/friends', + success: (res) => { + if (res.statusCode === 200) { + resolve(res.data.data) + } else { + reject(res.message) + } + } + }) + }) +} + +export default { + getToken, + getFriends +} diff --git a/utils/im/index.js b/utils/im/index.js new file mode 100644 index 0000000..adc615e --- /dev/null +++ b/utils/im/index.js @@ -0,0 +1,142 @@ +import * as RongIMLib from '@rongcloud/imlib-uni' +import store from '@/store/index.js' +import { + getFriends +} from '@/apis/interfaces/im.js' + +const initIm = (KEY) => { + RongIMLib.init(KEY) + addListeners() +} + +const setNotifyBadge = (count) => { + // 获取未读消息数量 + RongIMLib.getTotalUnreadCount(({ + code, + count + }) => { + if (code === 0) { + if (count > 0) { + uni.setTabBarBadge({ + index: 2, + text: String(count > 99 ? '99+' : count) + }) + } else { + uni.removeTabBarBadge({ + index: 2 + }) + } + } + }) +} + +/** + * 连接IM服务 + * @param {string} token token + * @param {object} userInfo {userId: string, name: string, portraitUrl: string} + */ +const connect = (token, userInfo) => { + RongIMLib.connect(token, res => { + console.log('连接结果', res); + }) + + store.dispatch('setSenderInfo', userInfo) + + setNotifyBadge() +} + +const addListeners = () => { + // 添加连接状态监听函数 + RongIMLib.addConnectionStatusListener((res) => { + console.log('连接状态监', res.data.status); + }) + // 添加消息监听函数 + RongIMLib.addReceiveMessageListener((res) => { + console.log('收到消息', res.data.message); + newMessage(res.data.message) + }) +} + +// 维护消息列表 +const newMessage = (msg) => { + RongIMLib.getConversationNotificationStatus(msg.conversationType, msg.targetId, ({ + code, + status + }) => { + if (code === 0) { + if (status) { + triTone() + } + } + }); + + setNotifyBadge() + + store.dispatch('newMessage', msg) +} + +// 播放状态 +let tipState = false + +const triTone = () => { + if (tipState == false) { + const innerAudioContext = uni.createInnerAudioContext() + innerAudioContext.autoplay = true + innerAudioContext.src = '/static/tri-tone.mp3' + innerAudioContext.onPlay(() => { + tipState = true + }) + innerAudioContext.onEnded(() => { + tipState = false + }) + } +} + +/** + * 发送消息 + * @param {number} conversationType 消息类型 + * @param {string} targetId 会话id + * @param {string} content 消息内容 + * @param {function} callback 回调函数 + */ +const sendMsg = (conversationType, targetId, content, callback) => { + const msg = { + conversationType: conversationType, + targetId: String(targetId), + content: { + objectName: 'RC:TxtMsg', + content: content, + user: store.getters.sender + } + } + RongIMLib.sendMessage(msg, ({ + code, + messageId + }) => { + if (code === 0) { + callback(messageId) + } else { + uni.showToast({ + icon: 'none', + title: '发送失败' + }) + } + }) +} + +/** + * 同步好友信息,保存头像地址等 + */ +const syncFriends = () => { + getFriends().then(res => { + store.dispatch('updateFriends', res) + }) +} + +export default { + initIm, + connect, + sendMsg, + setNotifyBadge, + syncFriends +}