Browse Source

分享测试

zhujindu 10 months ago
parent
commit
f2bd6175cd
1 changed files with 28 additions and 29 deletions
  1. 28 29
      src/views/home/index.vue

+ 28 - 29
src/views/home/index.vue

@@ -79,38 +79,37 @@ export default {
     this.getDict();
   },
   mounted() {
-    getTicketFun(['showMenuItems', 'hideMenuItems', 'onMenuShareAppMessage']).then((res) => {
-      this.wx.ready(() => {
-        console.log(this.wx);
-        console.log(this.wx.miniProgram);
-        // this.wx.hideMenuItems({
-        //   menuList: ['menuItem:favorite'], // 要显示的菜单项
-        // });
-        this.wx.showMenuItems({
-          menuList: ['menuItem:share:appMessage'], // 要显示的菜单项
-        });
-        this.wx.onMenuShareAppMessage({
-          title: '企业微信',
-          desc: '己的微信让每个企业都有自己的微信',
-          link: 'https://work.weixin.qq.com/',
-          imgUrl:
-            'https://cdn-svs-test.nipponpaint.com.cn/%E5%90%B4%E5%BA%B7-%E9%97%A8%E5%BA%97%E7%85%A7-%E5%A4%A9%E5%BB%B6%E7%BB%BC%E5%90%88%E7%BB%8F%E8%90%A5%E9%83%A8-20250109033940.jpg?Expires=2051941182&OSSAccessKeyId=LTAI5tG1DTJFA16BHkzHVxjz&Signature=T7%2FszxqrMyc%2FZWQV955BOGMYFgc%3D',
-          success: () => {
-            // 用户确认分享后回调
-            console.log('用户确认分享后回调');
+    getTicketFun(['sendChatMessage'], 'agentConfig').then((res) => {
+      wx.invoke(
+        'sendChatMessage',
+        {
+          msgtype: 'text', //消息类型,必填
+          enterChat: true, //为true时表示发送完成之后顺便进入会话,仅移动端3.1.10及以上版本支持该字段
+          text: {
+            content: '你好', //文本内容
           },
-          error: () => {
-            console.log('error');
-            if (res.errMsg.indexOf('no permission') > 0) {
-              alert('未agentConfig');
-            }
+          image: {
+            mediaid: '', //图片的素材id
           },
-          cancel: () => {
-            // 用户取消分享后回调
-            console.log('用户取消分享后回调');
+          video: {
+            mediaid: '', //视频的素材id
           },
-        });
-      });
+          file: {
+            mediaid: '', //文件的素材id
+          },
+          news: {
+            link: '', //H5消息页面url 必填
+            title: '', //H5消息标题
+            desc: '', //H5消息摘要
+            imgUrl: '', //H5消息封面图片URL
+          },
+        },
+        function (res) {
+          if (res.err_msg == 'sendChatMessage:ok') {
+            //发送成功
+          }
+        }
+      );
     });
   },
   methods: {