Authored by 黄敬囿

Merge branch 'feature/lottery-price' into 'master'

YOHOOD抽奖

YOHOOD抽奖需求

See merge request !19
import md5 from './vendors/md5';
import {GET} from './libs/request';
import {WeToast} from './vendors/toast/wetoast';
import { GET } from './libs/request';
import { WeToast } from './vendors/toast/wetoast';
import objectAssign from './vendors/object-assign';
import {API_HOST, MINI_APP_TYPE} from './libs/config';
import { API_HOST, MINI_APP_TYPE } from './libs/config';
import mta from './vendors/mta_analysis';
import {Event} from '/login/utils/index.js';
import {wxLogin} from '/login/utils/login/login';
import { Event } from '/login/utils/index.js';
import { wxLogin } from '/login/utils/login/login';
import appReport from './libs/appReport';
import iconfSwitch from './libs/switch';
import {isStringEmpty, getYHStorageSync} from './utils/util';
import { isStringEmpty, getYHStorageSync } from './utils/util';
import regeneratorRuntime from '/login/libs/regenerator-runtime/index';
import {
... ... @@ -17,13 +17,13 @@ import {
YB_ENTER_FOREGROUND,
YB_ENTER_BACKGROUND,
YB_AWAKE_MP,
YB_MY_LOGIN
YB_MY_LOGIN,
} from './libs/yas';
import router from './pages/zeroSell/router/router';
const event = new Event();
global.event = event;
App({
async onLaunch(options) {
let that = this;
... ... @@ -41,51 +41,51 @@ App({
that.getSimplePise();
this.checkNetworkType();
if (options && options.scene){
this.globalData.ch = options.scene
if (options && options.scene) {
this.globalData.ch = options.scene;
}
if (options && options.query && options.query.union_type){
this.updateUnionType(options.query.union_type)
if (options && options.query && options.query.union_type) {
this.updateUnionType(options.query.union_type);
}
wx.checkSession({
success: function () {
success: function() {
that.getWechatThirdSession();
that.getUserInfo();
that.getUnionID();
that.getUser_union_type();
},
fail: function () {
fail: function() {
wx.setStorage({
key: 'WXThird_session',
data: ''
data: '',
});
wx.setStorage({
key: 'userInfo',
data: {}
data: {},
});
wx.setStorage({
key: 'unionID',
data: ''
data: '',
});
wx.setStorage({
key: 'user_union_type',
data: ''
data: '',
});
}
},
});
this.getSessionkey();
let timestamp = new Date().getTime() + '';
this.globalData.sid = md5(timestamp);
if (options){
if (options) {
let channel = options.query.channel;
let channelType = options.query.type;
let params = { 'CHANNEL': channel, 'TYPE': channelType };
yasReport(YB_LAUNCH_APP, params, this);
let params = { CHANNEL: channel, TYPE: channelType };
yasReport(YB_LAUNCH_APP, params, this);
}
this.mtainit(options);
await wxLogin();
... ... @@ -101,74 +101,86 @@ App({
logged(userInfo);
}
} else {
event.once('user-login-success', (userInfo) => {
yasReport(YB_MY_LOGIN, {LOGIN_TYPE: 4});
event.once('user-login-success', userInfo => {
yasReport(YB_MY_LOGIN, { LOGIN_TYPE: 4 });
if (loginSuccess) {
loginSuccess(userInfo);
}
});
wx.navigateTo({
url: '/login/login-page/login-page',
})
});
}
});
},
//当应用程序进入前台显示状态时触发
//当应用程序进入前台显示状态时触发
onShow(options) {
iconfSwitch(this).then(data => {
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch');
this.globalData.hasSetSwitch = true;
iconfSwitch(this).then(
data => {
console.log(
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch',
);
this.globalData.hasSetSwitch = true;
if (data['javaapi'] && '0' === data['javaapi']) {
this.globalData.switch_javaApiEnable = false;
}
}, () => {
this.globalData.hasSetSwitch = true;
});
let that = this
},
() => {
this.globalData.hasSetSwitch = true;
},
);
let that = this;
let params = {};
yasReport(YB_ENTER_FOREGROUND, params, that)
if (!that.globalData.hasReportAwakeAction){
let pathParam = ""
if(options && options.query) {
yasReport(YB_ENTER_FOREGROUND, params, that);
if (!that.globalData.hasReportAwakeAction) {
let pathParam = '';
if (options && options.query) {
for (var Key in options.query) {
if (pathParam.length == 0) {
pathParam = Key + '=' + options.query[Key] + '';
} else {
pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
pathParam =
pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
}
}
}
let path = '';
if (options && options.path) {
path = options.path
path = options.path;
}
if(pathParam!==""){
path = path + "?" + pathParam
if (pathParam !== '') {
path = path + '?' + pathParam;
}
params = {
PAGE_PATH: path
PAGE_PATH: path,
};
yasReport(YB_AWAKE_MP, params, this);
that.globalData.hasReportAwakeAction = true;
}
if (options && options.scene){
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {
'activeWay': options.scene + ''
}
}, this);
}else{
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {}
}, this);
if (options && options.scene) {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {
activeWay: options.scene + '',
},
},
this,
);
} else {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'RESUME',
param: {},
},
this,
);
}
let scene = options ? options.scene : '';
... ... @@ -176,19 +188,22 @@ App({
},
//当应用程序进入后台状态时触发
onHide () {
onHide() {
let params = {};
yasReport(YB_ENTER_BACKGROUND, params);
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'STOP',
param: {}
}, this);
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'STOP',
param: {},
},
this,
);
},
getUserInfo: function () {
var value = getYHStorageSync('userInfo','app')
getUserInfo: function() {
var value = getYHStorageSync('userInfo', 'app');
if (value) {
this.globalData.userInfo = value;
}
... ... @@ -199,126 +214,128 @@ App({
return this.globalData.userInfo.mobile;
},
getUser_union_type: function () {
getUser_union_type: function() {
this.getUnionTypeWithUid(this.getUid());
},
/*
*union_type表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效48小时
*/
getUnion_type: function () {
*union_type表示渠道号,在推广阶段通过商品详情页等传入。
* 接收到该参数时,赋值给全局变量时,持久化到本地。
* 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
* 时效48小时
*/
getUnion_type: function() {
try {
var value = this.checkUnion_type(this.globalData.union_type, this.globalData.union_type_time);
var value = this.checkUnion_type(
this.globalData.union_type,
this.globalData.union_type_time,
);
if (!value) {
let union_type = getYHStorageSync('union_type','app');
let union_type_time = getYHStorageSync('union_type_time','app');
value = this.checkUnion_type(union_type, union_type_time);
let union_type = getYHStorageSync('union_type', 'app');
let union_type_time = getYHStorageSync('union_type_time', 'app');
value = this.checkUnion_type(union_type, union_type_time);
}
return value
return value;
} catch (e) {
// console.log(e)
}
},
checkUnion_type: function (union_type, union_type_time) {
if (!union_type)return '';
checkUnion_type: function(union_type, union_type_time) {
if (!union_type) return '';
let time_old = union_type_time;
let time_new = new Date().getTime() + '';
var dayDiff = parseInt ((parseInt(time_new) - parseInt(time_old)) / 1000 );
var dayDiff = parseInt((parseInt(time_new) - parseInt(time_old)) / 1000);
if (dayDiff > 2 * 24 * 3600) {
return '';
}
return union_type;
},
getUnionID: function () {
var value = getYHStorageSync('unionID','app')
getUnionID: function() {
var value = getYHStorageSync('unionID', 'app');
if (value) {
this.globalData.WXUnion_ID = value;
}
},
getWechatThirdSession: function () {
getWechatThirdSession: function() {
try {
var that = this
var value = this.globalData.WXThird_session
var that = this;
var value = this.globalData.WXThird_session;
if (!isStringEmpty(value)) {
that.globalData.WXThird_session = value;
}else{
value = getYHStorageSync('WXThird_session','app')
} else {
value = getYHStorageSync('WXThird_session', 'app');
}
return value
return value;
} catch (e) {
// console.log(e)
}
},
setUserInfo: function (cb) {
setUserInfo: function(cb) {
this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
key: 'userInfo',
data: this.globalData.userInfo,
});
if (this.globalData.userInfo.uid) {
this.getUnionTypeWithUid(this.globalData.userInfo.uid);
}
},
setSessionkey: function (sessionkey) {
setSessionkey: function(sessionkey) {
this.globalData.sessionkey = sessionkey;
wx.setStorage({
key: "sessionkey",
data: this.globalData.sessionkey
})
key: 'sessionkey',
data: this.globalData.sessionkey,
});
},
setWechatThirdSession: function (session) {
setWechatThirdSession: function(session) {
this.globalData.WXThird_session = session;
wx.setStorage({
key: "WXThird_session",
data: this.globalData.WXThird_session
})
key: 'WXThird_session',
data: this.globalData.WXThird_session,
});
},
setWXUnionID: function (unionID) {
setWXUnionID: function(unionID) {
this.globalData.WXUnion_ID = unionID;
wx.setStorage({
key: "unionID",
data: unionID
})
key: 'unionID',
data: unionID,
});
},
setOpenID:function(openID){
if(openID=='') return
setOpenID: function(openID) {
if (openID == '') return;
this.globalData.openID = openID;
wx.setStorage({
key: "openID",
data: openID
})
},
getOpenID: function () {
let openid = ''
if (!isStringEmpty(this.globalData.openID)){
openid = this.globalData.openID
}else{
openid = getYHStorageSync('open_id','app')
this.globalData.openID = openid
key: 'openID',
data: openID,
});
},
getOpenID: function() {
let openid = '';
if (!isStringEmpty(this.globalData.openID)) {
openid = this.globalData.openID;
} else {
openid = getYHStorageSync('open_id', 'app');
this.globalData.openID = openid;
}
return openid
return openid;
},
updateUid: function (uid) {
updateUid: function(uid) {
this.getUserInfo();
this.globalData.userInfo.uid = uid;
wx.setStorage({
key: "userInfo",
data: this.globalData.userInfo
})
key: 'userInfo',
data: this.globalData.userInfo,
});
this.getUnionTypeWithUid(uid);
},
... ... @@ -330,88 +347,87 @@ App({
systemInfo: null,
WXThird_session: '',
WXUnion_ID: '',
openID:'',
openID: '',
p2SecretKey: '',
sessionkey: '',
sid: '',
udid:'',
cid:'1',
mobileRegisterState:'',
udid: '',
cid: '1',
mobileRegisterState: '',
hasReportAwakeAction: false,
defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
miniapp_type: MINI_APP_TYPE,
union_type:'',//渠道号,大数据上传用
union_type: '', //渠道号,大数据上传用
union_type_time: '',
ch:'',
networkType:'0',
deviceInfo:{},
ch: '',
networkType: '0',
deviceInfo: {},
currentScene: 1001,
user_union_type: '',//用户相关unionType 要与union_type区分开
user_union_type_imageUrl: '',//联盟图片
user_nounion_type_imageUrl:'',//非联盟用户分享banner图片
user_union_type: '', //用户相关unionType 要与union_type区分开
user_union_type_imageUrl: '', //联盟图片
user_nounion_type_imageUrl: '', //非联盟用户分享banner图片
shareId: '',
shareInfo: {},
},
isLogin: function () {
isLogin: function() {
let uid = this.getUid();
return uid > 0;
},
getUid: function () {
getUid: function() {
let uid = this.globalData.userInfo.uid;
if(!uid || uid === 0){
if (!uid || uid === 0) {
let userInfo = this.getUserInfo();
uid = userInfo.uid || 0
uid = userInfo.uid || 0;
}
return uid;
},
getMiniappType:function(){
return MINI_APP_TYPE
getMiniappType: function() {
return MINI_APP_TYPE;
},
//获取加签的秘钥
getSimplePise: function () {
let that = this
let data = {
"udid": that.globalData.udid,
"method": 'resources.simple.pice'}
let method = "GET"
getSimplePise: function() {
let that = this;
let data = {
udid: that.globalData.udid,
method: 'resources.simple.pice',
};
let method = 'GET';
let header = {
'Content-Type': 'application/x-www-form-urlencoded'
}
'Content-Type': 'application/x-www-form-urlencoded',
};
wx.request({
url:API_HOST,
url: API_HOST,
data,
method,
header: header,
success: function (res) {
success: function(res) {
// console.log("res:", res)
if (res && res.data && res.data.data && res.data.data.sk){
if (res && res.data && res.data.data && res.data.data.sk) {
that.globalData.p2SecretKey = res.data.data.sk;
wx.setStorage({
key: "p2SecretKey",
data: res.data.data.sk
key: 'p2SecretKey',
data: res.data.data.sk,
});
}
},
fail: function (err) {
}
fail: function(err) {},
});
},
/*
获取用户相关union_type
*/
getUnionTypeWithUid: function (uid) {
getUnionTypeWithUid: function(uid) {
if (!uid) return;
let param = {
method: 'app.union.shareOrder.queryUnionTypeByUid',
uid,
}
};
let that = this;
GET(API_HOST, param)
.then(data => {
... ... @@ -422,14 +438,13 @@ App({
that.globalData.user_nounion_type_imageUrl = data.data.applyImageUrl;
}
})
.catch(error => {
});
.catch(error => {});
},
getShareInfo: function () {
getShareInfo: function() {
let param = {
share_id: this.globalData.shareId,
}
};
let that = this;
GET(API_HOST + '/operations/api/v5/webshare/getShare', param)
.then(data => {
... ... @@ -437,35 +452,31 @@ App({
that.globalData.shareInfo = data.data;
}
})
.catch(error => {
});
.catch(error => {});
},
fastloginSwitch: function () {
let that = this
fastloginSwitch: function() {
let that = this;
let param = {
method: 'app.passport.fastloginSwitch',
};
GET(API_HOST, param)
.then(json => {
})
.catch(error => {
});
.then(json => {})
.catch(error => {});
},
checkUDID:function(){
let that = this
checkUDID: function() {
let that = this;
try {
var value = getYHStorageSync('udid','app')
var value = getYHStorageSync('udid', 'app');
if (value) {
that.globalData.udid = value;
}else{
} else {
let udidValue = md5(that.getUUID());
that.globalData.udid = udidValue;
try {
wx.setStorageSync('udid', udidValue)
} catch (e) {
}
wx.setStorageSync('udid', udidValue);
} catch (e) {}
}
//获取签名秘钥
} catch (e) {
... ... @@ -474,15 +485,15 @@ App({
}
},
checkNetworkType:function(){
checkNetworkType: function() {
let that = this;
let net = '';
wx.getNetworkType({
success: function (res) {
success: function(res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
var networkType = res.networkType;
if (networkType === 'wifi') {
net = '1';
} else if (networkType === '2g') {
... ... @@ -495,30 +506,43 @@ App({
net = '0';
}
},
complete:function(res){
appReport({
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'START',
param: {}
}, that);
}
})
complete: function(res) {
appReport(
{
reportType: 'start',
pt: 'LIFECYCLE',
pn: 'START',
param: {},
},
that,
);
},
});
that.globalData.networkType = net;
},
getUUID: function () {
let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8);
getUUID: function() {
let value =
'' +
Date.now() +
'-' +
Math.floor(1e7 * Math.random()) +
'-' +
Math.random()
.toString(16)
.replace('.', '') +
'-' +
String(Math.random() * 31242)
.replace('.', '')
.slice(0, 8);
return value;
},
loginCallBack: function (response) {
},
loginCallBack: function(response) {},
getSessionkey: function () {
getSessionkey: function() {
if (this.isLogin) {
var value = getYHStorageSync('sessionkey','app');
var value = getYHStorageSync('sessionkey', 'app');
if (value) {
this.globalData.sessionkey = value;
}
... ... @@ -527,18 +551,18 @@ App({
},
//更新渠道号同时更新时间戳,48小时失效
updateUnionType: function (union_type) {
if (union_type){
updateUnionType: function(union_type) {
if (union_type) {
let timeS = new Date().getTime() + '';
this.globalData.union_type = union_type;
this.globalData.union_type_time = timeS;
wx.setStorage({
key: "union_type_time",
key: 'union_type_time',
data: timeS,
});
wx.setStorage({
key: "union_type",
data: union_type
key: 'union_type',
data: union_type,
});
}
},
... ... @@ -547,11 +571,9 @@ App({
},
mtainit() {
mta.App.init({
"appID": "500570715",
"eventID": "500570797",
appID: '500570715',
eventID: '500570797',
});
},
WeToast
WeToast,
});
... ...
... ... @@ -7,6 +7,7 @@
"pages/zeroSell/error",
"pages/bindPhoneNumber/bindPhoneNumber",
"pages/choosecountry/choosecountry",
"pages/zeroSell/originalPriceSell",
"login/login-page/login-page"
],
"window": {
... ... @@ -22,4 +23,4 @@
"wxf9bac5064053057a"
],
"sitemapLocation": "sitemap40.json"
}
\ No newline at end of file
}
... ...
import { getUserInfo, getPhoneNumber, checkUnionIdIsBind } from '../utils/login/login.js';
import {
getUserInfo,
getPhoneNumber,
checkUnionIdIsBind,
} from '../utils/login/login.js';
Component({
/**
* 组件的属性列表
... ... @@ -6,41 +10,42 @@ Component({
properties: {
theme: {
type: String,
value: 'light'
value: 'light',
},
isShow: Boolean,
openType: {
type: String,
value: "getUserInfo",
observer: function (newValue, oldValue) {
if (newValue === "getPhoneNumber") {
value: 'getUserInfo',
observer: function(newValue, oldValue) {
if (newValue === 'getPhoneNumber') {
this.setData({
loginBtnTitle: "绑定手机号"
})
loginBtnTitle: '绑定手机号',
});
} else if (newValue === 'getUserInfo') {
this.setData({
loginBtnTitle: "微信授权登录"
})
loginBtnTitle: '微信授权登录',
});
} else {
this.setData({
loginBtnTitle: "微信登录",
checkUnionIdIsBind: 'checkUnionIdIsBind'
})
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: ''
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: '',
},
/**
... ... @@ -48,7 +53,7 @@ Component({
*/
methods: {
getUserInfo,
getPhoneNumber,
checkUnionIdIsBind
}
})
getPhoneNumber,
checkUnionIdIsBind,
},
});
... ...
// page/subPackage/pages/zeroSell/components/help.js
import router from '../router/router'
import router from '../router/router';
Component({
/**
* 组件的属性列表
*/
properties: {
url: {
type: String,
value: 'https://activity.yoho.cn/feature/2765.html',
},
text: {
type: String,
value: '查看活动说明',
},
title: {
type: String,
value: '活动说明',
obsever: function(title) {
this.setData({
title,
});
},
},
},
/**
* 组件的初始数据
*/
data: {
url: 'https://activity.yoho.cn/feature/2765.html',
title: '活动说明'
title: '活动说明',
},
/**
... ... @@ -24,9 +39,9 @@ Component({
methods: {
_onTap() {
router.go('webview', {
url: this.data.url,
title: this.data.title
})
}
}
})
url: this.properties.url,
title: this.data.title,
});
},
},
});
... ...
<view class="help" bindtap="_onTap">
<image class="helpe-img" src="../images/que_ic@2x.png"></image>
<text>查看活动说明 </text>
<view class="help" bindtap="_onTap">
<image class="helpe-img" src="../images/que_ic@2x.png"></image>
<text>{{text}}</text>
</view>
\ No newline at end of file
... ...
// page/subPackage/pages/zeroSell/components/action-bar.js
import ZeroSellService from '../../service/zero-sell';
import CommonService from '../../service/common';
import { fomartCountdownTime } from '../../../../utils/util';
const event = global.event;
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
// UNKNOWN: 0,
// READY: 1, // 未开始
// START: 2, // 参加
// ALEADY: 3, // 已参加活动
// WAIT: 4, // 等待抽奖中
// LUCK: 5, // 抽奖结束
// END: 6, // 活动结束
// PEOPLE_LIMIT_WAIT: 7 // 人数达到活动限制、已满员、人数不足统一为待开奖状态
status: {
type: Number,
value: 1,
},
num: {
type: Number,
value: 0,
},
shareUid: {
type: Number,
value: 0,
},
actId: {
type: Number,
value: 0,
},
copyText: {
type: String,
value: '',
},
text: {
type: String,
value: '',
},
type: {
type: Number,
value: 0,
},
// time in seconds
formatTimeList: {
type: Array,
value: [],
observer(value) {
this.setData({
remainingTime: value.join(':'),
});
},
},
isLogin: {
type: Boolean,
value: false,
},
activityStatus: {
type: Number,
status: 1,
},
},
/**
* 组件的初始数据
*/
data: {
show: false,
code: '',
error: false,
fellow: false,
remainingTime: '',
},
ready() {
this.service = new ZeroSellService();
this.commonService = new CommonService();
},
/**
* 组件的方法列表
*/
methods: {
fetchCode() {
wx.showLoading({
mask: true,
});
event.emit('user-is-login', {
logged: this.getCode.bind(this),
loginSuccess: function() {},
});
},
getCode(userInfo) {
this.service
.fetchCode({
shareUid: this.properties.shareUid,
uid: app.getUid(),
actPrizeId: this.properties.actId,
userThumb: userInfo.avatarUrl,
userName: userInfo.nickName,
})
.then(result => {
wx.hideLoading();
if (result.code === 200) {
this.setData({
show: true,
code: result.data.prizeCode,
});
this.triggerEvent('gaincodesuccess', this.properties.actId);
} else {
this.setData({
error: true,
errorText: result.message,
});
}
});
},
goShare() {
this.triggerEvent('share');
this.setData({
show: false,
error: false,
fellow: false,
});
},
hadJoinToShare() {
this.goShare();
this.triggerEvent('changeStatus');
},
goMyList() {
wx.reLaunch({
url: '/pages/zeroSell/index?tabIndex=3&reload=0',
});
},
goList() {
wx.navigateTo({
url: '/pages/zeroSell/index?reload=0',
});
},
cancelFellow() {
this.setData({
fellow: false,
});
},
cancelAlert() {
this.setData({
show: false,
error: false,
});
this.triggerEvent('changeStatus');
},
openFellowAlert() {
this.setData({
fellow: true,
});
},
hiddenAlert(e) {
this.setData({
show: false,
error: false,
fellow: false,
});
this.triggerEvent('changeStatus');
},
submitFormId(e) {
return this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getOpenID() || '',
miniapp_type: app.getMiniappType(),
});
},
goLogin() {
const event = global.event;
event.emit('user-is-login', {
logged: this.logged,
loginSuccess: this.loginSuccess,
});
},
logged() {},
loginSuccess() {},
},
});
... ...
{
"component": true,
"usingComponents": {
"zero-alert": "../alert",
"new-lucky-alert": "../new-lucky-alert",
"fellow-alert": "../fellow-alert"
}
}
... ...
<!-- page/subPackage/pages/zeroSell/components/action-bar.wxml -->
<view class="action-bar" wx:if="{{isLogin}}">
<block wx:if="{{status === 1}}">
<view class="action-item over">
<text>距开始</text>
<text class="remaining-time">{{remainingTime}}</text>
</view>
</block>
<block wx:elif="{{status === 2}}">
<form bindsubmit='submitFormId' report-submit='true' class="action-item">
<button class="action-item confirm" style="border-radius: unset;" form-type="submit" bindtap="fetchCode">
参加抽奖
</button>
</form>
</block>
<block wx:elif="{{status === 3}}">
<button class="action-item ok" bindtap="goShare" open-type="share">邀请好友参加,增加中奖率</button>
</block>
<block wx:elif="{{status >= 3}}">
<view class="action-item over">已结束</view>
</block>
</view>
<view class="action-bar2" wx:else>
<block wx:if="{{activityStatus === 1}}">
<button class="action-item over" bindtap="goLogin">
<text>距开始</text>
<text class="remaining-time">{{remainingTime}}</text>
</button>
</block>
<block wx:if="{{activityStatus === 2}}">
<button class="action-item confirm" bindtap="goLogin">参加抽奖</button>
</block>
<block wx:elif="{{activityStatus >= 3}}">
<button class="action-item over" bindtap="goLogin">已结束</button>
</block>
</view>
<new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert">
<view class="code-alert">
<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 open-type="share" class="share" form-type="submit" bindtap="hadJoinToShare">
分享一下,中奖概率立马double
</button>
</form>
<view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
</view>
</new-lucky-alert>
<zero-alert wx:if="{{error}}">
<view class="error-alert">
<view class="error-title">OOPS</view>
<view class="error-content">{{errorText}}</view>
</view>
<view class="foot">
<view class="foot-item" bindtap="cancelAlert">确定</view>
</view>
</zero-alert>
<fellow-alert show="{{fellow}}" bindok="cancelFellow" copyText="{{copyText}}" type="{{type}}" text="{{text}}"></fellow-alert>
\ No newline at end of file
... ...
@import '../action-bar.wxss';
/* page/subPackage/pages/zeroSell/components/action-bar.wxss */
.action-bar {
display: flex;
width: 100%;
height: 100rpx;
}
.action-item {
flex: 1;
color: white;
text-align: center;
font-size: 32rpx;
height: 100rpx;
line-height: 100rpx;
background-color: white;
border-radius: unset
}
.action-list {
flex: 0;
position: relative;
flex-basis: 150rpx;
}
.action-image {
width: 46rpx;
height: 42rpx;
position: absolute;
top: 50%;
left: 50%;
/* transform: translateY(-50%); */
transform: translate(-50%, -50%);
}
.over {
background-color: #B0B0B0;
}
.code-alert {
text-align: center;
color: black;
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: #444444;
}
.code {
min-width: 192rpx;
height: 50rpx;
font-size: 28rpx;
font-weight: bolder;
line-height: 50rpx;
text-align: center;
border: 1rpx solid black;
margin-left: 20rpx;
}
.share {
font-size: 28rpx;
color: #FFFFFF;
background: #64ad88;
border-radius: 28px;
width: 460rpx;
height: 80rpx;
line-height: 80rpx;
margin-top: 50rpx;
vertical-align: center;
}
.share-desc {
font-size: 20rpx;
color: #B0B0B0;
font-family: PingFangSC-Medium;
margin-top: 10rpx;
}
.foot {
display: flex;
position: absolute;
box-sizing: border-box;
bottom: 0;
width: 100%;
height: 90rpx;
line-height: 90rpx;
font-size: 28rpx;
font-weight: bolder;
text-align: center;
border-top: 1rpx solid #E0E0E0;
}
.foot-item {
flex: 1;
text-align: center;
font-size: 32rpx;
height: 90rpx;
line-height: 90rpx;
color: black;
border: none !important;
border-radius: unset;
}
.foot-item + .foot-item {
border-left: 1rpx solid #E0E0E0 !important;
}
.info {
color: #D0021B !important;
}
.error-alert {
text-align: center;
color: black;
margin-top: 40rpx;
}
.error-title {
font-size: 40rpx;
color: #D0021B ;
margin-bottom: 30rpx;
}
.error-content {
font-size: 30rpx;
padding: 0 100rpx;
}
.ok,
.confirm {
background-color: #132f48;
}
.remaining-time {
margin-left: 20rpx;
width: 140rpx;
display: inline-block;
}
... ...
// page/subPackage/pages/zeroSell/components/product-detail-header.js
import { formatTimeByDefined } from '../../../../utils/util';
Component({
properties: {
product: {
type: Object,
observer(product) {
const { end_time: endTime, start_time: startTime, status } = product;
let nextActivityTime = '';
if (status === 1 || status >=3 ) {
nextActivityTime = `${formatTimeByDefined(
startTime,
'Y.M.D h:m',
)}-${formatTimeByDefined(endTime, 'h:m')}`;
}
this.setData({
nextActivityTime,
});
},
},
avatars: {
type: Array,
},
shareFlag: {
type: Boolean,
value: false,
observer(value) {
this.setData({ show: value });
},
},
formatTimeList: {
type: Array,
value: [],
},
},
data: {
show: false,
isEnd: false,
nextActivityTime: '',
},
ready() {},
methods: {},
});
... ...
{
"component": true,
"usingComponents": {
"avatars": "../avatar-swiper"
}
}
\ No newline at end of file
... ...
<wxs src="../helper.wxs" module="helper" />
<view class="product_countdown" wx:if="{{product.status === 2 && formatTimeList.length > 0}}" hidden="{{ show }}">
<view class="countdown_label">
<text class="countdown_labeltext">抽奖</text>
<text class="countdown_labeltext">倒计时</text>
</view>
<view wx:for="{{formatTimeList}}" 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 !== 2}}">:</view>
</view>
</view>
<view class="next-preview" wx:if="{{product.status === 1 || product.status >= 3}}" hidden="{{ show }}">
<text class="next-tip">{{product.status === 1 ? '下一场活动时间' : '活动时间'}}</text>
<text class="next-time">{{nextActivityTime}}</text>
</view>
<view class="avatarcontainer">
<view class="avatars" wx:if="{{avatars.length > 0 && !show}}">
<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_lucky_bg">
<view class="product_lucky">
<text>原价购</text>
<text class="price-info">{{product.lottery_price}}</text>
</view>
<view class="product_price">
<text>市场参考价</text>
<text class="price-info line">{{product.price}}</text>
</view>
</view>
\ No newline at end of file
... ...
.product_image {
width: 690rpx;
height: 434rpx;
}
.product_name {
display: inline-block;
margin-top: 10rpx;
letter-spacing: -0.34px;
width: 686rpx;
font-size: 30rpx;
font-weight: bold;
word-break: break-all;
color: #222222;
}
.product_lucky_bg {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-evenly;
margin: 30rpx 20rpx 56rpx 20rpx;
font-size: 22rpx;
}
.product_price,
.product_lucky {
display: flex;
flex-direction: column;
justify-content: center;
}
.product_price {
color: #999999;
}
.price-info {
font-weight: bold;
font-size: 36rpx;
}
.line {
text-decoration: line-through;
}
.product_margin {
margin-bottom: 40rpx;
}
.product_countdown {
display: flex;
height: 92rpx;
margin-top: 44rpx;
margin-bottom: 36rpx;
justify-content: center;
align-items: center;
}
.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;
position: relative;
}
.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;
}
.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;
}
.next-preview {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20rpx;
margin-top: 28rpx;
}
.next-tip {
background-color: #132f48;
color: white;
border-radius: 20rpx;
height: 30rpx;
padding: 5rpx 20rpx;
font-size: 24rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
}
.next-time {
font-size: 36rpx;
}
... ...
import ZeroSellService from './service/zero-sell';
import CommonService from './service/common';
import {
decodePhoneNumber,
getUnionID,
decodeUnionId,
openAuthorizeSettings,
} from '../../utils/login';
import { getQRCodeSource } from '../../libs/miniQRCodeRoute';
import { Toast } from '../../vendors/zanui/index';
import router from './router/router';
import { formatImageUrl, fomartCountdownTime } from '../../utils/util';
import { jumpByUrl } from '../../libs/urlRoute';
import { yasReport, YB_PAGE_OPEN_L, YB_LUCK_DT_JOIN_C } from '../../libs/yas';
const ACTIVITY = {
UNKNOWN: 0,
READY: 1, // 活动未开始
START: 2, // 活动开始
END: 3, // 活动结束
LUCK: 4, // 活动已开奖、抽奖结束
END_LESS_PEOPLE: 5, // 人数不足
};
const ACTION_BAR_STATUS = {
UNKNOWN: 0,
READY: 1, // 未开始
START: 2, // 参加
ALEADY: 3, // 已参加活动
WAIT: 4, // 等待抽奖中
LUCK: 5, // 抽奖结束
END: 6, // 活动结束
PEOPLE_LIMIT_WAIT: 7, // 人数达到活动限制、已满员、人数不足统一为待开奖状态
};
let app = getApp();
let timeoutId = null; // 定时器ID
/**
* YOHOOD 原价购 抽奖
*/
Page(
Object.assign(
{
/**
* 页面的初始数据
*/
data: {
isGoApp: false,
tabIdx: '',
showAuth: false,
actPrizeId: '',
shareUid: 0,
scene: '',
appParameter: '',
myPrizeCount: 0,
product: {},
avatars: [],
recommends: [],
actionStatus: ACTION_BAR_STATUS.UNKNOWN,
snapData: {},
hasUnionID: false,
uid: 0,
isLogin: false,
bannerSrc: null,
bannerUrl: null,
loading: false,
page: 1,
codeList: [],
animation: null,
shareFlag: false,
notice: {},
lottery: {},
formatTimeList: [],
isCountdownEnd: false,
activityId: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
app = getApp();
wx.hideShareMenu();
this.service = new ZeroSellService();
this.commonService = new CommonService();
let data = {};
let currentScene = app.globalData.currentScene;
let isGoApp =
currentScene == 1036 || currentScene == 1069 ? true : false;
data.isGoApp = isGoApp;
if (options.shareUid) {
data.shareUid = options.shareUid;
}
if (options.tabIdx) {
data.tabIdx = options.tabIdx;
}
if (options.actPrizeId) {
data.actPrizeId = options.actPrizeId;
}
let appParameter = `https://m.yohobuy.com?openby:yohobuy={"action":"go.h5","params":{"param":{},"url":"https://m.yohobuy.com/activity/yoluck/${
data.actPrizeId
}.html"}}`;
data.appParameter = appParameter;
if (options.scene && options.scene.length === 32) {
data.scene = options.scene;
}
this.setData(data);
new app.WeToast();
this._getDetailBanner();
yasReport(YB_PAGE_OPEN_L);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
wx.showLoading({
mask: true,
});
setTimeout(() => {
app = app || getApp();
let uid = app.getUid();
this.setData({
hasUnionID:
app.globalData.WXUnion_ID !== null &&
app.globalData.WXUnion_ID !== '' &&
app.globalData.WXUnion_ID !== undefined
? true
: false,
isLogin: app.isLogin(),
uid,
});
this._getUser();
// this._getGroupList();
if (this.data.shareUid && this.data.scene) {
this._init();
} else if (this.data.scene && !this.data.shareUid) {
this._fetchParams(this.data.scene).then(() => {
return this._init();
});
} else {
this._init();
}
}, 1100);
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
wx.hideLoading();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
wx.showLoading({
mask: true,
});
const {product = {}} = this.data;
if(product.status === ACTIVITY.END || product.status === ACTIVITY.LUCK) {
wx.navigateTo({url: '/pages/zeroSell/originalPriceSell'})
}else {
this._init({isPulldown: true}).then(() => {
wx.stopPullDownRefresh();
});
}
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
if (this.data.loading) return;
let page = this.data.page || 1;
page = page + 1;
this.setData({
page,
loading: true,
});
// this._loadGroupList(page);
},
_getMineCode(actPrizeId) {
if (this.data.uid) {
this.service
.fetchMyPrizeList({
uid: this.data.uid,
actPrizeId,
})
.then(res => {
let len = res.data.length;
if (len) {
res.data.map(value => {
value.user_thumb = formatImageUrl(value.user_thumb, 60, 60);
});
this.setData({
codeList: res.data,
});
wx.getSystemInfo({
success: sys => {
let animation = wx.createAnimation({
duration: 400 * len,
});
setTimeout(
function() {
wx.createSelectorQuery()
.select('.code-list-item-container')
.boundingClientRect()
.exec(r => {
if (r && r[0] && r[0].height) {
animation
.height(
r[0].height - (65 * sys.screenWidth) / 375,
)
.step();
this.setData({
animation: animation.export(),
});
}
});
}.bind(this),
800,
);
},
});
}
});
}
},
_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(options = {}) {
const { isPulldown, id } = options
let params = {
actPrizeId: isPulldown ? '' : this.data.actPrizeId || id,
};
return this.service
.getYohoodDetail(params)
.then(r1 => {
wx.hideLoading();
if (r1.code === 200 && r1.data) {
let product = r1.data;
this._getMineCode(product.id);
this._formatCountdownTime(product);
this.setData({
product: product,
activityId: product.id,
myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
notice: JSON.parse(product.notice || '{}'),
lottery: JSON.parse(product.lottery_info || '{}'),
});
this._setActionStatus();
} else {
return Promise.reject();
}
})
.catch(e => {
wx.hideLoading();
console.error(e);
});
},
_formatCountdownTime(product) {
let { remaining, id} = product;
// 初始化倒计时时间
const formatTimeList = fomartCountdownTime(remaining);
this.setData({
formatTimeList,
});
// 清除定时器
clearInterval(timeoutId)
if(!remaining) {
return
}
timeoutId = setInterval(() => {
remaining--;
const formatTimeList = fomartCountdownTime(remaining);
const isCountdownEnd = formatTimeList.join('') === '000000';
if (isCountdownEnd) {
// 延时500毫秒调接口
const timeId = setTimeout(()=> {
this.changeActionStatus({id});
clearTimeout(timeId)
},500)
clearInterval(timeoutId);
}
this.setData({
formatTimeList
});
}, 1000);
},
_fetchParams(code) {
return getQRCodeSource(code).then(result => {
this.setData({
shareUid: +result.shareUid,
actPrizeId: result.actPrizeId,
});
});
},
_setActionStatus() {
let status = ACTION_BAR_STATUS.START;
let activityStatus = this.data.product.status;
if (activityStatus === ACTIVITY.UNKNOWN) {
status = ACTION_BAR_STATUS.END;
} else if (activityStatus === ACTIVITY.READY) {
status = ACTION_BAR_STATUS.READY;
} else if (activityStatus >= ACTIVITY.END) {
if (this._isInActivity()) {
if (activityStatus === ACTIVITY.LUCK) {
status = ACTION_BAR_STATUS.LUCK;
} else if (
activityStatus === ACTIVITY.END_LESS_PEOPLE ||
activityStatus === ACTIVITY.END
) {
status = ACTION_BAR_STATUS.WAIT;
} else {
status = ACTION_BAR_STATUS.WAIT;
}
} else {
if (
activityStatus === ACTIVITY.END_LESS_PEOPLE ||
activityStatus === ACTIVITY.END
) {
status = ACTION_BAR_STATUS.PEOPLE_LIMIT_WAIT;
} else {
status = ACTION_BAR_STATUS.END;
}
}
} else {
if (this._isInActivity()) {
status = ACTION_BAR_STATUS.ALEADY;
} else {
status = ACTION_BAR_STATUS.START;
}
}
this.setData({
actionStatus: status,
});
},
_isInActivity() {
return this.data.myPrizeCount > 0;
},
changeActionStatus(options = {}) {
wx.showLoading({
mask: true,
});
this._init(options);
},
share(event) {
this.setData({
'actionsheet.show': true,
});
},
_jumpBanner() {
if (this.data.bannerUrl == null) {
return;
}
jumpByUrl(this.data.bannerUrl);
},
_getDetailBanner() {
let commonService = this.commonService;
commonService
.getResourceCode('ccc32dbedf164a52b4efa34383878860')
.then(data => {
this.setData({
bannerSrc: formatImageUrl(data.src, 750, 140, 2),
bannerUrl: data.url,
});
})
.catch(error => {});
},
_getUser() {
const userInfo = app.getUserInfo();
if (app.isLogin() && (!userInfo || !userInfo.nickName)) {
return this.service
.getUserProfile({ uid: app.getUid() })
.then(json => {
if (json && json.code && json.code === 200) {
userInfo.nickName = json.data.nickname || '';
userInfo.avatarUrl = json.data.head_ico || '';
app.setUserInfo(userInfo);
}
});
} else {
return Promise.resolve();
}
},
handleZanActionsheetCancel({ componentId }) {
this.setData({
'actionsheet.show': false,
});
},
handleZanActionsheetClick({ componentId, index }) {
this.setData({
'actionsheet.show': false,
});
if (index === 1) {
router.go('snapShare', this.data.snapData);
}
},
onShareAppMessage(res) {
let params = {
TITLE: `有货UFOYOHOOD现场搞事情,点一下原价购买${
this.data.product.name
}`,
DESC: '我在YOHOOD发现一个不错的商品赶快来看看吧!',
};
this.setData({
shareFlag: true,
});
setTimeout(
function() {
this.setData({ shareFlag: false });
}.bind(this),
600,
);
if (res.from === 'menu') {
// 用户点击右上角分享
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/zeroSell/originalPriceSell?actPrizeId=${
this.data.product.id
}`,
};
} else if (res.from === 'button') {
// 用户点击分享按钮
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/zeroSell/originalPriceSell?actPrizeId=${
this.data.product.id
}&shareUid=${app.getUid()}`,
};
}
},
reportSuccess({ detail }) {
yasReport(YB_LUCK_DT_JOIN_C, { ACTIVITY_ID: detail });
},
getUserInfo: function(e) {
var that = this;
if (e.detail.errMsg === 'getUserInfo:ok') {
decodeUnionId(app.getWechatThirdSession(), e, function(response) {
if (response.isHaveUnionID) {
that.setData({
hasUnionID: true,
});
}
});
} else {
openAuthorizeSettings(function(response) {
if (response.isHaveUnionID) {
that.setData({
hasUnionID: true,
});
}
});
}
},
getPhoneNumber: function(e) {
this.setData({
showAuth: false,
});
var that = this;
if (e.detail.errMsg === 'getPhoneNumber:ok') {
decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', function(
result,
) {
if (result.code != 200) {
that.wetoast.toast({
title: result.message,
titleClassName: 'wetoast-title',
duration: 1000,
success: function() {
that.loginAndRegisterTapped();
}.bind(that),
});
} else {
if (result.is_register) {
that.showZanToast(
{
title:
'欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',
success: function() {
let uid =
app.globalData.userInfo.uid > 0
? app.globalData.userInfo.uid
: 0;
that.setData({
uid,
isLogin: app.isLogin(),
});
},
},
1500,
);
} else {
let uid =
app.globalData.userInfo.uid > 0
? app.globalData.userInfo.uid
: 0;
that.setData({
uid,
isLogin: app.isLogin(),
});
}
}
});
} else {
let needBind = true;
that.setData({
needBind,
});
// that.loginAndRegisterTapped(true);
wx.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber',
});
}
},
launchAppError: function(e) {
wx.showToast({
title: '打开失败!您可能未安装Yoho!Buy官方APP,请下载后再尝试。',
icon: 'none',
duration: 3000,
});
},
//跳转到登录页面
loginAndRegisterTapped(needBind) {
let that = this;
let app = getApp();
if (wx.getSetting) {
wx.getSetting({
success: res => {
if (
res &&
res.authSetting &&
res.authSetting['scope.userInfo'] !== null &&
res.authSetting['scope.userInfo'] !== undefined &&
res.authSetting['scope.userInfo'] === false
) {
wx.showModal({
title: '',
content: '检测到您未打开微信用户信息授权,开启后即可进行登录',
confirmText: '去开启',
confirmColor: '#000000',
success: function(res) {
if (res.confirm) {
wx.openSetting({
success: res => {
if (
res.authSetting['scope.userInfo'] !== null &&
res.authSetting['scope.userInfo'] !== undefined &&
res.authSetting['scope.userInfo'] === true
) {
getUnionID(app.getWechatThirdSession(), function(
response,
) {});
}
},
});
} else {
wx.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber',
});
}
},
});
} else {
wx.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber',
});
}
},
});
} else {
wx.showModal({
title: '提示',
content:
'当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
});
}
},
},
Toast,
),
);
... ...
{
"navigationBarTitleText": "YO!LUCK原价购",
"enablePullDownRefresh": true,
"usingComponents": {
"product-item": "./components/product-item",
"product-header": "./components/yohoodLottery/product-detail-header",
"prize-progress": "./components/prize-progress",
"more": "./components/more",
"avatars": "./components/avatar-swiper",
"help": "./components/help",
"fellow-bar": "./components/fellow-bar",
"action-bar": "./components/yohoodLottery/action-bar",
"zero-alert": "./components/alert",
"group-recommend": "./components/group-recommend"
}
}
... ...
<view class="header {{shareFlag || (notice.content || product.status >= 3 ? 'mt-header': '') }}">
<product-header product="{{product}}" shareFlag="{{shareFlag}}" format-timeList="{{formatTimeList}}" bindchangeStatus="changeActionStatus" avatars="{{avatars}}"></product-header>
</view>
<view class="lottery-info">
<view class="flow-tile-wrap">
<text>活动流程</text>
<help url="https://activity.yoho.cn/feature/5901.html" text="活动规则" title="原价购活动说明"></help>
</view>
<image mode="aspectFill" class="jion-tips-image" src="https://cdn.yoho.cn/o_1dhq2n6551qc5djrv5v1geekcq8.png"></image>
</view>
<view class="machine {{shareFlag ? 'machine-t-m' : 'machine-t-l'}}">
<view class="open-shadow"></view>
<view class="code-list" animation="{{animation}}">
<view class="code-list-item-container">
<view class="code-list-item">
<view class="content"></view>
</view>
<view class="code-list-item" wx:for="{{codeList}}" wx:key="{{index}}">
<view class="content">
<image class="thumb" mode="widthFix" src="{{item.user_thumb}}"></image>
<view class="text">
<view>我的</view>
<view>抽奖码</view>
</view>
<view class="my-code">{{item.prize_code}}</view>
</view>
<image class="shadow" src="https://img11.static.yhbimg.com/yhb-img01/2018/12/27/19/0140fa3243af949068d2aabeedb0ea0666.png" mode="widthFix" wx:if="{{index == 2 && codeList.length>3 }}"></image>
</view>
</view>
</view>
</view>
<view class="fellow-bar" wx:if="{{product.status && !shareFlag}}">
<block wx:if="{{product.status >= 3}}">
<view class="endTip">
<text>{{notice.content || '本场活动已结束(下拉刷新可查看新活动)'}}</text>
</view>
</block>
<block wx:elif="{{notice.content}}">
<fellow-bar notice="{{notice}}"></fellow-bar>
</block>
</view>
<view class="action-bar">
<action-bar activity-status="{{product.status}}" format-timeList="{{formatTimeList}}" is-login="{{isLogin}}" status="{{actionStatus}}" num="{{myPrizeCount}}" share-uid="{{shareUid}}" act-id="{{activityId}}" bindchangeStatus="changeActionStatus" bindshare="share" copyText="{{lottery.miniappCopy}}" text="{{lottery.miniappTip}}" bindgaincodesuccess="reportSuccess" type="{{lottery.miniappType}}"></action-bar>
</view>
<view class="foot"></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__}}" />
<zero-alert wx:if="{{showAuth}}">
<view class="auth-content">OOPS 用户尚未授权登录</view>
<button class="auth-foot action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>
授权登录
</button>
</zero-alert>
<button wx:if="{{isGoApp}}" class="appBtn" bindtap='goApp' type="default" hover-class="none" open-type="launchApp" app-parameter="{{appParameter}}" binderror="launchAppError">
<image class="appImg" src="./images/back2App@3x.png"></image>
</button>
\ No newline at end of file
... ...
/* page/subPackage/pages/zeroSell/detail.wxss */
@import '../../vendors/zanui/actionsheet/index.wxss';
.line {
height: 20rpx;
background-color: #f0f0f0;
}
.product-item {
margin-bottom: 80rpx;
}
.header {
position: relative;
text-align: center;
overflow: hidden;
}
.mt-header {
margin-top: 80rpx;
}
.fellow-bar {
position: fixed;
width: 100%;
top: 0rpx;
z-index: 1000;
}
.action-bar {
position: fixed;
width: 100%;
bottom: 0;
z-index: 999;
}
.foot {
height: 160rpx;
}
.action-item {
flex: 1;
color: white;
text-align: center;
font-size: 32rpx;
height: 100rpx;
line-height: 100rpx;
background-color: white;
border-radius: unset;
}
.action-list {
flex: 0;
position: relative;
flex-basis: 150rpx;
}
.action-image {
width: 46rpx;
height: 42rpx;
position: absolute;
top: 50%;
left: 50%;
/* transform: translateY(-50%); */
transform: translate(-50%, -50%);
}
.action-bar2 {
display: flex;
width: 100%;
height: 100rpx;
}
.auth-content {
font-size: 28rpx;
color: #444444;
line-height: 40rpx;
text-align: center;
margin-top: 96rpx;
}
.auth-foot {
position: absolute;
box-sizing: border-box;
bottom: 0;
width: 100%;
height: 90rpx;
line-height: 90rpx;
font-size: 32rpx;
font-weight: bolder;
text-align: center;
border-top: 1rpx solid #e0e0e0;
}
.jion-tips-image {
margin-left: 30rpx;
width: 690rpx;
height: 80rpx;
margin-top: 20rpx;
}
.machine {
background-image: url('https://cdn.yoho.cn/o_1dh8e94lvd4g1ut18pk1in8ure8.png');
background-size: contain;
background-repeat: no-repeat;
min-height: 258rpx;
position: relative;
margin-left: 83.6rpx;
width: 598rpx;
overflow: hidden;
}
.machine-t-l {
margin-top: 20rpx;
}
.machine-t-m {
margin-top: 40rpx;
}
.machine .code-list {
position: relative;
width: 410rpx;
height: 22rpx;
margin: 110rpx auto 0 78rpx;
overflow: hidden;
}
.code-list .code-list-item {
margin-top: -12rpx;
width: 410rpx;
height: 164rpx;
overflow: hidden;
position: relative;
}
.code-list .code-list-item-container {
position: absolute;
bottom: 0;
width: 410rpx;
}
.code-list .code-list-item .code {
float: left;
}
.machine .code {
width: 410rpx;
position: relative;
}
.code-list .code-list-item .content {
width: 410rpx;
height: 164rpx;
position: relative;
background-image: url('https://img11.static.yhbimg.com/yhb-img01/2018/12/27/19/0140fa3243af949068d2aabeedb0ea0666.png');
background-size: cover;
background-repeat: no-repeat;
overflow: hidden;
z-index: 4;
}
.code-list .code-list-item .content .thumb {
width: 60rpx;
height: 60rpx;
margin: 46rpx 10rpx 46rpx 32rpx;
border-radius: 30rpx;
}
.code-list .code-list-item .content .my-code {
height: 44rpx;
float: right;
vertical-align: middle;
line-height: 156rpx;
font-size: 32rpx;
margin-right: 46rpx;
}
.code-list .code-list-item .content .text {
font-size: 16rpx;
display: inline-block;
height: 172rpx;
vertical-align: middle;
}
.code-list .code-list-item .shadow {
width: 410rpx;
position: absolute;
top: 6rpx;
}
.code-list .down {
width: 20rpx;
height: 20rpx;
margin-left: 50%;
}
.open-shadow {
box-shadow: 0rpx 0rpx 16rpx 4rpx #000;
width: 394rpx;
height: 0rpx;
position: absolute;
top: 112rpx;
z-index: 10;
left: 82rpx;
}
.appBtn {
position: fixed;
width: 80rpx;
height: 160rpx;
right: 50rpx;
bottom: 148rpx;
padding: 0;
align-self: center;
background-color: transparent !important;
z-index: 99;
}
.appBtn::after {
border: none;
}
.appBtn .appImg {
width: 80rpx;
height: 160rpx;
}
.flow-tile-wrap {
display: flex;
font-size: 36rpx;
padding: 0 30rpx;
align-items: center;
justify-content: space-between;
}
.endTip {
background-color: #999999;
height: 80rpx;
color: #ffffff;
display: flex;
align-items: center;
padding-left: 30rpx;
font-size: 28rpx;
letter-spacing: -0.34rpx;
}
... ...
... ... @@ -6,8 +6,8 @@ import iconfSwitch from '../../../libs/switch';
import md5 from '../../../vendors/md5';
//注:g_sourceApiArry与g_toJavaApiArry的length要相等,且一一对应
const g_sourceApiArry = [ '/list', '/content', '/list/recommend', '/code/recent', '/list/mine', '/code/gain', '/code/mine' ];
const g_toJavaApiArry = [ 'app.yoluck.activityList', 'app.yoluck.getContent', 'app.yoluck.recommendList', 'app.yoluck.recent', 'app.yoluck.participationList', 'app.yoluck.getCode', 'app.yoluck.userCode' ];
const g_sourceApiArry = [ '/list', '/content', '/list/recommend', '/code/recent', '/list/mine', '/code/gain', '/code/mine','/yohood/content' ];
const g_toJavaApiArry = [ 'app.yoluck.activityList', 'app.yoluck.getContent', 'app.yoluck.recommendList', 'app.yoluck.recent', 'app.yoluck.participationList', 'app.yoluck.getCode', 'app.yoluck.userCode','app.yohood.getContent' ];
const app = getApp();
... ... @@ -32,7 +32,7 @@ class Service {
//适配服务器更换Java接口,开关控制是否切换
if (app.globalData.switch_javaApiEnable && pathIndex >= 0) {
if (result.data.list) {
if (result.data&& result.data.list) {
let newList = Humps.decamelizeKeys(Object.values(result.data.list));
result.data.list = newList;
} else {
... ...
... ... @@ -49,6 +49,21 @@ class ZeroSellService extends Service {
});
}
getYohoodDetail(data) {
return this._get('/yohood/content', data).then(result => {
if (result.code === 200) {
Object.keys(result.data).forEach(item => {
if (item === 'my_code_num') {
result.data['myCodeNum'] = result.data[item];
}
})
return result;
}
return result;
});
}
getRecommend(data) {
data.channel = 0
return this._get('/list/recommend', data).then(result => {
... ...
... ... @@ -71,10 +71,18 @@
"scene": "1011"
},
{
"id": -1,
"id": 5,
"name": "YOLUCK DETAIL",
"pathName": "pages/zeroSell/detail",
"query": "actPrizeId=41"
"query": "actPrizeId=224",
"scene": null
},
{
"id": 6,
"name": "YOHOOD LOTTERY",
"pathName": "pages/zeroSell/originalPriceSell",
"query": "",
"scene": null
},
{
"id": 6,
... ...
'use strict'
'use strict';
//获取应用实例
/**
* 时间戳转化为年 月 日 时 分 秒
/**
* 时间戳转化为年 月 日 时 分 秒
* time: 传入时间戳
* format:返回格式,支持自定义,但参数必须与formateArr里保持一致
* format:返回格式,支持自定义,但参数必须与formateArr里保持一致
* formatTimeByDefined(1488481383,'Y/M/D h:m:s') => 2017/03/03 03:03:03
*/
*/
function formatTimeByDefined(time, format) {
var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
var returnArr = [];
... ... @@ -26,31 +25,35 @@ function formatTimeByDefined(time, format) {
format = format.replace(formateArr[i], returnArr[i]);
}
return format;
}
}
function formatTime(date) {
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return (
[year, month, day].map(formatNumber).join('/') +
' ' +
[hour, minute, second].map(formatNumber).join(':')
);
}
function formatNumber(n) {
n = n.toString()
return n[1] ? n : '0' + n
n = n.toString();
return n[1] ? n : '0' + n;
}
function getDeviceInfo(wx) {
let res = wx.getSystemInfoSync(),
windowWidth;
let res = wx.getSystemInfoSync(),
windowWidth;
windowWidth = res.windowWidth;
return { windowWidth };
windowWidth = res.windowWidth;
return { windowWidth };
}
function shouldDiscardTap(currentTimeStamp, lastTimeStamp) {
... ... @@ -61,31 +64,41 @@ function shouldDiscardTap(currentTimeStamp, lastTimeStamp) {
return false;
}
function formatImgUrl (json) {
json.data && json.data.map((item, index) => {
let replaceStr = "{width}";
let url = item.src;
url = url.replace(new RegExp('{width}'), windowWidth * 2).replace(new RegExp('{height}'), 100).replace(new RegExp('{mode}'), '2');
item.src = url;
// console.log(url)
});
function formatImgUrl(json) {
json.data &&
json.data.map((item, index) => {
let replaceStr = '{width}';
let url = item.src;
url = url
.replace(new RegExp('{width}'), windowWidth * 2)
.replace(new RegExp('{height}'), 100)
.replace(new RegExp('{mode}'), '2');
item.src = url;
// console.log(url)
});
return json;
}
function getImageUrl(url, windowWidth,height){
if(!url){
function getImageUrl(url, windowWidth, height) {
if (!url) {
return '';
}
return url.replace(new RegExp('{width}'), windowWidth *2).replace(new RegExp('{height}'), height?height:100).replace(new RegExp('{mode}'), '2');
return url
.replace(new RegExp('{width}'), windowWidth * 2)
.replace(new RegExp('{height}'), height ? height : 100)
.replace(new RegExp('{mode}'), '2');
}
function formatImageUrl(url, width, height, mode){
function formatImageUrl(url, width, height, mode) {
url = url || '';
if (url && url.indexOf('?') === -1) {
url = url + '?imageView2/{mode}/w/{width}/h/{height}';
url = url + '?imageView2/{mode}/w/{width}/h/{height}';
}
return url.replace(/{width}/g, width).replace(/{height}/g, height).replace('{mode}', mode || 2);
return url
.replace(/{width}/g, width)
.replace(/{height}/g, height)
.replace('{mode}', mode || 2);
}
// 自动识别 2倍 3倍图
... ... @@ -98,31 +111,40 @@ function getImageUrlWithWH(image_url, image_width, image_height) {
if (!image_url) {
return '';
}
return image_url.replace(/{width}/g, parseInt(image_width * DEVICE_WIDTH_RATIO * pixelRatio)).replace(/{height}/g, parseInt(image_height * DEVICE_WIDTH_RATIO * pixelRatio)).replace('{mode}', 2);
return image_url
.replace(
/{width}/g,
parseInt(image_width * DEVICE_WIDTH_RATIO * pixelRatio),
)
.replace(
/{height}/g,
parseInt(image_height * DEVICE_WIDTH_RATIO * pixelRatio),
)
.replace('{mode}', 2);
}
function getBrandID (url) {
let params = url.split("openby:yohobuy=")
function getBrandID(url) {
let params = url.split('openby:yohobuy=');
if (params.length == 2) {
let jsonParam = JSON.parse(params[1])
let jsonParam = JSON.parse(params[1]);
return jsonParam.params.brand_id;
}
return null;
}
function isStringEmpty(str){
if (str===undefined || str ===null || str ===''){
return true
}else{
return false
function isStringEmpty(str) {
if (str === undefined || str === null || str === '') {
return true;
} else {
return false;
}
return true;
}
function getGoodDetailParam(url) {
let params = url.split("openby:yohobuy=")
let params = url.split('openby:yohobuy=');
if (params.length == 2) {
let jsonParam = JSON.parse(params[1])
let jsonParam = JSON.parse(params[1]);
return JSON.stringify(jsonParam.params);
}
return null;
... ... @@ -130,29 +152,29 @@ function getGoodDetailParam(url) {
function formatDateTime(inputTime) {
var date = new Date();
date.setTime(inputTime*1000);
date.setTime(inputTime * 1000);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
m = m < 10 ? '0' + m : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
return y + '.' + m + '.'+d;
};
function formateTimestamp(start,end){
var startTime = formatDateTime(start)
var endTime = formatDateTime(end)
return startTime+'-'+endTime
d = d < 10 ? '0' + d : d;
return y + '.' + m + '.' + d;
}
function formateTimestamp(start, end) {
var startTime = formatDateTime(start);
var endTime = formatDateTime(end);
return startTime + '-' + endTime;
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
function getSknFromUrl(url) {
... ... @@ -160,7 +182,9 @@ function getSknFromUrl(url) {
url = decodeURIComponent(url).toLowerCase();
let components = url.split('/');
let lastElement = components.pop();
let startLegal = url.startsWith('https://m.yohobuy.com/product') || url.startsWith('http://m.yohobuy.com/product');
let startLegal =
url.startsWith('https://m.yohobuy.com/product') ||
url.startsWith('http://m.yohobuy.com/product');
let endLegal = lastElement.endsWith('.html');
if (!startLegal || !endLegal) {
return '';
... ... @@ -175,7 +199,9 @@ function getShopIdFromUrl(url) {
url = decodeURIComponent(url).toLowerCase();
let components = url.split('/');
let lastElement = components.pop();
let startLegal = url.startsWith('https://m.yohobuy.com/shop') || url.startsWith('http://m.yohobuy.com/shop');
let startLegal =
url.startsWith('https://m.yohobuy.com/shop') ||
url.startsWith('http://m.yohobuy.com/shop');
let endLegal = lastElement.endsWith('.html');
if (!startLegal || !endLegal) {
return '';
... ... @@ -187,9 +213,9 @@ function getShopIdFromUrl(url) {
}
function getShopID(url) {
let params = url.split("openby:yohobuy=")
let params = url.split('openby:yohobuy=');
if (params.length == 2) {
let jsonParam = JSON.parse(params[1])
let jsonParam = JSON.parse(params[1]);
return jsonParam.params.shop_id;
}
return null;
... ... @@ -202,22 +228,23 @@ function contains(arr, obj) {
}
}
return -1;
}
}
function getGuangType(url) {
let params = url.split("openby:yohobuy=")
let params = url.split('openby:yohobuy=');
if (params.length == 2) {
let jsonParam = JSON.parse(params[1])
let jsonParam = JSON.parse(params[1]);
return jsonParam.params.type;
}
return null;
}
// public method for encoding
// public method for encoding
function base64Encode(input) {
let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
let _keyStr =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var output = "";
var output = '';
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = _utf8_encode(input);
... ... @@ -234,21 +261,25 @@ function base64Encode(input) {
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
_keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
_keyStr.charAt(enc3) + _keyStr.charAt(enc4);
output =
output +
_keyStr.charAt(enc1) +
_keyStr.charAt(enc2) +
_keyStr.charAt(enc3) +
_keyStr.charAt(enc4);
}
return output;
}
// public method for decoding
// public method for decoding
function base64Decode(input) {
let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var output = "";
let _keyStr =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var output = '';
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
while (i < input.length) {
enc1 = _keyStr.indexOf(input.charAt(i++));
enc2 = _keyStr.indexOf(input.charAt(i++));
... ... @@ -270,13 +301,13 @@ function base64Decode(input) {
}
function _utf8_encode(string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
string = string.replace(/\r\n/g, '\n');
var utftext = '';
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
} else if (c > 127 && c < 2048) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
... ... @@ -284,16 +315,15 @@ function _utf8_encode(string) {
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
}
// private method for UTF-8 decoding
// private method for UTF-8 decoding
function _utf8_decode(utftext) {
var string = "";
var string = '';
var i = 0;
var c = 0;
var c = 0;
var c1 = 0;
var c2 = 0;
var c3 = 0;
... ... @@ -302,14 +332,16 @@ function _utf8_decode(utftext) {
if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if ((c > 191) && (c < 224)) {
} else if (c > 191 && c < 224) {
c2 = utftext.charCodeAt(i + 1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
string += String.fromCharCode(
((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63),
);
i += 3;
}
}
... ... @@ -319,7 +351,7 @@ function _utf8_decode(utftext) {
key: 关键词
fromPage: 来源页面名称
**/
function getYHStorageSync(key,fromPage) {
function getYHStorageSync(key, fromPage) {
// console.log(key)
// console.log(fromPage)
try {
... ... @@ -344,7 +376,7 @@ key: 关键词
value: 内容
fromPage: 来源页面名称
**/
function setStorageSync(key,value, fromPage) {
function setStorageSync(key, value, fromPage) {
try {
wx.setStorageSync(key, value);
return true;
... ... @@ -366,6 +398,26 @@ function removeStorageSync(key, fromPage) {
}
}
/**
* 格式化倒计时时间
* time in seconds
*/
function fomartCountdownTime(remainingTimeInSeconds = 0) {
if (remainingTimeInSeconds < 0) {
return [];
}
const timeInHour = Math.floor(remainingTimeInSeconds / 3600);
let remainingTime = remainingTimeInSeconds - timeInHour * 3600;
const timeInMinute = Math.floor(remainingTime / 60);
remainingTime = parseInt(remainingTime - timeInMinute * 60);
return [timeInHour, timeInMinute, remainingTime].map(time => {
return `${time > 9 ? time : `0${time}`}`;
});
}
module.exports = {
formatTimeByDefined,
formatTime: formatTime,
... ... @@ -389,5 +441,6 @@ module.exports = {
base64Decode,
getYHStorageSync,
setStorageSync,
removeStorageSync
}
\ No newline at end of file
removeStorageSync,
fomartCountdownTime,
};
... ...