Просмотр исходного кода

微信小程序消息推送订阅临时更新

liuyao 1 год назад
Родитель
Сommit
bb7b6b21f2
1 измененных файлов с 43 добавлено и 29 удалено
  1. 43 29
      components/dkbase/dk-form/dk-form.js

+ 43 - 29
components/dkbase/dk-form/dk-form.js

@@ -811,44 +811,58 @@ Component({
         card: item.card
       })
     },
+    /**
+     * @desc   : 消息订阅
+     * @author : 刘尧
+     * @date   : 2024/1/26 11:46
+     */
     openRemindDatePopTime(e) {
       const that = this
       const tmplIds = Constants.miniMessageModelIds
-      // 获取微信基础配置
-      wx.getSetting({
-        withSubscriptions: true,
+      wx.requestSubscribeMessage({
+        tmplIds: tmplIds,
         success(res) {
-          let bol = false
-          // 适配存在多个订阅消息模板的情况
-          if (res.subscriptionsSetting.itemSettings) {
-            const obj = res.subscriptionsSetting.itemSettings
-            Object.keys(obj).forEach((key) => {
-              if (obj[key] !== 'accept') {
-                bol = true
-              }
-            })
-          } else {
-            bol = true
-          }
-          if (bol) {
-            // 如果配置中用户未订阅消息 则弹窗
-            wx.requestSubscribeMessage({
-              tmplIds: tmplIds,
-              success(res) {
-                that.openDatePopTime(e)
-              },
-              fail(res) {
-                that.openDatePopTime(e)
-              }
-            })
-          } else {
-            that.openDatePopTime(e)
-          }
+          that.openDatePopTime(e)
         },
         fail(res) {
           that.openDatePopTime(e)
         }
       })
+      // 获取微信基础配置
+      // wx.getSetting({
+      //   withSubscriptions: true,
+      //   success(res) {
+      //     let bol = false
+      //     // 适配存在多个订阅消息模板的情况
+      //     if (res.subscriptionsSetting.itemSettings) {
+      //       const obj = res.subscriptionsSetting.itemSettings
+      //       Object.keys(obj).forEach((key) => {
+      //         if (obj[key] !== 'accept') {
+      //           bol = true
+      //         }
+      //       })
+      //     } else {
+      //       bol = true
+      //     }
+      //     if (bol) {
+      //       // 如果配置中用户未订阅消息 则弹窗
+      //       wx.requestSubscribeMessage({
+      //         tmplIds: tmplIds,
+      //         success(res) {
+      //           that.openDatePopTime(e)
+      //         },
+      //         fail(res) {
+      //           that.openDatePopTime(e)
+      //         }
+      //       })
+      //     } else {
+      //       that.openDatePopTime(e)
+      //     }
+      //   },
+      //   fail(res) {
+      //     that.openDatePopTime(e)
+      //   }
+      // })
     },
     /**
      * @desc   : 关闭日期pop