Authored by QC-L

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

... ... @@ -9,7 +9,13 @@ let crypto = require('./libs/cryptojs/cryptojs.js').Crypto
import md5 from './vendors/md5';
var mta = require('./vendors/mta_analysis.js')
import { wechatLoginAction } from './utils/login';
import regeneratorRuntime from '/login/libs/regenerator-runtime/index.js';
import { isStringEmpty, getYHStorageSync} from './utils/util';
import { Event } from '/login/utils/index.js';
import { wxLogin } from '/login/utils/login/login.js';
import { appReport } from './libs/appReport.js';
global.event = new Event();
import { logEvent,
YB_LAUNCH_APP,
... ... @@ -21,10 +27,9 @@ import { logEvent,
YB_SERVICE_PUSH
} from './libs/analytics.js';
import { appReport } from './libs/appReport.js';
App({
onLaunch: function (options) {
async onLaunch(options) {
let that = this;
let res = wx.getSystemInfoSync();
if (!res.screenHeight) {
... ... @@ -89,11 +94,12 @@ App({
logEvent(YB_LAUNCH_APP, params, this);
}
setTimeout(function () {
wechatLoginAction(function (response) {
that.getShareInfo();
});
// wechatLoginAction(function (response) {
// that.getShareInfo();
// });
}, 1000);
this.mtainit(options);
await wxLogin();
},
//当应用程序进入前台显示状态时触发
... ...
... ... @@ -6,7 +6,8 @@
"pages/zeroSell/snapshootShare",
"pages/zeroSell/h5Page",
"pages/bindPhoneNumber/bindPhoneNumber",
"pages/choosecountry/choosecountry"
"pages/choosecountry/choosecountry",
"login/login-page/login-page"
],
"window": {
"navigationBarTextStyle": "white",
... ...
.row {
display: flex;
flex-direction: row;
}
.column {
display: flex;
flex-direction: column;
}
\ No newline at end of file
... ...
.margin {
margin: 20rpx;
}
.margin-top-bottom {
margin: 20rpx 0;
}
.margin-left-right {
margin: 0 20rpx;
}
.margin-left {
margin-left: 20rpx;
}
.margin-top {
margin-top: 20rpx;
}
.margin-right {
margin-right: 20rpx;
}
.margin-bottom {
margin-bottom: 20rpx;
}
.padding {
margin: 20rpx;
}
.padding-top-bottom {
padding: 20rpx 0;
}
.padding-left-right {
padding: 0 20rpx;
}
.padding-left {
padding-left: 20rpx;
}
.padding-top {
padding-top: 20rpx;
}
.padding-right {
padding-right: 20rpx;
}
.padding-bottom {
padding-bottom: 20rpx;
}
.border-slim {
border: 1rpx solid #E0E0E0;
}
.border-slim-top {
border-top: 1rpx solid #E0E0E0;
}
.border-slim-bottom {
border-bottom: 1rpx solid #E0E0E0;
}
.border-slim-top {
border-top: 1rpx solid #E0E0E0;
}
.border-slim-left {
border-left: 1rpx solid #E0E0E0;
}
.border-slim-right {
border-right: 1rpx solid #E0E0E0;
}
.border-semibold {
border: 2rpx solid #E0E0E0;
}
.border-semibold-left {
border-left: 2rpx solid #E0E0E0;
}
.border-semibold-right {
border-right: 2rpx solid #E0E0E0;
}
.border-semibold-top {
border-top: 2rpx solid #E0E0E0;
}
.border-semibold-bottom {
border-bottom: 2rpx solid #E0E0E0;
}
\ No newline at end of file
... ...
.small-text-size {
font-size: 20rpx;
}
.text-size {
font-size: 24rpx;
}
.middle-text-size {
font-size: 28rpx;
}
.large-text-size {
font-size: 32rpx;
}
.big-large-text-size {
font-size: 36rpx;
}
... ...
@import './common-flex.wxss';
@import './common-space.wxss';
@import './common-text.wxss';
\ No newline at end of file
... ...
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
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; };
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; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1542938356632, function(require, module, exports) {
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var regeneratorRuntime = (function (exports) {
"use strict";
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);
// The ._invoke method unifies the implementations of the .next,
// .throw, and .return methods.
generator._invoke = makeInvokeMethod(innerFn, self, context);
return generator;
}
exports.wrap = wrap;
// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
return { type: "normal", arg: fn.call(obj, arg) };
} catch (err) {
return { type: "throw", arg: err };
}
}
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};
// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
return this._invoke(method, arg);
};
});
}
exports.isGeneratorFunction = function(genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};
exports.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
genFun[toStringTagSymbol] = "GeneratorFunction";
}
}
genFun.prototype = Object.create(Gp);
return genFun;
};
// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
exports.awrap = function(arg) {
return { __await: arg };
};
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}
return Promise.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration.
result.value = unwrapped;
resolve(result);
}, function(error) {
// If a rejected Promise was yielded, throw the rejection back
// into the async generator function so it can be handled there.
return invoke("throw", error, resolve, reject);
});
}
}
var previousPromise;
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new Promise(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
previousPromise ? previousPromise.then(
callInvokeWithMethodAndArg,
// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
callInvokeWithMethodAndArg
) : callInvokeWithMethodAndArg();
}
// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
this._invoke = enqueue;
}
defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
exports.AsyncIterator = AsyncIterator;
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
exports.async = function(innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList)
);
return exports.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
};
function makeInvokeMethod(innerFn, self, context) {
var state = GenStateSuspendedStart;
return function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
if (method === "throw") {
throw arg;
}
// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return doneResult();
}
context.method = method;
context.arg = arg;
while (true) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if (context.method === "next") {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;
} else if (context.method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}
context.dispatchException(context.arg);
} else if (context.method === "return") {
context.abrupt("return", context.arg);
}
state = GenStateExecuting;
var record = tryCatch(innerFn, self, context);
if (record.type === "normal") {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;
if (record.arg === ContinueSentinel) {
continue;
}
return {
value: record.arg,
done: context.done
};
} else if (record.type === "throw") {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
context.method = "throw";
context.arg = record.arg;
}
}
};
}
// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (method === undefined) {
// A .throw or .return when the delegate iterator has no .throw
// method always terminates the yield* loop.
context.delegate = null;
if (context.method === "throw") {
// Note: ["return"] must be used for ES3 parsing compatibility.
if (delegate.iterator["return"]) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
context.method = "return";
context.arg = undefined;
maybeInvokeDelegate(delegate, context);
if (context.method === "throw") {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}
context.method = "throw";
context.arg = new TypeError(
"The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if (record.type === "throw") {
context.method = "throw";
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
}
var info = record.arg;
if (! info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
return ContinueSentinel;
}
if (info.done) {
// Assign the result of the finished delegate to the temporary
// variable specified by delegate.resultName (see delegateYield).
context[delegate.resultName] = info.value;
// Resume execution at the desired location (see delegateYield).
context.next = delegate.nextLoc;
// If context.method was "throw" but the delegate handled the
// exception, let the outer generator proceed normally. If
// context.method was "next", forget context.arg since it has been
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
if (context.method !== "return") {
context.method = "next";
context.arg = undefined;
}
} else {
// Re-yield the result returned by the delegate method.
return info;
}
// The delegate iterator is finished, so forget it and continue with
// the outer generator.
context.delegate = null;
return ContinueSentinel;
}
// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
defineIteratorMethods(Gp);
Gp[toStringTagSymbol] = "Generator";
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};
Gp.toString = function() {
return "[object Generator]";
};
function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };
if (1 in locs) {
entry.catchLoc = locs[1];
}
if (2 in locs) {
entry.finallyLoc = locs[2];
entry.afterLoc = locs[3];
}
this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal";
delete record.arg;
entry.completion = record;
}
function Context(tryLocsList) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}
exports.keys = function(object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();
// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}
// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
next.done = true;
return next;
};
};
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}
if (typeof iterable.next === "function") {
return iterable;
}
if (!isNaN(iterable.length)) {
var i = -1, next = function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}
next.value = undefined;
next.done = true;
return next;
};
return next.next = next;
}
}
// Return an iterator with no values.
return { next: doneResult };
}
exports.values = values;
function doneResult() {
return { value: undefined, done: true };
}
Context.prototype = {
constructor: Context,
reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
// function.sent implementation.
this.sent = this._sent = undefined;
this.done = false;
this.delegate = null;
this.method = "next";
this.arg = undefined;
this.tryEntries.forEach(resetTryEntry);
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
stop: function() {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}
return this.rval;
},
dispatchException: function(exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;
if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
context.method = "next";
context.arg = undefined;
}
return !! caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
if (entry.tryLoc === "root") {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return handle("end");
}
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else {
throw new Error("try statement without catch or finally");
}
}
}
},
abrupt: function(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
}
var record = finallyEntry ? finallyEntry.completion : {};
record.type = type;
record.arg = arg;
if (finallyEntry) {
this.method = "next";
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}
return this.complete(record);
},
complete: function(record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" ||
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
this.method = "return";
this.next = "end";
} else if (record.type === "normal" && afterLoc) {
this.next = afterLoc;
}
return ContinueSentinel;
},
finish: function(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
this.complete(entry.completion, entry.afterLoc);
resetTryEntry(entry);
return ContinueSentinel;
}
}
},
"catch": function(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt");
},
delegateYield: function(iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};
if (this.method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}
return ContinueSentinel;
}
};
// Regardless of whether this script is executing as a CommonJS module
// or not, return the runtime object so that we can declare the variable
// regeneratorRuntime in the outer scope, which allows this module to be
// injected easily by `bin/regenerator --include-runtime script.js`.
return exports;
}(
// If this script is executing as a CommonJS module, use module.exports
// as the regeneratorRuntime namespace. Otherwise create a new empty
// object. Either way, the resulting object will be used to initialize
// the regeneratorRuntime variable at the top of this file.
typeof module === "object" ? module.exports : {}
));
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1542938356632);
})()
//# sourceMappingURL=index.js.map
\ No newline at end of file
... ...
{"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"]}
\ No newline at end of file
... ...
// component/login-component/login-component.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
openType: 'getUserInfo'
},
getUserInfo(e) {
this.setData({
openType: 'getPhoneNumber'
})
},
/**
* 组件的方法列表
*/
methods: {
}
})
... ...
{
"component": true,
"usingComponents": {
"login": "../login/login"
}
}
\ No newline at end of file
... ...
<!--component/login-component/login-component.wxml-->
<login theme="light" openType="{{openType}}" bindgetuserinfo="getUserInfo"></login>
... ...
/* component/login-component/login-component.wxss */
\ No newline at end of file
... ...
// pages/login-page/login-page.js
import regeneratorRuntime from '../libs/regenerator-runtime/index.js';
import { getSettingPromise } from '../utils/index.js'
const event = global.event;
Page({
/**
* 页面的初始数据
*/
data: {
openType: 'getUserInfo'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.checkUnionId();
event.on('wechat-login-success', this.loginSuccess);
event.on('wechat-login-callback', this.loginCallback);
event.on('wechat-login-change-status', this.loginChangeStatus);
event.on('wechat-login-error', this.loginError);
},
async checkUnionId() {
let union_id = wx.getStorageSync('union_id');
let res = await getSettingPromise();
if (res.authSetting["scope.userInfo"] !== null &&
res.authSetting["scope.userInfo"] !== undefined &&
res.authSetting["scope.userInfo"] === true) {
if (union_id) {
this.setData({
openType: 'none-open-type',
})
} else {
this.setData({
openType: 'getUserInfo'
})
}
} else {
this.setData({
openType: 'getUserInfo'
})
}
},
loginChangeStatus(params) {
let { openType } = params;
this.setData({
openType
})
},
loginCallback(params) {
console.log(params);
},
loginSuccess(params) {
console.log(params);
this.goReferer();
},
loginError(error) {
console.error(error);
},
goReferer() {
wx.navigateBack({
delta: 1
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('wechat-login-success', this.loginSuccess);
event.remove('wechat-login-callback', this.loginCallback);
event.remove('wechat-login-change-status', this.loginChangeStatus);
event.remove('wechat-login-error', this.loginError);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {
"login": "../login/login"
}
}
\ No newline at end of file
... ...
<!--pages/login-page/login-page.wxml-->
<login theme="light" openType="{{openType}}" bindgetuserinfo="getUserInfo"></login>
... ...
/* pages/login-page/login-page.wxss */
page {
height: 100%;
}
\ No newline at end of file
... ...
// component/login/login.js
import { getUserInfo, getPhoneNumber, checkUnionIdIsBind } from '../utils/login/login.js';
Component({
/**
* 组件的属性列表
*/
properties: {
theme: {
type: String,
value: 'light'
},
isShow: Boolean,
openType: {
type: String,
value: "getUserInfo",
observer: function (newValue, oldValue) {
if (newValue === "getPhoneNumber") {
this.setData({
loginBtnTitle: "绑定手机号"
})
} else if (newValue === 'getUserInfo') {
this.setData({
loginBtnTitle: "微信授权登录"
})
} else {
this.setData({
loginBtnTitle: "微信登录",
checkUnionIdIsBind: 'checkUnionIdIsBind'
})
}
}
}
},
/**
* 组件的初始数据
*/
data: {
logo: "https://feature.yoho.cn/1019/youhuo2.png",
lightLogo: "https://img11.static.yhbimg.com/article/2018/11/29/11/018a4f01d4621f9072788f6510ac83bfec.png",
loginBtnTitle: "微信授权登录",
subLogoTitle: "LIVE IN STAY COOL",
tips: "还差一步,绑定手机号,加入Yoho!Family!",
checkUnionIdIsBind: ''
},
/**
* 组件的方法列表
*/
methods: {
getUserInfo,
getPhoneNumber,
checkUnionIdIsBind
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<block wx:if="{{theme}}">
<view class="login-{{theme}}-bg login-bg column" catchtouchmove>
<image class="login-logo" src="{{theme === 'light' ? lightLogo : logo}}"></image>
<view class="login-sub-logo-title-view row">
<text class="login-sub-logo-title-line login-{{theme}}-sub-logo-title-line">––</text>
<text class="login-sub-logo-title login-{{theme}}-sub-logo-title">{{subLogoTitle}}</text>
<text class="login-sub-logo-title-line login-{{theme}}-sub-logo-title-line">––</text>
</view>
<button class="login-btn login-{{theme}}-btn" bindtap="{{checkUnionIdIsBind}}" bindgetuserinfo="getUserInfo" bindgetphonenumber="getPhoneNumber" open-type="{{openType}}">{{loginBtnTitle}}</button>
<text class="login-text-tips login-{{theme}}-text-tips" wx:if="{{openType == 'getPhoneNumber'}}">{{tips}}</text>
</view>
</block>
\ No newline at end of file
... ...
/* component/login/login.wxss */
@import '../common/style/common.wxss';
.login-bg {
width: 100%;
height: 100%;
align-items: center;
}
.login-dark-bg {
background-color: #252222;
}
.login-light-bg {
background-color: white;
}
.login-btn::after {
border-radius: 0;
border: 0;
}
.login-btn {
line-height: 88rpx;
font-size: 32rpx;
letter-spacing: 8rpx;
text-align: center;
border-radius: 44rpx;
width: 80%;
}
.login-dark-btn {
color: #fff;
background-color: #a69073;
}
.login-light-btn {
color: #fff;
background-color: #222;
}
.login-logo {
width: 366rpx;
height: 312rpx;
margin-top: 242rpx;
}
.login-text-tips {
font-family: PingFang-SC-Light;
font-size: 24rpx;
letter-spacing: 0;
text-align: center;
margin-top: 24rpx;
}
.login-dark-text-tips {
color: #fff;
}
.login-light-text-tips {
color: #b0b0b0;
}
.login-sub-logo-title {
font-family: Arial-BoldMT;
font-size: 28rpx;
letter-spacing: 0;
text-align: left;
font-weight: 500;
margin-left: 20rpx;
margin-right: 20rpx;
}
.login-dark-sub-logo-title {
color: #fff;
}
.login-light-sub-logo-title {
color: #222;
}
.login-sub-logo-title-line {
font-family: Arial-BoldMT;
font-size: 28rpx;
letter-spacing: 0;
text-align: left;
font-weight: 500;
padding-bottom: 10rpx;
}
.login-dark-sub-logo-title-line {
color: #fff;
}
.login-light-sub-logo-title-line {
color: #222;
}
.login-sub-logo-title-view {
align-items: center;
margin-top: 58rpx;
margin-bottom: 216rpx;
}
... ...
/**
* description: 参考借鉴 Node.js 的 EventEmitter
* 对象管理 event 事件
* @func on 监听
* @func emit 触发
* @func once 监听只执行一次
* @func remove 移除某个类型的某个事件
* @func removeAll 移除某个类型的全部事件/所有类型的全部事件
*/
export default class EventEmitter {
constructor() {
this._events = Object.create(null);
this._eventsCount = 0;
}
/**
* emit 触发事件
* @param type 事件名
* @param ...args 参数
*/
emit(type) {
let events, handler, len, isFn;
events = this._events;
handler = events[type];
if (!handler)
return false;
isFn = typeof handler === 'function';
len = arguments.length;
// 优化性能
switch(len) {
case 0:
throw new Error('"emit" not have arguments');
break;
case 1:
emitNone(handler, isFn, this);
break;
case 2:
emitOne(handler, isFn, this, arguments[1]);
break;
case 3:
emitTwo(handler, isFn, this, arguments[1], arguments[2]);
break;
case 4:
emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
break;
default:
args = new Array(len - 1);
for (let i = 1; i < len; i++) {
args[i - 1] = arguments[i];
}
emitMany(handler, isFn, this, args);
}
return true;
}
_addListener(type, listener, prepend) {
let events;
let existing;
if (typeof listener !== 'function')
throw new Error('"listener" argument must be a function');
events = this._events;
if (typeof events === 'undefined') {
events = this._events = Object.create(null);
this._eventsCount = 0;
} else {
existing = events[type];
}
if (!existing) {
existing = events[type] = listener;
++this._eventsCount;
} else {
if (typeof existing === 'function') {
existing = events[type] = prepend ? [listener, existing] : [existing, listener];
} else if (prepend) {
existing.unshift(listener);
} else {
existing.push(listener);
}
}
return this;
}
/**
* on 监听事件
* @param type 事件名
* @param listener 监听函数
*/
on(type, listener) {
return this._addListener(type, listener, false);
}
/**
* once 监听只执行一次事件
* @param type 事件名
* @param listener 只执行一次的监听函数
*/
once(type, listener) {
if (typeof listener !== 'function')
throw new Error('"listener" argument must be a function');
this.on(type, _onceWrap(this, type, listener));
return this;
}
/**
* prepend 优先监听事件
* @param type 事件名
* @param listener 要优先的监听函数
*/
prepend(type, listener) {
return this._addListener(type, listener, true);
}
/**
* prependOnce 优先只执行一次的监听事件
* @param type 事件名
* @param listener 要优先且只执行一次的监听函数
*/
prependOnce(type, listener) {
if (typeof listener !== 'function')
throw new TypeError('"listener" argument must be a function');
this.prepend(type, _onceWrap(this, type, listener));
return this;
}
/**
* remove 移除的监听事件
* @param type 事件名
* @param listener 要移除的监听函数(可选)
*/
remove(type, listener) {
let list, events, position, originalListener;
if (typeof listener !== 'function')
throw new TypeError('"listener" argument must be a function');
events = this._events;
if (!events) {
return this;
}
list = events[type];
if (!list) {
return this;
}
if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0) {
this._events = Object.create(null);
} else {
delete events[type];
}
} else if (typeof list !== 'function') {
position = -1;
for (let i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
}
if (position < 0) {
return this;
}
if (position === 0) {
list.shift();
} else {
spliceOne(list, position);
}
if (list.length === 1) {
events[type] = list[0];
}
}
return this;
}
/**
* removeAll 移除某事件名的全部监听事件/移除全部事件名的事件
* @param type 事件名
*/
removeAll(type) {
let listeners, events;
events = this._events;
if (!events)
return this;
if (arguments.length === 0) {
var keys = Object.keys(events);
var key;
for (let i = 0; i < keys.length; ++i) {
key = keys[i];
this.removeAll(key);
}
this._events = Object.create(null);
this._eventsCount = 0;
return this;
}
listeners = events[type];
if (typeof listeners === 'function') {
this.remove(type, listeners);
} else if (listeners !== undefined) {
for (let i = listeners.length - 1; i >= 0; i--) {
this.remove(type, listeners[i]);
}
}
return this;
}
eventNames() {
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
}
}
const emitNone = (handler, isFn, self) => {
if (isFn) {
handler.call(self);
} else {
let len = handler.length;
let listeners = arrayClone(handler, len);
for (let i = 0; i < len; ++i)
listeners[i].call(self);
}
}
const emitOne = (handler, isFn, self, arg1) => {
if (isFn) {
handler.call(self, arg1);
} else {
let len = handler.length;
let listeners = arrayClone(handler, len);
for (let i = 0; i < len; ++i)
listeners[i].call(self, arg1);
}
}
const emitTwo = (handler, isFn, self, arg1, arg2) => {
if (isFn) {
handler.call(self, arg1, arg2);
} else {
let len = handler.length;
let listeners = arrayClone(handler, len);
for (let i = 0; i < len; ++i)
listeners[i].call(self, arg1, arg2);
}
}
const emitThree = (handler, isFn, self, arg1, arg2, arg3) => {
if (isFn) {
handler.call(self, arg1, arg2, arg3);
} else {
let len = handler.length;
let listeners = arrayClone(handler, len);
for (let i = 0; i < len; ++i)
listeners[i].call(self, arg1, arg2, arg3);
}
}
const emitMany = (handler, isFn, self, args) => {
if (isFn) {
handler.apply(self, args);
} else {
let len = handler.length;
let listeners = arrayClone(handler, len);
for (let i = 0; i < len; ++i)
listeners[i].apply(self, args);
}
}
const spliceOne = (list, index) => {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
list.pop();
}
function onceWrapper(...args) {
if (!this.fired) {
this.target.remove(this.type, this.wrapFn);
this.fired = true;
Reflect.apply(this.listener, this.target, args);
}
}
const _onceWrap = (target, type, listener) => {
var state = { fired: false, wrapFn: undefined, target, type, listener };
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
\ No newline at end of file
... ...
export const toPromise = (platform) => {
return (method) => {
return (option) => {
return new Promise ((resolve, reject) => {
platform[method]({
...option,
success: (res) => { resolve(res) },
fail: (err) => { reject(err) }
})
})
}
}
}
export const toPromiseWX = toPromise(wx);
const setStoragePromise = toPromiseWX('setStorage');
export const getSettingPromise = toPromiseWX('getSetting');
export const setStorageValueForKey = (key, value) => {
return setStoragePromise({
key,
data: value
});
}
import EventEmitter from './event.js';
export const Event = EventEmitter;
... ...
import LoginService from '../service/login-service.js';
import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
import { toPromiseWX, setStorageValueForKey } from '../index.js';
const login = new LoginService();
const loginPromise = toPromiseWX('login');
const saveLoginData = (loginData) => {
setStorageValueForKey('open_id', loginData.openid);
setStorageValueForKey('srd_session', loginData.srd_session);
if (loginData && loginData.unionid) {
setStorageValueForKey('union_id', loginData.unionid);
}
}
export const wxLogin = async () => {
try {
// 调用 wx.login
const res = await loginPromise();
// 根据上传的 code 返回 open_id 等信息
const loginData = await login.checkLogin(res.code);
// 本地存储 open_id srd_session union_id
await saveLoginData(loginData);
} catch (error) {
// 注意: 此处应异常上报
console.log(error);
}
};
export const getUserInfo = async (e) => {
const event = global.event;
try {
if (e.detail.errMsg === 'getUserInfo:ok') {
await setStorageValueForKey('userInfo', e.detail.userInfo);
const srd_session = wx.getStorageSync('srd_session') || '';
const json = await login.decodeUserInfo(srd_session, e.detail.encryptedData, e.detail.iv);
if (json && json.union_id) {
wechatUnionIdIsBind(json.union_id, e.detail.userInfo);
} else {
throw new Error('微信授权失败,请使用手机号登录');
}
} else {
throw new Error('微信授权失败,请使用手机号登录');
}
} catch (error) {
event.emit('wechat-login-error', error);
}
}
export const getPhoneNumber = async (e) => {
const event = global.event;
try {
if (e.detail.errMsg === 'getPhoneNumber:ok') {
const srd_session = wx.getStorageSync('srd_session') || '';
const union_id = wx.getStorageSync('union_id') || '';
const phoneNumberInfo = await login.decodeUserInfo(srd_session, e.detail.encryptedData, e.detail.iv);
const { phoneNumber, countryCode } = phoneNumberInfo;
if (!(countryCode && phoneNumber)) {
throw new Error('手机号获取失败,请使用手机号登录');
}
const bindResult = await login.bindMiniAppByAuto(union_id, phoneNumber, countryCode);
console.log(bindResult);
} else {
throw new Error('手机号获取失败,请使用手机号登录');
}
} catch (error) {
console.log(error);
event.emit('wechat-login-error', error);
}
}
export const checkUnionIdIsBind = (e) => {
let union_id = wx.getStorageSync('union_id') || '';
let userInfo = wx.getStorageSync('userInfo') || {};
wechatUnionIdIsBind(union_id, userInfo);
}
const wechatUnionIdIsBind = async (union_id, userInfo) => {
const event = global.event;
let globalData = getApp().globalData;
try {
const user_bind_info = await login.wechatUserIsBind(union_id);
if (user_bind_info && user_bind_info.is_bind === 'Y') {
const { mobile, session_key, uid, ssouid } = user_bind_info;
// 保存 uid session_key
const newUserInfo = Object.assign(userInfo, { mobile, session_key, uid, ssouid });
await setStorageValueForKey('userInfo', newUserInfo);
await setStorageValueForKey('sessionkey', session_key);
globalData.sessionkey = session_key;
globalData.userInfo = userInfo;
// 赋值全局变量
// 上传保存头像
login.sendWeChatUserData(uid, userInfo.nickName, userInfo.avatarUrl).catch(error => {});
// 触发事件登录成功
event.emit('wechat-login-success', newUserInfo);
} else {
// 修改按钮状态, 获取手机号绑定手机号
event.emit('wechat-login-change-status', { openType: 'getPhoneNumber' });
}
} catch (error) {
event.emit('wechat-login-error', error);
}
}
\ No newline at end of file
... ...
/**
* 网络请求基类
* @param url 网络请求地址(可选)
* @param other 其他参数(自选)
*
*/
import { GET } from '../../../libs/request';
import config from '../../../config.js';
import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
export default class BaseService {
constructor() {
this.url = config.domains.service;
}
async GET(params, options) {
let path = options && options.path ? options.path: '';
let url = this.url + path;
return await GET(url, {
...params
}).then(res => {
if (res.code === 200) {
return res.data
}
})
}
}
\ No newline at end of file
... ...
import BaseService from './base-service.js';
import config from '../../../config.js';
import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
const WECHAT_SMALLPROGRAM_ONLOGIN = 'wechat.smallProgram.onLogin';
const WECHAT_SMALLPROGRAM_DECODEUSERINFO = 'wechat.smallProgram.decodeUserInfo';
const WECHAT_ADDUNIONUPDUSER = 'app.wechat.addUnionUpdUser';
const WECHAT_PASSPORT_SIGNINBYOPENID = 'app.passport.signinByOpenID';
const WECHAT_PASSPORT_MINIAPPBINDBYAUTO = 'app.passport.miniAppBindByAuto';
const WECHAT_ADDUPDUSER = 'app.wechat.addUpdUser';
const WECHAT_PASSPORT_VERIFY = 'app.passport.verify'
const WechatPath = '/wechat/';
export default class LoginService extends BaseService {
async checkLogin(code) {
return await this.GET({
method: WECHAT_SMALLPROGRAM_ONLOGIN,
jsCode: code,
miniapp_type: config.mini_app_type
}, {
path: WechatPath
})
}
async decodeUserInfo(srdSession, encryptedData, iv) {
return await this.GET({
method: WECHAT_SMALLPROGRAM_DECODEUSERINFO,
srdSession,
encryptedData,
iv
}, {
path: WechatPath
});
}
async checkUidAndSessionKey(uid, session_key) {
let params = {}
if (uid) {
params.uid = uid
}
if (session_key) {
params.session_key = session_key;
}
return await this.GET({
method: WECHAT_PASSPORT_VERIFY,
...params
})
}
async sendWeChatUserDataWithUnionId(unionId, nickname, avatarUrl) {
if (!unionId || !nickname || !avatarUrl || avatarUrl === "images/mine_default_head.png") throw new Error('请检查 unionId 或用户信息是否有误');
return await this.GET({
method: WECHAT_ADDUNIONUPDUSER,
unionId,
headIco: avatarUrl,
nickname
});
}
async sendWeChatUserData(uid, nickname, avatarUrl) {
if (!uid || !nickname || !avatarUrl || avatarUrl === "images/mine_default_head.png") throw new Error('请检查 uid 或用户信息是否有误');
return await this.GET({
method: WECHAT_ADDUPDUSER,
uid,
headIco: avatarUrl,
nickname
});
}
async wechatUserIsBind(unionId) {
return await this.GET({
method: WECHAT_PASSPORT_SIGNINBYOPENID,
openId: unionId,
})
}
async bindMiniAppByAuto(union_id, mobile, areaCode = 86) {
return await this.GET({
method: WECHAT_PASSPORT_MINIAPPBINDBYAUTO,
open_id: union_id,
mobile,
area: areaCode
})
}
}
\ No newline at end of file
... ...
... ... @@ -94,7 +94,9 @@ Component({
},
goMyList() {
router.go('myList');
wx.reLaunch({
url: '/pages/zeroSell/index?tabIndex=3',
})
},
goList() {
... ...
... ... @@ -6,7 +6,13 @@ Component({
properties: {
currentKey: {
type: Number,
value: 0
value: 0,
observer(newVal) {
this.setData({
key: newVal
});
this._updateNav();
}
}
},
... ...
... ... @@ -2,6 +2,10 @@
import ZeroSellService from './service/zero-sell'
import CommonService from './service/common'
import { getSettingPromise } from '../../login/utils/index.js'
import regeneratorRuntime from '../../login/libs/regenerator-runtime/index.js';
const event = global.event;
import {
decodePhoneNumber,
... ... @@ -31,6 +35,9 @@ Page(Object.assign({
}, {
page: 1,
products: []
},{
page: 1,
products: []
}],
tabIndex: 0,
... ... @@ -49,15 +56,36 @@ Page(Object.assign({
dialogSrc: null,
dialogUrl: null,
bannerSrc: null,
bannerUrl: null
bannerUrl: null,
openType: 'getUserInfo'
},
onLoad(options) {
this.checkUnionId();
event.on('wechat-login-success', this.loginSuccess);
event.on('wechat-login-callback', this.loginCallback);
event.on('wechat-login-change-status', this.loginChangeStatus);
event.on('wechat-login-error', this.loginError);
this.service = new ZeroSellService();
this.commonService = new CommonService();
this._init();
let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
this.setData({
hasUnionID: app.globalData.WXUnion_ID !== null && app.globalData.WXUnion_ID !== '' && app.globalData.WXUnion_ID !== undefined ? true : false,
isLogin: app.isLogin(),
uid
})
if (options && options.tabIndex) {
this.setData({
tabIndex: options.tabIndex
})
this._init(options.tabIndex);
} else {
this._init();
}
new app.WeToast();
if(!(options && +options.reload === 0)) {
this._getResouceCode()
... ... @@ -127,8 +155,8 @@ Page(Object.assign({
});
},
_init() {
let tabIndex = this.data.tabIndex;
_init(my_tabIndex) {
let tabIndex = my_tabIndex || this.data.tabIndex;
let page = this.data.list[tabIndex].page;
let pageKey = `list[${tabIndex}].page`;
let productsKey = `list[${tabIndex}].products`
... ... @@ -138,7 +166,7 @@ Page(Object.assign({
})
this._getProceedingData();
this._getReleaseData();
this._getReleaseData(1);
return this._getPage(page).then(list => {
if (list.length === 0) {
... ... @@ -213,6 +241,9 @@ Page(Object.assign({
},
_getProceedingData() {
if (!this.data.isLogin) {
return;
}
let type = 0;
let page = 1;
let limit = 1000;
... ... @@ -228,13 +259,17 @@ Page(Object.assign({
});
},
_getReleaseData() {
_getReleaseData(my_page) {
if (!this.data.isLogin) {
return;
}
let type = 1;
let my_zero_list = this.data.my_zero_list;
let page = my_zero_list[type].page;
let oldData = my_zero_list[type].data;
let key = `my_zero_list[${type}].data`;
let keyPage = `my_zero_list[${type}].page`;
console.log('执行了');
this.service.getMyList({type, page}).then(res => {
let data = []
if (res && res.code === 200) {
... ... @@ -263,6 +298,9 @@ Page(Object.assign({
},
onTabChange({detail}) {
if (detail === 3 && !this.data.isLogin) {
return;
}
this.setData({
tabIndex: detail,
[`list[${detail}].page`]: 1
... ... @@ -385,8 +423,59 @@ Page(Object.assign({
}
},
goMyList() {
router.go('myList');
async checkUnionId() {
let union_id = wx.getStorageSync('union_id');
let res = await getSettingPromise();
if (res.authSetting["scope.userInfo"] !== null &&
res.authSetting["scope.userInfo"] !== undefined &&
res.authSetting["scope.userInfo"] === true) {
if (union_id) {
this.setData({
openType: 'none-open-type',
})
} else {
this.setData({
openType: 'getUserInfo'
})
}
} else {
this.setData({
openType: 'getUserInfo'
})
}
},
loginChangeStatus(params) {
let { openType } = params;
this.setData({
openType
})
},
loginCallback(params) {
console.log(params);
},
loginSuccess(params) {
console.log(params);
let app = getApp();
this.setData({
isLogin: app.isLogin(),
});
this._getProceedingData();
this._getReleaseData(1);
},
loginError(error) {
console.log(error);
router.go('bindPhoneNumber');
},
goReferer() {
wx.navigateBack({
delta: 1
});
},
}, Toast));
\ No newline at end of file
... ...
... ... @@ -9,6 +9,7 @@
"tabs": "./components/tabs",
"tabs-pane": "./components/tabs-pane",
"dialog": "../../component/dialog/dialog",
"prize-item": "./components/prize-item"
"prize-item": "./components/prize-item",
"login": "../../login/login/login"
}
}
\ No newline at end of file
... ...
... ... @@ -44,7 +44,7 @@
</block>
</block>
<block wx:else>
<view>登录页面</view>
<login theme="light" openType="{{openType}}"></login>
</block>
<!-- <view class="productList">
<block wx:for="{{list[2].products}}" wx:key="{{item.id}}">
... ... @@ -52,8 +52,9 @@
</block>
</view> -->
</tabs-pane>
<block wx:if="{{isLogin}}">
<view class="list-foot-blank">{{footText}}</view>
</block>
</tabs>
<block wx:if="{{tabIndex !== 3}}">
<view class="bottom-banner" bindtap="_jumpBanner" wx:if="{{bannerSrc != null}}">
... ...
... ... @@ -5,7 +5,8 @@ const route = {
myList: '/pages/zeroSell/myList',
detail: '/pages/zeroSell/detail',
snapShare: '/pages/zeroSell/snapshootShare',
webview: '/pages/zeroSell/h5Page'
webview: '/pages/zeroSell/h5Page',
bindPhoneNumber: '/pages/bindPhoneNumber/bindPhoneNumber'
};
function jumpFn(name, qs) {
... ...