![5640239-fb3a37a5bdfd2a26.png](https://upload-images.jianshu.io/upload_images/5640239-fb3a37a5bdfd2a26.png)
自动触发服务器脚本,自动打包,更新
1.把github上的项目克隆到本地
2.初始化项目,用node.js搭建环境,是已经过时的项目了
![5640239-b8f3fc4f97349cc9.png](https://upload-images.jianshu.io/upload_images/5640239-b8f3fc4f97349cc9.png)
3.安装模块
![5640239-8e9ca592807716f6.png](https://upload-images.jianshu.io/upload_images/5640239-8e9ca592807716f6.png)
4.进入微信开发者平台
https://open.weixin.qq.com/
![5640239-b114d7922ddb3fd9.png](https://upload-images.jianshu.io/upload_images/5640239-b114d7922ddb3fd9.png)
5.g82.jscook.cn 怎么保存啊?
![5640239-dcdd9b3d9a1d568f.png](https://upload-images.jianshu.io/upload_images/5640239-dcdd9b3d9a1d568f.png)
6.搭建服务?
![5640239-afc8f3a2b2ab6fdd.png](https://upload-images.jianshu.io/upload_images/5640239-afc8f3a2b2ab6fdd.png)
执行node.js,访问
![5640239-1c14d6a2a82d2966.png](https://upload-images.jianshu.io/upload_images/5640239-1c14d6a2a82d2966.png)
看端口监听好了没有:在谷歌里
在static里面写一个html静态文件:helloword;
文件是怎样访问到的?
![5640239-71e7e3b15d79d304.png](https://upload-images.jianshu.io/upload_images/5640239-71e7e3b15d79d304.png)
把文件映射到接口中
cat 来查看文件,要是没有,就创建一个
![5640239-9ef11ce9957e4c0b.png](https://upload-images.jianshu.io/upload_images/5640239-9ef11ce9957e4c0b.png)
Svon(555486L7I7L5对话) 21:48:29
vim .gitignore
Svon(555486L7I7L5对话) 21:48:37
里面的内容
Svon(555486L7I7L5对话) 21:48:38
node_modules
![5640239-16ef6b4b4cd407da.png](https://upload-images.jianshu.io/upload_images/5640239-16ef6b4b4cd407da.png)
如果没有出现node-modules,就正常提交
![5640239-8d081ca419f9b0c5.png](https://upload-images.jianshu.io/upload_images/5640239-8d081ca419f9b0c5.png)
![5640239-2796e0cf40723f95.png](https://upload-images.jianshu.io/upload_images/5640239-2796e0cf40723f95.png)
![5640239-f22d95d879a57d14.png](https://upload-images.jianshu.io/upload_images/5640239-f22d95d879a57d14.png)
![5640239-e236b07aa4859419.png](https://upload-images.jianshu.io/upload_images/5640239-e236b07aa4859419.png)
把3000全部改成8000,上传到服务器,再push下来;
![5640239-1d58d4780f372c56.png](https://upload-images.jianshu.io/upload_images/5640239-1d58d4780f372c56.png)
报错了,所以要安装一下模块啊
![5640239-fc4edbf6b46c0307.png](https://upload-images.jianshu.io/upload_images/5640239-fc4edbf6b46c0307.png)
ctrl+s强制退出
怎么杀死进程
![5640239-824c29c01a1567e1.png](https://upload-images.jianshu.io/upload_images/5640239-824c29c01a1567e1.png)
安装好 并能够启动
![5640239-19753d94b8c51d6c.png](https://upload-images.jianshu.io/upload_images/5640239-19753d94b8c51d6c.png)
服务器中的APP是能够启动的
![5640239-e339180d8cfa392c.png](https://upload-images.jianshu.io/upload_images/5640239-e339180d8cfa392c.png)
============================================
1.进到服务器里面
登录
2.功能设置里面
3.把本地的代码push到服务器上;
4.把id拷贝到项目里面去
![5640239-31c020db4dad482c.png](https://upload-images.jianshu.io/upload_images/5640239-31c020db4dad482c.png)
http://www.jscss.cc/2016/10/31/weixin-token.html
![5640239-2577337944b1cdaa.png](https://upload-images.jianshu.io/upload_images/5640239-2577337944b1cdaa.png)
显示秘钥
![5640239-fa8b0e1cf45451c5.png](https://upload-images.jianshu.io/upload_images/5640239-fa8b0e1cf45451c5.png)
我的秘钥
开发者ID
AppID(应用ID)
wx097da5def31d2464
AppSecret(应用密钥)
966343205c3f45147deb296836c6a0bc 隐藏 重置
![5640239-79aeea1a54e6120f.png](https://upload-images.jianshu.io/upload_images/5640239-79aeea1a54e6120f.png)
域名加接口
![5640239-c35be81d69e69ee7.png](https://upload-images.jianshu.io/upload_images/5640239-c35be81d69e69ee7.png)
兼容模式:
![5640239-ef99443990511ad1.png](https://upload-images.jianshu.io/upload_images/5640239-ef99443990511ad1.png)
放到app
![5640239-98e64a6654b5b4a7.png](https://upload-images.jianshu.io/upload_images/5640239-98e64a6654b5b4a7.png)
本地把代码提交到github上,再pull下来
![5640239-3cec8e9d1822cda6.png](https://upload-images.jianshu.io/upload_images/5640239-3cec8e9d1822cda6.png)
改一下
![5640239-e565fe45ea992302.png](https://upload-images.jianshu.io/upload_images/5640239-e565fe45ea992302.png)
完成第一步:
node.js进程管理:
http://www.jscss.cc/2016/10/31/pm2.html
怎么把服务器清空再进行配置?
==================
周六:
微信JS-SDK说明文档
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN
打开微信的项目,安装一个模块;
npm install wechat-api --save
![5640239-6002af723c2f6106.png](https://upload-images.jianshu.io/upload_images/5640239-6002af723c2f6106.png)
新建一个jssdk.js,在app中间引过来
![5640239-bd5406f4c3c798a1.png](https://upload-images.jianshu.io/upload_images/5640239-bd5406f4c3c798a1.png)
用app对象开了一个路由,路由就是接口地址;
![5640239-bb4f34ccc315d256.png](https://upload-images.jianshu.io/upload_images/5640239-bb4f34ccc315d256.png)
use:post+get 两种都可以请求到这个接口:
进入到项目根目录
![5640239-5acf51e0ff5c40d1.png](https://upload-images.jianshu.io/upload_images/5640239-5acf51e0ff5c40d1.png)
输出的信息:
![5640239-37f5305106de90e6.png](https://upload-images.jianshu.io/upload_images/5640239-37f5305106de90e6.png)
复制到头部里面去:
var querystring = require('querystring');
var fs = require('fs');
var path = require("path");
var crypto = require("crypto");
var Url = require("url");
var WechatAPI = require('wechat-api');
var config = require("./config.js")();
![5640239-6ef3183dd7918fad.png](https://upload-images.jianshu.io/upload_images/5640239-6ef3183dd7918fad.png)
处理post请求的模块:
![5640239-d8eddaa3939261f8.png](https://upload-images.jianshu.io/upload_images/5640239-d8eddaa3939261f8.png)
在APP中引进来
//post 请求处理模块
var bodyparser = require("body-parser");
//post 请求处理模块
var bodyparser = require("body-parser");
![5640239-b0925818a5339b28.png](https://upload-images.jianshu.io/upload_images/5640239-b0925818a5339b28.png)
在post 请求的文本里处理这些信息;
![5640239-371a16dd1cc14d9b.png](https://upload-images.jianshu.io/upload_images/5640239-371a16dd1cc14d9b.png)
jssdk两种请求方式:
callback相当于一个全局函数;
![5640239-5fbccb945378d2ef.png](https://upload-images.jianshu.io/upload_images/5640239-5fbccb945378d2ef.png)
重启:
![5640239-dda4199e41ac7093.png](https://upload-images.jianshu.io/upload_images/5640239-dda4199e41ac7093.png)
要弹出消息,就得调用json callback;
通过参数取出函数名就可以了;
![5640239-2e03fe6e6a04b627.png](https://upload-images.jianshu.io/upload_images/5640239-2e03fe6e6a04b627.png)
返回的是一个已经拼装好的代码;
怎么把data转换成 一个字符串:
![5640239-2dfd3a2e4465e0d9.png](https://upload-images.jianshu.io/upload_images/5640239-2dfd3a2e4465e0d9.png)
http://doxmate.cool/node-webot/wechat-api/api.html
这两个API参数怎么获取:
var api = new WechatAPI(appid, appsecret);
![5640239-37ece46d74e7499f.png](https://upload-images.jianshu.io/upload_images/5640239-37ece46d74e7499f.png)
因为已经配置过,只需要去config里面取一下就行了
![5640239-13dacf35399a28ca.png](https://upload-images.jianshu.io/upload_images/5640239-13dacf35399a28ca.png)
权限签名认证好以后:返回参数:
![5640239-cc74f8cd56500fda.png](https://upload-images.jianshu.io/upload_images/5640239-cc74f8cd56500fda.png)
Svon(555486L7I7L5对话) 11:38:23
var param = {
debug: false,
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'],
url: 'http://www.xxx.com'
};
api.getJsConfig(param, callback);
不管能不能调用成功,先把结果返回去看看:
只要是域名写对了,基本上都可以出来的;
![5640239-d9959f472ee50579.png](https://upload-images.jianshu.io/upload_images/5640239-d9959f472ee50579.png)
引入一个jQuery文件:
![5640239-446468d0038d30af.png](https://upload-images.jianshu.io/upload_images/5640239-446468d0038d30af.png)
![5640239-a48b736ae67a7cda.png](https://upload-images.jianshu.io/upload_images/5640239-a48b736ae67a7cda.png)
返回的就是接口;
json完成:
![5640239-397e831d52909a9b.png](https://upload-images.jianshu.io/upload_images/5640239-397e831d52909a9b.png)
![5640239-bff891c37db975ad.png](https://upload-images.jianshu.io/upload_images/5640239-bff891c37db975ad.png)
如果要进行缓存的话,就要把代码分开写吧;
想调用微信的jssdk,需要调用:
![5640239-a1a0242ed0b766d0.png](https://upload-images.jianshu.io/upload_images/5640239-a1a0242ed0b766d0.png)
创建 test文件,引入index;
自定义分享:
![5640239-cc8b2bc70c093195.png](https://upload-images.jianshu.io/upload_images/5640239-cc8b2bc70c093195.png)
本地调试完成:
配置域名的原因:
上传至服务器:阿里云,就可以了