wafer2-nodejs 本地部署服务器

友情提示:假设你已经部署好了腾讯云微信小程序服务,如果没有,就不用往下看了,果断选云开发。

-------------------------------------------------------------------------------------------------------------------------------------------------

首先config.js 

var host = "http://localhost:5757"

然后

  qcloudAppId: '',
  qcloudSecretId: '',
  qcloudSecretKey: '',
  port: '5757',
  rootPathname: '',
  serverHost: '',
  tunnelServerUrl: '',
  tunnelSignatureKey: '',
  wxMessageToken: '',

或者去server/node_modules/wafer-node-sdk/index.js这个文件将里的下面这段代码需要注释掉,不然会报ERR_INIT_SDK_LOST_CONFIG

/*

if ([rootPathname, useQcloudLogin, cos, serverHost, tunnelServerUrl, tunnelSignatureKey, qcloudAppId, qcloudSecretId, qcloudSecretKey, wxMessageToken].some(v => v === undefined)) throw new Error(ERRORS.ERR_INIT_SDK_LOST_CONFIG)

*/

总之就是在腾讯云服务器上有的几个值,在我们本地没有,要么注释掉,要么赋个值。

mysql下填写本地服务器上的mysql的相应值,大概如下:

  mysql: {
    host: 'localhost',
    port: 3306,
    user: 'root',
    db: 'cauth',
    pass: '123456',
    char: 'utf8mb4'
  },

mysql的数据库cAuth, 需要从腾讯云服务器上导出,再导入本地,不然会提示找不到一些表格,也就两张表,cAppinfo, cSessionInfo

在node app.js启动web服务器,在小程序里载入client代码,

点击测试登录接口,

loginUrl:`${host}/weapp/login`,

如果一切没问题,应该能返回登录用户信息了

ctx.state.$wxInfo

{ loginState: 1,

userinfo:xxxxxxx

参考链接:https://www.jianshu.com/p/ffa90a0e9770

猜你喜欢

转载自www.cnblogs.com/lfri/p/11978919.html