diff --git a/package-lock.json b/package-lock.json index 79fad23..cf3748b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4841,6 +4841,11 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "nim-web-sdk-ng": { + "version": "10.4.0", + "resolved": "https://registry.npmmirror.com/nim-web-sdk-ng/-/nim-web-sdk-ng-10.4.0.tgz", + "integrity": "sha512-eJCIE7/VlnqLDZb81wF8NDvep9WKfHeL7PH8OeFn7AmN2G/nFGuNkl6tcGEw635U6mitLwCV0CBdQ6tSF16mEA==" + }, "node-releases": { "version": "2.0.10", "resolved": "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.10.tgz", diff --git a/src/app.wpy b/src/app.wpy index 56554a3..2732c23 100644 --- a/src/app.wpy +++ b/src/app.wpy @@ -14,6 +14,9 @@ import wepy from '@wepy/core' import vuex from '@wepy/x' import promisify from '@wepy/use-promisify' +import { wx_login } from './utils/util' +import { IM } from './utils/im' +import {service} from './config' wepy.use(promisify) wepy.use(vuex) @@ -33,6 +36,7 @@ wepy.app({ navRight: 0, // 胶囊距右方间距(方保持左、右间距一致) navTop: 0, // 胶囊距顶部间距 navHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致) + windowHeight: 0, userInfo: null, uploadData: null, nim: null, @@ -42,6 +46,7 @@ wepy.app({ onLaunch() { let vm = this + vm.appLogin() wx.getSystemInfo({ success: res => { vm.$options.globalData.bottomHeight = res.screenHeight - res.safeArea.bottom @@ -67,6 +72,7 @@ wepy.app({ vm.$options.globalData.navRight = systemInfo.screenWidth - menuButtonInfo.right vm.$options.globalData.navTop = menuButtonInfo.top vm.$options.globalData.navHeight = menuButtonInfo.height + vm.$options.globalData.windowHeight = systemInfo.windowHeight - vm.$options.globalData.navBarHeight }, onShow(options) { @@ -91,13 +97,36 @@ wepy.app({ onHide() {}, - methods: {} + methods: { + appLogin() { + let vm = this + wx_login().then((e) => { + wx.hideLoading() + let {accid, token} = e.data.user.wyy_user + vm.$options.globalData.nim = IM(accid, token) + }).catch((msg) => { + wx.showModal({ // 使用模态框提示用户进行操作 + title: '温馨提示:', + content: `${msg}`, + showCancel: false, + success: function (res) { + if (res.confirm) { + wx.navigateBack({ + delta: 1 + }) + } + } + }) + }) + } + } }) { pages: [ 'pages/tabBar/welcome', +'pages/tabBar/dynamic', 'pages/tabBar/home', 'pages/tabBar/news', 'pages/tabBar/user', @@ -151,18 +180,23 @@ borderStyle: 'black', list: [ { pagePath: 'pages/tabBar/home', -iconPath: './images/tabbar/inactiveHome.png', -selectedIconPath: './images/tabbar/activeHome.png', -text: '健康' +selectedIconPath: './images/tabbar/homeActive.png', +iconPath: './images/tabbar/home.png', +text: '推荐' +}, { +pagePath: 'pages/tabBar/dynamic', +selectedIconPath: './images/tabbar/attentionActive.png', +iconPath: './images/tabbar/attention.png', +text: '发现' }, { pagePath: 'pages/tabBar/news', -iconPath: './images/tabbar/inactiveServe.png', -selectedIconPath: './images/tabbar/activeServe.png', -text: '商城' +selectedIconPath: './images/tabbar/messageActive.png', +iconPath: './images/tabbar/message.png', +text: '消息' }, { pagePath: 'pages/tabBar/user', -iconPath: './images/tabbar/inactiveMy.png', -selectedIconPath: './images/tabbar/activeMy.png', +selectedIconPath: './images/tabbar/myActive.png', +iconPath: './images/tabbar/my.png', text: '我的' }] }, @@ -170,10 +204,6 @@ useExtendedLib: { 'weui': true }, plugins: { -"QNBleApi": { -"version": "4.7.1", -"provider": "wx2a4ca48ed5e96748" -}, "FL-plugin": { "version": "0.0.3", "provider": "wxc41491431733671e" diff --git a/src/images/tabbar/activeHome.png b/src/images/tabbar/activeHome.png deleted file mode 100644 index ac3ff46..0000000 Binary files a/src/images/tabbar/activeHome.png and /dev/null differ diff --git a/src/images/tabbar/activeMy.png b/src/images/tabbar/activeMy.png deleted file mode 100644 index d66e968..0000000 Binary files a/src/images/tabbar/activeMy.png and /dev/null differ diff --git a/src/images/tabbar/activeServe.png b/src/images/tabbar/activeServe.png deleted file mode 100644 index 414406b..0000000 Binary files a/src/images/tabbar/activeServe.png and /dev/null differ diff --git a/src/images/tabbar/attention.png b/src/images/tabbar/attention.png new file mode 100644 index 0000000..5d17c8b Binary files /dev/null and b/src/images/tabbar/attention.png differ diff --git a/src/images/tabbar/attentionActive.png b/src/images/tabbar/attentionActive.png new file mode 100644 index 0000000..6d4a260 Binary files /dev/null and b/src/images/tabbar/attentionActive.png differ diff --git a/src/images/tabbar/home.png b/src/images/tabbar/home.png new file mode 100644 index 0000000..84c4acc Binary files /dev/null and b/src/images/tabbar/home.png differ diff --git a/src/images/tabbar/homeActive.png b/src/images/tabbar/homeActive.png new file mode 100644 index 0000000..4776808 Binary files /dev/null and b/src/images/tabbar/homeActive.png differ diff --git a/src/images/tabbar/inactiveHome.png b/src/images/tabbar/inactiveHome.png deleted file mode 100644 index 91acdbd..0000000 Binary files a/src/images/tabbar/inactiveHome.png and /dev/null differ diff --git a/src/images/tabbar/inactiveMy.png b/src/images/tabbar/inactiveMy.png deleted file mode 100644 index 9378fce..0000000 Binary files a/src/images/tabbar/inactiveMy.png and /dev/null differ diff --git a/src/images/tabbar/inactiveServe.png b/src/images/tabbar/inactiveServe.png deleted file mode 100644 index 8c2146f..0000000 Binary files a/src/images/tabbar/inactiveServe.png and /dev/null differ diff --git a/src/images/tabbar/mapIcon.png b/src/images/tabbar/mapIcon.png new file mode 100644 index 0000000..5fad020 Binary files /dev/null and b/src/images/tabbar/mapIcon.png differ diff --git a/src/images/tabbar/mapIconActive.png b/src/images/tabbar/mapIconActive.png new file mode 100644 index 0000000..024802d Binary files /dev/null and b/src/images/tabbar/mapIconActive.png differ diff --git a/src/images/tabbar/message.png b/src/images/tabbar/message.png new file mode 100644 index 0000000..48af13e Binary files /dev/null and b/src/images/tabbar/message.png differ diff --git a/src/images/tabbar/messageActive.png b/src/images/tabbar/messageActive.png new file mode 100644 index 0000000..80ecb73 Binary files /dev/null and b/src/images/tabbar/messageActive.png differ diff --git a/src/images/tabbar/my.png b/src/images/tabbar/my.png new file mode 100644 index 0000000..5e87be7 Binary files /dev/null and b/src/images/tabbar/my.png differ diff --git a/src/images/tabbar/myActive.png b/src/images/tabbar/myActive.png new file mode 100644 index 0000000..fbb1eb5 Binary files /dev/null and b/src/images/tabbar/myActive.png differ diff --git a/src/mixins/https.js b/src/mixins/https.js index 3c1223c..b0f1b76 100644 --- a/src/mixins/https.js +++ b/src/mixins/https.js @@ -12,7 +12,6 @@ export default { $get({url = '', headers = {}, data = {}, timeout = 8000}) { let vm = this const methods = 'GET' - vm.$showLoading('') return new Promise((resolve, reject) => { this.$ajax({url, headers, methods, data, timeout}).then(({code, data}) => { resolve({code, data}) diff --git a/src/mixins/plugins.js b/src/mixins/plugins.js index fd9e141..e0e6ac9 100644 --- a/src/mixins/plugins.js +++ b/src/mixins/plugins.js @@ -193,6 +193,105 @@ const getDiffTime = (recordTime, yearsFlag) => { return '数据异常' } +const commentTimeHandle = (dateStr, typ) => { + let time = dateStr + let type = typ + let repTime = time.replace(/-/g, '/')// 用正则兼容ios + let targetDate = new Date(repTime) + let year = targetDate.getFullYear() + let month = targetDate.getMonth() + 1 + let day = targetDate.getDate() + let nowDate = new Date() + let timeTamp = Date.parse(repTime) + let publishTime = timeTamp / 1000, // 获取dataStr的秒数 + date = new Date(publishTime * 1000), // 获取dateStr的标准格式 + // 获取date 中的 月 日 时 分 秒 + M = date.getMonth() + 1, + D = date.getDate(), + H = date.getHours(), + m = date.getMinutes(), + s = date.getSeconds() + // 对 月 日 时 分 秒 小于10时, 加0显示 例如: 09-09 09:01 + if (M < 10) { + M = '0' + M + } + if (D < 10) { + D = '0' + D + } + if (H < 10) { + H = '0' + H + } + if (m < 10) { + m = '0' + m + } + if (s < 10) { + s = '0' + s + } + + let nowTime = new Date().getTime() / 1000, // 获取此时此刻日期的秒数 + diffValue = nowTime - publishTime, // 获取此时 秒数 与 要处理的日期秒数 之间的差值 + diff_days = parseInt(diffValue / 86400), // 一天86400秒 获取相差的天数 取整 + diff_hours = parseInt(diffValue / 3600), // 一时3600秒 + diff_minutes = parseInt(diffValue / 60), + diff_secodes = parseInt(diffValue) + if (type == 3) { + if (diff_days <= 0) { + return '今天' + ' ' + H + ':' + m + } else if (diff_days > 0 && diff_days < 2) { + return '昨天' + ' ' + H + ':' + m + } else if (year == nowDate.getFullYear()) { + return month + '-' + day + ' ' + H + ':' + m + } else { + return year + '-' + month + } + } + if (type == 2) { + if (diff_days <= 0) { + return '今天' + } else if (diff_days > 0 && diff_days < 2) { + return '昨天' + } else if (year == nowDate.getFullYear()) { + if (day > 9) { + return month + '/' + day + } else { + return month + '/' + 0 + day + } + } else { + if (day > 9) { + return month + '/' + day + } else { + return month + '/' + 0 + day + } + } + } else { + if (diff_days > 0 && diff_days < 2) { // 相差天数 0 < diff_days < 2 时, 直接返出 + return diff_days + '天前' + } else if (diff_days <= 0 && diff_hours > 0) { + return diff_hours + '小时前' + } else if (diff_hours <= 0 && diff_minutes > 0) { + return diff_minutes + '分钟前' + } else if (diff_secodes < 60) { + if (diff_secodes <= 0) { + return '刚刚' + } else { + return diff_secodes + '秒前' + } + } else if (year == nowDate.getFullYear()) { + if (day > 9) { + return month + '-' + day + } else { + return month + '-' + 0 + day + } + } else { + if (day > 9) { + return year + '-' + month + '-' + day + } else { + return year + '-' + month + '-' + 0 + day + } + } + } +} + const getElement_WH = (element) => { // 获取元素位置 return new Promise((resolve) => { let query = wx.createSelectorQuery() @@ -210,5 +309,6 @@ module.exports = { timeContrast, getVideoTime, getDiffTime, + commentTimeHandle, getElement_WH } diff --git a/src/pages/news/chitchat.wpy b/src/pages/news/chitchat.wpy index ebc947b..69b2b5e 100644 --- a/src/pages/news/chitchat.wpy +++ b/src/pages/news/chitchat.wpy @@ -69,6 +69,20 @@ page { float: right; } + .ui-error-icon, .ui-error-icon-v2{ + width: 40rpx; + height: 40rpx; + position: absolute; + top: 50%; + left: -50rpx; + transform: translateY(-50%); + } + + .ui-error-icon-v2{ + left: initial; + right: -60rpx + } + .ui-user-pic { width: 86rpx; height: 86rpx; @@ -102,7 +116,6 @@ page { } .ui-msg-left-pic, .ui-msg-right-pic{ - border: 2rpx solid #eaeaea; max-width: 200rpx; max-height: 200rpx; border-radius: 20rpx; @@ -565,7 +578,9 @@ page { {{item.time}} - + + + @@ -867,7 +882,7 @@ wepy.page({ showTime: timeContrast(format(msg.time), vm.lastTime), name: msg.fromNick, userId: msg.from, - isSend: 1, + isSend: msg.status == 'sendFailed' ? 2 : 1, // sendFailed 发送失败 msgType: 'image' }) vm.lastTime = format(msg.time) @@ -882,9 +897,12 @@ wepy.page({ }) } }) + } else { + vm.sendFileError() } wx.hideLoading() }).catch(() => { + vm.uploadState = false wx.hideLoading() }) }, @@ -933,6 +951,7 @@ wepy.page({ } }) }, + // 发送语音 sendAudio(file) { let vm = this vm.openShow = false @@ -968,9 +987,7 @@ wepy.page({ vm.lastTime = format(msg.time) vm.$nextTick(() => { vm.toView = `id_${msg.time}` - }) - // 防止音频撑开触发加载历史数据 - vm.$nextTick(() => { + // 防止音频撑开触发加载历史数据 setTimeout(() => { vm.uploadState = false }, 500) @@ -978,6 +995,30 @@ wepy.page({ } }) }, + // 发送图片或视频失败 + sendFileError() { + let vm = this + let timeData = new Date().getTime() + vm.msgList.push({ + text: '', + attach: {url: 'https://image.fulllinkai.com/202408/19/fc68d5ba0d7c952f08e2ae3f04ed70a9.png', w: 200, h: 162}, + id: `id_${timeData}`, + isSelf: true, + avatar: vm.myAvatar, + name: vm.myName, + userId: vm.myUserId, + isSend: 2, + msgType: 'image' + }) + vm.lastTime = format(timeData) + vm.$nextTick(() => { + vm.toView = `id_${timeData}` + // 防止音频撑开触发加载历史数据 + setTimeout(() => { + vm.uploadState = false + }, 500) + }) + }, // 标记信息已读 sendMsgReceipt(e) { app.globalData.nim.msg.sendMsgReceipt({ @@ -1039,6 +1080,7 @@ wepy.page({ } vm.$showLoading('') app.globalData.nim.msgLog.getHistoryMsgs(data).then((object) => { + console.log(object, '222222222222222222') if (object && object.length > 0) { if (vm.msgList && vm.msgList.length == 0) { vm.sendMsgReceipt(object[0]) @@ -1073,6 +1115,7 @@ wepy.page({ videoDur: item.type == 'video' ? getVideoTime(item.attach.dur) : '', audioDur: item.type == 'audio' ? (item.attach.dur / 1000).toFixed(0) : '', name: item.fromNick, + isSend: 1, userId: item.from, msgType: item.type }) @@ -1502,13 +1545,23 @@ wepy.page({ // 底部输入框高度 vm.changeInputHeight(true) vm.$nextTick(() => { - // 获取历史消息 - vm.getHistoryMsg() - // 实时获取对方发送的消息 - app.globalData.nim.on('msg', function (e) { - vm.reception(e) - }) + setTimeout(() => { + // 获取历史消息 + vm.getHistoryMsg() + // 实时获取对方发送的消息 + app.globalData.nim.on('msg', function (e) { + vm.reception(e) + }) + }, 3000) }) + // vm.$nextTick(() => { + // // 获取历史消息 + // vm.getHistoryMsg() + // // 实时获取对方发送的消息 + // app.globalData.nim.on('msg', function (e) { + // vm.reception(e) + // }) + // }) wx.setNavigationBarTitle({ title: vm.otherUserName, success: function () {} diff --git a/src/pages/tabBar/dynamic.wpy b/src/pages/tabBar/dynamic.wpy new file mode 100644 index 0000000..ce356fc --- /dev/null +++ b/src/pages/tabBar/dynamic.wpy @@ -0,0 +1,733 @@ + + + + + +{ +navigationBarTitleText: '', +navigationStyle: 'custom', +enablePullDownRefresh: false, +backgroundColorTop: '#ffffff', +backgroundColorBottom: '#ffffff', +usingComponents: { +pageScroll: '~@/components/pageScroll' +} +} + diff --git a/src/pages/user/test.wpy b/src/pages/user/test.wpy index af17760..371b285 100644 --- a/src/pages/user/test.wpy +++ b/src/pages/user/test.wpy @@ -78,7 +78,8 @@ wepy.page({ onShow() { }, onLoad() { - this.getList() + let vm = this + vm.getList() } }) diff --git a/src/styles/reset.less b/src/styles/reset.less index 50a3b59..b1fe4c5 100644 --- a/src/styles/reset.less +++ b/src/styles/reset.less @@ -139,7 +139,7 @@ } } -no_border { +.no_border { border: none !important; } diff --git a/src/utils/im.js b/src/utils/im.js index a6f4b71..5db3b2d 100644 --- a/src/utils/im.js +++ b/src/utils/im.js @@ -2,7 +2,6 @@ import NIM from 'nim-web-sdk-ng/dist/v2/NIM_MINIAPP_SDK' import { service } from '../config.js' const IM = (account, token) => { - console.log(account, token, '8888888888888888') let nim = NIM.getInstance({ debugLevel: 'off', appkey: '9bc3ed1f7d8197b6b69f8f5b742824b1', @@ -20,7 +19,7 @@ const IM = (account, token) => { eventList.forEach((key) => { nim.on(key, (res) => { - console.log(`Receive ${key} event:`, res ? JSON.parse(JSON.stringify(res)) : res) + // console.log(`Receive ${key} event:`, res ? JSON.parse(JSON.stringify(res)) : res) }) }) @@ -171,7 +170,6 @@ const IM = (account, token) => { }) nim.on('myTeamMembers', function (e) { - console.log(e, nim.session, '/////////////') let muteNotList = [] if (e && e.length > 0) { e.forEach((i) => {