Authored by 李奇

Merge branch 'v_1217' into 'master'

V 1217



See merge request !1
Showing 100 changed files with 3584 additions and 184 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

... ... @@ -9,7 +9,14 @@ 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';
const event = new Event();
global.event = event;
import { logEvent,
YB_LAUNCH_APP,
... ... @@ -21,10 +28,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 +95,31 @@ 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();
event.on('user-is-login', ({ logged, loginSuccess }) => {
const userInfo = wx.getStorageSync('userInfo');
console.log(userInfo);
if (userInfo && userInfo.uid && userInfo.session_key) {
this.globalData.userInfo = userInfo;
if (logged) {
logged(userInfo);
}
} else {
event.once('user-login-success', (userInfo) => {
if (loginSuccess) {
loginSuccess(userInfo);
}
});
wx.navigateTo({
url: '/login/login-page/login-page',
})
}
});
},
//当应用程序进入前台显示状态时触发
... ... @@ -272,7 +298,7 @@ App({
if (!isStringEmpty(this.globalData.openID)){
openid = this.globalData.openID
}else{
openid = getYHStorageSync('openID','app')
openid = getYHStorageSync('open_id','app')
this.globalData.openID = openid
}
return openid
... ... @@ -371,6 +397,7 @@ App({
获取用户相关union_type
*/
getUnionTypeWithUid: function (uid) {
if (!uid) return;
let param = {
method: 'app.union.shareOrder.queryUnionTypeByUid',
uid,
... ...
{
"pages": [
"pages/bindPhoneNumber/bindPhoneNumber",
"pages/zeroSell/index",
"pages/zeroSell/detail",
"pages/zeroSell/myList",
"pages/zeroSell/snapshootShare",
"pages/zeroSell/h5Page"
"pages/zeroSell/h5Page",
"pages/bindPhoneNumber/bindPhoneNumber",
"pages/choosecountry/choosecountry",
"login/login-page/login-page"
],
"window": {
"navigationBarTextStyle": "white",
... ... @@ -13,6 +15,9 @@
"backgroundColor": "#fff",
"backgroundTextStyle": "dark",
"onReachBottomDistance": 100
}
},
"navigateToMiniProgramAppIdList": [
"wx207f18be42db9028"
]
}
... ...
import { jumpByUrl } from '../../libs/urlRoute';
import { postFormId } from '../../libs/formIdCollectRequest.js';
import {
logEvent,
YB_MAIN_POP_UP_C,
} from '../../libs/analytics.js'
Component({
options: {
multipleSlots: true
},
properties: {
src: {
type: String,
value: ""
},
url: {
type: String,
value: ""
}
},
dada: {
isShow: false,
},
methods: {
hideDialog(){
this.setData({
isShow: false,
});
},
showDialog(){
this.setData({
isShow: true,
});
},
jumpByRule(){
let that = this;
if (that.properties.url == null){
return;
}
let params = {
TO_PATH: that.properties.url
};
logEvent(YB_MAIN_POP_UP_C, params);
jumpByUrl(that.properties.url,'home');
that.hideDialog();
},
//formId上报
formSubmit(e) {
// console.log('----formSubmit---', e);
let formId = e.detail.formId;
postFormId(formId,'1');
}
}
})
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='container' hidden="{{!isShow}}" catchtouchmove="true">
<view class='dialog-mask'>
<view class='dialog'>
<form bindsubmit='formSubmit' report-submit='true'>
<image src="{{src}}" class='dialog-image' mode='aspecdtFit' bindtap='jumpByRule'></image>
<button class='image-btn' form-type='submit' bindtap='jumpByRule'></button>
</form>
<form bindsubmit='formSubmit' report-submit='true'>
<view class='dialog-close' bindtap='hideDialog'>
<image class='close' src="./images/close.png" ></image>
<button class='dialog-btn' form-type='submit'></button>
</view>
</form>
</view>
</view>
</view>
\ No newline at end of file
... ...
.dialog-mask{
position: fixed;
z-index: 4999;
width: 100%;
height: 100%;
top: 0;
right: 0;
left: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
background: rgba(0, 0, 0, 0.6);
}
.dialog{
position: fixed;
z-index: 5000;
top: 110rpx;
display: flex;
flex-direction: column;
align-items: center;
height: wrap;
width: 100%;
}
.dialog-image{
height: 680rpx;
width: 680rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.dialog-close{
height: 110rpx;
width: 100rpx;
margin-top: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.close {
width: 80rpx;
height: 80rpx;
}
.dialog-btn {
height: 110rpx;
width: 100rpx;
background-color: red;
position: absolute;
opacity: 0;
}
.image-btn {
height: 680rpx;
width: 680rpx;
background-color: red;
position: absolute;
top: 0rpx;
opacity: 0;
}
... ...
// export const API_HOST = 'https://api.yoho.cn';
// export const SERVICE_HOST = 'https://api.yoho.cn';
export const API_HOST = 'https://api.yoho.cn';
export const SERVICE_HOST = 'https://api.yoho.cn';
export const APP_REPORT_HOST = 'https://app.yoho.cn/collect/v3';
export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile';
// export const ACTIVITY_HOST = 'http://192.168.102.49:6006';
// export const ACTIVITY_HOST = 'http://172.16.10.53:6006'
// export const ACTIVITY_HOST = 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com';
export const ACTIVITY_HOST = 'https://action.yoho.cn';
// export const API_HOST = 'http://dev-api.yohops.com:9999';
... ... @@ -12,8 +14,8 @@ export const ACTIVITY_HOST = 'https://action.yoho.cn';
// export const API_HOST = 'http://api-test1.yohops.com:9999';
// export const SERVICE_HOST = 'http://api-test1.yohops.com:9999/';
export const API_HOST = 'http://api-test3.dev.yohocorp.com';
export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com';
// export const API_HOST = 'http://api-test3.dev.yohocorp.com';
// export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com';
// export const API_HOST = 'http://api-test2.dev.yohocorp.com';
// export const SERVICE_HOST = 'http://api-test2.dev.yohocorp.com';
... ...
... ... @@ -76,7 +76,9 @@ function request(method = 'GET') {
params.session_key = sessionkey;
params.source_type = "wechat";
params.client_type = "miniapp";
params.business_line = "miniapp";
if (!params.business_line) {
params.business_line = "miniapp";
}
params.user_source = "wechat"
if (params && !params.hasOwnProperty('udid')) {
... ...
.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;
}
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
\ 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;
const app = getApp();
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);
if (bindResult && bindResult.is_register === 0) {
const newUserInfo = {
is_bind: bindResult.is_bind,
mobile: bindResult.profile,
session_key: bindResult.session_key,
uid: bindResult.uid,
ssouid: bindResult.ssouid,
union_id: union_id,
vip: bindResult.vip
};
let userInfo = wx.getStorageSync('userInfo');
userInfo = Object.assign(userInfo, newUserInfo);
await setStorageValueForKey('userInfo', userInfo);
await setStorageValueForKey('sessionkey', bindResult.session_key);
app.globalData.userInfo = userInfo;
setTimeout(() => {
event.emit('wechat-login-success');
}, 1000);
event.emit('user-login-success', newUserInfo);
wx.showToast({
icon: 'none',
title: '手机号授权成功!\r\n为享受更多权益,已为您注册有货会员!',
duration: 3000
});
} else if (bindResult && (bindResult.is_register === 2 || bindResult.is_register === 3 || bindResult.is_register === 4)) {
const newUserInfo = {
is_bind: bindResult.is_bind,
mobile: bindResult.profile,
session_key: bindResult.session_key,
uid: bindResult.uid,
ssouid: bindResult.ssouid,
union_id: union_id,
vip: bindResult.vip
};
let userInfo = wx.getStorageSync('userInfo');
userInfo = Object.assign(userInfo, newUserInfo);
await setStorageValueForKey('userInfo', userInfo);
await setStorageValueForKey('sessionkey', bindResult.session_key);
app.globalData.userInfo = userInfo;
event.emit('wechat-login-success');
event.emit('user-login-success', newUserInfo);
}
} else {
throw new Error('手机号获取失败,请使用手机号登录');
}
} catch (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);
event.emit('user-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
} else {
throw res
}
})
}
}
\ 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
... ...
... ... @@ -9,7 +9,7 @@ let CHOOSED_COUNTRY_ID = 'CHOOSED_COUNTRY_ID'
let CHOOSED_COUNTRY_NAME = 'CHOOSED_COUNTRY_NAME'
let app = getApp();
const {extend,Toast} = require('../../vendors/zanui/index');
const event = global.event;
Page(extend({},Toast,{
/**
* 页面的初始数据
... ... @@ -185,11 +185,12 @@ Page(extend({},Toast,{
//如果是从h5页面唤起,则重新用webview 打开h5链接;其他页面直接返回上一层
if (that.data.h5back){
wx.navigateBack({
delta: 1,
delta: 2,
})
wx.redirectTo({
url: '../webview/webview?url=' + that.data.h5back
})
event.emit('wechat-login-success');
}else{
if (result.is_register){
that.showZanToast({
... ... @@ -200,8 +201,9 @@ Page(extend({},Toast,{
prePage[prePage.length - 2].bindPhoneNumComplete();
}
wx.navigateBack({
delta: 1,
delta: 2,
})
event.emit('wechat-login-success');
}
}, 1500);
} else {
... ... @@ -210,6 +212,7 @@ Page(extend({},Toast,{
if (prePage.length > 1 && prePage[prePage.length - 2].bindPhoneNumComplete != undefined) {
prePage[prePage.length - 2].bindPhoneNumComplete();
}
event.emit('wechat-login-success');
wx.navigateBack({
delta: 1,
})
... ... @@ -427,6 +430,7 @@ bindBtnAction:function (needBind, callBackFun) {
} else {
that.redirectAction();
}
event.emit('wechat-login-success');
}
})
},
... ... @@ -438,21 +442,21 @@ redirectAction: function() {
let that = this;
if (that.data.h5back) {
wx.navigateBack({
delta: 1,
delta: 2,
})
wx.redirectTo({
url: '../webview/webview?url=' + that.data.h5back
})
} else {
let prePage = getCurrentPages();
that.newCustomerStorage();
if (prePage.length > 1 && prePage[prePage.length - 2].bindPhoneNumComplete != undefined) {
prePage[prePage.length - 2].bindPhoneNumComplete();
}
// let prePage = getCurrentPages();
// that.newCustomerStorage();
// if (prePage.length > 1 && prePage[prePage.length - 2].bindPhoneNumComplete != undefined) {
// prePage[prePage.length - 2].bindPhoneNumComplete();
// }
// console.log("currentPage:", getCurrentPages())
wx.navigateBack({
delta: 1,
delta: 2,
})
return
}
... ...
... ... @@ -66,7 +66,7 @@
<button catchtap="bindBtnAction" class="view-bindBtn {{disabledClass == undefined ? 'disabled' : disabledClass}}" >完成</button>
<button class="view-verifyBtn" open-type="{{hasUnionID?'getPhoneNumber':'getUserInfo'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>自动验证</button>
<!-- <button class="view-verifyBtn" open-type="{{hasUnionID?'getPhoneNumber':'getUserInfo'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>自动验证</button> -->
</view>
... ...
{
"navigationBarTitleText": "选择国家"
}
\ No newline at end of file
... ...
// pages/choosecountry/choosecountry.js
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { getYHStorageSync } from '../../utils/util';
let CACH_KEY = 'country_cach';
let CHOOSED_COUNTRY_ID = 'CHOOSED_COUNTRY_ID'
let CHOOSED_COUNTRY_NAME = 'CHOOSED_COUNTRY_NAME'
Page({
/**
* 页面的初始数据
*/
data: {
list:[]
},
getArea: function () {
let param={
method: 'app.passport.getArea'
}
GET(API_HOST,param)
.then(json=>{
if(json && json.code == 200){
let datalist = json.data;
if(datalist && datalist.length>0){
// wx.setStorageSync(CACH_KEY, datalist);
this.setData({
list: datalist
})
wx.setStorage({
key: CACH_KEY,
data: datalist,
})
}
}else{
this.useCache();
}
})
.catch(error=>{
this.useCache();
})
},
useCache:function(){
let datalist = getYHStorageSync(CACH_KEY,'choosecountry');
this.setData({
list: datalist
})
},
chooseCountry:function(e){
let country = e.currentTarget.dataset.country;
let country_area = e.currentTarget.dataset.area;
let country_id = e.currentTarget.dataset.id;
wx.setStorage({
key: CHOOSED_COUNTRY_ID,
data: country_area,
})
wx.setStorage({
key: CHOOSED_COUNTRY_NAME,
data: country,
})
// console.log('选择了国家:' + country+":::"+country_area+":::"+country_id)
wx.navigateBack({
delta: 1
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getArea();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
<!--pages/choosecountry/choosecountry.wxml-->
<template name='country'>
<view class='countrycontainer' bindtap='chooseCountry' data-country='{{item.name}}'
data-area='{{item.area}}' data-id='{{item.id}}'>
<view class='countryname'>{{item.name}}</view>
<view class='countrycode'>+{{item.area}}</view>
</view>
</template>
<view class='rootcontainer'>
<block wx:for='{{list}}'wx:key="{{index}}">
<template is='country' data="{{item}}"/>
</block>
</view>
... ...
/* pages/choosecountry/choosecountry.wxss */
.rootcontainer{
width: 100%;
height: 100%;
background-color: white;
display: flex;
flex-direction: column;
align-items: center;
}
.countrycontainer{
width: 710rpx;
height: 100rpx;
margin-left: 20rpx;
margin-right: 20rpx;
border-bottom: 1rpx solid #b0b0b0;
display: flex;
flex-direction: row;
align-items: center;
}
.countryname{
text-align: left;
flex: 1;
color: #444444;
font-size: 34rpx;
margin-left: 10rpx
}
.countrycode{
margin-right: 10rpx;
color: #b0b0b0;
font-size: 34rpx
}
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent
}
\ No newline at end of file
... ...
... ... @@ -86,14 +86,25 @@ Component({
},
goShare() {
this.triggerEvent('share');
this.setData({
show: false,
error: false,
fellow: false
});
},
goMyList() {
router.go('myList');
wx.reLaunch({
url: '/pages/zeroSell/index?tabIndex=3&reload=0',
})
},
goList() {
router.go('index');
wx.navigateTo({
url: '/pages/zeroSell/index?reload=0',
})
},
cancelAlert() {
... ... @@ -112,7 +123,17 @@ Component({
});
},
hiddenAlert(e) {
this.setData({
show: false,
error: false,
fellow: false
});
console.log('隐藏');
},
submitFormId(e) {
console.log(e.detail);
return this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
... ...
... ... @@ -2,6 +2,7 @@
"component": true,
"usingComponents": {
"zero-alert": "./alert",
"new-lucky-alert": "./new-lucky-alert",
"fellow-alert": "./fellow-alert"
}
}
\ No newline at end of file
... ...
... ... @@ -16,12 +16,12 @@
</block>
<block wx:elif="{{status === 3}}">
<view class="action-item confirm" bindtap="goMyList">
<!-- <view class="action-item confirm" bindtap="goMyList">
我的抽奖码({{num}})
</view>
</view> -->
<view class="action-item ok" bindtap="goShare">
获取更多抽奖码
分享得更多抽奖码,增加中奖率
</view>
</block>
... ... @@ -46,23 +46,29 @@
</block>
</view>
<zero-alert wx:if="{{show}}">
<new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert">
<view class="code-alert">
<view class="title">你的抽奖码是</view>
<view class="code">{{code}}</view>
<view class="share">分享可以获得更多抽奖码,中奖几率up!</view>
<text class="code-title">参加抽奖成功</text>
<view class="code-bg">
<view class="title">你的抽奖码是</view>
<view class="code">{{code}}</view>
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<button class="share" form-type="submit" bindtap="goShare">分享一下,中奖概率立马double</button>
</form>
<view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<!-- <form bindsubmit='submitFormId' report-submit='true'>
<view class="foot">
<button class="foot-item info" plain="true" hover-class="none" form-type="submit" bindtap="goShare">去分享</button>
<button class="foot-item" plain="true" hover-class="none" form-type="submit" bindtap="cancelAlert">取消</button>
</view>
</form>
</form> -->
<!-- <view class="foot-item info" bindtap="goShare">去分享</view>
<view class="foot-item" bindtap="cancelAlert">取消</view> -->
</zero-alert>
</new-lucky-alert>
<zero-alert wx:if="{{error}}">
<view class="error-alert">
... ...
... ... @@ -47,34 +47,62 @@
}
.code-alert {
text-align: center;
color: black;
margin-top: 40rpx;
margin-top: -400rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.code-title {
margin-top: -10rpx;
}
.code-bg {
margin-top: 80rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.title {
font-size: 28rpx;
color: #B0B0B0;
margin-bottom: 30rpx;
color: #444444;
}
.code {
display: inline-block;
min-width: 260rpx;
height: 72rpx;
font-size: 40rpx;
min-width: 192rpx;
height: 50rpx;
font-size: 28rpx;
font-weight: bolder;
line-height: 72rpx;
line-height: 50rpx;
text-align: center;
border: 1rpx solid black;
margin-bottom: 30rpx;
padding: 0 20rpx;
margin-left: 20rpx;
}
.share {
font-size: 28rpx;
color: #444444;
color: #FFFFFF;
background: #FF4C00;
border-radius: 28px;
width: 460rpx;
height: 80rpx;
line-height: 80rpx;
margin-top: 90rpx;
vertical-align: center;
}
.share-desc {
font-size: 20rpx;
color: #B0B0B0;
font-family: PingFangSC-Medium;
margin-top: 10rpx;
}
.foot {
... ...
... ... @@ -15,9 +15,8 @@
.modal-dialog {
height: 380rpx;
width: 540rpx;
overflow: hidden;
position: fixed;
top: 40%;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
... ...
<swiper wx:if="{{list.length !== 0}}" indicator-dots="{{indicatorDots}}"
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" vertical="{{true}}" class="swiper" circular="{{true}}">
<block wx:for="{{list}}">
... ...
... ... @@ -6,6 +6,14 @@ Component({
properties: {
list: {
type: Array
},
bannerSrc: {
type: String,
value: null
},
bannerUrl: {
type: String,
value: null
}
},
... ... @@ -20,6 +28,8 @@ Component({
* 组件的方法列表
*/
methods: {
jumpUrl:function() {
this.triggerEvent('tapUrl')
}
}
})
... ...
... ... @@ -5,6 +5,9 @@
</view>
<view class="desc-content">
<view class="banner" bindtap="_jumpBanner" wx:if="{{bannerSrc != null && bannerSrc !== ''}}">
<image class="banner-img" src="{{bannerSrc}}"></image>
</view>
<block wx:for="{{list}}">
<block wx:if="{{item.floor_type === 1}}">
<view >{{item.content}}</view>
... ...
... ... @@ -33,4 +33,15 @@
display: block;
width: 100%;
margin: 50rpx 0;
}
.banner {
width: 100%;
height: 234rpx;
}
.banner-img {
width: 100%;
height: 234rpx;
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@
<view class="fellow-bar">
<view class="title">关注有货公众号“潮流有货”,开奖后查看中奖结果</view>
<view class="title">关注公众号"潮流有货",发送开奖后查看中奖结果</view>
<view class="btn" bindtap="onClick">去关注</view>
</view>
... ...
// pages/zeroSell/components/group-recommend-cell.js
import { getImageUrl } from '../../../utils/util.js';
Component({
/**
* 组件的属性列表
*/
properties: {
product: {
type: Object,
value: {},
observer(newValue) {
newValue.default_images = getImageUrl(newValue.default_images, 483, 645);
this.setData({
group_product: newValue
})
}
}
},
/**
* 组件的初始数据
*/
data: {
group_product: {},
group_number_image: '../../../images/tab@3x.png',
free_post: '../../../images/free-post@3x.png'
},
/**
* 组件的方法列表
*/
methods: {
clickGroupDetail(e) {
this.triggerEvent('handlegroupdetail', e.currentTarget.dataset.groupProduct);
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--pages/zeroSell/components/group-recommend-cell.wxml-->
<!-- <text>pages/zeroSell/components/group-recommend-cell.wxml</text> -->
<view class="group-product-cell-bg" bindtap="clickGroupDetail" data-group-product="{{group_product}}">
<view class="group-product-header">
<image class="group-product-left-icon" src="{{group_number_image}}">
</image>
<text class="group-product-left-icon group-product-left-icon-number">{{group_product.people_num}}人团</text>
<image class="group-product-image" src="{{group_product.default_images}}"></image>
</view>
<view class="group-product-name">{{group_product.product_name}}</view>
<view class="group-price">
<view class="group-prict-bg">
<text class="group-price-market">¥{{group_product.market_price}}</text>
<text class="group-price-collage">¥{{group_product.collage_price}}</text>
</view>
<image class="group-free-post" src="{{free_post}}"></image>
</view>
</view>
... ...
/* pages/zeroSell/components/group-recommend-cell.wxss */
.group-product-image {
width: 322rpx;
height: 430rpx;
}
.group-product-cell-bg {
margin-top: 20rpx;
}
.group-product-left-icon {
margin-top: 10rpx;
width: 88rpx;
height: 40rpx;
position: absolute;
margin-left: -15rpx;
color: #FFFFFF;
font-size: 22rpx;
font-family: PingFangSC-Medium;
}
.group-product-left-icon-number {
margin-left: 0rpx;
margin-top: 19rpx;
}
.group-product-name {
width: 322rpx;
height: 56rpx;
font-family: PingFangSC-Medium;
font-size: 20rpx;
color: #444444;
margin-top: 24rpx;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
white-space: normal !important;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.group-price {
display: flex;
flex-direction: row;
align-items: center;
}
.group-price-market {
text-decoration: line-through;
}
.group-price-collage {
font-size: 32rpx;
color: #D0021B;
margin-left: 20rpx;
letter-spacing: 2rpx;
}
.group-prict-bg {
font-size: 22rpx;
color: #444444;
font-family: SanFranciscoText-Medium;
}
.group-free-post {
width: 60rpx;
height: 40rpx;
margin-left: 20rpx;
}
\ No newline at end of file
... ...
// pages/zeroSell/components/group-recommend.js
Component({
/**
* 组件的属性列表
*/
properties: {
groupRecommendList: {
type: Array,
value: []
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
groupDetail(e) {
this.triggerEvent('goToGroupMiniApp', e.detail);
}
}
})
... ...
{
"component": true,
"usingComponents": {
"group-recommend-cell": "./group-recommend-cell"
}
}
\ No newline at end of file
... ...
<!--pages/zeroSell/components/group-recommend.wxml-->
<view class="title-view">
<view class="space-line"></view>
<text class="title">邀新团</text>
</view>
<view class="group-list">
<block wx:for="{{groupRecommendList}}">
<group-recommend-cell product="{{item}}" bindhandlegroupdetail="groupDetail"></group-recommend-cell>
</block>
</view>
\ No newline at end of file
... ...
/* pages/zeroSell/components/group-recommend.wxss */
.group-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
margin-left: 40rpx;
margin-right: 40rpx;
}
.space-line {
background-color: #444444;
width: 8rpx;
height: 30rpx;
margin-right: 10rpx;
}
.title-view {
margin-left: 32rpx;
margin-top: 20rpx;
font-size: 32rpx;
color: #444444;
letter-spacing: -0.14px;
display: flex;
flex-direction: row;
align-items: center;
font-family: PingFangSC-Medium;
}
\ No newline at end of file
... ...
<!--page/subPackage/pages/zeroSell/components/head-counter.wxml-->
<wxs src="./helper.wxs" module="helper" />
<view class="head-counter">
<view class="title">
<vivew class="txt">已有</vivew>
<!-- <view class="head-counter"> -->
<!-- <view class="title">
<view class="txt">已有</view>
<block wx:for="{{helper.formatN('000000', count)}}">
<view class="num-wrapper">
<text>{{item}}</text>
... ... @@ -17,5 +17,18 @@
<view style="font-size: 28rpx;" wx:elif="{{status === 1 || status === 2}}"> 达到{{num}}人开奖 </view>
<view style="font-size: 28rpx;" wx:elif="{{status === 3}}"> 等待开奖中 </view>
<view style="font-size: 28rpx;" wx:elif="{{status === 4}}"> 已开奖 </view>
<view style="font-size: 28rpx;" wx:elif="{{status === 5}}"> 人数不足 活动结束 </view>
<view style="font-size: 28rpx;" wx:elif="{{status === 5}}"> 人数不足 活动结束 </view> -->
<!-- </view> -->
<view class="container">
<view class="text">
已有{{count}}人参加,
<text wx:if="{{status === 0}}"> 活动结束 </text>
<text wx:elif="{{status === 1 || status === 2}}"> 达到{{num}}人开奖 </text>
<text wx:elif="{{status === 3}}"> 等待开奖中 </text>
<text wx:elif="{{status === 4}}"> 已开奖 </text>
<text wx:elif="{{status === 5}}"> 人数不足 活动结束 </text>
</view>
</view>
... ...
... ... @@ -43,4 +43,22 @@
left: 0;
opacity: 0.4;
background-color: black;
}
.text {
font-family: PingFang-SC-Medium;
font-size: 28rpx;
color: #FFFFFF;
letter-spacing: -0.36rpx;
text-align: center;
display: inline-block;
margin-top: 15rpx;
}
.container {
width: 600rpx;
height: 64rpx;
background-color: #222;
text-align: center;
margin: 0 auto;
}
\ No newline at end of file
... ...
<view class="help" bindtap="_onTap"> 活动说明 </view>
\ No newline at end of file
<view class="help" bindtap="_onTap">
<image class="helpe-img" src="../images/que_ic@2x.png"></image>
<text>查看活动说明 </text>
</view>
\ No newline at end of file
... ...
/* page/subPackage/pages/zeroSell/components/help.wxss */
.help {
width: 200rpx;
width: 100%;
height: 65rpx;
font-size: 24rpx;
line-height: 65rpx;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 40rpx;
color: white;
text-align: left;
padding-left: 20rpx;
color: #222222;
text-align: center;
text-decoration: underline;
}
.helpe-img {
width: 30rpx;
height: 30rpx;
vertical-align: middle;
margin-right: 10rpx;
position: relative;
top: -2rpx;
}
\ No newline at end of file
... ...
// pages/zeroSell/components/new-lucky-alert.js.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
hidenMask(e) {
this.triggerEvent('hiddenalert')
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="modal-mask" catchtap="hidenMask"></view>
<view class="modal-dialog">
<image class="modal-dialog-bg" src="/images/alert_bg@3x.png"></image>
<slot></slot>
</view>
\ No newline at end of file
... ...
/* pages/zeroSell/components/new-lucky-alert.js.wxss */
.modal-mask {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background: #000;
opacity: 0.5;
overflow: hidden;
z-index: 9000;
}
.modal-dialog {
height: 550rpx;
width: 550rpx;
position: fixed;
top: 40%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
z-index: 9999;
border-radius: 10rpx;
overflow: visible;
display: flex;
flex-direction: column;
}
.modal-dialog-bg {
width: 550rpx;
height: 550rpx;
}
\ No newline at end of file
... ...
... ... @@ -2,7 +2,8 @@
.prize-item {
border-bottom: 2rpx dashed #E0E0E0;
padding: 20rpx 30rpx;
padding: 20rpx 0rpx;
margin-left: 30rpx;
position: relative;
z-index: 1;
overflow: hidden;
... ... @@ -39,6 +40,6 @@
padding: 8rpx;
bottom: 20rpx;
right: 30rpx;
border: 1rpx solid black;
color: black;
color: white;
background-color: #222;
}
\ No newline at end of file
... ...
... ... @@ -10,7 +10,7 @@
}
.step {
padding-top: 20rpx;
padding-top: 23rpx;
}
.step-image {
... ...
... ... @@ -4,6 +4,12 @@ Component({
properties: {
product: {
type: Object
},
avatars: {
type: Array
}
},
ready:function() {
// console.log(`productdetail: ${this.properties.avatars}`)
}
});
... ...
{
"component": true,
"usingComponents": {}
"usingComponents": {
"time-countdown": "./timeCountDown/time-countdown",
"avatars": "./avatar-swiper"
}
}
\ No newline at end of file
... ...
<wxs src="./helper.wxs" module="helper" />
<view wx:if="{{product.status === 2}}">
<view class="countdown_label">
<text class="countdown_labeltext">抽奖</text>
<text class="countdown_labeltext">倒计时</text>
</view>
<time-countdown class="product_countdown" wx:if="{{product.status === 2}}" endTime="{{product.end_time}}"></time-countdown>
</view>
<view class="avatarcontainer">
<view class="avatars" wx:if="{{product.status === 2 && avatars.length > 0}}">
<avatars list="{{avatars}}"></avatars>
</view>
<image class="product_image" src="{{product.cover_img}}"></image>
</view>
<view class="product_name" >{{product.name}}</view>
<view class="product_price" >{{product.price}}</view>
<view class="product_time">{{helper.formatTime(product.start_time, product.end_time)}}</view>
\ No newline at end of file
<view class="product_lucky_bg">
<view class="product_lucky"><text>抽奖价 ¥ <text class="lucky">0</text></text></view>
<view class="product_price" >{{product.price}}</view>
</view>
<view wx:if="{{product.status !== 2}}" class="product_time">{{helper.formatTime(product.start_time, product.end_time)}}</view>
<view class="product_margin"></view>
\ No newline at end of file
... ...
... ... @@ -8,25 +8,35 @@
.product_name {
display: inline-block;
margin-top: 30rpx;
width: 570rpx;
font-size: 36rpx;
letter-spacing: -0.34px;
width: 686rpx;
font-size: 28rpx;
font-weight: bold;
word-break:break-all;
color: #444444;
}
.product_lucky_bg {
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: center;
margin-left: 32rpx;
margin-right: 32rpx;
}
.product_price {
color: #B0B0B0;
font-size: 36rpx;
font-size: 24rpx;
font-weight: bold;
margin-top: 26rpx;
margin-left: 20rpx;
text-decoration: line-through;
}
.product_time {
color: #B0B0B0;
font-size: 24rpx;
margin-top: 16rpx;
margin-bottom: 40rpx;
}
.product_time:before {
... ... @@ -47,4 +57,60 @@
background-color: #D8D8D8;
margin-left: 20rpx;
vertical-align: 6rpx
}
.product_margin {
margin-bottom: 40rpx;
}
.product_countdown {
display: inline-block;
height: 92rpx;
margin-top: 44rpx;
margin-bottom: 36rpx;
}
.countdown_label {
width: 60rpx;
font-family: PingFang-SC-Regular;
font-size: 20rpx;
color: #222222;
letter-spacing: -0.36rpx;
text-align: center;
display: inline-block;
margin-right: 16rpx;
vertical-align: text-top;
position: relative;
top: -4rpx;
}
.countdown_labeltext {
display: block;
}
.avatars {
display: inline-block;
text-align: center;
margin-left: auto;
margin-right: auto;
left: calc(50% - 180rpx);
top: 36rpx;
position: absolute;
}
.avatarcontainer {
position: relative;
}
.product_lucky {
color: #D0021B;
font-size: 24rpx;
font-family: PingFangSC-Semibold;
display: flex;
flex-direction: row;
align-items: baseline;
}
.lucky {
font-size: 52rpx;
}
\ No newline at end of file
... ...
{
"component": true,
"usingComponents": {}
"usingComponents": {
"time-countdown": "./timeCountDown/time-countdown"
}
}
\ No newline at end of file
... ...
<wxs src="./helper.wxs" module="helper" />
<time-countdown class="product_countdown" wx:if="{{product.status === 2}}" endTime="{{product.end_time}}"></time-countdown>
<image class="product_image" src="{{product.cover_img}}"></image>
<view class="product_name" >{{product.name}}</view>
<view class="product_price" >{{product.price}}</view>
<view class="product_time">{{helper.formatTime(product.start_time, product.end_time)}}</view>
\ No newline at end of file
<view class="product_lucky_bg">
<view class="product_lucky"><text>抽奖价 ¥ <text class="lucky">0</text></text></view>
<view class="product_price" >{{product.price}}</view>
</view>
<view wx:if="{{product.status !== 2}}" class="product_time">{{helper.formatTime(product.start_time, product.end_time)}}</view>
<view class="product_margin"></view>
\ No newline at end of file
... ...
... ... @@ -6,27 +6,36 @@
}
.product_name {
display: inline-block;
margin-top: 30rpx;
width: 570rpx;
font-size: 36rpx;
font-weight: bold;
word-break:break-all;
color: #444444;
margin-left: 30rpx;
margin-right: 60rpx;
text-align: left;
}
.product_price {
color: #B0B0B0;
font-size: 36rpx;
font-size: 24rpx;
font-weight: bold;
margin-top: 26rpx;
margin-left: 30rpx;
}
.product_lucky_bg {
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: space-between;
margin-left: 30rpx;
margin-right: 60rpx;
}
.product_time {
color: #B0B0B0;
font-size: 24rpx;
margin-top: 16rpx;
margin-bottom: 40rpx;
}
.product_time:before {
... ... @@ -47,4 +56,28 @@
background-color: #D8D8D8;
margin-left: 20rpx;
vertical-align: 6rpx
}
.product_margin {
margin-bottom: 48rpx;
}
.product_countdown {
display: block;
height: 92rpx;
padding-top: 40rpx;
margin-bottom: 40rpx;
}
.product_lucky {
color: #D0021B;
font-size: 24rpx;
font-family: PingFangSC-Semibold;
display: flex;
flex-direction: row;
align-items: baseline;
}
.lucky {
font-size: 52rpx;
}
\ No newline at end of file
... ...
<view>
<block wx:if="{{product.status === 0}}">
<block wx:if="{{product.status === 0 || product.is_full === 1}}">
<view class="btn cancel" >活动结束</view>
</block>
... ...
... ... @@ -5,12 +5,13 @@
height: 88rpx;
text-align: center;
line-height: 88rpx;
font-size: 28rpx;
color: #444444;
font-size: 36rpx;
color:white;
margin-bottom: 44rpx;
}
.ok {
border: 4rpx solid #444444;
background: #222;
}
.cancel {
... ...
<view bindtap="goDetail">
<view class="product-item" bindtap="goDetail">
<product-item-header product="{{product}}"></product-item-header>
<product-item-status product="{{product}}"></product-item-status>
</view>
\ No newline at end of file
... ...
... ... @@ -4,4 +4,8 @@
.product-status {
text-align: center;
}
.product-item {
background-color: white;
}
\ No newline at end of file
... ...
... ... @@ -6,7 +6,13 @@ Component({
properties: {
currentKey: {
type: Number,
value: 0
value: 0,
observer(newVal) {
this.setData({
key: newVal
});
this._updateNav();
}
}
},
... ...
... ... @@ -18,6 +18,7 @@
font-size: 32rpx;
color: #B0B0B0;
background-color: white;
font-weight: bold;
}
.active {
... ...
// pages/zeroSell/components/timeCountDown/time-countdown.js
Component({
/**
* 组件的属性列表
*/
properties: {
endTime: {//结束时间
type: Number
},
formatTime: {
type: Array
}
},
/**
* 组件的初始数据
*/
data: {
},
ready: function() {
this.setData({
formatTime: this.formatCountDown(this.properties.endTime)
})
this.formatTime()
},
/**
* 组件的方法列表
*/
methods: {
formatTime:function() {
let self = this
setInterval(function() {
self.setData({
formatTime: self.formatCountDown(self.properties.endTime)
})
},1000)
},
formatCountDown:function formatCountDown(end) {
if (end === 0 || (end * 1000 - Date.now() < 0)) {
return '00000000'
}
var timeInSecond = (end * 1000 - Date.now()) / 1000
var day = 24 * 60 * 60
var numberOfDay = Math.floor(timeInSecond / day)
timeInSecond = timeInSecond - numberOfDay * day
numberOfDay = Math.min(numberOfDay, 99)
var hour = 60 * 60
var numberOfHour = Math.floor(timeInSecond / hour)
timeInSecond = timeInSecond - numberOfHour * hour
var minute = 60
var numberOfMinute = Math.floor(timeInSecond / minute)
timeInSecond = timeInSecond - numberOfMinute * minute
var numberOfSecond = parseInt(timeInSecond)
var list = [numberOfDay, numberOfHour, numberOfMinute, numberOfSecond]
for (var i = 0; i < list.length; i++) {
var item = list[i]
if (item < 10) {
list[i] = '0' + item
} else {
list[i] = '' + item
}
}
return list
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--pages/zeroSell/components/timeCountDown/time-countdown.wxml-->
<block wx:for="{{formatTime}}" wx:key="">
<view class="num-wrapper">
<view class="mask"></view>
<text class="num-text">{{item}}</text>
<view class="mask-left"></view>
<view class="mask-right"></view>
</view>
<view class="number-seprator" wx:if="{{index !== 3}}">:</view>
</block>
... ...
.num-wrapper {
display: inline-block;
position: relative;
width: 72rpx;
height: 84rpx;
font-size: 50rpx;
line-height: 84rpx;
background: #444;
color: white;
font-weight: bolder;
}
.num-wrapper + .num-wrapper {
margin-left: 10rpx;
}
.mask {
position: absolute;
width: 100%;
height: 50%;
top: 0;
left: 0;
opacity: 0.4;
background-color: black;
z-index: 0;
}
.num-text {
z-index: 99;
}
.mask-left {
position: absolute;
width:3.5rpx;
height: 8rpx;
top: calc(50% - 4rpx);
left: 0;
background-color: white;
}
.mask-right {
position: absolute;
width:3.5rpx;
height: 8rpx;
top: calc(50% - 4rpx);
right: 0;
background-color: white;
}
.number-seprator {
font-size: 60rpx;
line-height: 84rpx;
height: 84rpx;
margin-left: 10rpx;
margin-right: 10rpx;
box-sizing: border-box;
color: black;
display: inline-block;
}
\ No newline at end of file
... ...
// page/subPackage/pages/zeroSell/detail.js
import ZeroSellService from './service/zero-sell'
import CommonService from './service/common'
import {
decodePhoneNumber,
getUnionID,
... ... @@ -16,6 +17,8 @@ import {
} from '../../vendors/zanui/index';
import router from './router/router'
import {wrapperName} from './helper'
import { formatImageUrl } from '../../utils/util'
import { jumpByUrl } from '../../libs/urlRoute';
const ACTIVITY = {
UNKNOWN: 0,
... ... @@ -68,6 +71,10 @@ Page(Object.assign({
hasUnionID: false,
uid: 0,
isLogin: false,
bannerSrc:null,
bannerUrl: null,
loading: false,
page: 1,
actionsheet: {
componentId: 'shareActionSheet',
... ... @@ -84,7 +91,7 @@ Page(Object.assign({
image_src: '../../images/share_wechat@2x.png',
},
{
name: '分享到朋友圈',
name: '生成海报分享',
className: 'action-class',
loading: false,
image_src: '../../images/share_wxpeng@2x.png'
... ... @@ -100,6 +107,7 @@ Page(Object.assign({
app = getApp();
this.service = new ZeroSellService();
this.commonService = new CommonService();
let data = {};
... ... @@ -120,6 +128,8 @@ Page(Object.assign({
this.setData(data);
new app.WeToast();
this._getDetailBanner()
},
/**
... ... @@ -145,6 +155,7 @@ Page(Object.assign({
})
this._getUser();
this._getGroupList();
if (this.data.shareUid && this.data.scene) {
this._init();
... ... @@ -188,7 +199,29 @@ Page(Object.assign({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
if (this.data.loading) return;
let page = this.data.page || 1;
page = page + 1;
this.setData({
page,
loading: true
})
this._loadGroupList(page);
},
goToGroupMiniApp(e) {
console.log(e);
console.log(e.detail);
wx.navigateToMiniProgram({
appId: 'wx207f18be42db9028',
path: `pages/group/detail?productSkn=${e.detail.product_skn}&activityId=${e.detail.activity_id}&page_param=${e.detail.activity_id}`,
success(res) {
},
fail(error) {
}
})
},
/**
... ... @@ -198,6 +231,57 @@ Page(Object.assign({
},
goLogin() {
const event = global.event;
event.emit('user-is-login', { logged: this.logged, loginSuccess: this.loginSuccess });
},
logged() {
},
loginSuccess() {
},
_getGroupList() {
this.commonService.getGroupList({
limit: 20,
page: 1
}).then(res => {
if (res.code === 200 && res.data) {
this.setData({
groupList: res.data.list
})
}
});
},
_loadGroupList(page) {
this.commonService.getGroupList({
limit: 20,
page
}).then(res => {
if (res.code === 200 && res.data) {
let groupList = this.data.groupList || [];
if (res.data.list.length > 0) {
this.setData({
groupList: groupList.concat(res.data.list),
loading: false,
})
} else {
this.setData({
loading: false
})
}
}
}).catch(error => {
this.setData({
loading: false
});
});
},
_init() {
let params = {
actPrizeId: this.data.actPrizeId
... ... @@ -225,15 +309,16 @@ Page(Object.assign({
let participantCount = r1.code === 200 ? r1.data.joinNum : 0;
if (product.status >= ACTIVITY.END) {
participantCount = product.limit;
}
// if (product.status >= ACTIVITY.END) {
// participantCount = product.limit;
// }
this.setData({
product: product,
recommends: r2.code === 200 ? r2.data : [],
avatars: (r3.code === 200 ? r3.data : []).map(i => {
i.user_name = wrapperName(i.user_name);
i.user_thumb = formatImageUrl(i.user_thumb, 200, 200);
return i;
}),
... ... @@ -358,6 +443,26 @@ Page(Object.assign({
showAuth: true
})
},
_jumpBanner() {
if (this.data.bannerUrl == null) {
return;
}
jumpByUrl(that.data.bannerUrl);
},
_getDetailBanner() {
let commonService = this.commonService;
commonService.getResourceCode('ccc32dbedf164a52b4efa34383878860')
.then(data => {
// console.log(data)
this.setData({
bannerSrc: formatImageUrl(data.src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio, 2),
bannerUrl: data.url
})
})
.catch(error => {
console.log(error)
})
},
_getUser() {
const userInfo = app.getUserInfo();
... ... @@ -397,8 +502,8 @@ Page(Object.assign({
},
onShareAppMessage(res) {
let params = {
TITLE: `点一下!和我一起开黑0元抢${this.data.product.name}`,
DESC: '我在有货精选发现一个不错的商品赶快来看看吧!'
TITLE: `【0元抽奖】点一下,免费拿走${this.data.product.name}`,
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看吧!'
};
if (res.from === 'menu') {
... ... @@ -406,7 +511,7 @@ Page(Object.assign({
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/page/subPackage/pages/zeroSell/detail?actPrizeId=${this.data.product.id}`,
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}`,
imageUrl: this.data.product.cover_img,
success: function() {},
fail: function() {}
... ... @@ -417,7 +522,7 @@ Page(Object.assign({
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/page/subPackage/pages/zeroSell/detail?actPrizeId=${this.data.product.id}&shareUid=${app.getUid()}`,
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}&shareUid=${app.getUid()}`,
imageUrl: this.data.product.cover_img,
success: function() {},
fail: function() {}
... ...
... ... @@ -13,6 +13,7 @@
"fellow-bar": "./components/fellow-bar",
"action-bar": "./components/action-bar",
"quickNavigation": "/pages/quickNavigation/quickNavigation",
"zero-alert": "./components/alert"
"zero-alert": "./components/alert",
"group-recommend": "./components/group-recommend"
}
}
\ No newline at end of file
... ...
... ... @@ -3,24 +3,17 @@
<view class="header">
<product-header product="{{product}}"></product-header>
<product-header product="{{product}}" avatars="{{avatars}}"></product-header>
<view style="height: 20rpx;"></view>
<view class="help">
<help></help>
</view>
<view class="avatars" wx:if="{{product.status === 2 && avatars.length > 0}}">
<avatars list="{{avatars}}"></avatars>
</view>
</view>
<block wx:if="{{false}}">
<counter count="{{participantCount}}" num="{{product.limit}}" status="{{product.status}}"></counter>
<prize-progress step="{{step}}"></prize-progress>
<desc list="{{product.content}}"></desc>
</block>
<view class="help">
<help></help>
</view>
<desc list="{{product.content}}" bind:tapUrl="_jumpBanner" bannerSrc="{{bannerSrc}}" bannerUrl="{{bannerUrl}}"></desc>
<view class="line"></view>
... ... @@ -35,6 +28,8 @@
<view class="fellow-bar" wx:if="{{product.status}}">
<fellow-bar></fellow-bar>
</view>
<group-recommend groupRecommendList="{{groupList}}" bindgoToGroupMiniApp="goToGroupMiniApp">
</group-recommend>
<view class="action-bar">
<action-bar wx:if="{{isLogin}}" status="{{actionStatus}}" num="{{myPrizeCount}}" share-uid="{{shareUid}}" act-prize-id="{{actPrizeId}}" bindgetcode="changeActionStatus" bindshare="share" bind:requireauth="requireAuth"
... ... @@ -47,7 +42,7 @@
</view>
<block wx:if="{{product.status === 2}}">
<button class="action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>0元参加抽奖</button>
<button class="action-item confirm" bindtap="goLogin">0元参加抽奖</button>
</block>
<block wx:else>
... ... @@ -56,7 +51,6 @@
</view>
</block>
</view>
<view class="foot"></view>
</block>
... ... @@ -70,7 +64,7 @@
<import src="../../vendors/toast/wetoast.wxml"/>
<template is="wetoast" data="{{...__wetoast__}}"/>
<quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation>
<!-- <quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation> -->
<zero-alert wx:if="{{showAuth}}" >
<view class="auth-content">OOPS 用户尚未授权登录</view>
... ...
... ... @@ -15,30 +15,27 @@
position: relative;
text-align: center;
overflow: hidden;
margin-top: 56rpx;
}
.help {
position: absolute;
top: 20rpx;
right: -90rpx;
}
.avatars {
position: absolute;
top: 20rpx;
left: 32rpx;
width: 100%;
text-align: center;
margin-bottom: 60rpx;
}
.fellow-bar {
position: fixed;
width: 100%;
bottom: 100rpx;
top: 0rpx;
z-index: 999;
}
.action-bar {
position: fixed;
width: 100%;
bottom: 0
bottom: 0;
z-index: 999;
}
.foot {
... ...
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,
getUnionID,
decodeUnionId,
openAuthorizeSettings
openAuthorizeSettings,
} from '../../utils/login';
import {formatImageUrl} from '../../utils/util'
import {
Toast
Toast, Actionsheet
} from '../../vendors/zanui/index';
import router from './router/router';
import { jumpByUrl } from '../../libs/urlRoute';
let app = getApp()
... ... @@ -27,21 +35,85 @@ Page(Object.assign({
}, {
page: 1,
products: []
},{
page: 1,
products: []
}],
tabIndex: 0,
my_zero_list: [{
page: 1,
data: []
}, {
page: 1,
data: []
}],
footText: '',
hasUnionID: false,
uid: 0,
isLogin: false
isLogin: false,
dialogSrc: null,
dialogUrl: null,
bannerSrc: null,
bannerUrl: null,
openType: 'getUserInfo',
actionsheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
isNewShareStyle: true,
unionUserImageUrl: 'http://img12.static.yhbimg.com/sns/2018/08/02/15/029b6acc4f8bc0620ecd7ec2133fcf900c.png',
actions: [{
name: '分享给好友',
className: 'action-class',
loading: false,
openType: 'share',
image_src: '../../images/share_wechat@2x.png',
},
{
name: '生成海报分享',
className: 'action-class',
loading: false,
image_src: '../../images/share_wxpeng@2x.png'
}]
},
},
onLoad() {
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: Number(options.tabIndex)
})
this._init(options.tabIndex);
} else {
this._init();
}
new app.WeToast();
console.log(options.reload);
if(options && (Number(options.reload) !== 0)) {
console.log('执行了');
this._getResouceCode()
}
this._getBottomBanner()
},
onShow() {
... ... @@ -54,6 +126,8 @@ Page(Object.assign({
})
this._getUser();
this.dialog = this.selectComponent("#dialog");
},
onPullDownRefresh() {
... ... @@ -68,26 +142,28 @@ Page(Object.assign({
this.setData({
footText: '内容加载中...'
});
let tabIndex = this.data.tabIndex;
let page = this.data.list[tabIndex].page;
let pageKey = `list[${tabIndex}].page`;
let productsKey = `list[${tabIndex}].products`
this._getPage(page).then((list) => {
let oldList = this.data.list[tabIndex].products;
if (list.length > 0) {
if (tabIndex !== 3) {
let page = this.data.list[tabIndex].page;
let pageKey = `list[${tabIndex}].page`;
let productsKey = `list[${tabIndex}].products`
this._getPage(page).then((list) => {
let oldList = this.data.list[tabIndex].products;
if (list.length > 0) {
this.setData({
[productsKey]: oldList.concat(list),
[pageKey]: page + 1,
})
}
this.setData({
[productsKey]: oldList.concat(list),
[pageKey]: page + 1,
})
}
this.setData({
footText: '暂无更多内容'
});
})
footText: '暂无更多内容'
});
})
} else {
this._loadReleaseData();
}
},
_getPage(page) {
... ... @@ -100,8 +176,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`
... ... @@ -109,7 +185,8 @@ Page(Object.assign({
this.setData({
footText: '内容加载中...'
})
this._getProceedingData();
this._getReleaseData(1);
return this._getPage(page).then(list => {
if (list.length === 0) {
this.setData({
... ... @@ -153,12 +230,127 @@ Page(Object.assign({
}
},
_getResouceCode() {
this.commonService.getResourceCode('194ffd46254d6ad20e6c538bea4d89d7')
.then(data => {
// console.log(data)
this.setData({
dialogSrc: formatImageUrl(data.src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio, 2),
dialogUrl: data.url
})
this.dialog.showDialog();
})
.catch(error => {
console.log(error)
})
},
_getBottomBanner() {
this.commonService.getResourceCode('5a2203f5656fbc9788bd8af70f2823d3')
.then(data => {
// console.log(data)
this.setData({
bannerSrc: formatImageUrl(data.src, app.globalData.systemInfo.screenWidth, 70, 2),
bannerUrl: data.url
})
})
.catch(error => {
console.log(error)
})
},
_getProceedingData() {
if (!this.data.isLogin) {
return;
}
let type = 0;
let page = 1;
let limit = 1000;
let key = `my_zero_list[${type}].data`
this.service.getMyList({type, page, limit}).then(res => {
let data = []
if (res && res.code === 200) {
data = res.data;
}
this.setData({
[key]: data
})
});
},
_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) {
data = res.data;
}
this.setData({
[key]: data,
[keyPage]: 1
})
if (data.length === 0) {
this.setData({
footText: '暂无更多内容'
})
}
});
},
_loadReleaseData(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) {
data = res.data;
}
this.setData({
[key]: oldData.concat(data),
[keyPage]: ++page
})
if (data.length === 0) {
this.setData({
footText: '暂无更多内容'
})
}
});
},
_jumpBanner() {
if (this.data.bannerUrl == null) {
return;
}
jumpByUrl(this.data.bannerUrl);
},
onTabChange({detail}) {
this.setData({
tabIndex: detail,
[`list[${detail}].page`]: 1
});
if (detail === 3 && !this.data.isLogin) {
return;
}
this._init();
},
... ... @@ -276,8 +468,125 @@ Page(Object.assign({
}
},
goMyList() {
router.go('myList');
}
async checkUnionId() {
let union_id = wx.getStorageSync('union_id');
let res = await getSettingPromise();
}, Toast));
\ No newline at end of file
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) {
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
});
},
share({ detail }) {
this.setData({
'actionsheet.show': true,
'shareProduct': detail
})
},
handleZanActionsheetCancel({ componentId }) {
this.setData({
'actionsheet.show': false
})
},
handleZanActionsheetClick({ componentId, index }) {
this.setData({
'actionsheet.show': false
});
let qrcode = this.service.getQrCode({
shareUid: app.getUid(),
actPrizeId: this.data.shareProduct.act_prize_id
});
if (index === 1) {
if (this.data.shareProduct.name) {
router.go('snapShare', {
product_name: this.data.shareProduct.name,
default_image: this.data.shareProduct.cover_img,
product_price: this.data.shareProduct.price,
product_qrCode: qrcode
});
}
};
},
onShareAppMessage(res) {
let params = {
TITLE: `【0元抽奖】点一下,免费拿走${this.data.shareProduct.name}`,
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看吧!'
};
if (res.from === 'menu') {
// 用户点击右上角分享
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}`,
imageUrl: this.data.shareProduct.cover_img,
success: function () {
},
fail: function () {
}
};
} else if (res.from === 'button') {
// 用户点击分享按钮
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}&shareUid=${app.getUid()}`,
imageUrl: this.data.shareProduct.cover_img,
success: function () {
},
fail: function () {
}
};
}
}
}, Toast, Actionsheet));
\ No newline at end of file
... ...
... ... @@ -7,6 +7,9 @@
"product-item": "./components/product-item",
"quickNavigation": "/pages/quickNavigation/quickNavigation",
"tabs": "./components/tabs",
"tabs-pane": "./components/tabs-pane"
"tabs-pane": "./components/tabs-pane",
"dialog": "../../component/dialog/dialog",
"prize-item": "./components/prize-item",
"login": "../../login/login/login"
}
}
\ No newline at end of file
... ...
... ... @@ -2,15 +2,16 @@
<view class="list-top-blank"></view>
<tabs-pane name="进行中">
<view>
<block wx:for="{{list[0].products}}" wx:key="{{item.id}}">
<image class="topgif" src="./images/yoluck.gif"/>
<view class="productList">
<block wx:for="{{list[0].products}}" wx:key="{{item.id}}">
<product-item product="{{item}}" class="product"></product-item>
</block>
</view>
</tabs-pane>
<tabs-pane name="即将开始">
<view>
<view class="productList">
<block wx:for="{{list[1].products}}" wx:key="{{item.id}}">
<product-item product="{{item}}" class="product"></product-item>
</block>
... ... @@ -18,31 +19,81 @@
</tabs-pane>
<tabs-pane name="已结束">
<view>
<view class="productList">
<block wx:for="{{list[2].products}}" wx:key="{{item.id}}">
<product-item product="{{item}}" class="product"></product-item>
</block>
</view>
</tabs-pane>
<view class="list-foot-blank">{{footText}}</view>
<tabs-pane name="已参加">
<block wx:if="{{isLogin}}">
<view class="title-view">
<view class="space-line"></view>
<text class="title">进行中</text>
</view>
<block wx:if="{{my_zero_list[0].data && my_zero_list[0].data.length === 0}}">
<view class="list-foot-blank">您还没有参与的抽奖,赶紧去参加吧
</view>
</block>
<block wx:else>
<block wx:for="{{my_zero_list[0].data}}">
<prize-item item="{{item}}" bindshare="share"></prize-item>
</block>
</block>
<view class="title-view">
<view class="space-line"></view>
<text class="title">已公布</text>
</view>
<block wx:if="{{my_zero_list[1].data && my_zero_list[1].data.length === 0}}">
<view class="list-foot-blank">暂无已公布活动,请继续参加活动
</view>
</block>
<block wx:else>
<block wx:for="{{my_zero_list[1].data}}">
<prize-item item="{{item}}" bindshare="share"></prize-item>
</block>
</block>
</block>
<block wx:else>
<login theme="light" openType="{{openType}}"></login>
</block>
<!-- <view class="productList">
<block wx:for="{{list[2].products}}" wx:key="{{item.id}}">
<product-item product="{{item}}" class="product"></product-item>
</block>
</view> -->
</tabs-pane>
<block wx:if="{{tabIndex !== 3}}">
<view class="list-foot-blank">{{footText}}</view>
</block>
</tabs>
<block wx:if="{{tabIndex !== 3}}">
<view class="bottom-banner" bindtap="_jumpBanner" wx:if="{{bannerSrc != null}}">
<image class="bottom-banner-img" src="{{bannerSrc}}"></image>
</view>
</block>
<view class="bottom-bar">
<!-- <view class="bottom-bar">
<block wx:if="{{isLogin}}">
<view bindtap="goMyList">我的抽奖码</view>
</block>
</block>
<block wx:else>
<button class="bottom-btn" plain="true" hover-class="none" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>我的抽奖码</button>
</block>
</view>
</view> -->
<import src="../../../../vendors/zanui/toast/index.wxml"/>
<template is="zan-toast" data="{{zanToast}}"/>
<import src="../../../../vendors/toast/wetoast.wxml"/>
<template is="wetoast" data="{{...__wetoast__}}"/>
<quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation>
\ No newline at end of file
<dialog
id='dialog'
src="{{dialogSrc}}"
url="{{dialogUrl}}"
></dialog>
<import src="../../vendors/zanui/actionsheet/index.wxml" />
<template is="zan-actionsheet" data="{{...actionsheet}}" />
<!-- <quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation> -->
\ No newline at end of file
... ...
@import '../../vendors/zanui/actionsheet/index.wxss';
.product {
display: block;
width: 100%;
text-align: center;
margin-bottom: 80rpx;
margin-bottom: 20rpx;
}
.productList {
/* margin-bottom: 322rpx; */
background: #F0F0F0;
}
.list-top-blank,
... ... @@ -17,6 +23,18 @@
color: #ccc;
}
.bottom-banner {
/* position: fixed; */
/* padding-bottom: 88rpx; */
height: 234rpx;
width: 100%;
}
.bottom-banner-img {
width: 100%;
height: 234rpx;
}
.bottom-bar {
position: fixed;
bottom: 0;
... ... @@ -40,4 +58,30 @@
.tabs-class {
border-bottom: 1rpx solid #E0E0E0;
}
.topgif {
width: 100%;
height: 200rpx;
}
.space-line {
background-color: #444444;
width: 8rpx;
height: 30rpx;
margin-right: 10rpx;
}
.title-view {
border-bottom:2rpx dashed #E0E0E0;
margin-left: 32rpx;
margin-top: 20rpx;
padding-bottom: 20rpx;
font-size: 32rpx;
color: #444444;
letter-spacing: -0.14px;
display: flex;
flex-direction: row;
align-items: center;
font-family: PingFangSC-Medium;
}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,7 @@ Page(Object.assign({
*/
data: {
shareProduct: {},
recommends: [],
list: [{
page: 1,
data: []
... ... @@ -39,7 +40,7 @@ Page(Object.assign({
image_src: '../../images/share_wechat@2x.png',
},
{
name: '分享到朋友圈',
name: '生成海报分享',
className: 'action-class',
loading: false,
image_src: '../../images/share_wxpeng@2x.png'
... ... @@ -52,7 +53,6 @@ Page(Object.assign({
*/
onLoad: function (options) {
this.service = new ZeroSellService()
app = getApp();
},
... ... @@ -72,6 +72,7 @@ Page(Object.assign({
});
this._init();
this._getRecommend();
},
/**
... ... @@ -153,9 +154,22 @@ Page(Object.assign({
return this.service.getMyList({type, page}).then(result => {
this.setData({
footText: '暂无更多内容'
});
if(result.code !== 200 || result.data.length === 0) {
if(type == 0) {
this.setData({
footText: '您还没有参与的抽奖,赶紧去参加吧'
});
} else {
this.setData({
footText: '暂无已公布活动,请继续参加活动'
});
}
} else {
this.setData({
footText: ''
});
}
if (result.code !== 200) {
return [];
... ... @@ -165,6 +179,22 @@ Page(Object.assign({
});
},
_getRecommend() {
this.service.getRecommend({
actPrizeId: 0
})
.then(response => {
if (response && response.code === 200 && response.data){
this.setData({
recommends: response.data,
})
}
})
.catch(error => {
console.log(error)
})
},
share({detail}){
this.setData({
'actionsheet.show': true,
... ... @@ -201,8 +231,8 @@ Page(Object.assign({
},
onShareAppMessage(res) {
let params = {
TITLE: `点一下!和我一起开黑0元抢${this.data.shareProduct.name}`,
DESC: '我在有货精选发现一个不错的商品赶快来看看吧!'
TITLE: `【0元抽奖】点一下,免费拿走${this.data.shareProduct.name}`,
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看吧!'
};
if (res.from === 'menu') {
... ... @@ -210,7 +240,7 @@ Page(Object.assign({
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/page/subPackage/pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}`,
path: `pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}`,
imageUrl: this.data.shareProduct.cover_img,
success: function() {
},
... ... @@ -223,7 +253,7 @@ Page(Object.assign({
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/page/subPackage/pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}&shareUid=${app.getUid()}`,
path: `/pages/zeroSell/detail?actPrizeId=${this.data.shareProduct.act_prize_id}&shareUid=${app.getUid()}`,
imageUrl: this.data.shareProduct.cover_img,
success: function() {
},
... ...
... ... @@ -8,6 +8,9 @@
"tabs-pane": "./components/tabs-pane",
"prize-item": "./components/prize-item",
"fellow-bar": "./components/fellow-bar",
"quickNavigation": "/pages/quickNavigation/quickNavigation"
"quickNavigation": "/pages/quickNavigation/quickNavigation",
"more": "./components/more",
"product-item": "./components/product-item",
"product-header": "./components/product-detail-header"
}
}
\ No newline at end of file
... ...
... ... @@ -20,10 +20,17 @@
</block>
</tabs-pane>
<view class="list-foot-blank">{{footText}}</view>
<view class="list-foot-blank" wx:if="{{footText && footText.length > 0}}">{{footText}}</view>
</tabs>
<view style="height: 20rpx;background-color:#F0F0F0"></view>
<more wx:if="{{recommends.length > 0}}">
<block wx:for="{{recommends}}">
<view class="product-item" >
<product-item product="{{item}}"></product-item>
</view>
</block>
</more>
<template is="zan-actionsheet" data="{{...actionsheet}}" />
<quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation>
\ No newline at end of file
<!-- <quickNavigation id="quickNavigation" isShowIndicator="{{false}}" isShowShopCart="{{false}}" marginBottom="{{190}}"></quickNavigation> -->
\ No newline at end of file
... ...