bayi vor 1 Jahr
Ursprung
Commit
b14c95559d
4 geänderte Dateien mit 31 neuen und 10 gelöschten Zeilen
  1. 1 1
      api/global.js
  2. 0 1
      app.js
  3. 28 7
      pages/index/index.js
  4. 2 1
      pages/index/index.less

+ 1 - 1
api/global.js

@@ -27,7 +27,7 @@ module.exports = {
     // 获取邀新总榜
     getInviteRanking: data => request('/v3/activity/inviteNewRank',
         'get', data),
-    // 获取授权推送消息接口
+    // 获取授权推送消息模板
     setSubscribe: (data, method = 'get') => request('/v3/subscribe', method, data),
     //  生成用户分享二维码
     createWxCode: data => request('/qrCode', 'get', data),

+ 0 - 1
app.js

@@ -98,7 +98,6 @@ App({
                 }
             })
             // #elif ANDROID
-            console.log('eqw');
             wx.getMiniProgramCode({
                 success(res) {
                     if (res.code) {

+ 28 - 7
pages/index/index.js

@@ -5,7 +5,7 @@ import {
 } from "~/api/works"
 import {
     getBannerList,
-    setSubscribe
+    setSubscribe,
 } from '~/api/global'
 import event from '~/mixins/event'
 import share from '~/mixins/share'
@@ -131,30 +131,51 @@ Page({
     },
     async getSubscribe() {
         let tmplIds = await setSubscribe()
-        console.log(tmplIds);
+        console.log(tmplIds, tmplIds ? true : false);
         this.setData({
             tmplIds: tmplIds ? tmplIds : [],
             subscribeShow: tmplIds ? true : false,
         })
     },
     requestMessage() {
+        this.setData({
+            tmplIds: [
+                "oBzj9gVeL_6wI__PB5QdJuIG52KN__gyCAP3cQJ1Nqw",
+                "8miPEckOl2q7AKaHLBygFpDDFASnQf_NPSP34Qb0QcI",
+                "mGdQ9rUjqhC-D3HeFaZMaMkqw_Onfo1_PQbbHzWaXzI",
+            ]
+        })
         wx.requestSubscribeMessage({
             tmplIds: this.data.tmplIds,
             success: async (res) => {
-                console.log(res);
                 let accept = []
                 this.data.tmplIds.forEach(item => {
-                    console.log(res[item]);
                     if (res[item] == 'accept') {
                         accept.push(item)
                     }
                 })
-                let subscribeRes = await setSubscribe({
+                console.log(accept, 'accept');
+                await setSubscribe({
                     ids: accept
                 }, 'post')
-                console.log(subscribeRes);
                 this.getSubscribe()
-            }
+            },
+            /*     fail: (err) => {
+                    console.log(err);
+                    if (err.errCode == '20004') {
+                        // 20004
+                        wx.showModal({
+                            title: '温馨提示',
+                            content: '请同意允许我们向您发送订阅信息,请打开设置勾选订阅消息,这样能随时接到关于您作品的最新消息',
+                            complete: (res) => {
+                                if (res.cancel) {
+                                }
+                                if (res.confirm) {
+                                }
+                            }
+                        })
+                    }
+                } */
         })
     },
     onUnload() {

+ 2 - 1
pages/index/index.less

@@ -68,7 +68,8 @@
         }
     }
 }
-.subscribe{
+
+.subscribe {
     position: fixed;
     top: 0;
     left: 0;