From 885503a767ea22e39a0b237378009b89a1b8c034 Mon Sep 17 00:00:00 2001 From: abu <3109389044@qq.com> Date: Sat, 12 Apr 2025 17:11:06 +0800 Subject: [PATCH 1/2] vlog_progress_pause_ios_ad --- api/vlog.js | 15 +- components/vlog/videoComp.vue | 1742 ++++++++++------- components/vlog/videoDetail.vue | 1323 +++++++------ components/vlog/videoFollowComp.vue | 1710 +++++++++------- components/vlog/videoLocal.vue | 1027 ++++++++++ manifest.json | 27 +- .../JG-JPush/android/HiPushSDK-8.0.12.307.aar | Bin 0 -> 68888 bytes .../android/agconnect-core-1.7.3.302.aar | Bin 0 -> 46973 bytes .../android/availableupdate-6.9.0.300.aar | Bin 0 -> 37282 bytes .../JG-JPush/android/base-6.9.0.300.aar | Bin 0 -> 246636 bytes .../android/baselegacyapi-6.9.0.300.aar | Bin 0 -> 37487 bytes .../JG-JPush/android/com.heytap.msp_3.5.3.aar | Bin 0 -> 116644 bytes .../JG-JPush/android/device-6.9.0.300.aar | Bin 0 -> 52126 bytes .../android/firebase-common-20.3.1.aar | Bin 0 -> 67600 bytes .../android/firebase-components-17.1.0.aar | Bin 0 -> 32100 bytes .../android/firebase-datatransport-18.1.7.aar | Bin 0 -> 4421 bytes .../android/firebase-encoders-json-18.0.0.aar | Bin 0 -> 9223 bytes .../android/firebase-iid-interop-17.1.0.aar | Bin 0 -> 8426 bytes .../android/firebase-installations-17.1.3.aar | Bin 0 -> 55222 bytes .../firebase-installations-interop-17.1.0.aar | Bin 0 -> 6001 bytes .../firebase-measurement-connector-19.0.0.aar | Bin 0 -> 10625 bytes .../android/firebase-messaging-23.1.2.aar | Bin 0 -> 142101 bytes .../JG-JPush/android/hatool-6.9.0.300.aar | Bin 0 -> 83317 bytes .../libs/MiPush_SDK_Client_6_0_1-C.jar | Bin 0 -> 912460 bytes .../android/libs/commons-codec-1.6.jar | Bin 0 -> 232771 bytes .../libs/error_prone_annotations-2.9.0.jar | Bin 0 -> 15994 bytes .../libs/firebase-annotations-16.2.0.jar | Bin 0 -> 3769 bytes .../android/libs/firebase-encoders-17.0.0.jar | Bin 0 -> 17847 bytes .../libs/firebase-encoders-proto-16.0.0.jar | Bin 0 -> 38980 bytes .../JG-JPush/android/libs/javax.inject-1.jar | Bin 0 -> 2497 bytes .../android/libs/jpush-android-5.6.0.jar | Bin 0 -> 403195 bytes .../libs/jpush-android-plugin-fcm-v5.6.0.jar | Bin 0 -> 25253 bytes .../jpush-android-plugin-honor-v5.6.0.jar | Bin 0 -> 8569 bytes .../jpush-android-plugin-huawei-v5.6.0.jar | Bin 0 -> 15492 bytes .../jpush-android-plugin-meizu-v5.6.0.jar | Bin 0 -> 8663 bytes .../libs/jpush-android-plugin-nio-v5.6.0.jar | Bin 0 -> 6589 bytes .../libs/jpush-android-plugin-oppo-v5.6.0.jar | Bin 0 -> 8203 bytes .../libs/jpush-android-plugin-vivo-v5.6.0.jar | Bin 0 -> 8789 bytes .../jpush-android-plugin-xiaomi-v5.6.0.jar | Bin 0 -> 8430 bytes .../JG-JPush/android/libs/tasks-1.5.2.206.jar | Bin 0 -> 31146 bytes .../JG-JPush/android/log-6.9.0.300.aar | Bin 0 -> 9182 bytes .../android/network-common-6.0.2.300.aar | Bin 0 -> 53977 bytes .../network-framework-compat-6.0.2.300.aar | Bin 0 -> 29585 bytes .../android/network-grs-6.0.2.300.aar | Bin 0 -> 80793 bytes .../JG-JPush/android/niopush-sdk-v1.0.aar | Bin 0 -> 10284 bytes .../android/opendevice-6.11.0.300.aar | Bin 0 -> 71300 bytes .../android/play-services-base-18.0.1.aar | Bin 0 -> 548703 bytes .../android/play-services-basement-18.1.0.aar | Bin 0 -> 379617 bytes .../play-services-cloud-messaging-17.0.1.aar | Bin 0 -> 31573 bytes .../android/play-services-stats-17.0.2.aar | Bin 0 -> 14753 bytes .../android/play-services-tasks-18.0.2.aar | Bin 0 -> 73978 bytes .../JG-JPush/android/push-6.11.0.300.aar | Bin 0 -> 152384 bytes .../JG-JPush/android/push-internal-5.0.3.aar | Bin 0 -> 89744 bytes .../android/security-base-1.2.0.307.aar | Bin 0 -> 49462 bytes .../android/security-encrypt-1.2.0.307.aar | Bin 0 -> 47005 bytes .../android/security-ssl-1.2.0.307.aar | Bin 0 -> 91792 bytes .../JG-JPush/android/stats-6.9.0.300.aar | Bin 0 -> 26962 bytes .../JG-JPush/android/transport-api-3.0.0.aar | Bin 0 -> 4898 bytes .../android/transport-backend-cct-3.1.8.aar | Bin 0 -> 35074 bytes .../android/transport-runtime-3.1.8.aar | Bin 0 -> 112298 bytes .../JG-JPush/android/ui-6.9.0.300.aar | Bin 0 -> 98881 bytes .../android/uniplugin_jpush-release.aar | Bin 0 -> 69170 bytes .../android/vivo_pushSDK_v4.0.6.0_506.aar | Bin 0 -> 228100 bytes .../Headers/JPushModule.h | 17 + .../ios/UniPluginJPush.framework/Info.plist | Bin 0 -> 753 bytes .../PrivacyInfo.xcprivacy | 23 + .../UniPluginJPush.framework/UniPluginJPush | Bin 0 -> 2636392 bytes nativeplugins/JG-JPush/package.json | 169 ++ pages.json | 67 +- pages/me/me.nvue | 11 +- pages/me/myFans.nvue | 80 +- pages/me/myFollows.nvue | 169 +- pages/me/settings.vue | 227 +++ pages/me/{vlog.vue => vlog.nvue} | 0 pages/me/vlogerInfo.nvue | 687 +++++++ pages/me/vlogerInfo.vue | 0 pages/passport/login.vue | 1495 +++++++------- pages/search/search.nvue | 274 +++ pages/search/searchList.nvue | 260 +++ pages/tabbar/im/index.vue | 860 ++++---- pages/tabbar/vlog/index.nvue | 1353 +++++++------ static/images/playvd.png | Bin 0 -> 3121 bytes utils/storage.js | 8 +- vue.config.js | 8 +- 84 files changed, 7603 insertions(+), 3949 deletions(-) create mode 100644 components/vlog/videoLocal.vue create mode 100644 nativeplugins/JG-JPush/android/HiPushSDK-8.0.12.307.aar create mode 100644 nativeplugins/JG-JPush/android/agconnect-core-1.7.3.302.aar create mode 100644 nativeplugins/JG-JPush/android/availableupdate-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/base-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/baselegacyapi-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/com.heytap.msp_3.5.3.aar create mode 100644 nativeplugins/JG-JPush/android/device-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-common-20.3.1.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-components-17.1.0.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-datatransport-18.1.7.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-encoders-json-18.0.0.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-iid-interop-17.1.0.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-installations-17.1.3.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-installations-interop-17.1.0.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-measurement-connector-19.0.0.aar create mode 100644 nativeplugins/JG-JPush/android/firebase-messaging-23.1.2.aar create mode 100644 nativeplugins/JG-JPush/android/hatool-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/libs/MiPush_SDK_Client_6_0_1-C.jar create mode 100644 nativeplugins/JG-JPush/android/libs/commons-codec-1.6.jar create mode 100644 nativeplugins/JG-JPush/android/libs/error_prone_annotations-2.9.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/firebase-annotations-16.2.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/firebase-encoders-17.0.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/firebase-encoders-proto-16.0.0.jar create mode 100755 nativeplugins/JG-JPush/android/libs/javax.inject-1.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-fcm-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-honor-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-huawei-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-meizu-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-nio-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-oppo-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-vivo-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/jpush-android-plugin-xiaomi-v5.6.0.jar create mode 100644 nativeplugins/JG-JPush/android/libs/tasks-1.5.2.206.jar create mode 100644 nativeplugins/JG-JPush/android/log-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/network-common-6.0.2.300.aar create mode 100644 nativeplugins/JG-JPush/android/network-framework-compat-6.0.2.300.aar create mode 100644 nativeplugins/JG-JPush/android/network-grs-6.0.2.300.aar create mode 100644 nativeplugins/JG-JPush/android/niopush-sdk-v1.0.aar create mode 100644 nativeplugins/JG-JPush/android/opendevice-6.11.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/play-services-base-18.0.1.aar create mode 100644 nativeplugins/JG-JPush/android/play-services-basement-18.1.0.aar create mode 100644 nativeplugins/JG-JPush/android/play-services-cloud-messaging-17.0.1.aar create mode 100644 nativeplugins/JG-JPush/android/play-services-stats-17.0.2.aar create mode 100644 nativeplugins/JG-JPush/android/play-services-tasks-18.0.2.aar create mode 100644 nativeplugins/JG-JPush/android/push-6.11.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/push-internal-5.0.3.aar create mode 100644 nativeplugins/JG-JPush/android/security-base-1.2.0.307.aar create mode 100644 nativeplugins/JG-JPush/android/security-encrypt-1.2.0.307.aar create mode 100644 nativeplugins/JG-JPush/android/security-ssl-1.2.0.307.aar create mode 100644 nativeplugins/JG-JPush/android/stats-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/transport-api-3.0.0.aar create mode 100644 nativeplugins/JG-JPush/android/transport-backend-cct-3.1.8.aar create mode 100644 nativeplugins/JG-JPush/android/transport-runtime-3.1.8.aar create mode 100644 nativeplugins/JG-JPush/android/ui-6.9.0.300.aar create mode 100644 nativeplugins/JG-JPush/android/uniplugin_jpush-release.aar create mode 100644 nativeplugins/JG-JPush/android/vivo_pushSDK_v4.0.6.0_506.aar create mode 100644 nativeplugins/JG-JPush/ios/UniPluginJPush.framework/Headers/JPushModule.h create mode 100644 nativeplugins/JG-JPush/ios/UniPluginJPush.framework/Info.plist create mode 100644 nativeplugins/JG-JPush/ios/UniPluginJPush.framework/PrivacyInfo.xcprivacy create mode 100644 nativeplugins/JG-JPush/ios/UniPluginJPush.framework/UniPluginJPush create mode 100755 nativeplugins/JG-JPush/package.json create mode 100755 pages/me/settings.vue rename pages/me/{vlog.vue => vlog.nvue} (100%) create mode 100755 pages/me/vlogerInfo.nvue delete mode 100755 pages/me/vlogerInfo.vue create mode 100755 pages/search/search.nvue create mode 100755 pages/search/searchList.nvue create mode 100644 static/images/playvd.png diff --git a/api/vlog.js b/api/vlog.js index 9fafbee3..cba7cc96 100644 --- a/api/vlog.js +++ b/api/vlog.js @@ -43,11 +43,12 @@ export function vlogFollowList(page, pageSize,myId) { /** * 短视频列表-true */ -export function vlogList(page, pageSize,userId='',search='') { +export function vlogList(page, pageSize,userId='',cityCode='',search='') { let data = { page, pageSize, userId, + cityCode, search } return http.request({ @@ -338,3 +339,15 @@ export function vlogQueryMyFollows({myId,page,pageSize}) { params:{myId,page,pageSize} }); } + +/** + * 我的关注 + */ +export function vlogQueryDoIFollowVloger({myId,vlogerId}) { + return http.request({ + url: api.vlog + "/fans/queryDoIFollowVloger", + method: Method.GET, + needToken: true, + params:{myId,vlogerId} + }); +} \ No newline at end of file diff --git a/components/vlog/videoComp.vue b/components/vlog/videoComp.vue index 70961ba2..53bb1ed1 100755 --- a/components/vlog/videoComp.vue +++ b/components/vlog/videoComp.vue @@ -1,740 +1,1006 @@ - - + + - - \ No newline at end of file + var userId = myUserInfo.id; + var result = await vlogLike({ + userId, + vlogerId: vlog.vlogerId, + vlogId: vlog.vlogId + }); + console.log(result); + if (result.data.status == 200) { + me.reLikePlayList(vlog.vlogId); + me.refreshVlogCounts(); + } else { + uni.showToast({ + title: result.data.msg, + icon: 'none', + duration: 3000 + }); + } + } else if (isLike == 0) { + // 取消喜欢/点赞视频 + var myUserInfo = storage.getVlogUserInfo() || null; + if (myUserInfo == null) { + uni.navigateTo({ + url: '/pages/passport/login', + animationType: 'slide-in-bottom' + }); + return; + } + var userId = myUserInfo.id; + + var result = await vlogUnLike({ + userId, + vlogerId: vlog.vlogerId, + vlogId: vlog.vlogId + }); + if (result.data.status == 200) { + me.reDislikePlayList(vlog.vlogId); + me.refreshVlogCounts(); + } else { + uni.showToast({ + title: result.data.msg, + icon: 'none', + duration: 3000 + }); + } + } + }, + + // 喜欢/点赞的list重新设置 + reLikePlayList(vlogId) { + var me = this; + var playerList = me.playerList; + + // 关注以后,循环当前playerList,修改对应粉丝关系的doIFollowVloger改为true + for (var i = 0; i < playerList.length; i++) { + var vlog = playerList[i]; + if (vlog.vlogId == vlogId) { + vlog.doILikeThisVlog = true; + playerList.splice(i, 1, vlog); + } + } + me.playerList = playerList; + }, + reDislikePlayList(vlogId) { + var me = this; + var playerList = me.playerList; + + // 关注以后,循环当前playerList,修改对应粉丝关系的doIFollowVloger改为true + for (var i = 0; i < playerList.length; i++) { + var vlog = playerList[i]; + if (vlog.vlogId == vlogId) { + vlog.doILikeThisVlog = false; + playerList.splice(i, 1, vlog); + } + } + me.playerList = playerList; + }, + + // 关注后的list重新设置 + reFollowPlayList(vlogerId) { + var me = this; + var playerList = me.playerList; + + // 关注以后,循环当前playerList,修改对应粉丝关系的doIFollowVloger改为true + for (var i = 0; i < playerList.length; i++) { + var vlog = playerList[i]; + if (vlog.vlogerId == vlogerId) { + vlog.doIFollowVloger = true; + + playerList.splice(i, 1, vlog); + } + } + me.playerList = playerList; + }, + // 取关后的list重新设置 + reCancelPlayList(vlogerId) { + var me = this; + var playerList = me.playerList; + + // 关注以后,循环当前playerList,修改对应粉丝关系的doIFollowVloger改为true + for (var i = 0; i < playerList.length; i++) { + var vlog = playerList[i]; + if (vlog.vlogerId == vlogerId) { + vlog.doIFollowVloger = false; + playerList.splice(i, 1, vlog); + } + } + me.playerList = playerList; + }, + + // 关注博主 + async followMe(vlogerId) { + var me = this; + var myUserInfo = storage.getVlogUserInfo() || null; + if (myUserInfo == null) { + uni.navigateTo({ + url: '/pages/passport/login', + animationType: 'slide-in-bottom' + }); + return; + } + var userId = myUserInfo.id; + var result = await vlogFollow(userId, vlogerId); + if (result.data.status == 200) { + me.reFollowPlayList(vlogerId); + } else { + uni.showToast({ + title: result.data.msg, + icon: 'none', + duration: 3000 + }); + } + }, + // 查看用户详情 + goUserInfoSeeSee(userId) { + uni.setStorageSync('userPageId', userId); + const info = storage.getVlogUserInfo() || null; + if (info == null) { + uni.navigateTo({ + url: '/pages/passport/login', + animationType: 'slide-in-bottom' + }); + return; + } + let myUserId = info.id; + if (myUserId == userId) { + uni.switchTab({ + url: '/pages/me/me' + }); + } else { + uni.navigateTo({ + url: '/pages/me/vlogerInfo?userPageId=' + userId + }); + } + }, + + listScroll(e) { + // console.log(e.contentOffset.y); + this.progressFlag = false; + if (e.contentOffset.y > 0) { + this.$emit('showLoading'); + } + }, + + downloadVlog() { + var me = this; + var serverUrl = app.globalData.serverUrl; + var currentIndex = me.playerCur; + var vlog = me.playerList[currentIndex]; + var pendingLength = vlog.url; + }, + + copyLink() { + var me = me; + }, + + showQRCode() { + var me = me; + }, + + changeVlogToPrivate() { + var me = me; + }, + + // 下拉刷新的过程中,改变头部tab显示的字样 + onpullingdown(e) { + console.log('下拉中'); + }, + async onrefresh(e) { + // console.log('开始') + // this.refreshing = true; + // // 通过list组件的下拉刷新触发当前所在页面的下拉刷新 + // uni.startPullDownRefresh(); + // await this.displayVideoPaging(1,true) + // uni.stopPullDownRefresh() + // this.refreshing = false; + // this.$emit("hideLoading"); + console.log('开始'); + this.refreshing = true; + // 通过list组件的下拉刷新触发当前所在页面的下拉刷新 + uni.startPullDownRefresh(); + await this.displayVideoPaging(1, true); + uni.stopPullDownRefresh(); + this.refreshing = false; + this.$emit('hideLoading'); + }, + + onplay: function (e) { + // console.log('开始播放'); + // let timer = setTimeout(() => { + // this.progressFlag = true; + // clearTimeout(timer); + // }, 10); + this.progressFlag = true; + if (uni.getSystemInfoSync().platform == 'ios') { + this.doplay(0.1); + } + }, + onerror: function (err) {}, + // timeupdate: function (e) { + // if (e.detail.currentTime > 0.2) { + // this.doplay(e.detail.currentTime); + // } + // }, + + playOrPause() { + var me = this; + var playStatus = this.playStatus; + console.log(playStatus); + if (!playStatus) { + me.videoContext.pause(); + } else { + me.videoContext.play(); + } + this.playStatus = !playStatus; + }, + + scroll: function (e) { + let originalIndex = this.currentIndex; + let isNext = false; + if (e.contentOffset.y < this.contentOffsetY) { + isNext = true; + } + this.contentOffsetY = Number(e.contentOffset.y); + var num = this.playerList.length; + if (num > 0) { + var ht = Number(e.contentSize.height); + console.log(ht); + this.currentIndex = Math.round(Math.abs(this.contentOffsetY) / (ht / num)); + } else { + this.currentIndex = 0; + } + this.onchange(this.currentIndex); + + this.times = new Date().getTime(); + // 判断如果视频列表总长度-当前下标,少于3个,则开始分页查询后续的视频,并且追加到现有list中 + if (this.playerList.length - this.currentIndex < 3) { + // 如果要分页的page和总数totalPage相等,则没有更多 + if (this.page == this.totalPage || this.totalPage == 0) { + this.$emit('hideLoading'); + return; + } + this.displayVideoPaging(this.page + 1, false); + } + }, + + // 分页查询新的list, 并且追加到现有list中 + async displayVideoPaging(page, needClearList) { + // 查询首页短视频列表 + let me = this; + let myUserInfo = storage.getVlogUserInfo(); + let userId = ''; + if (myUserInfo != null) { + userId = myUserInfo.id; + this.userId = userId; + } + const result = await vlogList(page, 10, userId).catch((err) => { + uni.stopPullDownRefresh(); + }); + uni.stopPullDownRefresh(); + console.log(result); + if (result.data.status == 200) { + let vlogList = result.data.data.rows; + // 缺:该条视频是否被喜欢过 + let totalPage = result.data.data.total; + // me.playerList = vlogList; + if (needClearList) { + me.playerList = []; + } + me.playerList = me.playerList.concat(vlogList); + me.page = page; + me.totalPage = totalPage; + + if (needClearList) { + me.setThisVlogInfo(); + me.freshCommentCounts(); + } + } else { + uni.showToast({ + title: result.data.msg, + icon: 'none', + duration: 3000 + }); + } + }, + + doplay: function (time) { + if (time > 0) { + this.playerList[this.playerCur].play = true; + } + }, + onchange: function (index) { + console.log(index); + console.log(this.playerCur); + if (index != this.playerCur) { + this.playerList[this.playerCur].play = false; + this.playerCur = index; + this.playStatus = true; + this.progressWidth = 0; + } + this.progressFlag = true; + // let timer = setTimeout(() => { + // this.progressFlag = true; + // clearTimeout(timer); + // }, 20); + this.refreshVlogCounts(); + this.setThisVlogInfo(); + this.freshCommentCounts(); + }, + + // 设置当前vlog的信息 + setThisVlogInfo() { + var me = this; + var currentIndex = me.playerCur; + var vlog = me.playerList[currentIndex]; + this.thisVlog = vlog; + this.thisVlogId = vlog.vlogId; + this.thisVlogerId = vlog.vlogerId; + }, + + async refreshVlogCounts() { + // 查询当前点赞数,重新赋值给当前视频 + var me = this; + var currentIndex = me.playerCur; + var vlog = me.playerList[currentIndex]; + var result = await vlogTotalLikedCounts(vlog.vlogId); + if (result.data.status == 200) { + var counts = result.data.data; + me.reChangeVlogLikedCountsInPlayList(vlog.vlogId, counts); + } + }, + + reChangeVlogLikedCountsInPlayList(vlogId, counts) { + var me = this; + var playerList = me.playerList; + + // 关注以后,循环当前playerList,修改对应粉丝关系的doIFollowVloger改为true + for (var i = 0; i < playerList.length; i++) { + var vlog = playerList[i]; + if (vlog.vlogId == vlogId) { + vlog.likeCounts = counts; + playerList.splice(i, 1, vlog); + } + } + me.playerList = playerList; + }, + + commentToggle() { + this.$refs.comment.open(); + uni.hideTabBar({ + animation: true + }); + }, + shareToggle() { + this.$refs.share.open(); + uni.hideTabBar({ + animation: true + }); + } + } +}; + + + diff --git a/components/vlog/videoDetail.vue b/components/vlog/videoDetail.vue index e57d1775..341fedae 100755 --- a/components/vlog/videoDetail.vue +++ b/components/vlog/videoDetail.vue @@ -1,184 +1,235 @@ diff --git a/components/vlog/videoFollowComp.vue b/components/vlog/videoFollowComp.vue index b6a97f7a..c5b6c046 100755 --- a/components/vlog/videoFollowComp.vue +++ b/components/vlog/videoFollowComp.vue @@ -1,739 +1,999 @@ - - - - diff --git a/pages/me/vlog.vue b/pages/me/vlog.nvue similarity index 100% rename from pages/me/vlog.vue rename to pages/me/vlog.nvue diff --git a/pages/me/vlogerInfo.nvue b/pages/me/vlogerInfo.nvue new file mode 100755 index 00000000..2322906e --- /dev/null +++ b/pages/me/vlogerInfo.nvue @@ -0,0 +1,687 @@ + + + + + diff --git a/pages/me/vlogerInfo.vue b/pages/me/vlogerInfo.vue deleted file mode 100755 index e69de29b..00000000 diff --git a/pages/passport/login.vue b/pages/passport/login.vue index 059f4c4c..ab0d8f4b 100644 --- a/pages/passport/login.vue +++ b/pages/passport/login.vue @@ -1,717 +1,780 @@ - - - - - \ No newline at end of file + ], + showBack: false, + enabuleFetchCode: false, + enabulePrivacy: false, //隐私政策 + mobile: '', //手机号 + code: '', //验证码 + inputStyle: { + height: '104rpx', + 'border-bottom': '1rpx solid #D8D8D8', + 'letter-spacing': '1rpx', + 'font-size': '40rpx', + 'line-height': '40rpx', + color: '#333' + }, + placeholderStyle: 'font-size: 32rpx;line-height: 32rpx;color: #999999;', + loginList: [ + //第三方登录集合 + { + icon: 'weixin-fill', + color: '#00a327', + title: '微信', + code: 'WECHAT' + }, + { + icon: 'qq-fill', + color: '#38ace9', + title: 'QQ', + code: 'QQ' + }, + { + icon: 'apple-fill', + color: '#000000', + title: 'Apple', + code: 'APPLE' + } + ], + initurl: false + }; + }, + + onShow() { + //#ifdef H5 + let isWXBrowser = /micromessenger/i.test(navigator.userAgent); + if (isWXBrowser) { + webConnect('WECHAT').then((res) => { + let data = res.data; + if (data.success) { + window.location = data.result; + } + }); + } + //#endif + }, + + mounted() { + // #ifndef APP-PLUS + //判断是否微信浏览器 + var ua = window.navigator.userAgent.toLowerCase(); + if (ua.match(/MicroMessenger/i) == 'micromessenger') { + this.wechatLogin = true; + return; + } + // #endif + /** + * 条件编译判断当前客户端类型 + */ + //#ifdef H5 + this.clientType = 'H5'; + //#endif + + //#ifdef APP-PLUS + this.clientType = 'APP'; + /**如果是app 加载支持的登录方式*/ + let _this = this; + uni.getProvider({ + service: 'oauth', + success: (result) => { + _this.loginList = result.provider.map((value) => { + //展示title + let title = ''; + //系统code + let code = ''; + //颜色 + let color = '#8b8b8b'; + //图标 + let icon = ''; + //uni 联合登录 code + let appcode = ''; + switch (value) { + case 'weixin': + icon = 'weixin-circle-fill'; + color = '#00a327'; + title = '微信'; + code = 'WECHAT'; + break; + case 'qq': + icon = 'qq-circle-fill'; + color = '#38ace9'; + title = 'QQ'; + code = 'QQ'; + break; + case 'apple': + icon = 'apple-fill'; + color = '#000000'; + title = 'Apple'; + code = 'APPLE'; + break; + } + return { + title: title, + code: code, + color: color, + icon: icon, + appcode: value + }; + }); + }, + fail: (error) => { + uni.showToast({ + title: '获取登录通道失败' + error, + duration: 2000, + icon: 'none' + }); + } + }); + //#endif + + //特殊平台,登录方式需要过滤 + // #ifdef H5 + this.methodFilter(['QQ']); + // #endif + + //微信小程序,只支持微信登录 + // #ifdef MP-WEIXIN + this.methodFilter(['WECHAT']); + // #endif + }, + watch: { + current(val) { + val ? (this.showBack = true) : (this.showBack = false); + }, + mobile: { + handler(val) { + if (val.length == 11) { + this.enabuleFetchCode = true; + } + } + }, + + async flage(val) { + if (val) { + if (this.$refs.uCode.canGetCode) { + // 向后端请求验证码 + uni.showLoading({}); + let res = await sendMobile(this.mobile); + uni.hideLoading(); + // 这里此提示会被this.start()方法中的提示覆盖 + if (res.data.success) { + this.current = 1; + this.$refs.uCode.start(); + } else { + uni.showToast({ + title: res.data.message, + duration: 2000, + icon: 'none' + }); + this.flage = false; + } + } else { + this.$u.toast('请倒计时结束后再发送'); + } + } else { + this.$refs.verification.hide(); + } + } + }, + onLoad(options) { + if (options.init == 'index') { + this.initurl = true; + } + console.log(options); + if (options && options.state) { + this.stateLogin(options.state); + } + }, + methods: { + customback() { + if (this.initurl) { + uni.switchTab({ + url: '/pages/tabbar/vlog/index' + }); + } else { + uni.navigateBack(); + } + }, + //联合信息返回登录 + stateLogin(state) { + loginCallback(state).then((res) => { + console.log(res); + let data = res.data; + if (data.success) { + storage.setAccessToken(data.result.accessToken); + storage.setRefreshToken(data.result.refreshToken); + // 登录成功 + uni.showToast({ + title: '登录成功!', + icon: 'none' + }); + getUserInfo().then((user) => { + storage.setUserInfo(user.data.result); + storage.setHasLogin(true); + }); + getCurrentPages().length > 1 + ? uni.navigateBack({ + delta: getCurrentPages().length - 2 + }) + : uni.switchTab({ + url: '/pages/tabbar/vlog/index' + }); + } + }); + }, + /** 根据参数显示登录模块 */ + methodFilter(code) { + let way = []; + this.loginList.forEach((item) => { + if (code.length != 0) { + code.forEach((val) => { + if (item.code == val) { + way.push(item); + } + }); + } else { + uni.showToast({ + title: '配置有误请联系管理员', + duration: 2000, + icon: 'none' + }); + } + }); + this.loginList = way; + }, + //非h5 获取openid + async nonH5OpenId(item) { + console.log(item); + let _this = this; + //获取各个openid + await uni.login({ + provider: item.appcode, + // scopes: 'snsapi_userinfo', + success: function (res) { + uni.setStorageSync('type', item.code); + //微信小程序意外的其它方式直接在storage中写入openid + // #ifndef MP-WEIXIN + uni.setStorageSync('openid', res.authResult.openid); + // #endif + }, + fail(e) { + uni.showToast({ + title: '第三方登录暂不可用!', + icon: 'none', + duration: 3000 + }); + }, + complete(e) { + console.log(e); + //获取用户信息 + uni.getUserInfo({ + provider: item.appcode, + success: function (infoRes) { + //写入用户信息 + uni.setStorageSync('nickname', infoRes.userInfo.nickName); + uni.setStorageSync('avatar', infoRes.userInfo.avatarUrl); + + // #ifdef MP-WEIXIN + //微信小程序获取openid 需要特殊处理 如需获取openid请参考uni-id: https://uniapp.dcloud.net.cn/uniCloud/uni-id + _this.weixinMPOpenID(res).then((res) => { + //这里需要先行获得openid,再使用openid登录,小程序登录需要两步,所以这里特殊编译 + _this.goOpenidLogin('WECHAT_MP'); + }); + // #endif + + // #ifndef MP-WEIXIN + _this.goOpenidLogin('APP'); + //#endif + } + }); + } + }); + }, + //openid 登录 + goOpenidLogin(clientType) { + // 获取准备好的参数,进行登录系统 + let params = { + uuid: uni.getStorageSync('openid'), //联合登陆id + source: uni.getStorageSync('type'), //联合登陆类型 + nickname: uni.getStorageSync('nickname'), // 昵称 + avatar: uni.getStorageSync('avatar'), // 头像 + uniAccessToken: uni.getStorageSync('uni_access_token') //第三方token + }; + openIdLogin(params, clientType).then((res) => { + console.log(res); + if (!res.data.success) { + let errormessage = '第三方登录暂不可用'; + uni.showToast({ + // title: '未绑定第三方账号', + title: errormessage, + icon: 'none', + duration: 3000 + }); + return; + } else { + var infoData = res.data.result; + storage.setAccessToken(infoData.accessToken); + storage.setRefreshToken(infoData.refreshToken); + const vlogInfo = JSON.parse(infoData.tikUser); + // 将vlog的token和vlog用户信息放入缓存 + storage.setVlogToken(vlogInfo.userToken); + storage.setVlogUserInfo(vlogInfo); + // 登录成功 + uni.showToast({ + title: '第三方登录成功!', + icon: 'none' + }); + // 执行登录 + getUserInfo().then((user) => { + if (user.data.success) { + /** + * 个人信息存储到缓存userInfo中 + */ + storage.setUserInfo(user.data.result); + storage.setHasLogin(true); + + /** + * 计算出当前router路径 + * 1.如果跳转的链接为登录页面或跳转的链接为空页面。则会重新跳转到首页 + * 2.都不满足返回跳转页面 + */ + whetherNavigate(); + } else { + uni.switchTab({ + url: '/pages/tabbar/vlog/index' + }); + } + }); + } + }); + }, + //微信小程序获取openid + async weixinMPOpenID(res) { + await miniProgramLogin(res.code).then((res) => { + uni.setStorageSync('openid', res.data); + }); + }, + /**跳转到登录页面 */ + navigateLogin(connectLogin) { + // #ifdef H5 + let code = connectLogin.code; + let buyer = api.buyer; + window.open(buyer + `/passport/connect/connect/login/web/` + code, '_self'); + // #endif + // #ifdef APP-PLUS + this.nonH5OpenId(connectLogin); + // #endif + }, + + // 提交 + submit() { + /** + * 清空当前账号信息 + */ + storage.setHasLogin(false); + storage.setAccessToken(''); + storage.setRefreshToken(''); + storage.setUserInfo({}); + // 清理vlog信息 + storage.setVlogToken(''); + storage.setVlogUserInfo({}); + /** + * 执行登录 + */ + smsLogin( + { + mobile: this.mobile, + code: this.code + }, + this.clientType + ).then((res) => { + // console.log(res) + if (res.data.success) { + const infoData = res.data.result; + const vlogInfo = JSON.parse(infoData.tikUser); + storage.setAccessToken(infoData.accessToken); + storage.setRefreshToken(infoData.refreshToken); + // 将vlog的token和vlog用户信息放入缓存 + storage.setVlogToken(vlogInfo.userToken); + storage.setVlogUserInfo(vlogInfo); + + /** + * 登录成功后获取个人信息 + */ + getUserInfo().then((user) => { + // console.log(user) + if (user.data.success) { + /** + * 个人信息存储到缓存userInfo中 + */ + storage.setUserInfo(user.data.result); + storage.setHasLogin(true); + // 登录成功 + uni.showToast({ + title: '登录成功!', + icon: 'none' + }); + + /** + * 计算出当前router路径 + * 1.如果跳转的链接为登录页面或跳转的链接为空页面。则会重新跳转到首页 + * 2.都不满足返回跳转页面 + */ + whetherNavigate(); + } else { + uni.switchTab({ + url: '/pages/tabbar/home/index' + }); + } + }); + } + }); + }, + // 验证码验证 + verification(val) { + // console.log(val) + this.flage = val == this.$store.state.verificationKey ? true : false; + // console.log(this.flage) + }, + // 跳转 + navigateToPrivacy(val) { + uni.navigateTo({ + url: '/pages/mine/help/tips?type=' + val + }); + }, + // 点击获取验证码 + start() { + this.codeColor = '#999'; + this.$u.toast('验证码已发送'); + this.flage = false; + this.codeFlag = false; + + this.$refs.verification.hide(); + }, + /**点击验证码*/ + codeChange(text) { + this.tips = text; + }, + /** 结束验证码后执行 */ + end() { + this.codeColor = this.lightColor; + this.codeFlag = true; + console.log(this.codeColor); + }, + // 发送验证码 + fetchCode() { + if (!this.enabulePrivacy) { + uni.showToast({ + title: '请同意用户隐私', + duration: 2000, + icon: 'none' + }); + return false; + } + + if (!this.$u.test.mobile(this.mobile)) { + uni.showToast({ + title: '请填写正确手机号', + duration: 2000, + icon: 'none' + }); + return false; + } + if (this.tips == '重新获取验证码') { + uni.showLoading({ + title: '加载中' + }); + if (!this.codeFlag) { + let timer = setInterval(() => { + if (this.$refs.verification) { + this.$refs.verification.error(); //发送 + } + clearInterval(timer); + }, 100); + } + uni.hideLoading(); + } + if (!this.flage) { + this.$refs.verification.error(); //发送 + + return false; + } + } + } +}; + + + diff --git a/pages/search/search.nvue b/pages/search/search.nvue new file mode 100755 index 00000000..13f3d456 --- /dev/null +++ b/pages/search/search.nvue @@ -0,0 +1,274 @@ + + + + + diff --git a/pages/search/searchList.nvue b/pages/search/searchList.nvue new file mode 100755 index 00000000..7b82b210 --- /dev/null +++ b/pages/search/searchList.nvue @@ -0,0 +1,260 @@ + + + + + diff --git a/pages/tabbar/im/index.vue b/pages/tabbar/im/index.vue index bb7f34db..bf034508 100644 --- a/pages/tabbar/im/index.vue +++ b/pages/tabbar/im/index.vue @@ -1,300 +1,308 @@ @@ -303,199 +311,199 @@ uni-page-body, html, body, page { - width: 100% !important; - height: 100% !important; - overflow: hidden; + width: 100% !important; + height: 100% !important; + overflow: hidden; } .jolkp { - height: 66px; - display: flex; - font-size: 15px; - justify-content: end; - /* 设置背景图 */ - background-image: url("@/static/im/Rectangle.png"); - /* 让背景图覆盖整个元素 */ - background-size: cover; - /* 背景图不重复 */ - background-repeat: no-repeat; + height: 66px; + display: flex; + font-size: 15px; + justify-content: end; + /* 设置背景图 */ + background-image: url('@/static/im/Rectangle.png'); + /* 让背景图覆盖整个元素 */ + background-size: cover; + /* 背景图不重复 */ + background-repeat: no-repeat; } .jolkp_l { - width: 2rem; - height: 2rem; - background-image: url("@/static/im/Frame.png"); - /* 让背景图覆盖整个元素 */ - background-size: cover; - /* 背景图不重复 */ - background-repeat: no-repeat; - margin-top: 35px; - margin-right: 10px; + width: 2rem; + height: 2rem; + background-image: url('@/static/im/Frame.png'); + /* 让背景图覆盖整个元素 */ + background-size: cover; + /* 背景图不重复 */ + background-repeat: no-repeat; + margin-top: 35px; + margin-right: 10px; } .jolkp_h { - width: 2rem; - height: 2rem; - background-image: url("@/static/im/user.png"); - /* 让背景图覆盖整个元素 */ - background-size: cover; - /* 背景图不重复 */ - background-repeat: no-repeat; - margin-top: 35px; - margin-right: 20px; + width: 2rem; + height: 2rem; + background-image: url('@/static/im/user.png'); + /* 让背景图覆盖整个元素 */ + background-size: cover; + /* 背景图不重复 */ + background-repeat: no-repeat; + margin-top: 35px; + margin-right: 20px; } .jolkp_z { - width: 2rem; - height: 1.5rem; - background-image: url("@/static/im/znx.png"); - /* 让背景图覆盖整个元素 */ - background-size: cover; - /* 背景图不重复 */ - background-size: 100% 100%; + width: 2rem; + height: 1.5rem; + background-image: url('@/static/im/znx.png'); + /* 让背景图覆盖整个元素 */ + background-size: cover; + /* 背景图不重复 */ + background-size: 100% 100%; - margin-top: 35px; - margin-right: 20px; + margin-top: 35px; + margin-right: 20px; } .tiole { - margin-top: -10px; - margin-left: 105%; - color: #fff; - font-size: 14px; + margin-top: -10px; + margin-left: 105%; + color: #fff; + font-size: 14px; } .popup { - position: absolute; - top: 65px; - /* 调整弹出框的位置 */ - right: 5px; - background-color: #fff; - border: 1px solid #ccc; - border-radius: 4px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - z-index: 3; + position: absolute; + top: 65px; + /* 调整弹出框的位置 */ + right: 5px; + background-color: #fff; + border: 1px solid #ccc; + border-radius: 4px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + z-index: 3; } .popup ul { - list-style-type: none; - padding: 0; - margin: 0; + list-style-type: none; + padding: 0; + margin: 0; } .popup li { - padding: 10px 20px; - cursor: pointer; + padding: 10px 20px; + cursor: pointer; } .popup li:hover { - background-color: #f0f0f0; + background-color: #f0f0f0; } .fan { - width: 10%; - height: "100%"; - font-size: 18px; - display: flex; + width: 10%; + height: '100%'; + font-size: 18px; + display: flex; - padding: 5px; + padding: 5px; } @media screen and (device-width: 393px) and (device-height: 851px) and (-webkit-device-pixel-ratio: 3) { - .fan { - margin-right: 56% !important; - width: 10%; - height: "100%"; - font-size: 18px; - display: flex; - margin-top: 85%; - padding: 5px; - } + .fan { + margin-right: 56% !important; + width: 10%; + height: '100%'; + font-size: 18px; + display: flex; + margin-top: 85%; + padding: 5px; + } } .three { - width: 100%; - height: 10%; - display: flex; - justify-content: space-around; - align-items: center; - background: rgb(255, 255, 255); + width: 100%; + height: 10%; + display: flex; + justify-content: space-around; + align-items: center; + background: rgb(255, 255, 255); } .con { - width: 100%; - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; } .three_div1 { - height: 3rem; - width: 40%; - background-image: url("@/static/im/kf.png"); - background-size: 100% 100%; - background-repeat: no-repeat; - display: flex; - align-items: center; - justify-content: end; + height: 3rem; + width: 40%; + background-image: url('@/static/im/kf.png'); + background-size: 100% 100%; + background-repeat: no-repeat; + display: flex; + align-items: center; + justify-content: end; } .three_div2 { - width: 40%; - height: 3rem; - background-image: url("@/static/im/hy.png"); - background-size: 100% 100%; - background-repeat: no-repeat; - width: 40%; + width: 40%; + height: 3rem; + background-image: url('@/static/im/hy.png'); + background-size: 100% 100%; + background-repeat: no-repeat; + width: 40%; } .three_div3 { - height: 3rem; - background-image: url("@/static/im/da.png"); - background-size: 100% 100%; - background-repeat: no-repeat; - width: 40%; + height: 3rem; + background-image: url('@/static/im/da.png'); + background-size: 100% 100%; + background-repeat: no-repeat; + width: 40%; } .tui-conversation-item { - /* height: 10%; */ - padding: 12px; - display: flex; - align-items: center; - cursor: pointer; - box-sizing: border-box; - overflow: hidden; - border: 1px solid #d9d9d9; - width: 98%; - margin-top: 10px; - position: relative; + /* height: 10%; */ + padding: 12px; + display: flex; + align-items: center; + cursor: pointer; + box-sizing: border-box; + overflow: hidden; + border: 1px solid #d9d9d9; + width: 98%; + margin-top: 10px; + position: relative; } .content { - display: flex; - flex: 1; - padding-left: 8px; - justify-content: end; - box-sizing: border-box; - overflow: hidden; + display: flex; + flex: 1; + padding-left: 8px; + justify-content: end; + box-sizing: border-box; + overflow: hidden; } .left { - position: relative; - width: 36px; - height: 36px; + position: relative; + width: 36px; + height: 36px; } .znx { - max-height: 100vh; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - overflow-y: auto; + max-height: 100vh; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + overflow-y: auto; } .delete-button { - position: absolute; - right: 0; - top: 0; - bottom: 0; - width: 100px; - background-color: red; - color: white; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; + position: absolute; + right: 0; + top: 0; + bottom: 0; + width: 100px; + background-color: red; + color: white; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; } diff --git a/pages/tabbar/vlog/index.nvue b/pages/tabbar/vlog/index.nvue index f6ff22b1..a59236cc 100644 --- a/pages/tabbar/vlog/index.nvue +++ b/pages/tabbar/vlog/index.nvue @@ -1,582 +1,773 @@ - - - - \ No newline at end of file + } + } + + if (me.curIndex == 0) { + me.playLocalStatus = true; + } + if (me.curIndex == 1) { + me.playFollowStatus = true; + } + if (me.curIndex == 2) { + me.playStatus = true; + } + }, + onHide() { + var me = this; + // 显示和隐藏,需要判断根据不同tab做暂停或者隐藏 + if (me.curIndex == 0) { + me.playLocalStatus = false; + me.isDraw_lo = false; + } + if (me.curIndex == 1) { + me.playFollowStatus = false; + me.isDraw_gz = false; + } + if (me.curIndex == 2) { + me.playStatus = false; + me.isDraw_tj = false; + } + }, + + // 当前页下拉刷新 + // onPullDownRefresh() { + // var me = this; + // // 下拉刷新判断,如果是不同tab,那么组件中刷新的请求也不同 + // if (me.curIndex == 0) { + // this.$refs.videoFollowComp.displayVideoPaging(1, true); + // } else if (me.curIndex == 1) { + // this.$refs.videoComp.displayVideoPaging(1, true); + // } + + // }, + methods: { + getLocation() { + uni.getLocation({ + type: 'wg84', + success: (res) => { + console.log(res); + var latitude = res.latitude; + var longitude = res.longitude; + var location = latitude + ',' + longitude; + var key = config.aMapKey; + uni.request({ + url: 'https://apis.map.qq.com/ws/geocoder/v1/', + method: 'GET', + data: { + location, + key + }, + success: (address) => { + console.log(address); + var ad_info = address.data.result.ad_info; + var cityCode = ad_info.adcode; // 城市编码cityCode + storage.setCityCode(cityCode); + this.cityCode = cityCode; + var address_name = ad_info.district || ad_info.city; + this.tabList.forEach((i, index) => { + if (index == 0) { + i.name = address_name; + // this.selectorQuery(); + var timer = setTimeout(() => { + this.selectorQuery(); + clearTimeout(timer); + }, 300); + } + }); + } + }); + }, + fail: () => { + uni.showToast({ + icon: 'none', + title: '获取位置信息失败' + }); + // uni.showModal({ + // title:'提示', + // content:'获取位置信息失败', + // showCancel:false, + // success: (res) => { + // if(res.confirm){ + // } + // } + // }) + } + }); + }, + + // 前往搜索页面 + goSearch() { + uni.navigateTo({ + url: '/pages/search/search' + }); + }, + // ----------头部区域点击tabs + ontabtap(e) { + console.log(e); + let index = e.target.dataset.current || e.currentTarget.dataset.current; + this.isTap = true; + var currentSize = this.tabListSize[index]; + // if (obj.playerList.length === 0) { + // this.isDraw_gz = false; + // this.isDraw_lo = false; + // this.isDraw_tj = false; + // } else { + // this.isDraw_gz = preloadIndex == 1 ? true : false; + // this.isDraw_lo = preloadIndex == 0 ? true : false; + // this.isDraw_tj = preloadIndex == 2 ? true : false; + // } + this.updateIndicator(currentSize.left, currentSize.width); + this._touchTabIndex = index; + this.switchTab(index); + }, + // + selectorQuery() { + var dm = uni.createSelectorQuery().in(this); + dm.select('#head') + .boundingClientRect() + .exec((rect) => { + this._headHeight = rect[0].height; + }); + + // 查询 tabbar 宽度 + dm.in(this) + .select('#tab-bar') + .boundingClientRect() + .exec((rect) => { + this.tabbarWidth = rect[0].width; + console.log(this.tabbarWidth); + }); + // 查询 tabview 宽度 + dm.in(this) + .select('#tab-bar-view') + .boundingClientRect() + .exec((rect) => { + this.swiperWidth = rect[0].width; + console.log(this.swiperWidth); + }); + + // 因 nvue 暂不支持 class 查询 + // var queryTabSize = uni.createSelectorQuery().in(this); + var queryTabSize = dm; + for (var i = 0; i < this.tabList.length; i++) { + queryTabSize.select('#' + this.tabList[i].id).boundingClientRect(); + } + queryTabSize.exec((rects) => { + rects.forEach((rect) => { + rect.left = rect.left - 40; //修正 left 值,减去 padding-left: 40px + this.tabListSize[rect.dataset.id] = rect; + }); + console.log(this.tabListSize[this.tabIndex]); + this.updateIndicator(this.tabListSize[this.tabIndex].left, this.tabListSize[this.tabIndex].width); + this.switchTab(this.tabIndex); + }); + }, + + onswiperscroll(e) { + this.isDraw_gz = false; + this.isDraw_lo = false; + this.isDraw_tj = false; + console.log(this.playStatus); + // if (this.playStatus == true) { + // this.playStatus = this._lastTabIndex == 2 ? false : true; + // } + + // this.playFollowStatus = this._lastTabIndex == 1 ? false : true; + // this.playLocalStatus = this._lastTabIndex == 0 ? false : true; + + var offsetX = e.detail.dx; + var preloadIndex = this._lastTabIndex; + if (offsetX > TAB_PRELOAD_OFFSET) { + preloadIndex++; + } else if (offsetX < -TAB_PRELOAD_OFFSET) { + preloadIndex--; + } + let prop = this.pageList[preloadIndex]; + let obj = this.$refs[prop]; + if (!obj) return; + // 点击切换 + if (this.isTap) { + return; + } + // 切换失败 + if (preloadIndex === this._lastTabIndex || preloadIndex < 0 || preloadIndex > this.pageList.length - 1) { + // 是否有视频数据 + if (obj.playerList.length === 0) { + // this.loadTabData(preloadIndex); + this.isDraw_gz = false; + this.isDraw_lo = false; + this.isDraw_tj = false; + } else { + this.isDraw_gz = preloadIndex == 1 ? true : false; + this.isDraw_lo = preloadIndex == 0 ? true : false; + this.isDraw_tj = preloadIndex == 2 ? true : false; + } + return; + } + + // console.log(this.tabListSize) + var percentage = Math.abs(this.swiperWidth / offsetX); + var currentSize = this.tabListSize[this._lastTabIndex]; + var preloadSize = this.tabListSize[preloadIndex]; + var lineL = currentSize.left + (preloadSize.left - currentSize.left) / percentage; + var lineW = currentSize.width + (preloadSize.width - currentSize.width) / percentage; + this.updateIndicator(lineL, lineW); + }, + animationfinish(e) { + let index = e.detail.current; + console.log('当前索引' + index); + console.log('之前的索引' + this._lastTabIndex); + this._lastTabIndex = index; + if (this._touchTabIndex === index) { + this.isTap = false; + } + this.switchTab(index); + if (!this.tabListSize[index]) { + return; + } else { + // this.playStatus = index == 2 ? false : true; + // this.playFollowStatus = index == 1 ? true : false; + // this.playLocalStatus = index == 0 ? true : false; + this.isDraw_gz = index == 1 ? true : false; + this.isDraw_lo = index == 0 ? true : false; + this.isDraw_tj = index == 2 ? true : false; + + this.updateIndicator(this.tabListSize[index].left, this.tabListSize[index].width); + } + }, + updateIndicator(left, width) { + // console.log(left) + this.indicatorLineLeft = left; + this.indicatorLineWidth = width; + }, + + switchTab(index) { + if (this.tabIndex === index) { + return; + } + // console.dir(this.$refs) + let props = this.pageList[index]; + console.log(props); + console.log(index); + let obj = this.$refs[props]; + // if (obj.playerList.length === 0) { + // var info = storage.getVlogUserInfo() || null + // if(info!=null&&index==0){ + // obj.displayVideoPaging(this.page + 1, true); + // } + // } + + obj.setScrollRef(this._headHeight); + + console.log(this.cacheTab); + // 缓存 tabId + if (obj.playerList.length > MAX_CACHE_DATA) { + let isExist = this.cacheTab.indexOf(this.tabIndex); + if (isExist < 0) { + this.cacheTab.push(this.tabIndex); + } + } + this.tabIndex = index; + this.curIndex = index; + this.scrollTabTo(index); + this.scrollInto = this.tabList[index].id; + + // 释放 tabId + if (this.cacheTab.length > MAX_CACHE_PAGE) { + let cacheIndex = this.cacheTab[0]; + this.clearTabData(cacheIndex); + this.cacheTab.splice(0, 1); + } + // const el = this.$refs['tabitem' + index][0]; + // animation.transition(el, { + // duration: 3000, //ms + // timingFunction: 'ease', + // delay: 1000 //ms + // }); + }, + scrollTabTo(index) { + console.log(index); + const el = this.$refs['tabitem' + index][0]; + let offset = 0; + // TODO fix ios offset + if (index > 0) { + offset = this.tabbarWidth / 2 - this.tabListSize[index].width / 2; + if (this.tabListSize[index].right < this.tabbarWidth / 2) { + offset = this.tabListSize[0].width; + } + } + dom.scrollToElement(el, { + offset: -offset + }); + }, + + //---------------------------- + + // 左滑右滑选项卡改变选中状态 + changeTopTab: function (e) { + var current = e.detail.current; + this.curIndex = current; + this.tabIndex = current; + let timer = setTimeout(() => { + this.playLocalStatus = this.curIndex === 0 ? true : false; + this.playFollowStatus = this.curIndex === 1 ? true : false; + this.playStatus = this.curIndex === 2 ? true : false; + clearTimeout(timer); + }, 10); + }, + + // 下拉刷新,改变head的字样显示 + showLoading() { + this.isLoading = true; + }, + hideLoading() { + this.isLoading = false; + }, + letFollowVideoPause() { + this.playFollowStatus = false; + } + } +}; + + + diff --git a/static/images/playvd.png b/static/images/playvd.png new file mode 100644 index 0000000000000000000000000000000000000000..4dba79b4e3a2e3cce178199f62bee1849ec82dc5 GIT binary patch literal 3121 zcmV-149@e3P)Px=>q$gGRCr$Poojj%IS@tN-i6I#NLB`{EMYM?yKv7a#2+TuZauC_CF$^I<|Ar7 zZr$TjspYWj2Ke*#_V#o>pP%;o{ntm!IiJrz!_W8o{p;aycpYHrETOUjOXdEnbRU4& z?RMWn=j*zL|IhxjuImqg$(C>U2fG5~0!Aqmx1zc%%WKFmU%q_#K77eFJ0;NN)D14aX&n z>Z>kR^X}V*erInANbV34EUxZ98l4fVe1f)!%9alD4K#8Qlz!)a{i=6DhNa$MvNcXO^}mfaIJE zc{Pv{66FieSqy8vP7^>xaSCyl42i2_UK8FYm=Lsq3P6?++=L zfGi!ofmUV{@0qhddza7H1d!AM{dhc@%&T0!-#sWH3H|l-0in{+Yd8b41`u@6EcZGz^;Y>5F@>nkZ=@i6tr;UUVEq+i}ZV%sv#kp z)OIg`)K~b%2wYKVB74@LWRNV`${$i@6OMw*<8iMC0I8?#X3t7UI11jBJF5YJWXYy` zD78l08kxFeOQE!%14x=))mkgF36SW*1Ry#si+fT+!nYNR!|~n$fM|4-^`eA?x}-cT z08*}Dl^!?>t|Du4rvQ>HncV}*Y(ia<7dHUO)6MKDB_!{A>W;q7Y$o!9fdIrq6gK9- zQEoS3c31&qTO)TZl#p-~{5ZS-;?DkY6XM&7 zaXOW@0+3P#8$YkiCe$VW1`|LU8(cBG5)!Vc{2dVhQ8?5=A4*85Oa25DKpdD`IR&n$ zDAnY$qE<~Oy(zQF>_@?55GSTqPeTbwnA@yZQ~*TnOh^53MWs9#08*}@`yQ0pWVWMV z0C8_`%>B8E&NpeLcO-let(`%U4%4{-nT>>D(SU!Cr zN=QaM3I>pLUk&wy8j{hn34jb`_x#0hMdh}30Fv*i;ht1xlTnU>0c1Fvmn}#M$p}Zm z08-|sA)n@o%Ac?T$dDG-EJ~S8dM(}oMB}Aldr?Bt1$c4l@ivS3I zZKgmjB$g*y0Mg7J4E&KvUeRh|y$FD$M25C<1#+^8OK#1};@g9_#sv^7 zmrOX0>R-KWl|9&EO=w!HC6{igT5qk`Vp%z5!f{k^v^cf;94@w46B@YYk`?vF`_{(E zaX*06bjw72mmc9>OVzUGAcIU~TC1h1wp6X&bv)9E3}WS?LB~;TsXW5LDb}E-wOE$w z2-nML)jiF~AQo;KYz$?+5sLBuYw{n~|NePwNB|^ODcZd&psY8%oK#VRU~Y*5qt_d^ zL?VMotTT2e>UzWKHFkU<7Ea*d@a;qdhGFGVXdNQzpMv{i4Z zdWD1cAd?tAWtqw&+;@X5i^)INoU+E0wq%eLwFYmi+*0*$gc}o10Etm)f;KZA;l_j& zKw?xHxDEBjtl-nbQ50O`{1X_HpM(eqpJG}V5$29O-pI(dd8-10yH zNV$eCd!XLXgatq}I=bpbxuqKA%1Ca203=sAr_XVOs|^f*X!UH?8}&vV=>epUuBN@J zw^Xwn;l>0BKw?yK+(r$@s8>dELkJ+b$~kzBdZT_20HnUg@)0<~l}mcJLjbYUS~8M) zOGUl$I4l4nv8_!fN;qb_GLjo10LfL(@Hvif4aNR66o9nTK5ArTz2W^AMMnu@+z3F7 z1y31Hxuu%@%1Dat*KGkLSGmg1afDl0;K=R)BvL4=X6kyQ_g~y*rTe{c0Hk#UuEtky zsW`$d4=#X|YbfbK4F^|7Bw^tjg&G<2dr@zxc)yV!i(5~UL9}`%^`<<+4FgkeB*`Du z7(k+A(l=sDrPs7Zj{s6b)r~$m!fhaW=8yoADO}ED)EhafwS5LajPzG;sW`&52^@eJ z=&Xi=BV2=^eGCC0m9?hcs4Q^h?g6Bdz#QRL64tm|0I49jdP_yUQ6Wf?T>?m?P_fOF zaPU?Lry#YeK(Wm)iX6+J? zp6(PWw^V%VFUGRAZM*{V+QV6YYG!;CTIvm30!ZqotoKh+>Wx@?_213}keofb z*KJlR?2jzMZyE6qkO?3;Cs`h|h#HO_wvqlVTz7_MfaL7gJ!O%c`QHm2^+sJ&D|@#D zBzK$A z0um)0E#{wV2%h^}0c${#w^^6zTGb;Q;eyDu0;Yh3flEG_Ykv|`Zve+<1yuJwu8b(v^wn20Kt8gF6p|LwdU%=H zV%@Wh*%Xk{Q?1rP%H7_zo;TyiE6^N}ULm30h&Nf!EnNW86C~6dJ=;Bf?rs3-0TQ-U z=?3fl30Hu4F5KBt^=|dN`MU$;vJBOGk~~@dJjIr(RKdQVcMFJzEf-s=zRj(ey=y=& z3shW9Nf9f6aqop=NggwRR3nKv4XAuxvEc|&gb*fe!u@(a&06)aXz1a zk}YajYm7d-1mv^yVGDNoy8uo2{|h)Dnc@A%0fz8jfEdHP7OVIVA@H(pXW9LS00000 LNkvXXu0mjfxhk^I literal 0 HcmV?d00001 diff --git a/utils/storage.js b/utils/storage.js index b2a14228..ba5ce864 100644 --- a/utils/storage.js +++ b/utils/storage.js @@ -10,7 +10,13 @@ const FACE_LOGIN = isDev ? "face_login_dev" : "face_login"; const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login"; const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn"; const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data"; -export default { +export default { + setCityCode(val) { + return uni.setStorageSync('cityCode',val) + }, + getCityCode(){ + return uni.getStorageSync('cityCode') + }, /** * 写入RefreshVlogIndex */ diff --git a/vue.config.js b/vue.config.js index 904355d0..0b0be2f1 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,12 +1,12 @@ -const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default; +// const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default; module.exports = { parallel: false, configureWebpack: { plugins: [ - ScriptSetup({ - /* options */ - }), + // ScriptSetup({ + // /* options */ + // }), ], }, chainWebpack(config) { From 18bdb4d4d52362ee8812a5618e7ae04e1d809bbf Mon Sep 17 00:00:00 2001 From: abu <3109389044@qq.com> Date: Mon, 21 Apr 2025 17:35:54 +0800 Subject: [PATCH 2/2] push --- App.vue | 531 ++- TUIKit/assets/styles/common.scss | 120 +- TUIKit/components/TUIChat/index.vue | 649 +-- .../TUIChat/message-input/index.vue | 486 +- .../message-input/message-input-editor.vue | 570 +-- .../TUIContact/contact-info/index.vue | 860 ++-- TUIKit/components/TUIContact/index.vue | 276 +- TUIKit/components/TUIContact/indexsea.vue | 280 +- api/vlog.js | 828 ++-- components/vlog/videoComp.vue | 18 +- components/vlog/videoDetail.vue | 30 +- components/vlog/videoFollowComp.vue | 22 +- components/vlog/videoLocal.vue | 14 +- config/api.js | 14 +- .../android/assets/agconnect-services.json | 1 + .../android/assets/timpush-configs.json | 1 + .../android/manifestPlaceholders.json | 5 + nativeResources/android/mcs-services.json | 6 + .../ios/Resources/timpush-configs.json | 3 + package-lock.json | 4096 ++++++++++++----- package.json | 20 +- pages/publish/publish.nvue | 791 ++-- pages/search/search.nvue | 274 -- pages/search/search.vue | 296 ++ pages/search/searchList.nvue | 260 -- pages/search/searchList.vue | 399 ++ pages/search/searchVd.vue | 243 + pages/search/shop.vue | 818 ++++ pages/search/tuangou.vue | 288 ++ pages/search/user.vue | 220 + pages/tabbar/im/index.vue | 54 +- pages/tabbar/vlog/index.nvue | 16 +- uni_modules/TencentCloud-Push/changelog.md | 29 + uni_modules/TencentCloud-Push/index.js | 0 uni_modules/TencentCloud-Push/package.json | 90 + uni_modules/TencentCloud-Push/readme-npm.md | 299 ++ uni_modules/TencentCloud-Push/readme.md | 285 ++ .../utssdk/app-android/config.json | 29 + .../utssdk/app-android/index.uts | 152 + .../app-android/push-callback-options.uts | 5 + .../utssdk/app-android/push-callback.uts | 28 + .../app-android/push-listener-options.uts | 3 + .../utssdk/app-android/push-listener.uts | 25 + .../utssdk/app-ios/UTS.entitlements | 8 + .../utssdk/app-ios/config.json | 11 + .../utssdk/app-ios/index.uts | 125 + .../utssdk/app-ios/push-listener-options.uts | 3 + .../utssdk/app-ios/push-listener.uts | 24 + .../TencentCloud-Push/utssdk/interface.uts | 11 + utils/request.js | 41 +- utils/tools.js | 28 +- vue.config.js | 68 +- 52 files changed, 9284 insertions(+), 4469 deletions(-) create mode 100644 nativeResources/android/assets/agconnect-services.json create mode 100644 nativeResources/android/assets/timpush-configs.json create mode 100644 nativeResources/android/manifestPlaceholders.json create mode 100644 nativeResources/android/mcs-services.json create mode 100644 nativeResources/ios/Resources/timpush-configs.json delete mode 100755 pages/search/search.nvue create mode 100755 pages/search/search.vue delete mode 100755 pages/search/searchList.nvue create mode 100755 pages/search/searchList.vue create mode 100644 pages/search/searchVd.vue create mode 100644 pages/search/shop.vue create mode 100644 pages/search/tuangou.vue create mode 100644 pages/search/user.vue create mode 100644 uni_modules/TencentCloud-Push/changelog.md create mode 100644 uni_modules/TencentCloud-Push/index.js create mode 100644 uni_modules/TencentCloud-Push/package.json create mode 100644 uni_modules/TencentCloud-Push/readme-npm.md create mode 100644 uni_modules/TencentCloud-Push/readme.md create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/config.json create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/index.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/push-callback-options.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/push-callback.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/push-listener-options.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-android/push-listener.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-ios/UTS.entitlements create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-ios/config.json create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-ios/index.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener-options.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener.uts create mode 100644 uni_modules/TencentCloud-Push/utssdk/interface.uts diff --git a/App.vue b/App.vue index b7b6629f..d9d18293 100644 --- a/App.vue +++ b/App.vue @@ -1,273 +1,270 @@ - + + +/************************ */ +.w200 { + width: 200rpx !important; +} + +.flex1 { + flex: 1; //必须父级设置flex +} +.activate-line { + background-color: #ffffff; + + transition-duration: 300ms; +} +// uni-page-body, +// html, +// body, +// page { +// width: 100% ; +// height: 100% ; +// overflow: hidden; +// } + diff --git a/TUIKit/assets/styles/common.scss b/TUIKit/assets/styles/common.scss index 40ce2f71..90a0c8b5 100644 --- a/TUIKit/assets/styles/common.scss +++ b/TUIKit/assets/styles/common.scss @@ -1,60 +1,60 @@ -body, div, ul, ol, dt, dd, li, dl, h1, h2, h3, h4, p { - margin:0; - padding:0; - font-style:normal; - - /* font:12px/22px"\5B8B\4F53",Arial,Helvetica,sans-serif; */ -} - -ol, ul, li { - list-style:none; -} - -img { - border:0; - vertical-align:middle; - pointer-events:none; -} - -body{ - height: 100% important; - color:#000; - background:#FFF; -} - -.clear { - clear:both; - height:1px; - width:100%; - overflow:hidden; - margin-top:-1px; -} - -a { - color:#000; - text-decoration:none; - cursor: pointer; -} - -a:hover { - text-decoration:none; -} - -input, textarea { - user-select: auto; -} - -input:focus, input:active, textarea:focus, textarea:active { - outline: none; -} - -.chat-aside { - position: absolute; - top: 50px; - right: 0; - box-sizing: border-box; - width: 360px !important; - border-radius: 8px 0 0 8px; - z-index: 9999; - max-height: calc(100% - 50px); -} +body, div, ul, ol, dt, dd, li, dl, h1, h2, h3, h4, p { + margin:0; + padding:0; + font-style:normal; + + /* font:12px/22px"\5B8B\4F53",Arial,Helvetica,sans-serif; */ +} + +ol, ul, li { + list-style:none; +} + +img { + border:0; + vertical-align:middle; + pointer-events:none; +} + +body{ + height: 100% important; + color:#000; + background:#FFF; +} + +.clear { + clear:both; + height:1px; + width:100%; + overflow:hidden; + margin-top:-1px; +} + +a { + color:#000; + text-decoration:none; + cursor: pointer; +} + +a:hover { + text-decoration:none; +} + +input, textarea { + user-select: auto; +} + +input:focus, input:active, textarea:focus, textarea:active { + outline: none; +} + +.chat-aside { + position: absolute; + top: 50px; + right: 0; + box-sizing: border-box; + width: 360px !important; + border-radius: 8px 0 0 8px; + z-index: 9999; + max-height: calc(100% - 50px); +} diff --git a/TUIKit/components/TUIChat/index.vue b/TUIKit/components/TUIChat/index.vue index 4dcbac60..64b4074b 100644 --- a/TUIKit/components/TUIChat/index.vue +++ b/TUIKit/components/TUIChat/index.vue @@ -1,324 +1,325 @@ - - - - + + + + diff --git a/TUIKit/components/TUIChat/message-input/index.vue b/TUIKit/components/TUIChat/message-input/index.vue index a32fbe28..d8846bc3 100644 --- a/TUIKit/components/TUIChat/message-input/index.vue +++ b/TUIKit/components/TUIChat/message-input/index.vue @@ -1,243 +1,243 @@ - - - - + + + + diff --git a/TUIKit/components/TUIChat/message-input/message-input-editor.vue b/TUIKit/components/TUIChat/message-input/message-input-editor.vue index dff1ac43..02825a3e 100644 --- a/TUIKit/components/TUIChat/message-input/message-input-editor.vue +++ b/TUIKit/components/TUIChat/message-input/message-input-editor.vue @@ -1,285 +1,285 @@ - - - - + + + + diff --git a/TUIKit/components/TUIContact/contact-info/index.vue b/TUIKit/components/TUIContact/contact-info/index.vue index ef02c343..0a9c5f56 100644 --- a/TUIKit/components/TUIContact/contact-info/index.vue +++ b/TUIKit/components/TUIContact/contact-info/index.vue @@ -1,430 +1,430 @@ - + + + + diff --git a/pages/search/search.nvue b/pages/search/search.nvue deleted file mode 100755 index 13f3d456..00000000 --- a/pages/search/search.nvue +++ /dev/null @@ -1,274 +0,0 @@ - - - - - diff --git a/pages/search/search.vue b/pages/search/search.vue new file mode 100755 index 00000000..922c25da --- /dev/null +++ b/pages/search/search.vue @@ -0,0 +1,296 @@ + + + + + diff --git a/pages/search/searchList.nvue b/pages/search/searchList.nvue deleted file mode 100755 index 7b82b210..00000000 --- a/pages/search/searchList.nvue +++ /dev/null @@ -1,260 +0,0 @@ - - - - - diff --git a/pages/search/searchList.vue b/pages/search/searchList.vue new file mode 100755 index 00000000..a5dc65c3 --- /dev/null +++ b/pages/search/searchList.vue @@ -0,0 +1,399 @@ + + + + + diff --git a/pages/search/searchVd.vue b/pages/search/searchVd.vue new file mode 100644 index 00000000..31e19a0b --- /dev/null +++ b/pages/search/searchVd.vue @@ -0,0 +1,243 @@ + + + + + diff --git a/pages/search/shop.vue b/pages/search/shop.vue new file mode 100644 index 00000000..e8ffaf02 --- /dev/null +++ b/pages/search/shop.vue @@ -0,0 +1,818 @@ + + + + + diff --git a/pages/search/tuangou.vue b/pages/search/tuangou.vue new file mode 100644 index 00000000..321280e0 --- /dev/null +++ b/pages/search/tuangou.vue @@ -0,0 +1,288 @@ + + + + + diff --git a/pages/search/user.vue b/pages/search/user.vue new file mode 100644 index 00000000..d21e7149 --- /dev/null +++ b/pages/search/user.vue @@ -0,0 +1,220 @@ + + + + + diff --git a/pages/tabbar/im/index.vue b/pages/tabbar/im/index.vue index bf034508..1efdbbd2 100644 --- a/pages/tabbar/im/index.vue +++ b/pages/tabbar/im/index.vue @@ -117,6 +117,11 @@ import SelectFriendqlioa from '@/TUIKit/components/TUIGroup/index.vue'; import TUICore, { ExtensionInfo, TUIConstants } from '@tencentcloud/tui-core'; import storage from '@/utils/storage.js'; import { getUserimInfo, getMember, getMemberstate, getMemberdelete } from '@/api/members'; + +// push +import { TUIConversationService } from '@tencentcloud/chat-uikit-engine'; +import * as Push from '@/uni_modules/TencentCloud-Push'; + TUIChatKit.init(); let vueVersion = 2; // vueVersion = 3; @@ -161,8 +166,53 @@ export default { SDKAppID: par.sdkAppId, userID: par.userID, userSig: par.userSig, - useUploadPlugin: true, // If you need to send rich media messages, please set to true. - framework: `vue${vueVersion}` // framework used vue2 / vue3 + useUploadPlugin: true, + framework: `vue${vueVersion}` + }).then(() => { + Push.setRegistrationID(par.userID, () => { + console.log('设置id设置id设置id设置id设置id设置id设置id设置id设置id设置id', par.userID); + + Push.registerPush( + par.sdkAppId, + 'vkFpe55aYqfV7Sk5uGaoxhEstJ3tcI9dquk7JwG1GloDSLD2HeMWeQweWWXgNlhC', + (data) => { + console.log('registerPush ok', data); + Push.getRegistrationID((registrationID) => { + console.log('getRegistrationID ok', registrationID); + }); + }, + (errCode, errMsg) => { + console.error('registerPush failed', errCode, errMsg); + } + ); + }); + // 监听通知栏点击事件,获取推送扩展信息 + Push.addPushListener(Push.EVENT.NOTIFICATION_CLICKED, (res) => { + console.log('notification clicked', res); + // 解析扩展信息,跳转到相应的会话(代码仅供参考,发布前需要完善) + try { + const data = JSON.parse(res.data); + const conv_type = data?.entity?.chatType === 1 ? 'C2C' : 'GROUP'; + // 根据推送信息拼的 conversationID + const conversationID = `${conv_type}${data.entity.sender}`; + // 切换会话 + TUIConversationService.switchConversation(conversationID); + const chatPath = '/TUIKit/components/TUIChat/index'; + uni.navigateTo({ url: chatPath }); + } catch (error) { + console.log('error', error); + } + }); + // 监听在线推送 + Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, (res) => { + // res 为消息内容 + console.log('message received', res); + }); + // 监听在线推送被撤回 + Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, (res) => { + // res 为被撤回的消息 ID + console.log('message revoked', res); + }); }); } else { // 接口返回非 200 状态码,跳转登录页面 diff --git a/pages/tabbar/vlog/index.nvue b/pages/tabbar/vlog/index.nvue index a59236cc..b8bb88b4 100644 --- a/pages/tabbar/vlog/index.nvue +++ b/pages/tabbar/vlog/index.nvue @@ -229,7 +229,7 @@ export default { }, 300); }, onTabItemTap: function (e) { - console.log(e); + // console.log(e); // let tabIndex = e.index; // this.playStatus = tabIndex === 0 ? true : false; // 切换视频要做暂停或播放的判断 @@ -343,7 +343,8 @@ export default { } }); }, - fail: () => { + fail: (err) => { + console.log(err); uni.showToast({ icon: 'none', title: '获取位置信息失败' @@ -373,15 +374,7 @@ export default { let index = e.target.dataset.current || e.currentTarget.dataset.current; this.isTap = true; var currentSize = this.tabListSize[index]; - // if (obj.playerList.length === 0) { - // this.isDraw_gz = false; - // this.isDraw_lo = false; - // this.isDraw_tj = false; - // } else { - // this.isDraw_gz = preloadIndex == 1 ? true : false; - // this.isDraw_lo = preloadIndex == 0 ? true : false; - // this.isDraw_tj = preloadIndex == 2 ? true : false; - // } + this.updateIndicator(currentSize.left, currentSize.width); this._touchTabIndex = index; this.switchTab(index); @@ -433,7 +426,6 @@ export default { this.isDraw_gz = false; this.isDraw_lo = false; this.isDraw_tj = false; - console.log(this.playStatus); // if (this.playStatus == true) { // this.playStatus = this._lastTabIndex == 2 ? false : true; // } diff --git a/uni_modules/TencentCloud-Push/changelog.md b/uni_modules/TencentCloud-Push/changelog.md new file mode 100644 index 00000000..c5e53f6a --- /dev/null +++ b/uni_modules/TencentCloud-Push/changelog.md @@ -0,0 +1,29 @@ +## 1.2.0(2025-03-31) +- 适配出海手机支持 FCM 推送。 +## 1.1.0(2024-12-11) +- 大幅减小插件包体积,优化产品体验。 +- 兼容 HBuilderX 4.36 的 Breaking changes。如果您需要 vivo/荣耀 的厂商推送,请参考 [文档](https://cloud.tencent.com/document/product/269/103522),正确配置 `manifestPlaceholders.json` 和 `mcn-services.json`。 + +## 1.0.0(2024-11-29) +- 优化和 [TencentCloud-TUICallKit 插件](https://ext.dcloud.net.cn/plugin?id=9035) 融合时的产品体验。 +- 新增点击通知栏事件 NOTIFICATION_CLICKED,支持获取推送扩展信息。 +- 在线通道支持自定义铃音功能。 + +## 0.5.1(2024-11-07) +- 优化和 [@tencentcloud/chat-uikit-uniapp](https://cloud.tencent.com/document/product/269/64507) 融合时的产品体验。 +- 优化和 [TencentCloud-TUICallKit 插件](https://ext.dcloud.net.cn/plugin?id=9035) 融合时的产品体验。 +- 新增接口 disablePostNotificationInForeground,此接口可实现应用在前台时,开/关通知栏通知(默认开)。 +- 新增接口 createNotificationChannel,支持 FCM/OPPO 自定义铃音。 + +## 0.4.0(2024-10-17) +- 支持与 [TencentCloud-TUICallKit 插件](https://ext.dcloud.net.cn/plugin?id=9035) 融合打包。 + +## 0.3.0(2024-10-12) +- 新增接口 addPushListener/removePushListener,支持获取在线推送消息,支持推送消息撤回通知。 + +## 0.2.0(2024-09-18) +- 支持 FCM +- 支持 hihonor + +## 0.1.0(2024-09-10) + - 使用 uts 开发,基于腾讯云推送服务(Push),支持 iOS 和 Android 推送,同时适配各大厂商推送。 \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/index.js b/uni_modules/TencentCloud-Push/index.js new file mode 100644 index 00000000..e69de29b diff --git a/uni_modules/TencentCloud-Push/package.json b/uni_modules/TencentCloud-Push/package.json new file mode 100644 index 00000000..11c43552 --- /dev/null +++ b/uni_modules/TencentCloud-Push/package.json @@ -0,0 +1,90 @@ +{ + "name": "@tencentcloud/uni-app-push", + "id": "TencentCloud-Push", + "main": "index.js", + "displayName": "【官方】uni-app 腾讯云推送服务(Push)", + "version": "1.2.0", + "description": "使用 uts 开发,基于腾讯云推送服务(Push),支持 iOS 和 Android 推送,同时适配各大厂商推送。", + "license": "ISC", + "keywords": [ + "腾讯云", + "Push", + "推送", + "Android/iOS", + "谷歌FCM" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "腾讯云即时通信IM隐私保护指引: https://web.sdk.qcloud.com/document/Tencent-IM-Privacy-Protection-Guidelines.html\n移动推送隐私保护指引: https://privacy.qq.com/document/preview/8565a4a2d26e480187ed86b0cc81d727", + "permissions": "本地存储空间" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y", + "alipay": "y" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-android": "y", + "app-ios": "y", + "app-harmony": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/readme-npm.md b/uni_modules/TencentCloud-Push/readme-npm.md new file mode 100644 index 00000000..e3cba80a --- /dev/null +++ b/uni_modules/TencentCloud-Push/readme-npm.md @@ -0,0 +1,299 @@ +# TencentCloud-Push + +## 简介 + +使用 uts 开发,基于腾讯云推送服务(Push),支持 iOS 和 Android 推送,同时适配各大厂商推送。 + +腾讯云推送服务(Push)提供一站式 App 推送解决方案,助您轻松提升用户留存和互动活跃度,支持与腾讯云即时通信 IM SDK、实时音视频 TRTC SDK、音视频通话 SDK、直播 SDK等音视频终端产品协同集成,在不同场景联合使用,提升业务整体功能体验。 + + + + + +#### 数据可视化,辅助运营策略 + + + +#### 支持推送消息全链路问题排查 + + + +#### 六地服务部署,严守数据安全 + +提供了中国、东南亚(新加坡、印尼雅加达)、东北亚(韩国首尔)、欧洲(德国法兰克福)以及北美(美国硅谷)数据存储中心供选择,每个数据中心均支持全球接入。如果您的应用在境外上线且用户主要在境外,您可以根据消息传输需求及合规要求,选择适合您业务的境外数据中心,保障您的数据安全。 + + +## 快速跑通 + +### 步骤1:创建应用 + +进入 [控制台](https://console.cloud.tencent.com/im) ,单击创建应用,填写应用名称,选择数据中心,单击确定,完成应用创建。 + +![](https://qcloudimg.tencent-cloud.cn/image/document/e2761226f7d2bbdfb0a301192316c7d3.png) + +### 步骤2:开通推送服务 Push + +进入 [推送服务 Push](https://console.cloud.tencent.com/im/push-plugin-push-identifier),单击立即购买或免费试用 。(每个应用可免费试用一次,有效期7天) + +![](https://qcloudimg.tencent-cloud.cn/image/document/a7e1f3847c91a807ec9be3a586f1290f.png) + +### 步骤3:下载腾讯云推送服务(Push)并复制 Push SDK 到您的项目中 + +1. 下载腾讯云推送服务(Push)。 +``` +npm install @tencentcloud/uni-app-push +``` + +2. 复制 Push SDK 到您的项目中。 + +【macOS 端】 + +``` bash +mkdir -p ./uni_modules/TencentCloud-Push && rsync -av ./node_modules/@tencentcloud/uni-app-push/ ./uni_modules/TencentCloud-Push +``` +【Window 端】 + +``` bash +xcopy .\node_modules\@tencentcloud\uni-app-push .\uni_modules\TencentCloud-Push /i /e +``` + +### 步骤4:在 App.vue 中引入并注册腾讯云推送服务(Push) + +将 SDKAppID 和 appKey 替换为您在IM 控制台 - 推送服务 Push - 接入设置页面 获取的应用的信息。如图所示: + +![](https://sdk-web-1252463788.cos.ap-hongkong.myqcloud.com/im/assets/push/push.png) + +```ts +// 集成 TencentCloud-Push +import * as Push from '@/uni_modules/TencentCloud-Push'; +const SDKAppID = 0; // 您的 SDKAppID +const appKey = ''; // 客户端密钥 +Push.registerPush(SDKAppID, appKey, (data) => { + console.log('registerPush ok', data); + Push.getRegistrationID((registrationID) => { + console.log('getRegistrationID ok', registrationID); + }); + }, (errCode, errMsg) => { + console.error('registerPush failed', errCode, errMsg); + } +); + +// 监听通知栏点击事件,获取推送扩展信息 +Push.addPushListener(Push.EVENT.NOTIFICATION_CLICKED, (res) => { + // res 为推送扩展信息 + console.log('notification clicked', res); +}); + +// 监听在线推送 +Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, (res) => { + // res 为消息内容 + console.log('message received', res); +}); + +// 监听在线推送被撤回 +Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, (res) => { + // res 为被撤回的消息 ID + console.log('message revoked', res); +}); +``` + +### 步骤5:测试推送(测试前请务必打开手机通知权限,允许应用通知。) + +单击 HBuilderX 的 【运行 > 运行到手机或模拟器 > 制作自定义调试基座】,使用云端证书制作 Android 或 iOS 自定义调试基座。 + +![](https://qcloudimg.tencent-cloud.cn/image/document/742b7c05364e8ff9a16d5d5601aa038b.png) + +自定义调试基座打好后,安装到手机运行。 + +[登录](https://console.cloud.tencent.com/im/push-plugin-push-check) 控制台,使用测试工具进行在线推送测试。 +![](https://sdk-web-1252463788.cos.ap-hongkong.myqcloud.com/im/assets/push/test-online-push.png) + +## 厂商推送配置 +> - 请注意!HBuilderX 4.36 发布了不向下兼容的更新,如果您使用的是 HBuilderX 4.36 或者更高版本,且需要 vivo/荣耀 的厂商推送, +请升级推送版本到 1.1.0 或更高版本,并参考文档正确配置 `manifestPlaceholders.json` 和 `mcs-services.json`。 +> - 请在 `nativeResources` 目录下进行推送配置。若项目根目录尚未创建该文件夹,请新建一个名为 `nativeResources` 的文件夹。 +> - 离线推送厂商配置完成后,需要打包自定义基座。参考:[[快速跑通]>[步骤5:测试推送(测试前请务必打开手机通知权限,允许应用通知。)]](#user-content-step5) + +### 【Android】 + +1. 新建 nativeResources/android/assets 目录。 + +2. 在 [推送服务 Push > 接入设置 > 一键式快速配置](https://console.cloud.tencent.com/im/push-plugin-push-identifier) 下载 `timpush-configs.json` 文件,配置到 nativeResources/android/assets 目录下。 + +3. For 华为: + + 配置 `agconnect-services.json` (此文件获取详见 [厂商配置 > uniapp > 华为 > 步骤4:获取应用信息](https://cloud.tencent.com/document/product/269/103769))到 nativeResources/android 目录下。 + +4. For Google FCM: + + 4.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `project.plugins`,添加 `"com.google.gms.google-services"`,如下: + ``` + { + ... + "project": { + "plugins": [ + ... + "com.google.gms.google-services" + ] + } + } + ``` + + 4.2. 配置 `google-services.json` 文件到 nativeResources/android/ 目录。 + +5. For 荣耀: + + 5.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `dependencies`,添加 `"com.tencent.timpush:honor:8.3.6498"`,如下: + ``` + { + ... + "dependencies": [ + ... + "com.tencent.timpush:honor:8.3.6498" + ] + } + ``` + + 5.2. 配置 `mcs-services.json` 文件到 nativeResources/android 目录下。 + + 5.3. 配置 `appID` 到 nativeResources/android/manifestPlaceholders.json 中的 `"HONOR_APPID"`,如下: + ``` + { + "HONOR_APPID": "" + } + ``` + +6. For vivo: + + 6.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `dependencies`,添加 `"com.tencent.timpush:vivo:8.3.6498"`,如下: + ``` + { + ... + "dependencies": [ + ... + "com.tencent.timpush:vivo:8.3.6498" + ] + } + ``` + + 6.2. 配置 `appID` 和 `appKey` 到 nativeResources/android/manifestPlaceholders.json 中的 `VIVO_APPKEY` 和 `VIVO_APPID`,如下: + ``` + { + "VIVO_APPKEY": "", + "VIVO_APPID": "", + } + ``` + +### 【iOS】 + +1. 新建 nativeResources/ios/Resources 目录。 + +2. 在 nativeResources/ios/Resources 中**新建 timpush-configs.json 文件**。 + +3. 并将在 [IM控制台 > 推送服务 Push > 接入设置](https://console.cloud.tencent.com/im/push-plugin-push-identifier) 获取的证书ID,补充到 timpush-configs.json 文件中。 + + ``` + { + "businessID":"xxx" + } + ``` + +## 接口 + +| API | 描述| +|----|---| +| registerPush | 注册推送服务 (必须在 App 用户同意了隐私政策,并且允许为 App 用户提供推送服务后,再调用该接口使用推送服务)。
首次注册成功后,TencentCloud-Push SDK 生成该设备的标识 - RegistrationID。
业务侧可以把这个 RegistrationID 保存到业务服务器。业务侧根据 RegistrationID 向设备推送消息或者通知。| +| unRegisterPush | 反注册关闭推送服务。| +| setRegistrationID | 设置注册推送服务使用的推送 ID 标识,即 RegistrationID。
如果业务侧期望业务账号 ID 和推送 ID 一致,方便使用,可使用此接口,此时需注意,此接口需在 registerPush(注册推送服务)之前调用。| +| getRegistrationID | 注册推送服务成功后,获取推送 ID 标识,即 RegistrationID。| +| getNotificationExtInfo | 获取推送扩展信息。| +| getNotificationExtInfo | 收到离线推送时,点击通知栏拉起 app,调用此接口可获取推送扩展信息。| +| addPushListener | 添加 Push 监听器。| +| removePushListener | 移除 Push 监听器。| +| disablePostNotificationInForeground | 应用在前台时,开/关通知栏通知。| +| createNotificationChannel | 创建客户端通知 channel。| + + +```ts +registerPush(SDKAppID: number, appKey: string, onSuccess: (data: string) => void, onError?: (errCode: number, errMsg: string) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|SDKAppID|number|是|推送(Push)应用 ID| +|appKey|string|是|推送(Push)应用客户端密钥| +|onSuccess|function|是|接口调用成功的回调函数| +|onError|function|否|接口调用失败的回调函数| + +```ts +unRegisterPush(onSuccess: () => void, onError?: (errCode: number, errMsg: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| +|onError|function|否|接口调用失败的回调函数| + +```ts +setRegistrationID(registrationID: string, onSuccess: () => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|registrationID|string|是|设备的推送标识 ID,卸载重装会改变。| +|onSuccess|function|是|接口调用成功的回调函数| + + +```ts +getRegistrationID(onSuccess: (registrationID: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| + +```ts +getNotificationExtInfo(onSuccess: (extInfo: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| + +```ts +addPushListener(eventName: string, listener: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|eventName|string|是|推送事件类型| +|listener|function|是|推送事件处理方法| + +```ts +removePushListener(eventName: string, listener?: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|eventName|string|是|推送事件类型| +|listener|function|否|推送事件处理方法| + +```ts +disablePostNotificationInForeground(disable: boolean); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|disable|boolean|是|应用在前台时,开/关通知栏通知,默认开
- true: 应用在前台时,关闭通知栏通知。
- false: 应用在前台时,开启通知栏通知。| + +```ts +createNotificationChannel(options: any, listener: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|options.channelID|string|是|自定义 channel 的 ID| +|options.channelName|string|是|自定义 channel 的名称| +|options.channelDesc|string|否|自定义 channel 的描述| +|options.channelSound|string|否|自定义 channel 的铃音,音频文件名,不带后缀,音频文件需要放到 xxx/nativeResources/android/res/raw 中。
例如:
`options.channelSound = private_ring`,即设置 `xxx/nativeResources/android/res/raw/private_ring.mp3` 为自定义铃音| +|listener|function|是|接口调用成功的回调函数| diff --git a/uni_modules/TencentCloud-Push/readme.md b/uni_modules/TencentCloud-Push/readme.md new file mode 100644 index 00000000..f49324ed --- /dev/null +++ b/uni_modules/TencentCloud-Push/readme.md @@ -0,0 +1,285 @@ +# TencentCloud-Push + +## 简介 + +使用 uts 开发,基于腾讯云推送服务(Push),支持 iOS 和 Android 推送,同时适配各大厂商推送。 + +腾讯云推送服务(Push)提供一站式 App 推送解决方案,助您轻松提升用户留存和互动活跃度,支持与腾讯云即时通信 IM SDK、实时音视频 TRTC SDK、音视频通话 SDK、直播 SDK等音视频终端产品协同集成,在不同场景联合使用,提升业务整体功能体验。 + + + + + +#### 数据可视化,辅助运营策略 + + + +#### 支持推送消息全链路问题排查 + + + +#### 六地服务部署,严守数据安全 + +提供了中国、东南亚(新加坡、印尼雅加达)、东北亚(韩国首尔)、欧洲(德国法兰克福)以及北美(美国硅谷)数据存储中心供选择,每个数据中心均支持全球接入。如果您的应用在境外上线且用户主要在境外,您可以根据消息传输需求及合规要求,选择适合您业务的境外数据中心,保障您的数据安全。 + + +## 快速跑通 + +### 步骤1:创建应用 + +进入 [控制台](https://console.cloud.tencent.com/im) ,单击创建应用,填写应用名称,选择数据中心,单击确定,完成应用创建。 + +![](https://qcloudimg.tencent-cloud.cn/image/document/e2761226f7d2bbdfb0a301192316c7d3.png) + +### 步骤2:开通推送服务 Push + +进入 [推送服务 Push](https://console.cloud.tencent.com/im/push-plugin-push-identifier),单击立即购买或免费试用 。(每个应用可免费试用一次,有效期7天) + +![](https://qcloudimg.tencent-cloud.cn/image/document/a7e1f3847c91a807ec9be3a586f1290f.png) + +### 步骤3:将 [uni-app 腾讯云推送服务(Push)](https://ext.dcloud.net.cn/plugin?id=20169)插件导入 HbuilderX 中的工程。如图所示: + +![](https://qcloudimg.tencent-cloud.cn/image/document/ab8061fea2bf6659f571c2c11aa0d8f4.png) +![](https://qcloudimg.tencent-cloud.cn/image/document/13a3e33564e6ab79d3e609b36e8ba0d5.png) +![](https://qcloudimg.tencent-cloud.cn/image/document/3c7060f9db637c826009926c5f34a1b8.png) + +### 步骤4:在 App.vue 中引入并注册腾讯云推送服务(Push) + +将 SDKAppID 和 appKey 替换为您在IM 控制台 - 推送服务 Push - 接入设置页面 获取的应用的信息。如图所示: + +![](https://sdk-web-1252463788.cos.ap-hongkong.myqcloud.com/im/assets/push/push.png) + +```ts +// 集成 TencentCloud-Push +import * as Push from '@/uni_modules/TencentCloud-Push'; +const SDKAppID = 0; // 您的 SDKAppID +const appKey = ''; // 客户端密钥 +Push.registerPush(SDKAppID, appKey, (data) => { + console.log('registerPush ok', data); + Push.getRegistrationID((registrationID) => { + console.log('getRegistrationID ok', registrationID); + }); + }, (errCode, errMsg) => { + console.error('registerPush failed', errCode, errMsg); + } +); + +// 监听通知栏点击事件,获取推送扩展信息 +Push.addPushListener(Push.EVENT.NOTIFICATION_CLICKED, (res) => { + // res 为推送扩展信息 + console.log('notification clicked', res); +}); + +// 监听在线推送 +Push.addPushListener(Push.EVENT.MESSAGE_RECEIVED, (res) => { + // res 为消息内容 + console.log('message received', res); +}); + +// 监听在线推送被撤回 +Push.addPushListener(Push.EVENT.MESSAGE_REVOKED, (res) => { + // res 为被撤回的消息 ID + console.log('message revoked', res); +}); +``` + +### 步骤5:测试推送(测试前请务必打开手机通知权限,允许应用通知。) + +单击 HBuilderX 的 【运行 > 运行到手机或模拟器 > 制作自定义调试基座】,使用云端证书制作 Android 或 iOS 自定义调试基座。 + +![](https://qcloudimg.tencent-cloud.cn/image/document/742b7c05364e8ff9a16d5d5601aa038b.png) + +自定义调试基座打好后,安装到手机运行。 + +[登录](https://console.cloud.tencent.com/im/push-plugin-push-check) 控制台,使用测试工具进行在线推送测试。 +![](https://sdk-web-1252463788.cos.ap-hongkong.myqcloud.com/im/assets/push/test-online-push.png) + + +## 厂商推送配置 + +> - 请注意!HBuilderX 4.36 发布了不向下兼容的更新,如果您使用的是 HBuilderX 4.36 或者更高版本,且需要 vivo/荣耀 的厂商推送, +请升级推送版本到 1.1.0 或更高版本,并参考文档正确配置 `manifestPlaceholders.json` 和 `mcs-services.json`。 +> - 请在 `nativeResources` 目录下进行推送配置。若项目根目录尚未创建该文件夹,请新建一个名为 `nativeResources` 的文件夹。 +> - 厂商推送配置完成后,需要打包自定义基座。参考:[[快速跑通]>[步骤5:测试推送(测试前请务必打开手机通知权限,允许应用通知。)]](#step5) + +#### 【Android】 + +1. 新建 nativeResources/android/assets 目录。 + +2. 在 [推送服务 Push > 接入设置 > 一键式快速配置](https://console.cloud.tencent.com/im/push-plugin-push-identifier) 下载 `timpush-configs.json` 文件,配置到 nativeResources/android/assets 目录下。 + +3. For 华为: + + 配置 `agconnect-services.json` (此文件获取详见 [厂商配置 > uniapp > 华为 > 步骤4:获取应用信息](https://cloud.tencent.com/document/product/269/103769))到 nativeResources/android 目录下。 + +4. For Google FCM: + + 4.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `project.plugins`,添加 `"com.google.gms.google-services"`,如下: + ``` + { + ... + "project": { + "plugins": [ + ... + "com.google.gms.google-services" + ] + } + } + ``` + + 4.2. 配置 `google-services.json` 文件到 nativeResources/android/ 目录。 + +5. For 荣耀: + + 5.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `dependencies`,添加 `"com.tencent.timpush:honor:8.3.6498"`,如下: + ``` + { + ... + "dependencies": [ + ... + "com.tencent.timpush:honor:8.3.6498" + ] + } + ``` + + 5.2. 配置 `mcs-services.json` 文件到 nativeResources/android 目录下。 + + 5.3. 配置 `appID` 到 nativeResources/android/manifestPlaceholders.json 中的 `"HONOR_APPID"`,如下: + ``` + { + "HONOR_APPID": "" + } + ``` + +6. For vivo: + + 6.1. 编辑 uni_modules/TencentCloud-Push/utssdk/app-android/config.json 的 `dependencies`,添加 `"com.tencent.timpush:vivo:8.3.6498"`,如下: + ``` + { + ... + "dependencies": [ + ... + "com.tencent.timpush:vivo:8.3.6498" + ] + } + ``` + + 6.2. 配置 `appID` 和 `appKey` 到 nativeResources/android/manifestPlaceholders.json 中的 `VIVO_APPKEY` 和 `VIVO_APPID`,如下: + ``` + { + "VIVO_APPKEY": "", + "VIVO_APPID": "", + } + ``` + +#### 【iOS】 + +1. 新建 nativeResources/ios/Resources 目录。 + +2. 在 nativeResources/ios/Resources 目录下新建 `timpush-configs.json` 文件。 + +3. 将在 [IM控制台 > 推送服务 Push > 接入设置](https://console.cloud.tencent.com/im/push-plugin-push-identifier) 获取的证书ID,补充到 `timpush-configs.json` 文件中。 + + ``` + { + "businessID":"xxx" + } + ``` + +## 接口 + +| API | 描述| +|----|---| +| registerPush | 注册推送服务 (必须在 App 用户同意了隐私政策,并且允许为 App 用户提供推送服务后,再调用该接口使用推送服务)。
首次注册成功后,TencentCloud-Push SDK 生成该设备的标识 - RegistrationID。
业务侧可以把这个 RegistrationID 保存到业务服务器。业务侧根据 RegistrationID 向设备推送消息或者通知。| +| unRegisterPush | 反注册关闭推送服务。| +| setRegistrationID | 设置注册推送服务使用的推送 ID 标识,即 RegistrationID。
如果业务侧期望业务账号 ID 和推送 ID 一致,方便使用,可使用此接口,此时需注意,此接口需在 registerPush(注册推送服务)之前调用。| +| getRegistrationID | 注册推送服务成功后,获取推送 ID 标识,即 RegistrationID。| +| getNotificationExtInfo | 收到离线推送时,点击通知栏拉起 app,调用此接口可获取推送扩展信息。| +| addPushListener | 添加 Push 监听器。| +| removePushListener | 移除 Push 监听器。| +| disablePostNotificationInForeground | 应用在前台时,开/关通知栏通知(默认开)。| +| createNotificationChannel | 创建客户端通知 channel。| + +```ts +registerPush(SDKAppID: number, appKey: string, onSuccess: (data: string) => void, onError?: (errCode: number, errMsg: string) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|SDKAppID|number|是|推送(Push)应用 ID| +|appKey|string|是|推送(Push)应用客户端密钥| +|onSuccess|function|是|接口调用成功的回调函数| +|onError|function|否|接口调用失败的回调函数| + +```ts +unRegisterPush(onSuccess: () => void, onError?: (errCode: number, errMsg: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| +|onError|function|否|接口调用失败的回调函数| + +```ts +setRegistrationID(registrationID: string, onSuccess: () => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|registrationID|string|是|设备的推送标识 ID,卸载重装会改变。| +|onSuccess|function|是|接口调用成功的回调函数| + + +```ts +getRegistrationID(onSuccess: (registrationID: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| + +```ts +getNotificationExtInfo(onSuccess: (extInfo: string) => void): void; +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|onSuccess|function|是|接口调用成功的回调函数| + +```ts +addPushListener(eventName: string, listener: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|eventName|string|是|推送事件类型| +|listener|function|是|推送事件处理方法| + +```ts +removePushListener(eventName: string, listener?: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|eventName|string|是|推送事件类型| +|listener|function|否|推送事件处理方法| + +```ts +disablePostNotificationInForeground(disable: boolean); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|disable|boolean|是|应用在前台时,开/关通知栏通知,默认开
- true: 应用在前台时,关闭通知栏通知。
- false: 应用在前台时,开启通知栏通知。| + +```ts +createNotificationChannel(options: any, listener: (data: any) => void); +``` + +|属性|类型|必填|说明| +|----|---|----|----| +|options.channelID|string|是|自定义 channel 的 ID| +|options.channelName|string|是|自定义 channel 的名称| +|options.channelDesc|string|否|自定义 channel 的描述| +|options.channelSound|string|否|自定义 channel 的铃音,音频文件名,不带后缀,音频文件需要放到 xxx/nativeResources/android/res/raw 中。
例如:
`options.channelSound = private_ring`,即设置 `xxx/nativeResources/android/res/raw/private_ring.mp3` 为自定义铃音| +|listener|function|是|接口调用成功的回调函数| diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/config.json b/uni_modules/TencentCloud-Push/utssdk/app-android/config.json new file mode 100644 index 00000000..ff8cfffd --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/config.json @@ -0,0 +1,29 @@ +{ + "minSdkVersion": "21", + "dependencies": [ + "com.google.android.material:material:1.3.0", + "com.google.code.gson:gson:2.9.1", + "commons-codec:commons-codec:1.15", + "com.github.bumptech.glide:glide:4.12.0", + "com.tencent.timpush:timpush:8.5.6864", + "com.tencent.liteav.tuikit:tuicore:8.5.6864", + "com.tencent.timpush:huawei:8.5.6864", + "com.tencent.timpush:xiaomi:8.5.6864", + "com.tencent.timpush:oppo:8.5.6864", + "com.tencent.timpush:meizu:8.5.6864", + "com.tencent.timpush:fcm:8.5.6864", + "com.tencent.timpush:honor:8.5.6864", + "com.tencent.timpush:vivo:8.5.6864" + ], + "project": { + "plugins": [ + "com.huawei.agconnect", + "com.hihonor.mcs.asplugin" + ], + "dependencies": [ + "com.huawei.agconnect:agcp:1.9.1.301", + "com.google.gms:google-services:4.3.15", + "com.hihonor.mcs:asplugin:2.0.1.300" + ] + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/index.uts b/uni_modules/TencentCloud-Push/utssdk/app-android/index.uts new file mode 100644 index 00000000..ebba8512 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/index.uts @@ -0,0 +1,152 @@ +import { UTSAndroid } from 'io.dcloud.uts'; +import Context from 'android.content.Context'; +import TIMPushManager from 'com.tencent.qcloud.tim.push.TIMPushManager'; +import TIMPushConfig from 'com.tencent.qcloud.tim.push.config.TIMPushConfig'; +import { PushCallbackOptions } from './push-callback-options.uts'; +import { PushListenerOptions } from './push-listener-options.uts'; +import PushCallback from './push-callback.uts'; +import PushListener from './push-listener.uts'; + +const context: Context | null = UTSAndroid.getAppContext(); +console.warn('Push | package.name:', context?.getPackageName()); +TIMPushConfig.getInstance().setRunningPlatform(2); +const Push = TIMPushManager.getInstance(); + +export class EVENT { + static MESSAGE_RECEIVED: string = 'message_received' + static MESSAGE_REVOKED: string = 'message_revoked' + static NOTIFICATION_CLICKED: string = 'notification_clicked' +} + +let disableNotification = false; +export function disablePostNotificationInForeground(disable: boolean): void { + console.log('Push | disablePostNotificationInForeground', disable); + disableNotification = disable; + Push.disablePostNotificationInForeground(disableNotification); +} + +export function registerPush(SDKAppID: number, appKey: string, onSuccess: (data: string) => void, onError?: (errCode: number, errMsg: string) => void): void { + if (SDKAppID == 0) { + onError?.(9010001, 'Invalid SDKAppID'); + } else if (appKey == '') { + onError?.(9010002, 'Invalid appKey'); + } + const pushCbOptions: PushCallbackOptions = { + apiName: 'registerPush', + success: (res?: any) => { + Push.disablePostNotificationInForeground(disableNotification); + // 强转下类型,避免类型推断错误 + let token: string = res as string; + onSuccess(token); + }, + fail: (errCode: number, errMsg: string) => { + onError?.(errCode, errMsg); + } + }; + // 注意!!! 这里不要写成 new PushCallback({ api, success, fail }),否则会因类型推断不一致导致编译错误 + Push.registerPush(context, SDKAppID.toInt(), appKey, new PushCallback(pushCbOptions)); +} + +export function setRegistrationID(registrationID: string, onSuccess: () => void): void { + const pushCbOptions: PushCallbackOptions = { + apiName: 'setRegistrationID', + success: (res?: any) => { + onSuccess(); + }, + fail: (errCode: number, errMsg: string) => { + // 空实现 + } + }; + // 注意!!! 这里不要写成 new PushCallback({ api, success, fail }),否则会因类型推断不一致导致编译错误 + Push.setRegistrationID(registrationID, new PushCallback(pushCbOptions)); +} + +export function getRegistrationID(onSuccess: (registrationID: string) => void): void { + const pushCbOptions: PushCallbackOptions = { + apiName: 'getRegistrationID', + success: (res?: any) => { + // 强转下类型,避免类型推断错误 + let registrationID: string = res as string; + onSuccess(registrationID); + }, + fail: (errCode: number, errMsg: string) => { + // 空实现 + } + }; + // 注意!!! 这里不要写成 new PushCallback({ api, success, fail }),否则会因类型推断不一致导致编译错误 + Push.getRegistrationID(new PushCallback(pushCbOptions)); +} + +export function unRegisterPush(onSuccess: () => void, onError?: (errCode: number, errMsg: string) => void): void { + const pushCbOptions: PushCallbackOptions = { + apiName: 'unRegisterPush', + success: (res?: any) => { + onSuccess(); + }, + fail: (errCode: number, errMsg: string) => { + // 空实现 + }, + }; + // 注意!!! 这里不要写成 new PushCallback({ api, success, fail }),否则会因类型推断不一致导致编译错误 + Push.unRegisterPush(new PushCallback(pushCbOptions)); +} + +export function createNotificationChannel(options: any, onSuccess: (extInfo: string) => void): void { + const pushCbOptions: PushCallbackOptions = { + apiName: 'createNotificationChannel', + success: (res?: any) => { + let ret: string = res as string; + onSuccess(ret); + }, + fail: (errCode: number, errMsg: string) => { + // 空实现 + }, + }; + Push.callExperimentalAPI('createNotificationChannel', JSON.stringify(options), new PushCallback(pushCbOptions)); +} + +export function getNotificationExtInfo(onSuccess: (extInfo: string) => void): void { + const pushCbOptions: PushCallbackOptions = { + apiName: 'getNotificationExtInfo', + success: (res?: any) => { + let ret: string = res as string; + onSuccess(ret); + }, + fail: (errCode: number, errMsg: string) => { + // 空实现 + }, + }; + Push.callExperimentalAPI('getNotificationExtInfo', null, new PushCallback(pushCbOptions)); +} + +const listenerMap = new Map void>>(); + +const pushListenerOptions: PushListenerOptions = { + listener: (eventName: string, data: any) => { + listenerMap.get(eventName)?.forEach(item => { + item(data); + }); + }, +}; + +const pushListener = new PushListener(pushListenerOptions); + +@UTSJS.keepAlive +export function addPushListener(eventName: string, listener: (res: any) => void): void { + if(listenerMap.size === 0) { + Push.addPushListener(pushListener); + } + const listeners:Array<(res: any) => void> = [listener]; + listenerMap.get(eventName)?.forEach(item => { + listeners.push(item); + }) + listenerMap.set(eventName, listeners); +} + + +export function removePushListener(eventName: string, listener?: (res: any) => void): void { + listenerMap.delete(eventName); + if(listenerMap.size === 0) { + Push.removePushListener(pushListener); + } +} diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback-options.uts b/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback-options.uts new file mode 100644 index 00000000..ab6f7bf1 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback-options.uts @@ -0,0 +1,5 @@ +export type PushCallbackOptions = { + apiName: string + success: (res?: any) => void + fail: (errCode: number, errMsg: string) => void +} diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback.uts b/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback.uts new file mode 100644 index 00000000..32c9f572 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/push-callback.uts @@ -0,0 +1,28 @@ +import TIMPushCallback from 'com.tencent.qcloud.tim.push.TIMPushCallback'; +import { PushCallbackOptions } from './push-callback-options.uts'; + +const LOG_PREFIX: string = 'Push |'; +export default class PushCallback implements TIMPushCallback { + private apiName: string; + private success: (data?: any) => void; + private fail: (errCode: number, errMsg: string) => void; + + constructor(options: PushCallbackOptions) { + this.apiName = options.apiName; + this.success = options.success; + this.fail = options.fail; + } + + override onSuccess(data?: any) { + console.log(`${LOG_PREFIX} ${this.apiName} ok, data:`, data); + if (data == null) { + this.success?.(''); + } else { + this.success?.(data); + } + } + + override onError(errCode: Int, errMsg: string, data?: any) { + this.fail?.(errCode as number, errMsg); + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener-options.uts b/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener-options.uts new file mode 100644 index 00000000..a155ba25 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener-options.uts @@ -0,0 +1,3 @@ +export type PushListenerOptions = { + listener: (eventType: string, data: any) => void +} diff --git a/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener.uts b/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener.uts new file mode 100644 index 00000000..5c39c248 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-android/push-listener.uts @@ -0,0 +1,25 @@ +import TIMPushListener from 'com.tencent.qcloud.tim.push.TIMPushListener'; +import TIMPushMessage from 'com.tencent.qcloud.tim.push.TIMPushMessage'; +import { PushListenerOptions } from './push-listener-options.uts'; + +const LOG_PREFIX: string = 'Push | PushListener'; +export default class PushListener implements TIMPushListener { + private listener: (eventType: string, data: any) => void; + + constructor(options: PushListenerOptions) { + this.listener = options.listener; + console.log(`${LOG_PREFIX} ok`); + } + + override onRecvPushMessage(message: TIMPushMessage) { + this.listener('message_received', { data: message }); + } + + override onRevokePushMessage(messageID: string) { + this.listener('message_revoked', { data: messageID }); + } + + override onNotificationClicked(ext: string) { + this.listener('notification_clicked', { data: ext }); + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/utssdk/app-ios/UTS.entitlements b/uni_modules/TencentCloud-Push/utssdk/app-ios/UTS.entitlements new file mode 100644 index 00000000..903def2a --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-ios/UTS.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/uni_modules/TencentCloud-Push/utssdk/app-ios/config.json b/uni_modules/TencentCloud-Push/utssdk/app-ios/config.json new file mode 100644 index 00000000..f4b471db --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-ios/config.json @@ -0,0 +1,11 @@ +{ + "deploymentTarget": "9.0", + "dependencies-pods": [ + { + "name": "TXIMSDK_Plus_iOS_XCFramework", + "version": "8.5.6864" + }, { + "name": "TIMPush", + "version": "8.5.6864" + }] +} diff --git a/uni_modules/TencentCloud-Push/utssdk/app-ios/index.uts b/uni_modules/TencentCloud-Push/utssdk/app-ios/index.uts new file mode 100644 index 00000000..0d58ad2f --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-ios/index.uts @@ -0,0 +1,125 @@ +import { TIMPushManager } from "TIMPush" +import { NSObject } from "DCloudUTSFoundation" +import PushListener from './push-listener.uts' +import { PushListenerOptions } from './push-listener-options.uts' + +const LOG_PREFIX = 'Push |'; + +export class EVENT { + static MESSAGE_RECEIVED: string = 'message_received' + static MESSAGE_REVOKED: string = 'message_revoked' + static NOTIFICATION_CLICKED: string = 'notification_clicked' +} + +function setRunningPlatform(): void { + console.log(LOG_PREFIX, 'setRunningPlatform'); + const param = new NSString("{\"runningPlatform\":2}"); + TIMPushManager.callExperimentalAPI('setPushConfig', param = param, succ = (ext?: NSObject): void => { + let platform: string = ext as string; + console.log(LOG_PREFIX, 'setRunningPlatform ok. platform:', platform); + }, fail = (code?: Int32 ,desc?:String): void => { + console.log(LOG_PREFIX, `setRunningPlatform fail. code: ${code}, desc: ${desc}`); + } + ); +} + +let disableNotification = false; + +export function disablePostNotificationInForeground(_disable: boolean): void { + console.log(LOG_PREFIX, 'disablePostNotificationInForeground', _disable); + disableNotification = _disable; + TIMPushManager.disablePostNotificationInForeground(disable = disableNotification); +} + +export function registerPush(SDKAppID: number, appKey: string, onSuccess: (data: string) => void, onError?: (errCode: number, errMsg: string) => void): void { + if (SDKAppID == 0) { + onError?.(9010001, 'Invalid SDKAppID'); + } else if (appKey == '') { + onError?.(9010002, 'Invalid appKey'); + } + setRunningPlatform(); + TIMPushManager.registerPush(SDKAppID.toInt32(), appKey = appKey, succ = (deviceToken?: Data): void => { + TIMPushManager.disablePostNotificationInForeground(disable = disableNotification); + console.log('devicetoken ->', deviceToken, deviceToken?.count); + onSuccess(''); + }, fail = (code?: Int32 ,desc?:String): void => { + onError?.(code as number, desc as string); + } + ); +} + +export function unRegisterPush(onSuccess: () => void, onError: (errCode: number, errMsg: string) => void): void { + TIMPushManager.unRegisterPush((): void => { + onSuccess(); + }, fail = (code?: Int32 ,desc?:String): void => { + onError(code as number, desc as string); + } + ); +} + +export function setRegistrationID(registrationID: string, onSuccess: () => void): void { + console.log(LOG_PREFIX, 'setRegistrationID', `registrationID:${registrationID}`); + TIMPushManager.setRegistrationID(registrationID, callback = (): void => { + console.log(LOG_PREFIX, 'setRegistrationID ok'); + onSuccess(); + }); +} + +export function getRegistrationID(onSuccess: (registrationID: string) => void): void { + TIMPushManager.getRegistrationID((value ?: string): void => { + // 这里需要转一下,否则会有问题 + let ret: string = value as string; + onSuccess(ret); + }); +} + +export function createNotificationChannel(options: any, onSuccess: (data: string) => void): void { + // 空实现 +} + +// 注意!!!这里的 extInfo 不能写成 ext,否则会跟内部的 ext?:NSObject 有冲突;也不能写成 extension,否则会导致编译错误 +export function getNotificationExtInfo(onSuccess: (extInfo: string) => void): void { + console.log(LOG_PREFIX, 'getNotificationExtInfo'); + TIMPushManager.callExperimentalAPI('getNotificationExtInfo', param = {}, succ = (ext?: NSObject): void => { + let str: string = ext as string; + console.log(LOG_PREFIX, 'getNotificationExtInfo ok. ext:', str); + onSuccess(str); + }, fail = (code?: Int32 ,desc?:String): void => { + // 空实现 + } + ); +} + + +const listenerMap = new Map void>>(); + +const pushListenerOptions: PushListenerOptions = { + listener: (eventName: string, data: any) => { + listenerMap.get(eventName)?.forEach(item => { + item(data); + }); + }, +}; + +const pushListener = new PushListener(pushListenerOptions); + +@UTSJS.keepAlive +export function addPushListener(eventName: string, _listener: (res: any) => void): void { + console.log(LOG_PREFIX, 'addPushListener', eventName); + if(listenerMap.size === 0) { + TIMPushManager.addPushListener(listener = pushListener); + } + const listeners:Array<(res: any) => void> = [_listener]; + listenerMap.get(eventName)?.forEach(item => { + listeners.push(item); + }) + listenerMap.set(eventName, listeners); +} + +export function removePushListener(eventName: string, _listener?: (res: any) => void): void { + console.log(LOG_PREFIX, 'removePushListener', eventName); + listenerMap.delete(eventName); + if(listenerMap.size === 0) { + TIMPushManager.removePushListener(listener = pushListener); + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener-options.uts b/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener-options.uts new file mode 100644 index 00000000..db8c8ffa --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener-options.uts @@ -0,0 +1,3 @@ +export type PushListenerOptions = { + listener: (eventType: string, data: any) => void +} diff --git a/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener.uts b/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener.uts new file mode 100644 index 00000000..5e87c347 --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/app-ios/push-listener.uts @@ -0,0 +1,24 @@ +import { TIMPushListener, TIMPushMessage} from "TIMPush" +import { PushListenerOptions } from './push-listener-options.uts'; + +const LOG_PREFIX: string = 'Push | PushListener'; +export default class PushListener implements TIMPushListener { + private listener: (eventType: string, data: any) => void; + + constructor(options: PushListenerOptions) { + this.listener = options.listener; + console.log(`${LOG_PREFIX} ok`); + } + + onRecvPushMessage(message: TIMPushMessage) { + this.listener('message_received', { data: message }); + } + + onRevokePushMessage(messageID: string) { + this.listener('message_revoked', { data: messageID }); + } + + onNotificationClicked(ext: string) { + this.listener('notification_clicked', { data: ext }); + } +} \ No newline at end of file diff --git a/uni_modules/TencentCloud-Push/utssdk/interface.uts b/uni_modules/TencentCloud-Push/utssdk/interface.uts new file mode 100644 index 00000000..ecf8da4b --- /dev/null +++ b/uni_modules/TencentCloud-Push/utssdk/interface.uts @@ -0,0 +1,11 @@ +interface Push { + setRegistrationID(registrationID: string, onSuccess: () => void): void, + registerPush(SDKAppID: number, appKey: string, onSuccess: (data: string) => void, onError?: (errCode: number, errMsg: string) => void): void, + getRegistrationID(onSuccess: (registrationID: string) => void): void, + unRegisterPush(onSuccess: () => void, onError?: (errCode: number, errMsg: string) => void): void, + getNotificationExtInfo(onSuccess: (extInfo: string) => void): void + addPushListener(eventName: string, listener: (res: any) => void): void + removePushListener(eventName: string, listener?: (res: any) => void): void + disablePostNotificationInForeground(disable: boolean): void + createNotificationChannel(options: any, onSuccess: (data: string) => void): void +} diff --git a/utils/request.js b/utils/request.js index 0e86b214..4c51c601 100644 --- a/utils/request.js +++ b/utils/request.js @@ -26,13 +26,13 @@ function cleanStorage() { storage.setRefreshToken(""); console.log("清空token"); storage.setUuid(""); - storage.setUserInfo({}); - // 清理vlog信息 - storage.setVlogToken("") - storage.setVlogUserInfo({}) - // 清除初始化数据内容 + storage.setUserInfo({}); + // 清理vlog信息 + storage.setVlogToken("") + storage.setVlogUserInfo(null) + // 清除初始化数据内容 storage.setRefreshVlogIndex('0') //不需要刷新 - + // 防抖处理跳转 // #ifdef MP-WEIXIN @@ -96,23 +96,23 @@ http.interceptors.request.use( config.header.accessToken = accessToken; } - // 配置vlog所需参数 - let vlogToken = storage.getVlogToken(); - let vlogId = storage.getVlogUserInfo(); - // console.log(vlogId) - // console.log(vlogToken) - if(vlogToken){ - config.header.headerUserToken = vlogToken; - config.header.headerUserId = vlogId.id; + // 配置vlog所需参数 + let vlogToken = storage.getVlogToken(); + let vlogId = storage.getVlogUserInfo(); + // console.log(vlogId) + // console.log(vlogToken) + if (vlogToken) { + config.header.headerUserToken = vlogToken; + config.header.headerUserId = vlogId.id; } config.header = { ...config.header, uuid: storage.getUuid() || uuid.v1(), - }; + }; // console.log(config) return config; }, - (config) => { + (config) => { return Promise.reject(config); } ); @@ -124,8 +124,8 @@ let isRefreshing = false; let requests = []; // 必须使用异步函数,注意 http.interceptors.response.use( - async (response) => { - // console.log(isRefreshing) + async (response) => { + // console.log(isRefreshing) // console.log(response) /* 请求之后拦截器。可以使用async await 做异步操作 */ // token存在并且token过期 @@ -194,9 +194,8 @@ http.interceptors.response.use( duration: 1500, }); } - } - else if (response.data.code==502){ - cleanStorage(); + } else if (response.data.code == 502) { + cleanStorage(); } return response; }, diff --git a/utils/tools.js b/utils/tools.js index 5b254718..06497172 100644 --- a/utils/tools.js +++ b/utils/tools.js @@ -95,16 +95,28 @@ const theNextDayTime = () => { }; const graceNumber = (number) => { + // if (number == 0) { + // return "0"; + // } else if (number > 999 && number <= 9999) { + // return (number / 1000).toFixed(1) + "k"; + // } else if (number > 9999 && number <= 99999) { + // return (number / 10000).toFixed(1) + "w"; + // } else if (number > 99999) { + // return "10w+"; + // } + // return number; if (number == 0) { return "0"; - } else if (number > 999 && number <= 9999) { - return (number / 1000).toFixed(1) + "k"; - } else if (number > 9999 && number <= 99999) { - return (number / 10000).toFixed(1) + "w"; - } else if (number > 99999) { - return "10w+"; } - return number; + if (number < 1000) { + return number.toString(); + } else if (number < 10000) { + return (number / 1000).toFixed(1).replace(/\.0$/, '') + "k"; + } else if (number < 100000000) { + return (number / 10000).toFixed(1).replace(/\.0$/, '') + "w"; + } else { + return (number / 100000000).toFixed(1).replace(/\.0$/, '') + "亿+"; + } } // 时间格式化时间为: 多少分钟前、多少天前 @@ -237,6 +249,6 @@ export { getDateBeforeNow, isStrEmpty, getAstro, - getAnimal, + getAnimal, dateFormat }; \ No newline at end of file diff --git a/vue.config.js b/vue.config.js index 0b0be2f1..7f91f533 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,35 +1,35 @@ -// const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default; - -module.exports = { - parallel: false, - configureWebpack: { - plugins: [ - // ScriptSetup({ - // /* options */ - // }), - ], - }, - chainWebpack(config) { - // disable type check and let `vue-tsc` handles it - config.plugins.delete('fork-ts-checker'); - }, -}; -// module.exports = { -// /** -// * 此处为发行h5,微信小程序,app中删除console -// * 如需显示console 需要注释此处重新运行 -// */ -// chainWebpack: (config) => { -// // 发行或运行时启用了压缩时会生效 -// config.optimization.minimizer('terser').tap((args) => { -// const compress = args[0].terserOptions.compress -// // 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...) -// compress.drop_console = true -// compress.pure_funcs = [ -// '__f__', // App 平台 vue 移除日志代码 -// // 'console.debug' // 可移除指定的 console 方法 -// ] -// return args -// }) -// } +const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default; + +module.exports = { + parallel: false, + configureWebpack: { + plugins: [ + ScriptSetup({ + /* options */ + }), + ], + }, + chainWebpack(config) { + // disable type check and let `vue-tsc` handles it + config.plugins.delete('fork-ts-checker'); + }, +}; +// module.exports = { +// /** +// * 此处为发行h5,微信小程序,app中删除console +// * 如需显示console 需要注释此处重新运行 +// */ +// chainWebpack: (config) => { +// // 发行或运行时启用了压缩时会生效 +// config.optimization.minimizer('terser').tap((args) => { +// const compress = args[0].terserOptions.compress +// // 非 App 平台移除 console 代码(包含所有 console 方法,如 log,debug,info...) +// compress.drop_console = true +// compress.pure_funcs = [ +// '__f__', // App 平台 vue 移除日志代码 +// // 'console.debug' // 可移除指定的 console 方法 +// ] +// return args +// }) +// } // } \ No newline at end of file