From 9617d4a95093be4d25572d398c434a7746716f3f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 09 七月 2022 22:45:34 +0800
Subject: [PATCH] 2022-07-09

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |  140 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 134 insertions(+), 6 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index d44dc4a..433744b 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -834,6 +834,10 @@
                     })
                   }, 600)
                 }
+
+                if (res.status) {
+                  this.triggerNote(res) // 娑堟伅
+                }
                 resolve(res)
               }, () => {
                 this.updateStatus()
@@ -1327,6 +1331,9 @@
             })
           }, 600)
         }
+
+        this.triggerNote(res) // 娑堟伅
+
         if (params.length === 0) {
           this.execSuccess(res)
           _resolve()
@@ -1535,10 +1542,6 @@
       id = res.mk_b_id || res[btn.output] || ''
     }
 
-    if (btn.verify && btn.verify.noteEnable === 'true' && id) {
-      this.sendMessage(id)
-    }
-
     if (res.mk_icon) {
       sessionStorage.setItem('avatar', res.mk_icon)
     }
@@ -1596,9 +1599,134 @@
     }
   }
 
-  sendMessage = (id) => {
-    const { btn : { verify } } = this.props
+  triggerNote = (res) => {
+    const { btn } = this.props
 
+    if (!btn.verify) return
+    if (btn.verify.noteEnable !== 'true' && btn.verify.wxNote !== 'true') return
+
+    let id = ''
+    if (btn.output) {
+      id = res.mk_b_id || res[btn.output] || ''
+    }
+
+    if (!id) return
+
+    if (btn.verify.noteEnable === 'true') {
+      this.sendMessage(btn.verify, id)
+    }
+    if (btn.verify.wxNote === 'true') {
+      this.sendWxMessage(btn.verify, id)
+    }
+  }
+
+  sendWxMessage = (verify, id) => {
+    let param = {
+      func: 's_get_sms_weixin_local',
+      upid: id
+    }
+
+    param.LText = Utils.formatOptions(Utils.getuuid())
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+    Api.genericInterface(param).then(res => {
+      // res.data = [{openid: 'o2E7gvoSFvQRG7I8_gZxf4y3ONkQ', send_id: '2223333', first: '鎮ㄧ殑缂磋垂淇℃伅濡備笅', keyword1: '010000000001', keyword2: '2022骞�07鏈�03鏃�', keyword3: '渚涙殩缂磋垂', keyword4: '20鍏�', keyword5: '鎴愬姛', remark: '鎰熻阿鎮ㄧ殑浣跨敤锛�'}]
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+        return
+      } else if (!res.send_data || res.send_data.length === 0) {
+        return
+      }
+
+      let _param = {
+        touser: '',
+        template_id: verify.wxTemplateId,
+        data: {}
+      }
+
+      if (verify.wxNoteLink === 'url' && verify.wxNoteLinkUrl) {
+        _param.url = verify.wxNoteLinkUrl
+      } else if (verify.wxNoteLink === 'miniProgram' && window.GLOB.WXminiAppID) {
+        _param.miniprogram = {
+          appid: window.GLOB.WXminiAppID,
+          pagepath: '/pages/index/index'
+        }
+
+        if (verify.wxNoteLinkMenuId) {
+          _param.miniprogram.pagepath = `/pages/index/index?MenuId=${verify.wxNoteLinkMenuId}`
+        }
+      }
+
+      let keys = []
+      verify.wxNoteKeys.forEach(item => {
+        keys.push(item.key)
+
+        _param.data[item.key] = {value: '', color: item.color}
+      })
+
+      let params = res.send_data.map(item => {
+        let m = fromJS(_param).toJS()
+
+        m.touser = item.openid || ''
+        if (item.bid && m.miniprogram && m.miniprogram.pagepath.indexOf('MenuId') > -1) {
+          m.miniprogram.pagepath = m.miniprogram.pagepath + `&BID=${item.bid}`
+        }
+
+        if (item.send_id) { // 闃查噸鍏d
+          m.client_msg_id = item.send_id
+        }
+
+        keys.forEach(key => {
+          if (item[key] !== undefined) {
+            m.data[key].value = item[key]
+          }
+        })
+
+        return m
+      })
+
+      Api.wxAccessToken().then(res => {
+        if (!res.oa_access_token) return
+  
+        params.forEach(n => {
+          if (!n.touser) return
+
+          Api.wxNginxRequest(`cgi-bin/message/template/send?access_token=${res.oa_access_token}`, 'post', n).then(re => {
+            if (verify.wxNoteCallback === 'true') {
+              let _p = {
+                func: 's_get_sms_weixin_local_suc_err',
+                upid: id,
+                send_id: n.client_msg_id || '',
+                status_result: re.errcode === 0 ? 'S' : 'E',
+                msg_result: re.errmsg
+              }
+
+              _p.LText = Utils.formatOptions(Utils.getuuid())
+              _p.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+              _p.secretkey = Utils.encrypt(_p.LText, _p.timestamp)
+
+              Api.genericInterface(_p).then(result => {
+                if (!result.status) {
+                  notification.warning({
+                    top: 92,
+                    message: result.message,
+                    duration: 5
+                  })
+                }
+              })
+            }
+          })
+        })
+      })
+    })
+  }
+
+  sendMessage = (verify, id) => {
     let param = {
       func: 's_get_sms_local',
       TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭

--
Gitblit v1.8.0