wuhb 4 месяцев назад
Родитель
Сommit
1a30464732
3 измененных файлов с 33 добавлено и 6 удалено
  1. 12 1
      api/index/index.uts
  2. 4 3
      manifest.json
  3. 17 2
      pages/index/index.uvue

+ 12 - 1
api/index/index.uts

@@ -11,4 +11,15 @@ export const getMyNotify = (userId: string): Promise<any> => {
         url: url,
         method: 'GET'
     })
-}
+}
+
+/**
+ * 注册设备
+ */
+export const registerServer = (cid: string): Promise<any> => {
+    let url = `/push/register/${cid}`
+    return request({
+        url: url,
+        method: 'GET',
+    })
+}

+ 4 - 3
manifest.json

@@ -2,8 +2,8 @@
 	"name": "工效通APP",
 	"appid": "__UNI__1050C07",
 	"description": "工效通任务管理平台",
-	"versionName": "1.2.1",
-	"versionCode": "121",
+	"versionName": "1.2.3",
+	"versionCode": "123",
 	"uni-app-x": {},
 	"quickapp": {},
 	"mp-weixin": {
@@ -55,7 +55,8 @@
 		"distribute": {
 			"modules": {
 				"uni-map": {},
-				"uni-location": {}
+				"uni-location": {},
+				"uni-push": {}
 			},
 			"icons": {
 				"hdpi": "E:/宇光同行/工效APP/app/logo72.png",

+ 17 - 2
pages/index/index.uvue

@@ -143,7 +143,7 @@
 	// import { RequestOption } from '@/uni_modules/ygtx-keepService/utssdk/interface.uts';
 	import { getBaseUrl } from '../../utils/request'
 	import { KeepLive } from '@/uni_modules/android-keeplive'
-	import { getMyNotify } from '../../api/index/index'
+	import { getMyNotify, registerServer} from '../../api/index/index'
 	import {checkPermi} from '../../utils/storage'
 	// const handleStartKeepAlive = (userId: string) => {
 	// 	let notifyUrl = getBaseUrl() + "/mobile/notify";
@@ -556,6 +556,21 @@
 			console.error('处理超时工单点击事件失败:', e)
 		}
 	}
+	
+	const registerPush =() =>{
+		console.log("获取CID")
+		uni.getPushClientId({
+			success: (res) => {
+				console.log(res.cid);
+				registerServer(res.cid).then((result:any) => {
+					console.log("注册成功");
+				});
+			},
+			fail(err) {
+				console.log(err)
+			}
+		})
+	}
 
     // 初始化
     onMounted(() => {
@@ -567,9 +582,9 @@
 			if(userId!=null){
 				console.log("监听:"+userId)
 				handleKeepAlive()
+				registerPush();
 			}
         }
-
 		// 加载待接单数量
 		loadAssignedCount()