From 1e61215b48e59e94c1ed98e4ef956227d689d6bc Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Mon, 06 Nov 2023 08:48:39 +0800
Subject: [PATCH] fix:小程序订阅消息

---
 pages/actionChange/workOrderDetails/index.vue |    1 
 pages/actionChange/agencyPage/index.vue       |    4 +-
 pages/login/login.vue                         |   13 ++++++
 utils/subscribe.js                            |   55 +++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/pages/actionChange/agencyPage/index.vue b/pages/actionChange/agencyPage/index.vue
index 1313d84..0d8b9fd 100644
--- a/pages/actionChange/agencyPage/index.vue
+++ b/pages/actionChange/agencyPage/index.vue
@@ -15,7 +15,7 @@
 			</view>
 		</view>
 		<view>
-			<u-tabs :list="list" :scrollable="scrollable" lineWidth="60" @change="changeTap" />
+			<u-tabs :list="list" :scrollable="scrollable" lineWidth="60" :current='current' @change="changeTap" />
 		</view>
 		<view class="" v-if="userName">
 			<view class="dataRangeSerch" v-if="current===3">
@@ -161,7 +161,7 @@
 					value: 3,
 				}, ],
 				showeEscalationTime: false,
-				current: 0,
+				current: 1,
 				startTime: '',
 				endTime: '',
 				workOderList: [],
diff --git a/pages/actionChange/workOrderDetails/index.vue b/pages/actionChange/workOrderDetails/index.vue
index 3bfbe07..8c20e69 100644
--- a/pages/actionChange/workOrderDetails/index.vue
+++ b/pages/actionChange/workOrderDetails/index.vue
@@ -56,7 +56,6 @@
 					userId: this.userInfor.userId
 				}
 				this.$http.httpGet('/allocationApp/authority', params).then(res => {
-					res.data = false
 					if (!res.data) {
 						uni.showModal({
 							content: '���������������������������������������������',
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 4a89982..9a59fea 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -42,6 +42,9 @@
 		httpGet
 	} from '@/utils/http.js'
 	import store from '@/store/index.js'
+	import {
+		subScribeMsg
+	} from '@/utils/subscribe.js'
 	export default {
 		data() {
 			return {
@@ -83,6 +86,15 @@
 			uni.hideHomeButton()
 		},
 		methods: {
+			// ���������������������������
+			async aClick() {
+				let data = await subScribeMsg()
+				console.log('data', data)
+				if (data['YNqUZ1MgMvwY3G-NENVbcmIBR5dUotSdnwcz96CWrho'] === 'accept') { // ���������������������
+				} else {
+					console.log('������')
+				}
+			},
 			doRequire() {
 				uni.requirePrivacyAuthorize({
 					success: () => {
@@ -107,6 +119,7 @@
 				const value = uni.getStorageSync('openId')
 				console.log('openId', value)
 				if (value) {
+					this.aClick()
 					this.logining(value)
 				}
 			},
diff --git a/utils/subscribe.js b/utils/subscribe.js
new file mode 100644
index 0000000..11bfd9a
--- /dev/null
+++ b/utils/subscribe.js
@@ -0,0 +1,55 @@
+function subScribeMsg() {
+    return new Promise((resolve, reject) => {
+        let that = this
+        uni.getSetting({
+            withSubscriptions: true,
+            success(res) {
+                console.log('1', res, '������������', res.subscriptionsSetting)
+                if (!res.subscriptionsSetting.mainSwitch) {
+                    uni.showModal({
+                        title: '������������������������������������',
+                        success(res) {
+                            if (res.confirm) {
+                                uni.openSetting({
+                                    success(res) {
+                                        if (res.subscriptionsSetting) {
+                                            uni.showToast({
+                                                title: '������������������',
+                                                icon: 'none',
+                                            })
+                                        }
+                                    },
+                                    fail() {
+                                        uni.showToast({
+                                            title: '������������������',
+                                            icon: 'none',
+                                        })
+                                    },
+                                })
+                            } else if (res.cancel) {
+                                uni.showToast({
+                                    title: '������������������������',
+                                    icon: 'none',
+                                })
+                            }
+                        },
+                    })
+                } else {
+                    uni.requestSubscribeMessage({
+                        tmplIds: ['YNqUZ1MgMvwY3G-NENVbcmIBR5dUotSdnwcz96CWrho'],
+                        success(res) {
+                            console.log('requestSubscribeMessage ������������', res)
+                            resolve(res)
+                        },
+                        fail(errMessage) {
+                            reject(errMessage)
+                            console.log('������������ ������ ', errMessage)
+                        },
+                        complete() {}
+                    })
+                }
+            },
+        })
+    })
+}
+module.exports = { subScribeMsg }
\ No newline at end of file

--
Gitblit v1.8.0