# signature-wx-js-sdk

Description

微信接入js-sdk请求授权获得签名接口

Sequence diagram

Installation

git clone https://gitee.com/lovewestwind/signature-wx-js-sdk.git

Instructions

config appId & appSecret in signature.php

$appId = 'wxd0803523dcadc007'; $appSecret = '6413fed34058b3f6465ac07112cb96ca';

Use in nodejs

install axios

> npm install axios

install wx-js-sdk

> npm install weixin-js-sdk

define axios in main.js

import axios from 'axios' Vue.prototype.$axios = axios;

use in code

var authUrl = 'http://www.stanwind.com/demo/' this.$axios.get('http://localhost/signature.php?url=' + authUrl).then(redata => { var data = redata.data; wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 // 必填,公众号的唯一标识 appId: data.appId, // 必填,生成签名的时间戳 timestamp: data.timestamp, // 必填,生成签名的随机串 nonceStr: data.nonceStr, // 必填,签名 signature: data.signature, // 必填,需要使用的JS接口列表,所有JS接口列表 jsApiList: ['checkJsApi', 'scanQRCode'] // 必填,需要使用的JS接口列表 }); }); wx.error(function (res) { console.log('wx error->' + res.errMsg); }); wx.ready(function () { wx.checkJsApi({ jsApiList: ['scanQRCode'], success: function (res) { console.log('check js api -> ' + res.errMsg); } }); //微信方式 wx.scanQRCode({ needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, scanType: ["barCode"], // ["qrCode","barCode"] 可以指定扫二维码还是一维码,默认二者都有 success: function (res) { var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 //alert("扫描结果:"+result); console.log(result); var isbn = result.split(',')[1]; alert(isbn); } }); });

Test API

http://www.stanwind.com/wx/signature.php?url=http://www.stanwind.com/demo

Demo Response

{ appId: "wxd0803523dcadc007", timestamp: 1551237888, nonceStr: "wantongtest", signature: "565194473ed71928f8ac9ac7e40561ae31bff993", ticket: "LIKLckvwlJT9cWIhEQTwfC_L_JPglkNAJ6HDVuhbwpN-RbVVBcZib8sfe0I3to39DU1LiO5V4hwqIE3cepb51g", url: "http://www.stanwind.com/demo", code: "0" }

Contribution

Fork the repository Create Feat_xxx branch Commit your code Create Pull Request

Gitee Feature

You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md Gitee blog blog.gitee.com Explore open source project https://gitee.com/explore The most valuable open source project GVP The manual of Gitee https://gitee.com/help The most popular members https://gitee.com/gitee-stars/

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。