Authored by QC-L

添加登录逻辑判断 review by 黄敬囿

@@ -9,7 +9,13 @@ let crypto = require('./libs/cryptojs/cryptojs.js').Crypto @@ -9,7 +9,13 @@ let crypto = require('./libs/cryptojs/cryptojs.js').Crypto
9 import md5 from './vendors/md5'; 9 import md5 from './vendors/md5';
10 var mta = require('./vendors/mta_analysis.js') 10 var mta = require('./vendors/mta_analysis.js')
11 import { wechatLoginAction } from './utils/login'; 11 import { wechatLoginAction } from './utils/login';
  12 +import regeneratorRuntime from '/login/libs/regenerator-runtime/index.js';
12 import { isStringEmpty, getYHStorageSync} from './utils/util'; 13 import { isStringEmpty, getYHStorageSync} from './utils/util';
  14 +import { Event } from '/login/utils/index.js';
  15 +import { wxLogin } from '/login/utils/login/login.js';
  16 +import { appReport } from './libs/appReport.js';
  17 +
  18 +global.event = new Event();
13 19
14 import { logEvent, 20 import { logEvent,
15 YB_LAUNCH_APP, 21 YB_LAUNCH_APP,
@@ -21,10 +27,9 @@ import { logEvent, @@ -21,10 +27,9 @@ import { logEvent,
21 YB_SERVICE_PUSH 27 YB_SERVICE_PUSH
22 } from './libs/analytics.js'; 28 } from './libs/analytics.js';
23 29
24 -import { appReport } from './libs/appReport.js';  
25 30
26 App({ 31 App({
27 - onLaunch: function (options) { 32 + async onLaunch(options) {
28 let that = this; 33 let that = this;
29 let res = wx.getSystemInfoSync(); 34 let res = wx.getSystemInfoSync();
30 if (!res.screenHeight) { 35 if (!res.screenHeight) {
@@ -89,11 +94,12 @@ App({ @@ -89,11 +94,12 @@ App({
89 logEvent(YB_LAUNCH_APP, params, this); 94 logEvent(YB_LAUNCH_APP, params, this);
90 } 95 }
91 setTimeout(function () { 96 setTimeout(function () {
92 - wechatLoginAction(function (response) {  
93 - that.getShareInfo();  
94 - }); 97 + // wechatLoginAction(function (response) {
  98 + // that.getShareInfo();
  99 + // });
95 }, 1000); 100 }, 1000);
96 this.mtainit(options); 101 this.mtainit(options);
  102 + await wxLogin();
97 }, 103 },
98 104
99 //当应用程序进入前台显示状态时触发 105 //当应用程序进入前台显示状态时触发
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 "pages/zeroSell/snapshootShare", 6 "pages/zeroSell/snapshootShare",
7 "pages/zeroSell/h5Page", 7 "pages/zeroSell/h5Page",
8 "pages/bindPhoneNumber/bindPhoneNumber", 8 "pages/bindPhoneNumber/bindPhoneNumber",
9 - "pages/choosecountry/choosecountry" 9 + "pages/choosecountry/choosecountry",
  10 + "login/login-page/login-page"
10 ], 11 ],
11 "window": { 12 "window": {
12 "navigationBarTextStyle": "white", 13 "navigationBarTextStyle": "white",
  1 +.row {
  2 + display: flex;
  3 + flex-direction: row;
  4 +}
  5 +
  6 +.column {
  7 + display: flex;
  8 + flex-direction: column;
  9 +}
  1 +.margin {
  2 + margin: 20rpx;
  3 +}
  4 +
  5 +.margin-top-bottom {
  6 + margin: 20rpx 0;
  7 +}
  8 +
  9 +.margin-left-right {
  10 + margin: 0 20rpx;
  11 +}
  12 +
  13 +.margin-left {
  14 + margin-left: 20rpx;
  15 +}
  16 +
  17 +.margin-top {
  18 + margin-top: 20rpx;
  19 +}
  20 +
  21 +.margin-right {
  22 + margin-right: 20rpx;
  23 +}
  24 +
  25 +.margin-bottom {
  26 + margin-bottom: 20rpx;
  27 +}
  28 +
  29 +.padding {
  30 + margin: 20rpx;
  31 +}
  32 +
  33 +.padding-top-bottom {
  34 + padding: 20rpx 0;
  35 +}
  36 +
  37 +.padding-left-right {
  38 + padding: 0 20rpx;
  39 +}
  40 +
  41 +.padding-left {
  42 + padding-left: 20rpx;
  43 +}
  44 +
  45 +.padding-top {
  46 + padding-top: 20rpx;
  47 +}
  48 +
  49 +.padding-right {
  50 + padding-right: 20rpx;
  51 +}
  52 +
  53 +.padding-bottom {
  54 + padding-bottom: 20rpx;
  55 +}
  56 +
  57 +.border-slim {
  58 + border: 1rpx solid #E0E0E0;
  59 +}
  60 +
  61 +.border-slim-top {
  62 + border-top: 1rpx solid #E0E0E0;
  63 +}
  64 +
  65 +.border-slim-bottom {
  66 + border-bottom: 1rpx solid #E0E0E0;
  67 +}
  68 +
  69 +.border-slim-top {
  70 + border-top: 1rpx solid #E0E0E0;
  71 +}
  72 +
  73 +.border-slim-left {
  74 + border-left: 1rpx solid #E0E0E0;
  75 +}
  76 +
  77 +.border-slim-right {
  78 + border-right: 1rpx solid #E0E0E0;
  79 +}
  80 +
  81 +.border-semibold {
  82 + border: 2rpx solid #E0E0E0;
  83 +}
  84 +
  85 +.border-semibold-left {
  86 + border-left: 2rpx solid #E0E0E0;
  87 +}
  88 +
  89 +.border-semibold-right {
  90 + border-right: 2rpx solid #E0E0E0;
  91 +}
  92 +
  93 +.border-semibold-top {
  94 + border-top: 2rpx solid #E0E0E0;
  95 +}
  96 +
  97 +.border-semibold-bottom {
  98 + border-bottom: 2rpx solid #E0E0E0;
  99 +}
  1 +.small-text-size {
  2 + font-size: 20rpx;
  3 +}
  4 +
  5 +.text-size {
  6 + font-size: 24rpx;
  7 +}
  8 +
  9 +.middle-text-size {
  10 + font-size: 28rpx;
  11 +}
  12 +
  13 +.large-text-size {
  14 + font-size: 32rpx;
  15 +}
  16 +
  17 +.big-large-text-size {
  18 + font-size: 36rpx;
  19 +}
  20 +
  1 +@import './common-flex.wxss';
  2 +@import './common-space.wxss';
  3 +@import './common-text.wxss';
  1 +module.exports = (function() {
  2 +var __MODS__ = {};
  3 +var __DEFINE__ = function(modId, func, req) { var m = { exports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4 +var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = { exports: {} }; __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); if(typeof m.exports === "object") { Object.keys(m.exports).forEach(function(k) { __MODS__[modId].m.exports[k] = m.exports[k]; }); if(m.exports.__esModule) Object.defineProperty(__MODS__[modId].m.exports, "__esModule", { value: true }); } else { __MODS__[modId].m.exports = m.exports; } } return __MODS__[modId].m.exports; };
  5 +var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6 +var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7 +__DEFINE__(1542938356632, function(require, module, exports) {
  8 +/**
  9 + * Copyright (c) 2014-present, Facebook, Inc.
  10 + *
  11 + * This source code is licensed under the MIT license found in the
  12 + * LICENSE file in the root directory of this source tree.
  13 + */
  14 +
  15 +var regeneratorRuntime = (function (exports) {
  16 + "use strict";
  17 +
  18 + var Op = Object.prototype;
  19 + var hasOwn = Op.hasOwnProperty;
  20 + var undefined; // More compressible than void 0.
  21 + var $Symbol = typeof Symbol === "function" ? Symbol : {};
  22 + var iteratorSymbol = $Symbol.iterator || "@@iterator";
  23 + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  24 + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  25 +
  26 + function wrap(innerFn, outerFn, self, tryLocsList) {
  27 + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  28 + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  29 + var generator = Object.create(protoGenerator.prototype);
  30 + var context = new Context(tryLocsList || []);
  31 +
  32 + // The ._invoke method unifies the implementations of the .next,
  33 + // .throw, and .return methods.
  34 + generator._invoke = makeInvokeMethod(innerFn, self, context);
  35 +
  36 + return generator;
  37 + }
  38 + exports.wrap = wrap;
  39 +
  40 + // Try/catch helper to minimize deoptimizations. Returns a completion
  41 + // record like context.tryEntries[i].completion. This interface could
  42 + // have been (and was previously) designed to take a closure to be
  43 + // invoked without arguments, but in all the cases we care about we
  44 + // already have an existing method we want to call, so there's no need
  45 + // to create a new function object. We can even get away with assuming
  46 + // the method takes exactly one argument, since that happens to be true
  47 + // in every case, so we don't have to touch the arguments object. The
  48 + // only additional allocation required is the completion record, which
  49 + // has a stable shape and so hopefully should be cheap to allocate.
  50 + function tryCatch(fn, obj, arg) {
  51 + try {
  52 + return { type: "normal", arg: fn.call(obj, arg) };
  53 + } catch (err) {
  54 + return { type: "throw", arg: err };
  55 + }
  56 + }
  57 +
  58 + var GenStateSuspendedStart = "suspendedStart";
  59 + var GenStateSuspendedYield = "suspendedYield";
  60 + var GenStateExecuting = "executing";
  61 + var GenStateCompleted = "completed";
  62 +
  63 + // Returning this object from the innerFn has the same effect as
  64 + // breaking out of the dispatch switch statement.
  65 + var ContinueSentinel = {};
  66 +
  67 + // Dummy constructor functions that we use as the .constructor and
  68 + // .constructor.prototype properties for functions that return Generator
  69 + // objects. For full spec compliance, you may wish to configure your
  70 + // minifier not to mangle the names of these two functions.
  71 + function Generator() {}
  72 + function GeneratorFunction() {}
  73 + function GeneratorFunctionPrototype() {}
  74 +
  75 + // This is a polyfill for %IteratorPrototype% for environments that
  76 + // don't natively support it.
  77 + var IteratorPrototype = {};
  78 + IteratorPrototype[iteratorSymbol] = function () {
  79 + return this;
  80 + };
  81 +
  82 + var getProto = Object.getPrototypeOf;
  83 + var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  84 + if (NativeIteratorPrototype &&
  85 + NativeIteratorPrototype !== Op &&
  86 + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  87 + // This environment has a native %IteratorPrototype%; use it instead
  88 + // of the polyfill.
  89 + IteratorPrototype = NativeIteratorPrototype;
  90 + }
  91 +
  92 + var Gp = GeneratorFunctionPrototype.prototype =
  93 + Generator.prototype = Object.create(IteratorPrototype);
  94 + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  95 + GeneratorFunctionPrototype.constructor = GeneratorFunction;
  96 + GeneratorFunctionPrototype[toStringTagSymbol] =
  97 + GeneratorFunction.displayName = "GeneratorFunction";
  98 +
  99 + // Helper for defining the .next, .throw, and .return methods of the
  100 + // Iterator interface in terms of a single ._invoke method.
  101 + function defineIteratorMethods(prototype) {
  102 + ["next", "throw", "return"].forEach(function(method) {
  103 + prototype[method] = function(arg) {
  104 + return this._invoke(method, arg);
  105 + };
  106 + });
  107 + }
  108 +
  109 + exports.isGeneratorFunction = function(genFun) {
  110 + var ctor = typeof genFun === "function" && genFun.constructor;
  111 + return ctor
  112 + ? ctor === GeneratorFunction ||
  113 + // For the native GeneratorFunction constructor, the best we can
  114 + // do is to check its .name property.
  115 + (ctor.displayName || ctor.name) === "GeneratorFunction"
  116 + : false;
  117 + };
  118 +
  119 + exports.mark = function(genFun) {
  120 + if (Object.setPrototypeOf) {
  121 + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  122 + } else {
  123 + genFun.__proto__ = GeneratorFunctionPrototype;
  124 + if (!(toStringTagSymbol in genFun)) {
  125 + genFun[toStringTagSymbol] = "GeneratorFunction";
  126 + }
  127 + }
  128 + genFun.prototype = Object.create(Gp);
  129 + return genFun;
  130 + };
  131 +
  132 + // Within the body of any async function, `await x` is transformed to
  133 + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  134 + // `hasOwn.call(value, "__await")` to determine if the yielded value is
  135 + // meant to be awaited.
  136 + exports.awrap = function(arg) {
  137 + return { __await: arg };
  138 + };
  139 +
  140 + function AsyncIterator(generator) {
  141 + function invoke(method, arg, resolve, reject) {
  142 + var record = tryCatch(generator[method], generator, arg);
  143 + if (record.type === "throw") {
  144 + reject(record.arg);
  145 + } else {
  146 + var result = record.arg;
  147 + var value = result.value;
  148 + if (value &&
  149 + typeof value === "object" &&
  150 + hasOwn.call(value, "__await")) {
  151 + return Promise.resolve(value.__await).then(function(value) {
  152 + invoke("next", value, resolve, reject);
  153 + }, function(err) {
  154 + invoke("throw", err, resolve, reject);
  155 + });
  156 + }
  157 +
  158 + return Promise.resolve(value).then(function(unwrapped) {
  159 + // When a yielded Promise is resolved, its final value becomes
  160 + // the .value of the Promise<{value,done}> result for the
  161 + // current iteration.
  162 + result.value = unwrapped;
  163 + resolve(result);
  164 + }, function(error) {
  165 + // If a rejected Promise was yielded, throw the rejection back
  166 + // into the async generator function so it can be handled there.
  167 + return invoke("throw", error, resolve, reject);
  168 + });
  169 + }
  170 + }
  171 +
  172 + var previousPromise;
  173 +
  174 + function enqueue(method, arg) {
  175 + function callInvokeWithMethodAndArg() {
  176 + return new Promise(function(resolve, reject) {
  177 + invoke(method, arg, resolve, reject);
  178 + });
  179 + }
  180 +
  181 + return previousPromise =
  182 + // If enqueue has been called before, then we want to wait until
  183 + // all previous Promises have been resolved before calling invoke,
  184 + // so that results are always delivered in the correct order. If
  185 + // enqueue has not been called before, then it is important to
  186 + // call invoke immediately, without waiting on a callback to fire,
  187 + // so that the async generator function has the opportunity to do
  188 + // any necessary setup in a predictable way. This predictability
  189 + // is why the Promise constructor synchronously invokes its
  190 + // executor callback, and why async functions synchronously
  191 + // execute code before the first await. Since we implement simple
  192 + // async functions in terms of async generators, it is especially
  193 + // important to get this right, even though it requires care.
  194 + previousPromise ? previousPromise.then(
  195 + callInvokeWithMethodAndArg,
  196 + // Avoid propagating failures to Promises returned by later
  197 + // invocations of the iterator.
  198 + callInvokeWithMethodAndArg
  199 + ) : callInvokeWithMethodAndArg();
  200 + }
  201 +
  202 + // Define the unified helper method that is used to implement .next,
  203 + // .throw, and .return (see defineIteratorMethods).
  204 + this._invoke = enqueue;
  205 + }
  206 +
  207 + defineIteratorMethods(AsyncIterator.prototype);
  208 + AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  209 + return this;
  210 + };
  211 + exports.AsyncIterator = AsyncIterator;
  212 +
  213 + // Note that simple async functions are implemented on top of
  214 + // AsyncIterator objects; they just return a Promise for the value of
  215 + // the final result produced by the iterator.
  216 + exports.async = function(innerFn, outerFn, self, tryLocsList) {
  217 + var iter = new AsyncIterator(
  218 + wrap(innerFn, outerFn, self, tryLocsList)
  219 + );
  220 +
  221 + return exports.isGeneratorFunction(outerFn)
  222 + ? iter // If outerFn is a generator, return the full iterator.
  223 + : iter.next().then(function(result) {
  224 + return result.done ? result.value : iter.next();
  225 + });
  226 + };
  227 +
  228 + function makeInvokeMethod(innerFn, self, context) {
  229 + var state = GenStateSuspendedStart;
  230 +
  231 + return function invoke(method, arg) {
  232 + if (state === GenStateExecuting) {
  233 + throw new Error("Generator is already running");
  234 + }
  235 +
  236 + if (state === GenStateCompleted) {
  237 + if (method === "throw") {
  238 + throw arg;
  239 + }
  240 +
  241 + // Be forgiving, per 25.3.3.3.3 of the spec:
  242 + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  243 + return doneResult();
  244 + }
  245 +
  246 + context.method = method;
  247 + context.arg = arg;
  248 +
  249 + while (true) {
  250 + var delegate = context.delegate;
  251 + if (delegate) {
  252 + var delegateResult = maybeInvokeDelegate(delegate, context);
  253 + if (delegateResult) {
  254 + if (delegateResult === ContinueSentinel) continue;
  255 + return delegateResult;
  256 + }
  257 + }
  258 +
  259 + if (context.method === "next") {
  260 + // Setting context._sent for legacy support of Babel's
  261 + // function.sent implementation.
  262 + context.sent = context._sent = context.arg;
  263 +
  264 + } else if (context.method === "throw") {
  265 + if (state === GenStateSuspendedStart) {
  266 + state = GenStateCompleted;
  267 + throw context.arg;
  268 + }
  269 +
  270 + context.dispatchException(context.arg);
  271 +
  272 + } else if (context.method === "return") {
  273 + context.abrupt("return", context.arg);
  274 + }
  275 +
  276 + state = GenStateExecuting;
  277 +
  278 + var record = tryCatch(innerFn, self, context);
  279 + if (record.type === "normal") {
  280 + // If an exception is thrown from innerFn, we leave state ===
  281 + // GenStateExecuting and loop back for another invocation.
  282 + state = context.done
  283 + ? GenStateCompleted
  284 + : GenStateSuspendedYield;
  285 +
  286 + if (record.arg === ContinueSentinel) {
  287 + continue;
  288 + }
  289 +
  290 + return {
  291 + value: record.arg,
  292 + done: context.done
  293 + };
  294 +
  295 + } else if (record.type === "throw") {
  296 + state = GenStateCompleted;
  297 + // Dispatch the exception by looping back around to the
  298 + // context.dispatchException(context.arg) call above.
  299 + context.method = "throw";
  300 + context.arg = record.arg;
  301 + }
  302 + }
  303 + };
  304 + }
  305 +
  306 + // Call delegate.iterator[context.method](context.arg) and handle the
  307 + // result, either by returning a { value, done } result from the
  308 + // delegate iterator, or by modifying context.method and context.arg,
  309 + // setting context.delegate to null, and returning the ContinueSentinel.
  310 + function maybeInvokeDelegate(delegate, context) {
  311 + var method = delegate.iterator[context.method];
  312 + if (method === undefined) {
  313 + // A .throw or .return when the delegate iterator has no .throw
  314 + // method always terminates the yield* loop.
  315 + context.delegate = null;
  316 +
  317 + if (context.method === "throw") {
  318 + // Note: ["return"] must be used for ES3 parsing compatibility.
  319 + if (delegate.iterator["return"]) {
  320 + // If the delegate iterator has a return method, give it a
  321 + // chance to clean up.
  322 + context.method = "return";
  323 + context.arg = undefined;
  324 + maybeInvokeDelegate(delegate, context);
  325 +
  326 + if (context.method === "throw") {
  327 + // If maybeInvokeDelegate(context) changed context.method from
  328 + // "return" to "throw", let that override the TypeError below.
  329 + return ContinueSentinel;
  330 + }
  331 + }
  332 +
  333 + context.method = "throw";
  334 + context.arg = new TypeError(
  335 + "The iterator does not provide a 'throw' method");
  336 + }
  337 +
  338 + return ContinueSentinel;
  339 + }
  340 +
  341 + var record = tryCatch(method, delegate.iterator, context.arg);
  342 +
  343 + if (record.type === "throw") {
  344 + context.method = "throw";
  345 + context.arg = record.arg;
  346 + context.delegate = null;
  347 + return ContinueSentinel;
  348 + }
  349 +
  350 + var info = record.arg;
  351 +
  352 + if (! info) {
  353 + context.method = "throw";
  354 + context.arg = new TypeError("iterator result is not an object");
  355 + context.delegate = null;
  356 + return ContinueSentinel;
  357 + }
  358 +
  359 + if (info.done) {
  360 + // Assign the result of the finished delegate to the temporary
  361 + // variable specified by delegate.resultName (see delegateYield).
  362 + context[delegate.resultName] = info.value;
  363 +
  364 + // Resume execution at the desired location (see delegateYield).
  365 + context.next = delegate.nextLoc;
  366 +
  367 + // If context.method was "throw" but the delegate handled the
  368 + // exception, let the outer generator proceed normally. If
  369 + // context.method was "next", forget context.arg since it has been
  370 + // "consumed" by the delegate iterator. If context.method was
  371 + // "return", allow the original .return call to continue in the
  372 + // outer generator.
  373 + if (context.method !== "return") {
  374 + context.method = "next";
  375 + context.arg = undefined;
  376 + }
  377 +
  378 + } else {
  379 + // Re-yield the result returned by the delegate method.
  380 + return info;
  381 + }
  382 +
  383 + // The delegate iterator is finished, so forget it and continue with
  384 + // the outer generator.
  385 + context.delegate = null;
  386 + return ContinueSentinel;
  387 + }
  388 +
  389 + // Define Generator.prototype.{next,throw,return} in terms of the
  390 + // unified ._invoke helper method.
  391 + defineIteratorMethods(Gp);
  392 +
  393 + Gp[toStringTagSymbol] = "Generator";
  394 +
  395 + // A Generator should always return itself as the iterator object when the
  396 + // @@iterator function is called on it. Some browsers' implementations of the
  397 + // iterator prototype chain incorrectly implement this, causing the Generator
  398 + // object to not be returned from this call. This ensures that doesn't happen.
  399 + // See https://github.com/facebook/regenerator/issues/274 for more details.
  400 + Gp[iteratorSymbol] = function() {
  401 + return this;
  402 + };
  403 +
  404 + Gp.toString = function() {
  405 + return "[object Generator]";
  406 + };
  407 +
  408 + function pushTryEntry(locs) {
  409 + var entry = { tryLoc: locs[0] };
  410 +
  411 + if (1 in locs) {
  412 + entry.catchLoc = locs[1];
  413 + }
  414 +
  415 + if (2 in locs) {
  416 + entry.finallyLoc = locs[2];
  417 + entry.afterLoc = locs[3];
  418 + }
  419 +
  420 + this.tryEntries.push(entry);
  421 + }
  422 +
  423 + function resetTryEntry(entry) {
  424 + var record = entry.completion || {};
  425 + record.type = "normal";
  426 + delete record.arg;
  427 + entry.completion = record;
  428 + }
  429 +
  430 + function Context(tryLocsList) {
  431 + // The root entry object (effectively a try statement without a catch
  432 + // or a finally block) gives us a place to store values thrown from
  433 + // locations where there is no enclosing try statement.
  434 + this.tryEntries = [{ tryLoc: "root" }];
  435 + tryLocsList.forEach(pushTryEntry, this);
  436 + this.reset(true);
  437 + }
  438 +
  439 + exports.keys = function(object) {
  440 + var keys = [];
  441 + for (var key in object) {
  442 + keys.push(key);
  443 + }
  444 + keys.reverse();
  445 +
  446 + // Rather than returning an object with a next method, we keep
  447 + // things simple and return the next function itself.
  448 + return function next() {
  449 + while (keys.length) {
  450 + var key = keys.pop();
  451 + if (key in object) {
  452 + next.value = key;
  453 + next.done = false;
  454 + return next;
  455 + }
  456 + }
  457 +
  458 + // To avoid creating an additional object, we just hang the .value
  459 + // and .done properties off the next function object itself. This
  460 + // also ensures that the minifier will not anonymize the function.
  461 + next.done = true;
  462 + return next;
  463 + };
  464 + };
  465 +
  466 + function values(iterable) {
  467 + if (iterable) {
  468 + var iteratorMethod = iterable[iteratorSymbol];
  469 + if (iteratorMethod) {
  470 + return iteratorMethod.call(iterable);
  471 + }
  472 +
  473 + if (typeof iterable.next === "function") {
  474 + return iterable;
  475 + }
  476 +
  477 + if (!isNaN(iterable.length)) {
  478 + var i = -1, next = function next() {
  479 + while (++i < iterable.length) {
  480 + if (hasOwn.call(iterable, i)) {
  481 + next.value = iterable[i];
  482 + next.done = false;
  483 + return next;
  484 + }
  485 + }
  486 +
  487 + next.value = undefined;
  488 + next.done = true;
  489 +
  490 + return next;
  491 + };
  492 +
  493 + return next.next = next;
  494 + }
  495 + }
  496 +
  497 + // Return an iterator with no values.
  498 + return { next: doneResult };
  499 + }
  500 + exports.values = values;
  501 +
  502 + function doneResult() {
  503 + return { value: undefined, done: true };
  504 + }
  505 +
  506 + Context.prototype = {
  507 + constructor: Context,
  508 +
  509 + reset: function(skipTempReset) {
  510 + this.prev = 0;
  511 + this.next = 0;
  512 + // Resetting context._sent for legacy support of Babel's
  513 + // function.sent implementation.
  514 + this.sent = this._sent = undefined;
  515 + this.done = false;
  516 + this.delegate = null;
  517 +
  518 + this.method = "next";
  519 + this.arg = undefined;
  520 +
  521 + this.tryEntries.forEach(resetTryEntry);
  522 +
  523 + if (!skipTempReset) {
  524 + for (var name in this) {
  525 + // Not sure about the optimal order of these conditions:
  526 + if (name.charAt(0) === "t" &&
  527 + hasOwn.call(this, name) &&
  528 + !isNaN(+name.slice(1))) {
  529 + this[name] = undefined;
  530 + }
  531 + }
  532 + }
  533 + },
  534 +
  535 + stop: function() {
  536 + this.done = true;
  537 +
  538 + var rootEntry = this.tryEntries[0];
  539 + var rootRecord = rootEntry.completion;
  540 + if (rootRecord.type === "throw") {
  541 + throw rootRecord.arg;
  542 + }
  543 +
  544 + return this.rval;
  545 + },
  546 +
  547 + dispatchException: function(exception) {
  548 + if (this.done) {
  549 + throw exception;
  550 + }
  551 +
  552 + var context = this;
  553 + function handle(loc, caught) {
  554 + record.type = "throw";
  555 + record.arg = exception;
  556 + context.next = loc;
  557 +
  558 + if (caught) {
  559 + // If the dispatched exception was caught by a catch block,
  560 + // then let that catch block handle the exception normally.
  561 + context.method = "next";
  562 + context.arg = undefined;
  563 + }
  564 +
  565 + return !! caught;
  566 + }
  567 +
  568 + for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  569 + var entry = this.tryEntries[i];
  570 + var record = entry.completion;
  571 +
  572 + if (entry.tryLoc === "root") {
  573 + // Exception thrown outside of any try block that could handle
  574 + // it, so set the completion value of the entire function to
  575 + // throw the exception.
  576 + return handle("end");
  577 + }
  578 +
  579 + if (entry.tryLoc <= this.prev) {
  580 + var hasCatch = hasOwn.call(entry, "catchLoc");
  581 + var hasFinally = hasOwn.call(entry, "finallyLoc");
  582 +
  583 + if (hasCatch && hasFinally) {
  584 + if (this.prev < entry.catchLoc) {
  585 + return handle(entry.catchLoc, true);
  586 + } else if (this.prev < entry.finallyLoc) {
  587 + return handle(entry.finallyLoc);
  588 + }
  589 +
  590 + } else if (hasCatch) {
  591 + if (this.prev < entry.catchLoc) {
  592 + return handle(entry.catchLoc, true);
  593 + }
  594 +
  595 + } else if (hasFinally) {
  596 + if (this.prev < entry.finallyLoc) {
  597 + return handle(entry.finallyLoc);
  598 + }
  599 +
  600 + } else {
  601 + throw new Error("try statement without catch or finally");
  602 + }
  603 + }
  604 + }
  605 + },
  606 +
  607 + abrupt: function(type, arg) {
  608 + for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  609 + var entry = this.tryEntries[i];
  610 + if (entry.tryLoc <= this.prev &&
  611 + hasOwn.call(entry, "finallyLoc") &&
  612 + this.prev < entry.finallyLoc) {
  613 + var finallyEntry = entry;
  614 + break;
  615 + }
  616 + }
  617 +
  618 + if (finallyEntry &&
  619 + (type === "break" ||
  620 + type === "continue") &&
  621 + finallyEntry.tryLoc <= arg &&
  622 + arg <= finallyEntry.finallyLoc) {
  623 + // Ignore the finally entry if control is not jumping to a
  624 + // location outside the try/catch block.
  625 + finallyEntry = null;
  626 + }
  627 +
  628 + var record = finallyEntry ? finallyEntry.completion : {};
  629 + record.type = type;
  630 + record.arg = arg;
  631 +
  632 + if (finallyEntry) {
  633 + this.method = "next";
  634 + this.next = finallyEntry.finallyLoc;
  635 + return ContinueSentinel;
  636 + }
  637 +
  638 + return this.complete(record);
  639 + },
  640 +
  641 + complete: function(record, afterLoc) {
  642 + if (record.type === "throw") {
  643 + throw record.arg;
  644 + }
  645 +
  646 + if (record.type === "break" ||
  647 + record.type === "continue") {
  648 + this.next = record.arg;
  649 + } else if (record.type === "return") {
  650 + this.rval = this.arg = record.arg;
  651 + this.method = "return";
  652 + this.next = "end";
  653 + } else if (record.type === "normal" && afterLoc) {
  654 + this.next = afterLoc;
  655 + }
  656 +
  657 + return ContinueSentinel;
  658 + },
  659 +
  660 + finish: function(finallyLoc) {
  661 + for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  662 + var entry = this.tryEntries[i];
  663 + if (entry.finallyLoc === finallyLoc) {
  664 + this.complete(entry.completion, entry.afterLoc);
  665 + resetTryEntry(entry);
  666 + return ContinueSentinel;
  667 + }
  668 + }
  669 + },
  670 +
  671 + "catch": function(tryLoc) {
  672 + for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  673 + var entry = this.tryEntries[i];
  674 + if (entry.tryLoc === tryLoc) {
  675 + var record = entry.completion;
  676 + if (record.type === "throw") {
  677 + var thrown = record.arg;
  678 + resetTryEntry(entry);
  679 + }
  680 + return thrown;
  681 + }
  682 + }
  683 +
  684 + // The context.catch method must only be called with a location
  685 + // argument that corresponds to a known catch block.
  686 + throw new Error("illegal catch attempt");
  687 + },
  688 +
  689 + delegateYield: function(iterable, resultName, nextLoc) {
  690 + this.delegate = {
  691 + iterator: values(iterable),
  692 + resultName: resultName,
  693 + nextLoc: nextLoc
  694 + };
  695 +
  696 + if (this.method === "next") {
  697 + // Deliberately forget the last sent value so that we don't
  698 + // accidentally pass it on to the delegate.
  699 + this.arg = undefined;
  700 + }
  701 +
  702 + return ContinueSentinel;
  703 + }
  704 + };
  705 +
  706 + // Regardless of whether this script is executing as a CommonJS module
  707 + // or not, return the runtime object so that we can declare the variable
  708 + // regeneratorRuntime in the outer scope, which allows this module to be
  709 + // injected easily by `bin/regenerator --include-runtime script.js`.
  710 + return exports;
  711 +
  712 +}(
  713 + // If this script is executing as a CommonJS module, use module.exports
  714 + // as the regeneratorRuntime namespace. Otherwise create a new empty
  715 + // object. Either way, the resulting object will be used to initialize
  716 + // the regeneratorRuntime variable at the top of this file.
  717 + typeof module === "object" ? module.exports : {}
  718 +));
  719 +
  720 +}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  721 +return __REQUIRE__(1542938356632);
  722 +})()
  723 +//# sourceMappingURL=index.js.map
  1 +{"version":3,"sources":["runtime.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar regeneratorRuntime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n"]}
  1 +// component/login-component/login-component.js
  2 +Component({
  3 + /**
  4 + * 组件的属性列表
  5 + */
  6 + properties: {
  7 +
  8 + },
  9 +
  10 + /**
  11 + * 组件的初始数据
  12 + */
  13 + data: {
  14 + openType: 'getUserInfo'
  15 + },
  16 +
  17 + getUserInfo(e) {
  18 + this.setData({
  19 + openType: 'getPhoneNumber'
  20 + })
  21 + },
  22 +
  23 + /**
  24 + * 组件的方法列表
  25 + */
  26 + methods: {
  27 +
  28 + }
  29 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "login": "../login/login"
  5 + }
  6 +}
  1 +<!--component/login-component/login-component.wxml-->
  2 +<login theme="light" openType="{{openType}}" bindgetuserinfo="getUserInfo"></login>
  1 +/* component/login-component/login-component.wxss */
  1 +// pages/login-page/login-page.js
  2 +import regeneratorRuntime from '../libs/regenerator-runtime/index.js';
  3 +import { getSettingPromise } from '../utils/index.js'
  4 +const event = global.event;
  5 +Page({
  6 +
  7 + /**
  8 + * 页面的初始数据
  9 + */
  10 + data: {
  11 + openType: 'getUserInfo'
  12 + },
  13 +
  14 + /**
  15 + * 生命周期函数--监听页面加载
  16 + */
  17 + onLoad: function (options) {
  18 + this.checkUnionId();
  19 + event.on('wechat-login-success', this.loginSuccess);
  20 + event.on('wechat-login-callback', this.loginCallback);
  21 + event.on('wechat-login-change-status', this.loginChangeStatus);
  22 + event.on('wechat-login-error', this.loginError);
  23 + },
  24 +
  25 + async checkUnionId() {
  26 + let union_id = wx.getStorageSync('union_id');
  27 + let res = await getSettingPromise();
  28 +
  29 + if (res.authSetting["scope.userInfo"] !== null &&
  30 + res.authSetting["scope.userInfo"] !== undefined &&
  31 + res.authSetting["scope.userInfo"] === true) {
  32 + if (union_id) {
  33 + this.setData({
  34 + openType: 'none-open-type',
  35 + })
  36 + } else {
  37 + this.setData({
  38 + openType: 'getUserInfo'
  39 + })
  40 + }
  41 + } else {
  42 + this.setData({
  43 + openType: 'getUserInfo'
  44 + })
  45 + }
  46 + },
  47 +
  48 + loginChangeStatus(params) {
  49 + let { openType } = params;
  50 + this.setData({
  51 + openType
  52 + })
  53 + },
  54 +
  55 + loginCallback(params) {
  56 + console.log(params);
  57 + },
  58 +
  59 + loginSuccess(params) {
  60 + console.log(params);
  61 + this.goReferer();
  62 + },
  63 +
  64 + loginError(error) {
  65 + console.error(error);
  66 + },
  67 +
  68 + goReferer() {
  69 + wx.navigateBack({
  70 + delta: 1
  71 + });
  72 + },
  73 +
  74 + /**
  75 + * 生命周期函数--监听页面初次渲染完成
  76 + */
  77 + onReady: function () {
  78 +
  79 + },
  80 +
  81 + /**
  82 + * 生命周期函数--监听页面显示
  83 + */
  84 + onShow: function () {
  85 +
  86 + },
  87 +
  88 + /**
  89 + * 生命周期函数--监听页面隐藏
  90 + */
  91 + onHide: function () {
  92 +
  93 + },
  94 +
  95 + /**
  96 + * 生命周期函数--监听页面卸载
  97 + */
  98 + onUnload: function () {
  99 + event.remove('wechat-login-success', this.loginSuccess);
  100 + event.remove('wechat-login-callback', this.loginCallback);
  101 + event.remove('wechat-login-change-status', this.loginChangeStatus);
  102 + event.remove('wechat-login-error', this.loginError);
  103 + },
  104 +
  105 + /**
  106 + * 页面相关事件处理函数--监听用户下拉动作
  107 + */
  108 + onPullDownRefresh: function () {
  109 +
  110 + },
  111 +
  112 + /**
  113 + * 页面上拉触底事件的处理函数
  114 + */
  115 + onReachBottom: function () {
  116 +
  117 + },
  118 +
  119 + /**
  120 + * 用户点击右上角分享
  121 + */
  122 + onShareAppMessage: function () {
  123 +
  124 + }
  125 +})
  1 +{
  2 + "usingComponents": {
  3 + "login": "../login/login"
  4 + }
  5 +}
  1 +<!--pages/login-page/login-page.wxml-->
  2 +<login theme="light" openType="{{openType}}" bindgetuserinfo="getUserInfo"></login>
  1 +/* pages/login-page/login-page.wxss */
  2 +page {
  3 + height: 100%;
  4 +}
  1 +// component/login/login.js
  2 +import { getUserInfo, getPhoneNumber, checkUnionIdIsBind } from '../utils/login/login.js';
  3 +Component({
  4 + /**
  5 + * 组件的属性列表
  6 + */
  7 + properties: {
  8 + theme: {
  9 + type: String,
  10 + value: 'light'
  11 + },
  12 + isShow: Boolean,
  13 + openType: {
  14 + type: String,
  15 + value: "getUserInfo",
  16 + observer: function (newValue, oldValue) {
  17 + if (newValue === "getPhoneNumber") {
  18 + this.setData({
  19 + loginBtnTitle: "绑定手机号"
  20 + })
  21 + } else if (newValue === 'getUserInfo') {
  22 + this.setData({
  23 + loginBtnTitle: "微信授权登录"
  24 + })
  25 + } else {
  26 + this.setData({
  27 + loginBtnTitle: "微信登录",
  28 + checkUnionIdIsBind: 'checkUnionIdIsBind'
  29 + })
  30 + }
  31 + }
  32 + }
  33 + },
  34 +
  35 + /**
  36 + * 组件的初始数据
  37 + */
  38 + data: {
  39 + logo: "https://feature.yoho.cn/1019/youhuo2.png",
  40 + lightLogo: "https://img11.static.yhbimg.com/article/2018/11/29/11/018a4f01d4621f9072788f6510ac83bfec.png",
  41 + loginBtnTitle: "微信授权登录",
  42 + subLogoTitle: "LIVE IN STAY COOL",
  43 + tips: "还差一步,绑定手机号,加入Yoho!Family!",
  44 + checkUnionIdIsBind: ''
  45 + },
  46 +
  47 + /**
  48 + * 组件的方法列表
  49 + */
  50 + methods: {
  51 + getUserInfo,
  52 + getPhoneNumber,
  53 + checkUnionIdIsBind
  54 + }
  55 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<block wx:if="{{theme}}">
  2 + <view class="login-{{theme}}-bg login-bg column" catchtouchmove>
  3 + <image class="login-logo" src="{{theme === 'light' ? lightLogo : logo}}"></image>
  4 + <view class="login-sub-logo-title-view row">
  5 + <text class="login-sub-logo-title-line login-{{theme}}-sub-logo-title-line">––</text>
  6 + <text class="login-sub-logo-title login-{{theme}}-sub-logo-title">{{subLogoTitle}}</text>
  7 + <text class="login-sub-logo-title-line login-{{theme}}-sub-logo-title-line">––</text>
  8 + </view>
  9 + <button class="login-btn login-{{theme}}-btn" bindtap="{{checkUnionIdIsBind}}" bindgetuserinfo="getUserInfo" bindgetphonenumber="getPhoneNumber" open-type="{{openType}}">{{loginBtnTitle}}</button>
  10 + <text class="login-text-tips login-{{theme}}-text-tips" wx:if="{{openType == 'getPhoneNumber'}}">{{tips}}</text>
  11 + </view>
  12 +</block>
  1 +/* component/login/login.wxss */
  2 +@import '../common/style/common.wxss';
  3 +
  4 +.login-bg {
  5 + width: 100%;
  6 + height: 100%;
  7 + align-items: center;
  8 +}
  9 +
  10 +.login-dark-bg {
  11 + background-color: #252222;
  12 +}
  13 +
  14 +.login-light-bg {
  15 + background-color: white;
  16 +}
  17 +
  18 +.login-btn::after {
  19 + border-radius: 0;
  20 + border: 0;
  21 +}
  22 +
  23 +.login-btn {
  24 + line-height: 88rpx;
  25 + font-size: 32rpx;
  26 + letter-spacing: 8rpx;
  27 + text-align: center;
  28 + border-radius: 44rpx;
  29 + width: 80%;
  30 +}
  31 +
  32 +.login-dark-btn {
  33 + color: #fff;
  34 + background-color: #a69073;
  35 +}
  36 +
  37 +.login-light-btn {
  38 + color: #fff;
  39 + background-color: #222;
  40 +}
  41 +
  42 +.login-logo {
  43 + width: 366rpx;
  44 + height: 312rpx;
  45 + margin-top: 242rpx;
  46 +}
  47 +
  48 +.login-text-tips {
  49 + font-family: PingFang-SC-Light;
  50 + font-size: 24rpx;
  51 + letter-spacing: 0;
  52 + text-align: center;
  53 + margin-top: 24rpx;
  54 +}
  55 +
  56 +.login-dark-text-tips {
  57 + color: #fff;
  58 +}
  59 +
  60 +.login-light-text-tips {
  61 + color: #b0b0b0;
  62 +}
  63 +
  64 +.login-sub-logo-title {
  65 + font-family: Arial-BoldMT;
  66 + font-size: 28rpx;
  67 + letter-spacing: 0;
  68 + text-align: left;
  69 + font-weight: 500;
  70 + margin-left: 20rpx;
  71 + margin-right: 20rpx;
  72 +}
  73 +
  74 +.login-dark-sub-logo-title {
  75 + color: #fff;
  76 +}
  77 +
  78 +.login-light-sub-logo-title {
  79 + color: #222;
  80 +}
  81 +
  82 +.login-sub-logo-title-line {
  83 + font-family: Arial-BoldMT;
  84 + font-size: 28rpx;
  85 + letter-spacing: 0;
  86 + text-align: left;
  87 + font-weight: 500;
  88 + padding-bottom: 10rpx;
  89 +}
  90 +
  91 +.login-dark-sub-logo-title-line {
  92 + color: #fff;
  93 +}
  94 +
  95 +.login-light-sub-logo-title-line {
  96 + color: #222;
  97 +}
  98 +
  99 +.login-sub-logo-title-view {
  100 + align-items: center;
  101 + margin-top: 58rpx;
  102 + margin-bottom: 216rpx;
  103 +}
  1 +/**
  2 + * description: 参考借鉴 Node.js 的 EventEmitter
  3 + * 对象管理 event 事件
  4 + * @func on 监听
  5 + * @func emit 触发
  6 + * @func once 监听只执行一次
  7 + * @func remove 移除某个类型的某个事件
  8 + * @func removeAll 移除某个类型的全部事件/所有类型的全部事件
  9 + */
  10 +export default class EventEmitter {
  11 + constructor() {
  12 + this._events = Object.create(null);
  13 + this._eventsCount = 0;
  14 + }
  15 +
  16 + /**
  17 + * emit 触发事件
  18 + * @param type 事件名
  19 + * @param ...args 参数
  20 + */
  21 + emit(type) {
  22 + let events, handler, len, isFn;
  23 +
  24 + events = this._events;
  25 + handler = events[type];
  26 +
  27 + if (!handler)
  28 + return false;
  29 +
  30 + isFn = typeof handler === 'function';
  31 + len = arguments.length;
  32 +
  33 + // 优化性能
  34 + switch(len) {
  35 + case 0:
  36 + throw new Error('"emit" not have arguments');
  37 + break;
  38 + case 1:
  39 + emitNone(handler, isFn, this);
  40 + break;
  41 + case 2:
  42 + emitOne(handler, isFn, this, arguments[1]);
  43 + break;
  44 + case 3:
  45 + emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  46 + break;
  47 + case 4:
  48 + emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  49 + break;
  50 + default:
  51 + args = new Array(len - 1);
  52 + for (let i = 1; i < len; i++) {
  53 + args[i - 1] = arguments[i];
  54 + }
  55 + emitMany(handler, isFn, this, args);
  56 + }
  57 +
  58 + return true;
  59 + }
  60 +
  61 + _addListener(type, listener, prepend) {
  62 + let events;
  63 + let existing;
  64 + if (typeof listener !== 'function')
  65 + throw new Error('"listener" argument must be a function');
  66 +
  67 + events = this._events;
  68 +
  69 + if (typeof events === 'undefined') {
  70 + events = this._events = Object.create(null);
  71 + this._eventsCount = 0;
  72 + } else {
  73 + existing = events[type];
  74 + }
  75 +
  76 + if (!existing) {
  77 + existing = events[type] = listener;
  78 + ++this._eventsCount;
  79 + } else {
  80 + if (typeof existing === 'function') {
  81 + existing = events[type] = prepend ? [listener, existing] : [existing, listener];
  82 + } else if (prepend) {
  83 + existing.unshift(listener);
  84 + } else {
  85 + existing.push(listener);
  86 + }
  87 + }
  88 +
  89 + return this;
  90 + }
  91 +
  92 + /**
  93 + * on 监听事件
  94 + * @param type 事件名
  95 + * @param listener 监听函数
  96 + */
  97 + on(type, listener) {
  98 + return this._addListener(type, listener, false);
  99 + }
  100 +
  101 + /**
  102 + * once 监听只执行一次事件
  103 + * @param type 事件名
  104 + * @param listener 只执行一次的监听函数
  105 + */
  106 + once(type, listener) {
  107 + if (typeof listener !== 'function')
  108 + throw new Error('"listener" argument must be a function');
  109 + this.on(type, _onceWrap(this, type, listener));
  110 + return this;
  111 + }
  112 +
  113 + /**
  114 + * prepend 优先监听事件
  115 + * @param type 事件名
  116 + * @param listener 要优先的监听函数
  117 + */
  118 + prepend(type, listener) {
  119 + return this._addListener(type, listener, true);
  120 + }
  121 +
  122 + /**
  123 + * prependOnce 优先只执行一次的监听事件
  124 + * @param type 事件名
  125 + * @param listener 要优先且只执行一次的监听函数
  126 + */
  127 + prependOnce(type, listener) {
  128 + if (typeof listener !== 'function')
  129 + throw new TypeError('"listener" argument must be a function');
  130 + this.prepend(type, _onceWrap(this, type, listener));
  131 + return this;
  132 + }
  133 +
  134 + /**
  135 + * remove 移除的监听事件
  136 + * @param type 事件名
  137 + * @param listener 要移除的监听函数(可选)
  138 + */
  139 + remove(type, listener) {
  140 + let list, events, position, originalListener;
  141 +
  142 + if (typeof listener !== 'function')
  143 + throw new TypeError('"listener" argument must be a function');
  144 +
  145 + events = this._events;
  146 + if (!events) {
  147 + return this;
  148 + }
  149 +
  150 + list = events[type];
  151 + if (!list) {
  152 + return this;
  153 + }
  154 +
  155 + if (list === listener || list.listener === listener) {
  156 + if (--this._eventsCount === 0) {
  157 + this._events = Object.create(null);
  158 + } else {
  159 + delete events[type];
  160 + }
  161 + } else if (typeof list !== 'function') {
  162 + position = -1;
  163 +
  164 + for (let i = list.length - 1; i >= 0; i--) {
  165 + if (list[i] === listener || list[i].listener === listener) {
  166 + originalListener = list[i].listener;
  167 + position = i;
  168 + break;
  169 + }
  170 + }
  171 +
  172 + if (position < 0) {
  173 + return this;
  174 + }
  175 +
  176 + if (position === 0) {
  177 + list.shift();
  178 + } else {
  179 + spliceOne(list, position);
  180 + }
  181 +
  182 + if (list.length === 1) {
  183 + events[type] = list[0];
  184 + }
  185 + }
  186 +
  187 + return this;
  188 + }
  189 +
  190 + /**
  191 + * removeAll 移除某事件名的全部监听事件/移除全部事件名的事件
  192 + * @param type 事件名
  193 + */
  194 + removeAll(type) {
  195 + let listeners, events;
  196 +
  197 + events = this._events;
  198 +
  199 + if (!events)
  200 + return this;
  201 +
  202 + if (arguments.length === 0) {
  203 + var keys = Object.keys(events);
  204 + var key;
  205 + for (let i = 0; i < keys.length; ++i) {
  206 + key = keys[i];
  207 + this.removeAll(key);
  208 + }
  209 + this._events = Object.create(null);
  210 + this._eventsCount = 0;
  211 + return this;
  212 + }
  213 +
  214 + listeners = events[type];
  215 +
  216 + if (typeof listeners === 'function') {
  217 + this.remove(type, listeners);
  218 + } else if (listeners !== undefined) {
  219 + for (let i = listeners.length - 1; i >= 0; i--) {
  220 + this.remove(type, listeners[i]);
  221 + }
  222 + }
  223 +
  224 + return this;
  225 + }
  226 +
  227 + eventNames() {
  228 + return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  229 + }
  230 +}
  231 +
  232 +
  233 +const emitNone = (handler, isFn, self) => {
  234 + if (isFn) {
  235 + handler.call(self);
  236 + } else {
  237 + let len = handler.length;
  238 + let listeners = arrayClone(handler, len);
  239 + for (let i = 0; i < len; ++i)
  240 + listeners[i].call(self);
  241 + }
  242 +}
  243 +
  244 +const emitOne = (handler, isFn, self, arg1) => {
  245 + if (isFn) {
  246 + handler.call(self, arg1);
  247 + } else {
  248 + let len = handler.length;
  249 + let listeners = arrayClone(handler, len);
  250 + for (let i = 0; i < len; ++i)
  251 + listeners[i].call(self, arg1);
  252 + }
  253 +}
  254 +
  255 +const emitTwo = (handler, isFn, self, arg1, arg2) => {
  256 + if (isFn) {
  257 + handler.call(self, arg1, arg2);
  258 + } else {
  259 + let len = handler.length;
  260 + let listeners = arrayClone(handler, len);
  261 + for (let i = 0; i < len; ++i)
  262 + listeners[i].call(self, arg1, arg2);
  263 + }
  264 +}
  265 +
  266 +const emitThree = (handler, isFn, self, arg1, arg2, arg3) => {
  267 + if (isFn) {
  268 + handler.call(self, arg1, arg2, arg3);
  269 + } else {
  270 + let len = handler.length;
  271 + let listeners = arrayClone(handler, len);
  272 + for (let i = 0; i < len; ++i)
  273 + listeners[i].call(self, arg1, arg2, arg3);
  274 + }
  275 +}
  276 +
  277 +const emitMany = (handler, isFn, self, args) => {
  278 + if (isFn) {
  279 + handler.apply(self, args);
  280 + } else {
  281 + let len = handler.length;
  282 + let listeners = arrayClone(handler, len);
  283 + for (let i = 0; i < len; ++i)
  284 + listeners[i].apply(self, args);
  285 + }
  286 +}
  287 +
  288 +const spliceOne = (list, index) => {
  289 + for (; index + 1 < list.length; index++)
  290 + list[index] = list[index + 1];
  291 + list.pop();
  292 +}
  293 +
  294 +function onceWrapper(...args) {
  295 + if (!this.fired) {
  296 + this.target.remove(this.type, this.wrapFn);
  297 + this.fired = true;
  298 + Reflect.apply(this.listener, this.target, args);
  299 + }
  300 +}
  301 +
  302 +const _onceWrap = (target, type, listener) => {
  303 + var state = { fired: false, wrapFn: undefined, target, type, listener };
  304 + var wrapped = onceWrapper.bind(state);
  305 + wrapped.listener = listener;
  306 + state.wrapFn = wrapped;
  307 + return wrapped;
  308 +}
  1 +export const toPromise = (platform) => {
  2 + return (method) => {
  3 + return (option) => {
  4 + return new Promise ((resolve, reject) => {
  5 + platform[method]({
  6 + ...option,
  7 + success: (res) => { resolve(res) },
  8 + fail: (err) => { reject(err) }
  9 + })
  10 + })
  11 + }
  12 + }
  13 +}
  14 +
  15 +export const toPromiseWX = toPromise(wx);
  16 +const setStoragePromise = toPromiseWX('setStorage');
  17 +export const getSettingPromise = toPromiseWX('getSetting');
  18 +
  19 +export const setStorageValueForKey = (key, value) => {
  20 + return setStoragePromise({
  21 + key,
  22 + data: value
  23 + });
  24 +}
  25 +
  26 +import EventEmitter from './event.js';
  27 +
  28 +export const Event = EventEmitter;
  1 +import LoginService from '../service/login-service.js';
  2 +import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
  3 +import { toPromiseWX, setStorageValueForKey } from '../index.js';
  4 +
  5 +const login = new LoginService();
  6 +const loginPromise = toPromiseWX('login');
  7 +
  8 +const saveLoginData = (loginData) => {
  9 + setStorageValueForKey('open_id', loginData.openid);
  10 + setStorageValueForKey('srd_session', loginData.srd_session);
  11 + if (loginData && loginData.unionid) {
  12 + setStorageValueForKey('union_id', loginData.unionid);
  13 + }
  14 +}
  15 +
  16 +export const wxLogin = async () => {
  17 + try {
  18 + // 调用 wx.login
  19 + const res = await loginPromise();
  20 + // 根据上传的 code 返回 open_id 等信息
  21 + const loginData = await login.checkLogin(res.code);
  22 + // 本地存储 open_id srd_session union_id
  23 + await saveLoginData(loginData);
  24 + } catch (error) {
  25 + // 注意: 此处应异常上报
  26 + console.log(error);
  27 + }
  28 +};
  29 +
  30 +export const getUserInfo = async (e) => {
  31 + const event = global.event;
  32 + try {
  33 + if (e.detail.errMsg === 'getUserInfo:ok') {
  34 + await setStorageValueForKey('userInfo', e.detail.userInfo);
  35 + const srd_session = wx.getStorageSync('srd_session') || '';
  36 + const json = await login.decodeUserInfo(srd_session, e.detail.encryptedData, e.detail.iv);
  37 + if (json && json.union_id) {
  38 + wechatUnionIdIsBind(json.union_id, e.detail.userInfo);
  39 + } else {
  40 + throw new Error('微信授权失败,请使用手机号登录');
  41 + }
  42 + } else {
  43 + throw new Error('微信授权失败,请使用手机号登录');
  44 + }
  45 + } catch (error) {
  46 + event.emit('wechat-login-error', error);
  47 + }
  48 +}
  49 +
  50 +export const getPhoneNumber = async (e) => {
  51 + const event = global.event;
  52 + try {
  53 + if (e.detail.errMsg === 'getPhoneNumber:ok') {
  54 + const srd_session = wx.getStorageSync('srd_session') || '';
  55 + const union_id = wx.getStorageSync('union_id') || '';
  56 + const phoneNumberInfo = await login.decodeUserInfo(srd_session, e.detail.encryptedData, e.detail.iv);
  57 + const { phoneNumber, countryCode } = phoneNumberInfo;
  58 + if (!(countryCode && phoneNumber)) {
  59 + throw new Error('手机号获取失败,请使用手机号登录');
  60 + }
  61 + const bindResult = await login.bindMiniAppByAuto(union_id, phoneNumber, countryCode);
  62 + console.log(bindResult);
  63 + } else {
  64 + throw new Error('手机号获取失败,请使用手机号登录');
  65 + }
  66 + } catch (error) {
  67 + console.log(error);
  68 + event.emit('wechat-login-error', error);
  69 + }
  70 +}
  71 +
  72 +export const checkUnionIdIsBind = (e) => {
  73 + let union_id = wx.getStorageSync('union_id') || '';
  74 + let userInfo = wx.getStorageSync('userInfo') || {};
  75 + wechatUnionIdIsBind(union_id, userInfo);
  76 +}
  77 +
  78 +const wechatUnionIdIsBind = async (union_id, userInfo) => {
  79 + const event = global.event;
  80 + let globalData = getApp().globalData;
  81 + try {
  82 + const user_bind_info = await login.wechatUserIsBind(union_id);
  83 + if (user_bind_info && user_bind_info.is_bind === 'Y') {
  84 + const { mobile, session_key, uid, ssouid } = user_bind_info;
  85 + // 保存 uid session_key
  86 + const newUserInfo = Object.assign(userInfo, { mobile, session_key, uid, ssouid });
  87 + await setStorageValueForKey('userInfo', newUserInfo);
  88 + await setStorageValueForKey('sessionkey', session_key);
  89 + globalData.sessionkey = session_key;
  90 + globalData.userInfo = userInfo;
  91 + // 赋值全局变量
  92 +
  93 + // 上传保存头像
  94 + login.sendWeChatUserData(uid, userInfo.nickName, userInfo.avatarUrl).catch(error => {});
  95 + // 触发事件登录成功
  96 + event.emit('wechat-login-success', newUserInfo);
  97 + } else {
  98 + // 修改按钮状态, 获取手机号绑定手机号
  99 + event.emit('wechat-login-change-status', { openType: 'getPhoneNumber' });
  100 + }
  101 + } catch (error) {
  102 + event.emit('wechat-login-error', error);
  103 + }
  104 +}
  1 +/**
  2 + * 网络请求基类
  3 + * @param url 网络请求地址(可选)
  4 + * @param other 其他参数(自选)
  5 + *
  6 + */
  7 +import { GET } from '../../../libs/request';
  8 +import config from '../../../config.js';
  9 +import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
  10 +
  11 +export default class BaseService {
  12 + constructor() {
  13 + this.url = config.domains.service;
  14 + }
  15 +
  16 + async GET(params, options) {
  17 + let path = options && options.path ? options.path: '';
  18 + let url = this.url + path;
  19 + return await GET(url, {
  20 + ...params
  21 + }).then(res => {
  22 + if (res.code === 200) {
  23 + return res.data
  24 + }
  25 + })
  26 + }
  27 +}
  1 +import BaseService from './base-service.js';
  2 +import config from '../../../config.js';
  3 +import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
  4 +
  5 +const WECHAT_SMALLPROGRAM_ONLOGIN = 'wechat.smallProgram.onLogin';
  6 +const WECHAT_SMALLPROGRAM_DECODEUSERINFO = 'wechat.smallProgram.decodeUserInfo';
  7 +const WECHAT_ADDUNIONUPDUSER = 'app.wechat.addUnionUpdUser';
  8 +const WECHAT_PASSPORT_SIGNINBYOPENID = 'app.passport.signinByOpenID';
  9 +const WECHAT_PASSPORT_MINIAPPBINDBYAUTO = 'app.passport.miniAppBindByAuto';
  10 +const WECHAT_ADDUPDUSER = 'app.wechat.addUpdUser';
  11 +const WECHAT_PASSPORT_VERIFY = 'app.passport.verify'
  12 +const WechatPath = '/wechat/';
  13 +
  14 +export default class LoginService extends BaseService {
  15 + async checkLogin(code) {
  16 + return await this.GET({
  17 + method: WECHAT_SMALLPROGRAM_ONLOGIN,
  18 + jsCode: code,
  19 + miniapp_type: config.mini_app_type
  20 + }, {
  21 + path: WechatPath
  22 + })
  23 + }
  24 +
  25 + async decodeUserInfo(srdSession, encryptedData, iv) {
  26 + return await this.GET({
  27 + method: WECHAT_SMALLPROGRAM_DECODEUSERINFO,
  28 + srdSession,
  29 + encryptedData,
  30 + iv
  31 + }, {
  32 + path: WechatPath
  33 + });
  34 + }
  35 +
  36 + async checkUidAndSessionKey(uid, session_key) {
  37 + let params = {}
  38 + if (uid) {
  39 + params.uid = uid
  40 + }
  41 + if (session_key) {
  42 + params.session_key = session_key;
  43 + }
  44 + return await this.GET({
  45 + method: WECHAT_PASSPORT_VERIFY,
  46 + ...params
  47 + })
  48 + }
  49 +
  50 + async sendWeChatUserDataWithUnionId(unionId, nickname, avatarUrl) {
  51 + if (!unionId || !nickname || !avatarUrl || avatarUrl === "images/mine_default_head.png") throw new Error('请检查 unionId 或用户信息是否有误');
  52 + return await this.GET({
  53 + method: WECHAT_ADDUNIONUPDUSER,
  54 + unionId,
  55 + headIco: avatarUrl,
  56 + nickname
  57 + });
  58 + }
  59 +
  60 + async sendWeChatUserData(uid, nickname, avatarUrl) {
  61 + if (!uid || !nickname || !avatarUrl || avatarUrl === "images/mine_default_head.png") throw new Error('请检查 uid 或用户信息是否有误');
  62 + return await this.GET({
  63 + method: WECHAT_ADDUPDUSER,
  64 + uid,
  65 + headIco: avatarUrl,
  66 + nickname
  67 + });
  68 + }
  69 +
  70 + async wechatUserIsBind(unionId) {
  71 + return await this.GET({
  72 + method: WECHAT_PASSPORT_SIGNINBYOPENID,
  73 + openId: unionId,
  74 + })
  75 + }
  76 +
  77 + async bindMiniAppByAuto(union_id, mobile, areaCode = 86) {
  78 + return await this.GET({
  79 + method: WECHAT_PASSPORT_MINIAPPBINDBYAUTO,
  80 + open_id: union_id,
  81 + mobile,
  82 + area: areaCode
  83 + })
  84 + }
  85 +}
@@ -94,7 +94,9 @@ Component({ @@ -94,7 +94,9 @@ Component({
94 }, 94 },
95 95
96 goMyList() { 96 goMyList() {
97 - router.go('myList'); 97 + wx.reLaunch({
  98 + url: '/pages/zeroSell/index?tabIndex=3',
  99 + })
98 }, 100 },
99 101
100 goList() { 102 goList() {
@@ -6,7 +6,13 @@ Component({ @@ -6,7 +6,13 @@ Component({
6 properties: { 6 properties: {
7 currentKey: { 7 currentKey: {
8 type: Number, 8 type: Number,
9 - value: 0 9 + value: 0,
  10 + observer(newVal) {
  11 + this.setData({
  12 + key: newVal
  13 + });
  14 + this._updateNav();
  15 + }
10 } 16 }
11 }, 17 },
12 18
@@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
2 2
3 import ZeroSellService from './service/zero-sell' 3 import ZeroSellService from './service/zero-sell'
4 import CommonService from './service/common' 4 import CommonService from './service/common'
  5 +import { getSettingPromise } from '../../login/utils/index.js'
  6 +import regeneratorRuntime from '../../login/libs/regenerator-runtime/index.js';
  7 +
  8 +const event = global.event;
5 9
6 import { 10 import {
7 decodePhoneNumber, 11 decodePhoneNumber,
@@ -31,6 +35,9 @@ Page(Object.assign({ @@ -31,6 +35,9 @@ Page(Object.assign({
31 }, { 35 }, {
32 page: 1, 36 page: 1,
33 products: [] 37 products: []
  38 + },{
  39 + page: 1,
  40 + products: []
34 }], 41 }],
35 tabIndex: 0, 42 tabIndex: 0,
36 43
@@ -49,19 +56,40 @@ Page(Object.assign({ @@ -49,19 +56,40 @@ Page(Object.assign({
49 dialogSrc: null, 56 dialogSrc: null,
50 dialogUrl: null, 57 dialogUrl: null,
51 bannerSrc: null, 58 bannerSrc: null,
52 - bannerUrl: null 59 + bannerUrl: null,
  60 + openType: 'getUserInfo'
53 }, 61 },
54 62
55 onLoad(options) { 63 onLoad(options) {
  64 + this.checkUnionId();
  65 + event.on('wechat-login-success', this.loginSuccess);
  66 + event.on('wechat-login-callback', this.loginCallback);
  67 + event.on('wechat-login-change-status', this.loginChangeStatus);
  68 + event.on('wechat-login-error', this.loginError);
  69 +
56 this.service = new ZeroSellService(); 70 this.service = new ZeroSellService();
57 this.commonService = new CommonService(); 71 this.commonService = new CommonService();
58 72
59 - this._init(); 73 + let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
  74 +
  75 + this.setData({
  76 + hasUnionID: app.globalData.WXUnion_ID !== null && app.globalData.WXUnion_ID !== '' && app.globalData.WXUnion_ID !== undefined ? true : false,
  77 + isLogin: app.isLogin(),
  78 + uid
  79 + })
60 80
  81 + if (options && options.tabIndex) {
  82 + this.setData({
  83 + tabIndex: options.tabIndex
  84 + })
  85 + this._init(options.tabIndex);
  86 + } else {
  87 + this._init();
  88 + }
61 new app.WeToast(); 89 new app.WeToast();
62 - if(!(options && +options.reload === 0)) {  
63 - this._getResouceCode()  
64 - } 90 + if(!(options && +options.reload === 0)) {
  91 + this._getResouceCode()
  92 + }
65 this._getBottomBanner() 93 this._getBottomBanner()
66 }, 94 },
67 95
@@ -127,8 +155,8 @@ Page(Object.assign({ @@ -127,8 +155,8 @@ Page(Object.assign({
127 }); 155 });
128 }, 156 },
129 157
130 - _init() {  
131 - let tabIndex = this.data.tabIndex; 158 + _init(my_tabIndex) {
  159 + let tabIndex = my_tabIndex || this.data.tabIndex;
132 let page = this.data.list[tabIndex].page; 160 let page = this.data.list[tabIndex].page;
133 let pageKey = `list[${tabIndex}].page`; 161 let pageKey = `list[${tabIndex}].page`;
134 let productsKey = `list[${tabIndex}].products` 162 let productsKey = `list[${tabIndex}].products`
@@ -138,7 +166,7 @@ Page(Object.assign({ @@ -138,7 +166,7 @@ Page(Object.assign({
138 }) 166 })
139 167
140 this._getProceedingData(); 168 this._getProceedingData();
141 - this._getReleaseData(); 169 + this._getReleaseData(1);
142 170
143 return this._getPage(page).then(list => { 171 return this._getPage(page).then(list => {
144 if (list.length === 0) { 172 if (list.length === 0) {
@@ -213,6 +241,9 @@ Page(Object.assign({ @@ -213,6 +241,9 @@ Page(Object.assign({
213 }, 241 },
214 242
215 _getProceedingData() { 243 _getProceedingData() {
  244 + if (!this.data.isLogin) {
  245 + return;
  246 + }
216 let type = 0; 247 let type = 0;
217 let page = 1; 248 let page = 1;
218 let limit = 1000; 249 let limit = 1000;
@@ -228,13 +259,17 @@ Page(Object.assign({ @@ -228,13 +259,17 @@ Page(Object.assign({
228 }); 259 });
229 }, 260 },
230 261
231 - _getReleaseData() { 262 + _getReleaseData(my_page) {
  263 + if (!this.data.isLogin) {
  264 + return;
  265 + }
232 let type = 1; 266 let type = 1;
233 let my_zero_list = this.data.my_zero_list; 267 let my_zero_list = this.data.my_zero_list;
234 let page = my_zero_list[type].page; 268 let page = my_zero_list[type].page;
235 let oldData = my_zero_list[type].data; 269 let oldData = my_zero_list[type].data;
236 let key = `my_zero_list[${type}].data`; 270 let key = `my_zero_list[${type}].data`;
237 let keyPage = `my_zero_list[${type}].page`; 271 let keyPage = `my_zero_list[${type}].page`;
  272 + console.log('执行了');
238 this.service.getMyList({type, page}).then(res => { 273 this.service.getMyList({type, page}).then(res => {
239 let data = [] 274 let data = []
240 if (res && res.code === 200) { 275 if (res && res.code === 200) {
@@ -263,6 +298,9 @@ Page(Object.assign({ @@ -263,6 +298,9 @@ Page(Object.assign({
263 }, 298 },
264 299
265 onTabChange({detail}) { 300 onTabChange({detail}) {
  301 + if (detail === 3 && !this.data.isLogin) {
  302 + return;
  303 + }
266 this.setData({ 304 this.setData({
267 tabIndex: detail, 305 tabIndex: detail,
268 [`list[${detail}].page`]: 1 306 [`list[${detail}].page`]: 1
@@ -385,8 +423,59 @@ Page(Object.assign({ @@ -385,8 +423,59 @@ Page(Object.assign({
385 } 423 }
386 }, 424 },
387 425
388 - goMyList() {  
389 - router.go('myList');  
390 - } 426 + async checkUnionId() {
  427 + let union_id = wx.getStorageSync('union_id');
  428 + let res = await getSettingPromise();
  429 +
  430 + if (res.authSetting["scope.userInfo"] !== null &&
  431 + res.authSetting["scope.userInfo"] !== undefined &&
  432 + res.authSetting["scope.userInfo"] === true) {
  433 + if (union_id) {
  434 + this.setData({
  435 + openType: 'none-open-type',
  436 + })
  437 + } else {
  438 + this.setData({
  439 + openType: 'getUserInfo'
  440 + })
  441 + }
  442 + } else {
  443 + this.setData({
  444 + openType: 'getUserInfo'
  445 + })
  446 + }
  447 + },
  448 +
  449 + loginChangeStatus(params) {
  450 + let { openType } = params;
  451 + this.setData({
  452 + openType
  453 + })
  454 + },
  455 +
  456 + loginCallback(params) {
  457 + console.log(params);
  458 + },
  459 +
  460 + loginSuccess(params) {
  461 + console.log(params);
  462 + let app = getApp();
  463 + this.setData({
  464 + isLogin: app.isLogin(),
  465 + });
  466 + this._getProceedingData();
  467 + this._getReleaseData(1);
  468 + },
  469 +
  470 + loginError(error) {
  471 + console.log(error);
  472 + router.go('bindPhoneNumber');
  473 + },
  474 +
  475 + goReferer() {
  476 + wx.navigateBack({
  477 + delta: 1
  478 + });
  479 + },
391 480
392 }, Toast)); 481 }, Toast));
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 "tabs": "./components/tabs", 9 "tabs": "./components/tabs",
10 "tabs-pane": "./components/tabs-pane", 10 "tabs-pane": "./components/tabs-pane",
11 "dialog": "../../component/dialog/dialog", 11 "dialog": "../../component/dialog/dialog",
12 - "prize-item": "./components/prize-item" 12 + "prize-item": "./components/prize-item",
  13 + "login": "../../login/login/login"
13 } 14 }
14 } 15 }
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 </block> 44 </block>
45 </block> 45 </block>
46 <block wx:else> 46 <block wx:else>
47 - <view>登录页面</view> 47 + <login theme="light" openType="{{openType}}"></login>
48 </block> 48 </block>
49 <!-- <view class="productList"> 49 <!-- <view class="productList">
50 <block wx:for="{{list[2].products}}" wx:key="{{item.id}}"> 50 <block wx:for="{{list[2].products}}" wx:key="{{item.id}}">
@@ -52,8 +52,9 @@ @@ -52,8 +52,9 @@
52 </block> 52 </block>
53 </view> --> 53 </view> -->
54 </tabs-pane> 54 </tabs-pane>
55 -  
56 - <view class="list-foot-blank">{{footText}}</view> 55 + <block wx:if="{{isLogin}}">
  56 + <view class="list-foot-blank">{{footText}}</view>
  57 + </block>
57 </tabs> 58 </tabs>
58 <block wx:if="{{tabIndex !== 3}}"> 59 <block wx:if="{{tabIndex !== 3}}">
59 <view class="bottom-banner" bindtap="_jumpBanner" wx:if="{{bannerSrc != null}}"> 60 <view class="bottom-banner" bindtap="_jumpBanner" wx:if="{{bannerSrc != null}}">
@@ -5,7 +5,8 @@ const route = { @@ -5,7 +5,8 @@ const route = {
5 myList: '/pages/zeroSell/myList', 5 myList: '/pages/zeroSell/myList',
6 detail: '/pages/zeroSell/detail', 6 detail: '/pages/zeroSell/detail',
7 snapShare: '/pages/zeroSell/snapshootShare', 7 snapShare: '/pages/zeroSell/snapshootShare',
8 - webview: '/pages/zeroSell/h5Page' 8 + webview: '/pages/zeroSell/h5Page',
  9 + bindPhoneNumber: '/pages/bindPhoneNumber/bindPhoneNumber'
9 }; 10 };
10 11
11 function jumpFn(name, qs) { 12 function jumpFn(name, qs) {