npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-wx-jssdk

v1.0.10

Published

处理微信jssdk的使用问题

Downloads

8

Readme

vue-wx-jssdk

一、Introduction

微信端项目经常需要使用weixin-js-sdk来调用微信的一些接口,比如微信分享接口(onMenuShareAppMessage,onMenuShareTimeline..)、 拍照或从手机相册中选图接口(chooseImage)、录音接口(startRecord、stopRecord)等等。该插件是为了能在vue项目中能更方便地使用weixin-js-sdk。

二、Usage

1、下载

npm install vue-wx-jssdk --save

2、引入项目并配置

main.js文件

import Vue from 'vue';
import wxjssdkPlugin from 'vue-wx-jssdk';
import axios from 'axios';
const options = {
        
        /*
        *    config可以有两种形式:object或者promise
        *    1、如果是object,则必须包含以下属性:
        *        appId: '', // 必填,公众号的唯一标识
                 timestamp: , // 必填,生成签名的时间戳
                 nonceStr: '', // 必填,生成签名的随机串
                 signature: '',// 必填,签名
        *   
        *    2、如果是promise,则该promise的返回值中必须要能获取到上面格式的object。
        *    下面是一个promise格式的例子,该示例中,从后端的auth/base接口中获取微信配置信息。
        *    该接口返回一个对象,如:
        *    {
        *       data:{
        *           wx:{
        *                appId: 'xxx', 
                         timestamp: xx, 
                         nonceStr: 'xxx', 
                         signature: 'xxx',
        *           }
        *       }
        *    }
        *       
        *    
        * */
    
        config:axios.get('/auth/base'),
        
        // 如果config是promise,path需要指定如何从promise返回值中拿到符合格式的object;
        // 如果config是一个object,则无需指定path值
        path:'data.data.wx',
        
        // 声明用到的微信api
        actions:['onMenuShareAppMessage','onMenuShareTimeline']
};

Vue.use(wxjssdkPlugin,options);

3、使用接口

(1)在最外层的vue实例上使用:
    // 微信分享
    // vm是Vue的一个实例
    vm.wx.ready(function () {
        // 分享给朋友
        vm.wx.onMenuShareAppMessage({
            title: '微信分享标题',
            desc: '微信分享描述',
            link: location.href,
            imgUrl: location.origin+'/static/share.png',
            success: function () {
               alert("分享成功");
            }
        });
        // 分享到朋友圈
        vm.wx.onMenuShareTimeline({
            title: '微信分享标题',
            link: location.href,
            imgUrl: location.origin+'/static/share.png',
            success: function () {
                alert("分享成功");
            }
        });
    });
(2)在vue组件内使用:
    var _this = this;
    _this.wx.ready(function () {
        // 分享给朋友
        _this.wx.onMenuShareAppMessage({
            title: '微信分享标题',
            desc: '微信分享描述',
            link: location.href,
            imgUrl: location.origin+'/static/share.png',
            success: function () {
               alert("分享成功");
            }
        });
        // 分享到朋友圈
        _this.wx.onMenuShareTimeline({
            title: '微信分享标题',
            link: location.href,
            imgUrl: location.origin+'/static/share.png',
            success: function () {
                alert("分享成功");
            }
        });
    });