Explorar o código

fix: 修改bug

yezhihao hai 4 meses
pai
achega
7cb0bf8660
Modificáronse 7 ficheiros con 109 adicións e 63 borrados
  1. 60 26
      App.vue
  2. 1 1
      manifest.json
  3. 14 11
      pages/msg/im.vue
  4. 1 1
      pages/my/index.vue
  5. 4 3
      pages/my/myCompany.vue
  6. 22 20
      pages/my/setup.vue
  7. 7 1
      utils/login.js

+ 60 - 26
App.vue

@@ -1,6 +1,6 @@
 <script>
 export default {
-  onLaunch: function () {
+  onLaunch: function () {
 	uni.removeStorageSync('web_config')
 	// #ifdef APP-PLUS
 	// 初始化极光推送
@@ -626,39 +626,73 @@ export default {
 					if (res.notificationEventType == 'notificationOpened' && res.extras && res.extras.page) {
 						// tab页面
 						// /pages/index/index
-						// /pages/talentSearch/index
+						// /pages/talentSearch/index
 						// /pages/index/game/gameList
 						// /pages/msg/index
-						// /pages/my/index
-						const tabPages = [
-							'/pages/index/index',
-							'/pages/talentSearch/index',
-							'/pages/index/game/gameList',
-							'/pages/msg/index',
-							'/pages/my/index'
+						// /pages/my/index
+						const tabPages = [
+							'/pages/index/index',
+							'/pages/talentSearch/index',
+							'/pages/index/game/gameList',
+							'/pages/msg/index',
+							'/pages/my/index'
 						]
-						setTimeout(() => {
-							if (tabPages.includes(res.extras?.page)) {
-								uni.switchTab({
-									url: res.extras.page // 例如:/pages/detail/detail?id=123
-								})	
-							} else {
-								uni.navigateTo({
-									url: res.extras.page
-								})
+						setTimeout(() => {
+							if (tabPages.includes(res.extras?.page)) {
+								uni.switchTab({
+									url: res.extras.page // 例如:/pages/detail/detail?id=123
+								})	
+							} else {
+								uni.navigateTo({
+									url: res.extras.page
+								})
 							}					
 						}, 500)
 					}
 				})
+
+        const saveRid = (rid) => {
+          if (!rid) return false
+          this.$queue.setData('registerID', rid)
+          console.log('jpushModule registerID:', rid)
+          return true
+        }
+        const tryGetRid = (maxTry = 12) => {
+          let n = 0
+          const run = () => {
+            jpushModule.getRegistrationID((res) => {
+              console.log('获取设备ID', res)
+              // 不同版本字段名可能不同,这里做兼容
+              const rid = res?.registerID || res?.registrationID || res?.registrationId
+              if (res?.code === 0 && saveRid(rid)) return
+              n++
+              if (n >= maxTry) {
+                console.warn('jpushModule registerID empty after retry:', res)
+                return
+              }
+              setTimeout(run, 400 * n) // 递增重试
+            })
+          }
+          run()
+        }
+
+        jpushModule.addConnectEventListener && jpushModule.addConnectEventListener((result) => {
+          console.log('jpushModule connect:', result)
+          if (result.connectEnable) {
+            tryGetRid(12)
+          }
+        })
+
+        tryGetRid(12)
 				
-				jpushModule.getRegistrationID((res) => {
-					if (res.code === 0) {
-						console.log('获取设备ID', res)
-						this.$queue.setData('registerID', res?.registerID || '')
-					} else {
-						console.error('获取RegistrationID失败:', res)
-					}
-				})
+				// jpushModule.getRegistrationID((res) => {
+				// 	if (res.code === 0) {
+				// 		console.log('获取设备ID', res)
+				// 		this.$queue.setData('registerID', res?.registerID || '')
+				// 	} else {
+				// 		console.error('获取RegistrationID失败:', res)
+				// 	}
+				// })
 			}
 		},
 	}

+ 1 - 1
manifest.json

@@ -196,7 +196,7 @@
                 "JPUSH_GOOGLE_STORAGE_BUCKET" : "",
                 "JPUSH_HONOR_APPID" : "104533692",
                 "JPUSH_HUAWEI_APPID" : "116155907",
-                "JPUSH_ISPRODUCTION_IOS" : "",
+                "JPUSH_ISPRODUCTION_IOS" : "true",
                 "JPUSH_MEIZU_APPID" : "",
                 "JPUSH_MEIZU_APPKEY" : "",
                 "JPUSH_OPPO_APPID" : "36598376",

+ 14 - 11
pages/msg/im.vue

@@ -2400,7 +2400,8 @@
 					msg.length = min + ':' + sec;
 					console.log('msg.length___:' + msg.length)
 					uni.uploadFile({ // 上传接口
-						url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
+						// url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
+						url: this.$Request.config('APIHOST1') + '/alioss/upload', //真实的接口地址
 						filePath: e.tempFilePath,
 						name: 'file',
 						success: (uploadFileRes) => {
@@ -2556,7 +2557,7 @@
 				uni.connectSocket({
 					// url: 'wss://h5.youxb.icu/wss/sqx_fast/chatSocket/' + userId,
 					// url: this.config("WSHOST1") + userId,
-					url: configdata.WSHOST1 + '' + userId,
+					url: this.$Request.config('WSHOST1') + '' + userId,
 					// url: 'wss://h5.bosszan.com/wss/chatSocket/' + userId,
 					// url: 'ws://192.168.0.128:7152/sqx_fast/chatSocket/' + userId,
 					data() {
@@ -2608,14 +2609,15 @@
 					    showCancel: false,
 					    success() {
 						  // 退出极光推送
-						  logoutJP()
-							that.$queue.logout();
-							// #ifdef H5	
-							uni.reLaunch({ url: '/pages/public/loginphone?type=2' })
-							// #endif
-							// #ifndef H5
-							uni.reLaunch({ url: '/pages/public/loginV2' })
-							// #endif
+						  logoutJP(() => {
+							  that.$queue.logout();
+							  // #ifdef H5	
+							  uni.reLaunch({ url: '/pages/public/loginphone?type=2' })
+							  // #endif
+							  // #ifndef H5
+							  uni.reLaunch({ url: '/pages/public/loginV2' })
+							  // #endif
+						  })
 					    }
 					  })
 					}else{
@@ -2847,7 +2849,8 @@
 						for (let i = 0; i < res.tempFilePaths.length; i++) {
 							this.$queue.showLoading("上传中...");
 							uni.uploadFile({ // 上传接口
-								url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
+								// url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
+								url: this.$Request.config('APIHOST1') + '/alioss/upload',
 								filePath: res.tempFilePaths[i],
 								name: 'file',
 								success: (uploadFileRes) => {

+ 1 - 1
pages/my/index.vue

@@ -292,7 +292,7 @@
 											规则中心
 										</view>
 									</view>
-									<view v-if="iosAudit == 0" class="util-item"
+									<view v-if="iosAudit == 0 && showVipBanner" class="util-item"
 										@click="goNav('/pages/my/VIP/benefits')">
 										<image src="../../static/images/my/icon/utils/benefits.png"
 											style="width: 54rpx; height: 54rpx" mode=""></image>

+ 4 - 3
pages/my/myCompany.vue

@@ -438,9 +438,10 @@ export default {
 			})
 			setTimeout(() => {
 				// 退出极光推送
-				logoutJP()
-				this.$queue.toLogin()
-				this.$queue.logout()
+				logoutJP(() => {
+					this.$queue.toLogin()
+					this.$queue.logout()
+				})
 			}, 1500)
 		}
 	}

+ 22 - 20
pages/my/setup.vue

@@ -367,16 +367,17 @@ export default {
 					if (res.confirm) {
 						console.log("用户点击确定");
 						// 退出极光推送
-						logoutJP()
-						that.$queue.logout()
-						uni.$emit('offLogin')
-						uni.showToast({
-							title: "退出成功!",
-							icon: "none",
-							success: () => {
-								this.$queue.toLogin()
-							}
-						});
+						logoutJP(() => {
+							that.$queue.logout()
+							uni.$emit('offLogin')
+							uni.showToast({
+								title: "退出成功!",
+								icon: "none",
+								success: () => {
+									this.$queue.toLogin()
+								}
+							});
+						})
 						/* that.isLogin = true;
 						that.userName = "登录";
 						that.avatar = "../../static/logo.png";
@@ -425,16 +426,17 @@ export default {
 				//订单状态通知
 				if (res.code == 0) {
 					// 退出极光推送
-					logoutJP()
-					that.$queue.logout()
-					uni.$emit('offLogin')
-					uni.showToast({
-						title: "注销成功!",
-						icon: "none",
-						success: () => {
-							this.$queue.toLogin()
-						}
-					});
+					logoutJP(() => {
+						that.$queue.logout()
+						uni.$emit('offLogin')
+						uni.showToast({
+							title: "注销成功!",
+							icon: "none",
+							success: () => {
+								this.$queue.toLogin()
+							}
+						});
+					})
 				}else{
 					uni.showToast({
 						title: res.msg||'返回失败',

+ 7 - 1
utils/login.js

@@ -133,7 +133,7 @@ export function getJPLoginParams() {
 /**
  * 退出登录,断开极光推送连接
  */
-export function logoutJP() {
+export function logoutJP(callback) {
 	// 退出登录,断开极光推送连接
 	// #ifdef APP-PLUS
 	HttpRequest
@@ -141,6 +141,12 @@ export function logoutJP() {
 		.then(res => {
 			console.log('退出登录成功', res)
 		})
+		.finally(() => {
+			callback && callback()
+		})
+	// #endif
+	// #ifndef APP-PLUS
+	callback && callback()
 	// #endif
 }