index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  3. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4. var _my = require("../../__antmove/api/index.js")(my);
  5. var wx = _my; // 这是一个测试用的云函数
  6. var cloud = require("wx-server-sdk");
  7. cloud.init(); // 云函数入口函数
  8. exports.main = /*#__PURE__*/function () {
  9. var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(event) {
  10. var wxContext;
  11. return regeneratorRuntime.wrap(function _callee$(_context) {
  12. while (1) {
  13. switch (_context.prev = _context.next) {
  14. case 0:
  15. wxContext = cloud.getWXContext();
  16. return _context.abrupt("return", {
  17. event: event,
  18. openid: wxContext.OPENID,
  19. appid: wxContext.APPID,
  20. unionid: wxContext.UNIONID
  21. });
  22. case 2:
  23. case "end":
  24. return _context.stop();
  25. }
  26. }
  27. }, _callee);
  28. }));
  29. return function (_x) {
  30. return _ref.apply(this, arguments);
  31. };
  32. }();