Authored by 邱骏

form

... ... @@ -274,5 +274,8 @@ App({
},
getSystemInfo() {
return this.globalData.systemInfo;
},
getMiniappType() {
return config.mini_app_type;
}
});
... ...
... ... @@ -24,7 +24,8 @@ const config = {
unionType: '', // 渠道号
MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
appid: 'wx39f299b6485cf97a', // 业务中使用、与package.config.json内appid保持一致wx39f299b6485cf97a
business_line: 'miniappOffshop' // 业务线
business_line: 'miniappOffshop', // 业务线
mini_app_type: 4
};
export default config;
... ...
... ... @@ -4,8 +4,9 @@ import event from '../../common/event';
import LimitModel from '../../models/limit/index';
import helper from '../../utils/helper';
import wx from '../../utils/wx';
import { Actionsheet } from '../../vendors/zanui/index';
import { stringify } from '../../vendors/query-stringify';
import {Actionsheet} from '../../vendors/zanui/index';
import {stringify} from '../../vendors/query-stringify';
import commonModel from '../../models/common';
let app = getApp();
let router = global.router;
... ... @@ -17,558 +18,579 @@ let router = global.router;
*/
/**
* 接口:获取用户排队信息
* https://api.yoho.cn/?activityId=179&app_version=6.4.0&client_secret=ee1114702f3db67327afe9eeeac92b5a&client_type=iphone&fromPage=iFP_Queue&method=app.drawline.getUserActivityInfo&os_version=11.2.5&physical_channel=1&screen_size=375x667&session_key=3c9a644c3d95d9a7453c61f3009b2884&udid=1a61c0b4db7b6e27999b1237977b5347eb503956&uid=349709&v=7
* method=app.drawline.getUserActivityInfo
* activityId=179
*
* 接口:获取排队用户信息
* https://api.yoho.cn/?activityId=179&app_version=6.4.0&client_secret=e8f42148d30976fb44dfff1d89ea7a60&client_type=iphone&fromPage=iFP_Queue&limit=50&method=app.drawline.getQueueList&os_version=11.2.5&physical_channel=1&screen_size=375x667&session_key=3c9a644c3d95d9a7453c61f3009b2884&sort=0&udid=1a61c0b4db7b6e27999b1237977b5347eb503956&uid=349709&v=7
*
* 接口:排队活动
* https://api.yoho.cn/?activityId=179&app_version=6.4.0&client_secret=52db394bdb79e2dcf0e2a2782496ee78&client_type=iphone&fromPage=iFP_Queue&method=app.drawline.getActivityInfo&os_version=11.2.5&physical_channel=1&screen_size=375x667&session_key=3c9a644c3d95d9a7453c61f3009b2884&udid=1a61c0b4db7b6e27999b1237977b5347eb503956&uid=349709&v=7
* 接口:获取排队用户信息(列表)
* method=app.drawline.getQueueList
* activityId=179
* limit=50
* sort=0
*
*
* 接口:排队活动信息
* method=app.drawline.getActivityInfo
* activityId=179
*
*
* 接口:中奖列表
* https://api.yoho.cn/?activityId=179&app_version=6.4.0&client_secret=936b01c80de696e81c59fee6ea64fd50&client_type=iphone&fromPage=iFP_QueueResult&limit=20&method=app.drawline.getLuckyUserList&os_version=11.2.6&page=1&physical_channel=1&screen_size=375x667&session_key=3c9a644c3d95d9a7453c61f3009b2884&udid=1a61c0b4db7b6e27999b1237977b5347eb503956&uid=349709&v=7
* method=app.drawline.getLuckyUserList
* activityId=179
* limit=20
* page=1
*
* 接口:添加用户分享记录
* https://api.yoho.cn/?activityId=294&app_version=6.4.0&client_secret=e7ecfcd3410f5c8b0054c07b8366a700&client_type=iphone&fromPage=iFP_LimitPurchaseDetail&method=app.limitProduct.addUserShare&os_version=11.2.6&physical_channel=1&screen_size=375x667&session_key=d4c06294461b138058ce3aa2978cd602&udid=1a61c0b4db7b6e27999b1237977b5347eb503956&uid=349709&v=7 HTTP/1.1
*/
Page(Object.assign({
/**
/**
* 页面的初始数据
*/
data: {
userInfo: {}, // 用户信息
activityInfo: {}, // 活动信息
shareInfo: {
default_image: '',
product_name: '',
product_qrCode: '',
product_skn: '',
limitProductCode: ''
data: {
userInfo: {}, // 用户信息
activityInfo: {}, // 活动信息
shareInfo: {
default_image: '',
product_name: '',
product_qrCode: '',
product_skn: '',
limitProductCode: ''
},
test_uid: [349709, // 测试用
500030924,
500030922,
500030918,
500030916,
500030914,
500030912,
500030910,
500030908,
500030906,
500030904,
500030890,
500030888,
500030886,
500030884,
500030876,
500030830,
500030694,
500030690,
500030688
],
now_test_uid_index: 15,
h5PageUrl: [
{
title: '排队活动说明',
url: 'https://activity.yoho.cn/feature/249.html?nodownload=1'
}
],
bgStyle: [ // 排队图片
'../../static/images/limit/queue_bg_1.png',
'../../static/images/limit/queue_bg_2.png',
'../../static/images/limit/queue_bg_3.png',
'../../static/images/limit/queue_bg_4.png',
'../../static/images/limit/queue_bg_5.png',
'../../static/images/limit/queue_bg_6.png',
'../../static/images/limit/queue_bg_7.png',
'../../static/images/limit/queue_bg_8.png'
],
vipImage: [ // 3种用户vip等级小图标
'',
'../../static/images/limit/level-1.png',
'../../static/images/limit/level-2.png',
'../../static/images/limit/level-3.png'
],
defaultAvatar: '../../static/images/icons/default-avatar.png',
resultHead: [
'../../static/images/limit/fail-head.png',
'../../static/images/limit/success-head.png'
],
api_status: 0, // 用于防止连续点击参加活动 0:没调用接口 1:正在调用接口
giftImage: '../../static/images/limit/gift.png',
queueList: [], // 排队列表
scrollTop: 0, // 控制scroll-view滚动的实际位置
tempScrollTop: 0, // 手动滚动页面时保存当前滚动的位置
showMsg: 0, // 0不显示提示框, 1显示提示框
hidePopup: 0, // 用于显示头像旁边的气泡 0:显示 1:不显示
hideInviteButton: 1, // 用户显示邀请按钮
actionSheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
actions: [{
name: '邀请好友助力',
className: 'action-class',
loading: false,
openType: 'share'
}, {
name: '生成图片分享到朋友圈',
className: 'action-class',
loading: false,
}]
},
},
test_uid: [349709, // 测试用
500030924,
500030922,
500030918,
500030916,
500030914,
500030912,
500030910,
500030908,
500030906,
500030904,
500030890,
500030888,
500030886,
500030884,
500030876,
500030830,
500030694,
500030690,
500030688
],
now_test_uid_index: 15,
h5PageUrl: [
{
title: '排队活动说明',
url: 'https://activity.yoho.cn/feature/249.html?nodownload=1'
}
],
bgStyle: [ // 排队图片
'../../static/images/limit/queue_bg_1.png',
'../../static/images/limit/queue_bg_2.png',
'../../static/images/limit/queue_bg_3.png',
'../../static/images/limit/queue_bg_4.png',
'../../static/images/limit/queue_bg_5.png',
'../../static/images/limit/queue_bg_6.png',
'../../static/images/limit/queue_bg_7.png',
'../../static/images/limit/queue_bg_8.png'
],
vipImage: [ // 3种用户vip等级小图标
'',
'../../static/images/limit/level-1.png',
'../../static/images/limit/level-2.png',
'../../static/images/limit/level-3.png'
],
defaultAvatar: '../../static/images/icons/default-avatar.png',
resultHead: [
'../../static/images/limit/fail-head.png',
'../../static/images/limit/success-head.png'
],
api_status: 0, // 用于防止连续点击参加活动 0:没调用接口 1:正在调用接口
giftImage: '../../static/images/limit/gift.png',
queueList: [], // 排队列表
scrollTop: 0, // 控制scroll-view滚动的实际位置
tempScrollTop: 0, // 手动滚动页面时保存当前滚动的位置
showMsg: 0, // 0不显示提示框, 1显示提示框
hidePopup: 0, // 用于显示头像旁边的气泡 0:显示 1:不显示
hideInviteButton: 1, // 用户显示邀请按钮
actionSheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
actions: [{
name: '邀请好友助力',
className: 'action-class',
loading: false,
openType: 'share'
}, {
name: '生成图片分享到朋友圈',
className: 'action-class',
loading: false,
}]
},
},
/**
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options);
let actId = options.actId;
let uid = app.getUid();
if (actId) {
this.getActivityInfo(actId).then(res => {
console.log('res', res);
if (res.code === 200) {
this.getQueueList(actId, 0);
}
if (uid) {
this.getUserActivityInfo(actId, uid);
onLoad: function (options) {
console.log(options);
let actId = options.actId;
let uid = app.getUid();
if (actId) {
this.getActivityInfo(actId).then(res => {
console.log('res', res);
if (res.code === 200) {
this.getQueueList(actId, 0);
}
if (uid) {
this.getUserActivityInfo(actId, uid);
}
}); // 获取活动信息
for (let i in options) {
options[i] = decodeURIComponent(options[i]);
}
this.setData({
shareInfo: Object.assign(this.data.shareInfo, options)
});
}
}); // 获取活动信息
for (let i in options) {
options[i] = decodeURIComponent(options[i]);
}
this.setData({
shareInfo: Object.assign(this.data.shareInfo, options)
});
}
},
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
},
},
/**
/**
* 生命周期函数--监听页面显示
*/
onShow: function(options) {
setTimeout(this.hidePopup, 4000);
if (app.getUid()) {
this.setData({
hideInviteButton: 0
});
}
},
onShow: function (options) {
setTimeout(this.hidePopup, 4000);
if (app.getUid()) {
this.setData({
hideInviteButton: 0
});
}
},
/**
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
onHide: function () {
},
/**
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
onUnload: function () {
},
/**
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
let actId = this.data.activityInfo.activityId;
if (actId) {
this.getActivityInfo(actId).then(res => {
console.log('res', res);
if (res.code === 200) {
this.getQueueList(actId, 0);
wx.stopPullDownRefresh();
onPullDownRefresh: function () {
let actId = this.data.activityInfo.activityId;
if (actId) {
this.getActivityInfo(actId).then(res => {
console.log('res', res);
if (res.code === 200) {
this.getQueueList(actId, 0);
wx.stopPullDownRefresh();
}
}); // 获取活动信息
}
}); // 获取活动信息
}
},
},
/**
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
console.log('到底部啦');
let actId = this.data.activityInfo.activityId;
let sort = this.data.queueList[this.data.queueList.length - 1].sort;
let limit = 50;
if (sort > 1) {
if (sort - 1 < limit) {
limit = sort - 1;
}
this.getQueueList(actId, sort - 1, limit, true);
}
},
onReachBottom: function () {
console.log('到底部啦');
let actId = this.data.activityInfo.activityId;
let sort = this.data.queueList[this.data.queueList.length - 1].sort;
let limit = 50;
if (sort > 1) {
if (sort - 1 < limit) {
limit = sort - 1;
}
this.getQueueList(actId, sort - 1, limit, true);
}
},
/**
/**
* 用户点击右上角分享
*/
onShareAppMessage: function(res) {
let params = {
FROM: res.from,
SHARE_RESUIL: 0,
TITLE: decodeURIComponent(this.data.shareInfo.product_name),
DESC: '我在有货限定频道发现一个不错的商品赶快来看看吧!',
PATH: `/pages/product/detail/detail?limitProductCode=
onShareAppMessage: function (res) {
let params = {
FROM: res.from,
SHARE_RESUIL: 0,
TITLE: decodeURIComponent(this.data.shareInfo.product_name),
DESC: '我在有货限定频道发现一个不错的商品赶快来看看吧!',
PATH: `/pages/product/detail/detail?limitProductCode=
${this.data.shareInfo.limitProductCode}&originUid=${app.getUid()}`,
IMG: decodeURIComponent(this.data.shareInfo.default_image)
};
// 用户点击右上角分享
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: params.PATH, // 分享路径
imageUrl: params.IMG,
success: function() {
params.SHARE_RESUIL = 1;
},
fail: function() {
params.SHARE_RESUIL = 2;
}
};
},
share: function() {
this.setData({
'actionSheet.show': true
});
},
handleZanActionsheetCancel() {
this.setData({
'actionSheet.show': false
});
},
// 当行动按钮中有一个被点击时触发
// index 代表被点击按钮在传入参数 actions 中的位置
handleZanActionsheetClick({index}) {
this.setData({
'actionSheet.show': false
});
let uid = this.data.originUid || this.data.uid;
if (index === 1) {
router.go('snapShare', this.data.shareInfo);
}
},
IMG: decodeURIComponent(this.data.shareInfo.default_image)
};
// 用户点击右上角分享
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: params.PATH, // 分享路径
imageUrl: params.IMG,
success: function () {
params.SHARE_RESUIL = 1;
},
fail: function () {
params.SHARE_RESUIL = 2;
}
};
},
share: function () {
this.setData({
'actionSheet.show': true
});
},
handleZanActionsheetCancel() {
this.setData({
'actionSheet.show': false
});
},
// 当行动按钮中有一个被点击时触发
// index 代表被点击按钮在传入参数 actions 中的位置
handleZanActionsheetClick({index}) {
this.setData({
'actionSheet.show': false
});
/**
let uid = this.data.originUid || this.data.uid;
if (index === 1) {
router.go('snapShare', this.data.shareInfo);
}
},
/**
* 邀请好友助力排队按钮
*/
inviteFriends: function(e) {
this.share();
},
inviteFriends: function (e) {
this.share();
},
/**
/**
* scroll-view滚动事件
*/
scroll: function(e) {
console.log(e);
let scrollTop = e.detail.scrollTop;
scroll: function (e) {
console.log(e);
let scrollTop = e.detail.scrollTop;
this.setData({
tempScrollTop: scrollTop
});
},
this.setData({
tempScrollTop: scrollTop
});
},
/**
/**
* 跳转到我的排队列表
*/
navigateToMyList: function(e) {
router.go('myList', Object.assign({actId: this.data.activityInfo.activityId}, this.data.shareInfo));
},
navigateToMyList: function (e) {
router.go('myList', Object.assign({actId: this.data.activityInfo.activityId}, this.data.shareInfo));
},
/**
/**
* 点击用户头像,跳转到用户对应位置<已取消该功能>
*/
userTap: function(e) {
console.log(this.data.userInfo);
let uid = this.data.userInfo.uid;
let sort = this.data.userInfo.sort || 0;
let limit = sort >= 50 ? 50 : sort;
let actId = this.data.activityInfo.activityId;
let list_length = this.data.queueList.length > 200 ? 200 : this.data.queueList.length;
for (let i = 0; i < list_length; i++) {
let item = this.data.queueList[i];
if (item.uid === uid) {
this.scrollPage('item_' + item.uid);
console.log(item.uid);
break;
} else if (i === list_length - 1) {
console.log(i);
this.getQueueList(actId, sort, limit).then(res => {
console.log('111', res);
if (res.code === 200) {
let item_id = 'item_' + uid;
this.scrollPage(item_id);
}
});
}
}
},
userTap: function (e) {
console.log(this.data.userInfo);
let uid = this.data.userInfo.uid;
let sort = this.data.userInfo.sort || 0;
let limit = sort >= 50 ? 50 : sort;
let actId = this.data.activityInfo.activityId;
let list_length = this.data.queueList.length > 200 ? 200 : this.data.queueList.length;
for (let i = 0; i < list_length; i++) {
let item = this.data.queueList[i];
if (item.uid === uid) {
this.scrollPage('item_' + item.uid);
console.log(item.uid);
break;
} else if (i === list_length - 1) {
console.log(i);
this.getQueueList(actId, sort, limit).then(res => {
console.log('111', res);
if (res.code === 200) {
let item_id = 'item_' + uid;
this.scrollPage(item_id);
}
});
}
}
},
/**
/**
* 关闭提示框
*/
closeMsg: function(e) {
this.setData({
showMsg: 0
});
},
closeMsg: function (e) {
this.setData({
showMsg: 0
});
},
/**
/**
* 隐藏气泡
*/
hidePopup: function(e) {
this.setData({
hidePopup: 1
});
},
hidePopup: function (e) {
this.setData({
hidePopup: 1
});
},
/**
/**
* 点击参加活动按钮
*/
joinInQueue: function(e) {
let uid = app.getUid();
let activityId = this.data.activityInfo.activityId;
let isEnd = this.data.activityInfo.isEnd === 0 ? 0 : 1;
if (activityId && uid && !isEnd) {
this.addQueue(this.data.activityInfo.activityId, uid);
} else if (isEnd) {
this.setData({
showMsg: 1
});
} else if (!uid) {
let pages = getCurrentPages();
let referer = pages[pages.length - 1].route + '?' + stringify(this.data.shareInfo);
router.go('userCenter', { referer });
}
},
joinInQueue: function (e) {
let uid = app.getUid();
let activityId = this.data.activityInfo.activityId;
let isEnd = this.data.activityInfo.isEnd === 0 ? 0 : 1;
if (activityId && uid && !isEnd) {
this.addQueue(this.data.activityInfo.activityId, uid);
} else if (isEnd) {
this.setData({
showMsg: 1
});
} else if (!uid) {
let pages = getCurrentPages();
let referer = pages[pages.length - 1].route + '?' + stringify(this.data.shareInfo);
router.go('userCenter', {referer});
}
},
/**
/**
* 获取活动信息
*/
getActivityInfo: function(actId) {
return LimitModel.getActivityInfo(actId).then(res => { // 获取活动信息
console.log(res);
if (res.code === 200) {
let topBanner = helper.image(res.data.topBanner, 750, 352, 1);
let isBegin = res.data.isBegin;
let isDrawEnd = res.data.isDrawEnd;
let isEnd = res.data.isEnd;
let prizeType = res.data.prizeType;
let activityName = res.data.activityName;
let activityId = res.data.activityId;
let bgStyle = res.data.bgStyle && res.data.bgStyle.length > 0 ? res.data.bgStyle : this.data.bgStyle;
this.setData({
activityInfo: {
topBanner: topBanner,
isBegin: isBegin, // 是否已开始 0-未开始 1-进行中 2-已结束
isDrawEnd: isDrawEnd, // 是否已开奖 1-开奖 0-未开奖
isEnd: isEnd, // 是否已结束 1-结束 0-未结束
prizeType: prizeType, // 奖品类型1-有货币 2-优惠券 3-限购码
activityId: activityId,
activityName: activityName
},
bgStyle: bgStyle
getActivityInfo: function (actId) {
return LimitModel.getActivityInfo(actId).then(res => { // 获取活动信息
console.log(res);
if (res.code === 200) {
let topBanner = helper.image(res.data.topBanner, 750, 352, 1);
let isBegin = res.data.isBegin;
let isDrawEnd = res.data.isDrawEnd;
let isEnd = res.data.isEnd;
let prizeType = res.data.prizeType;
let activityName = res.data.activityName;
let activityId = res.data.activityId;
let bgStyle = res.data.bgStyle && res.data.bgStyle.length > 0 ? res.data.bgStyle : this.data.bgStyle;
this.setData({
activityInfo: {
topBanner: topBanner,
isBegin: isBegin, // 是否已开始 0-未开始 1-进行中 2-已结束
isDrawEnd: isDrawEnd, // 是否已开奖 1-开奖 0-未开奖
isEnd: isEnd, // 是否已结束 1-结束 0-未结束
prizeType: prizeType, // 奖品类型1-有货币 2-优惠券 3-限购码
activityId: activityId,
activityName: activityName
},
bgStyle: bgStyle
});
return Promise.resolve({code: res.code});
} else {
return Promise.reject({code: res.code});
}
});
return Promise.resolve({code: res.code});
} else {
return Promise.reject({code: res.code});
}
});
},
/**
},
/**
* 加入排队
*/
addQueue: function(actId, uid) {
if (!this.data.api_status) {
this.setData({
api_status: 1
});
LimitModel.addQueue(actId).then((res) => {
console.log('加入排队', res);
if (res.code === 200 && res.data) {
let sort = res.data.sort;
this.setData({
userInfo: Object.assign(this.data.userInfo, {sort: sort, isDrawline: 1}),
showMsg: 1,
api_status: 0
});
setTimeout(this.getQueueList, 1000);
// this.getQueueList(this.data.activityInfo.activityId, 0);
addQueue: function (actId, uid) {
if (!this.data.api_status) {
this.setData({
api_status: 1
});
LimitModel.addQueue(actId).then((res) => {
console.log('加入排队', res);
if (res.code === 200 && res.data) {
let sort = res.data.sort;
this.setData({
userInfo: Object.assign(this.data.userInfo, {sort: sort, isDrawline: 1}),
showMsg: 1,
api_status: 0
});
setTimeout(this.getQueueList, 1000);
// this.getQueueList(this.data.activityInfo.activityId, 0);
}
}).catch(() => {
console.log('错误');
this.setData({
api_status: 0
});
});
}
}).catch(() => {
console.log('错误');
this.setData({
api_status: 0
});
});
}
},
},
/**
/**
* 获取用户参与排队的信息
*/
getUserActivityInfo: function(actId) {
LimitModel.getUserActivityInfo(actId).then(res => {
console.log('getUserActivityInfo:', res);
this.setData({
userInfo: {
uid: res.data.uid,
headIco: helper.image(res.data.headIco, 128, 128, 1) || this.data.defaultAvatar,
isDrawline: res.data.isDrawline,
isLucky: res.data.isLucky,
sort: res.data.sort
}
});
if (this.data.activityInfo.isDrawEnd) {
this.setData({
showMsg: 1
getUserActivityInfo: function (actId) {
LimitModel.getUserActivityInfo(actId).then(res => {
console.log('getUserActivityInfo:', res);
this.setData({
userInfo: {
uid: res.data.uid,
headIco: helper.image(res.data.headIco, 128, 128, 1) || this.data.defaultAvatar,
isDrawline: res.data.isDrawline,
isLucky: res.data.isLucky,
sort: res.data.sort
}
});
if (this.data.activityInfo.isDrawEnd) {
this.setData({
showMsg: 1
});
}
});
}
});
},
},
/**
/**
* 获取排队列表
*/
getQueueList: function(actId, start = 0, limit = 50, isAdd = false) {
let that = this;
actId = actId || this.data.activityInfo.activityId;
return LimitModel.getQueueList(actId, start, limit).then(res => {
console.log(res);
if (res.data && res.data.length > 0) {
let result = [];
res.data.forEach((item, index) => {
if (!item.headIco) {
item.headIco = that.data.defaultAvatar;
} else {
item.headIco = helper.image(item.headIco, 100, 100, 1);
}
item.nickName = item.nickName || '用户' + item.uid;
item.nickName = item.nickName.length > 12 ? item.nickName.substring(0, 12) + '...' : item.nickName;
item.queueTime = this.formatTimeText(item.queueTime);
item.vipLevel = item.vipLevel || 0;
item.vipImage = this.data.vipImage[item.vipLevel];
let bgStyle = this.data.bgStyle;
let bgIndex = index % bgStyle.length;
item.background = helper.imgView(bgStyle[bgIndex], 340, 162, 1);
result.push(item);
getQueueList: function (actId, start = 0, limit = 50, isAdd = false) {
let that = this;
actId = actId || this.data.activityInfo.activityId;
return LimitModel.getQueueList(actId, start, limit).then(res => {
console.log(res);
if (res.data && res.data.length > 0) {
let result = [];
res.data.forEach((item, index) => {
if (!item.headIco) {
item.headIco = that.data.defaultAvatar;
} else {
item.headIco = helper.image(item.headIco, 100, 100, 1);
}
item.nickName = item.nickName || '用户' + item.uid;
item.nickName = item.nickName.length > 12 ? item.nickName.substring(0, 12) + '...' : item.nickName;
item.queueTime = this.formatTimeText(item.queueTime);
item.vipLevel = item.vipLevel || 0;
item.vipImage = this.data.vipImage[item.vipLevel];
let bgStyle = this.data.bgStyle;
let bgIndex = index % bgStyle.length;
item.background = helper.imgView(bgStyle[bgIndex], 340, 162, 1);
result.push(item);
});
if (isAdd) { // 如果是下拉则添加数据
this.setData({
queueList: this.data.queueList.concat(result)
});
} else { // 普通情况下覆盖
this.setData({
queueList: result
});
}
return Promise.resolve({code: 200, data: this.data.queueList});
} else {
return Promise.reject({code: 203, message: '获取失败'});
}
});
if (isAdd) { // 如果是下拉则添加数据
this.setData({
queueList: this.data.queueList.concat(result)
});
} else { // 普通情况下覆盖
this.setData({
queueList: result
});
}
return Promise.resolve({code: 200, data: this.data.queueList});
} else {
return Promise.reject({code: 203, message: '获取失败'});
}
});
},
scrollPage: function(id) { // 滚动页面到对应位置
if (id) {
let item_query = wx.createSelectorQuery();
item_query.select('#' + id).boundingClientRect();
item_query.selectViewport().scrollOffset();
item_query.exec(res => {
console.log('scroll:', res);
if (res.length > 0 && this.data.queueList.length > 6 && res[0].top !== 0) {
wx.pageScrollTo({
scrollTop: res[0].top + res[1].scrollTop,
duration: 500
});
// this.setData({
// scrollTop: res[0].top + this.data.tempScrollTop
// })
},
scrollPage: function (id) { // 滚动页面到对应位置
if (id) {
let item_query = wx.createSelectorQuery();
item_query.select('#' + id).boundingClientRect();
item_query.selectViewport().scrollOffset();
item_query.exec(res => {
console.log('scroll:', res);
if (res.length > 0 && this.data.queueList.length > 6 && res[0].top !== 0) {
wx.pageScrollTo({
scrollTop: res[0].top + res[1].scrollTop,
duration: 500
});
// this.setData({
// scrollTop: res[0].top + this.data.tempScrollTop
// })
}
});
}
});
}
},
},
/**
/**
* 跳转到活动说明的H5页面
*/
navigateToDescPage: function() {
router.goUrl(this.data.h5PageUrl[0].url + '&title=' + this.data.h5PageUrl[0].title);
},
navigateToDescPage: function () {
router.goUrl(this.data.h5PageUrl[0].url + '&title=' + this.data.h5PageUrl[0].title);
},
/**
/**
*跳转到中奖名单页面
*/
navigateToPrizeUserList: function() {
if (this.data.activityInfo.isDrawEnd) {
router.go('prizeUserList', {actId: this.data.activityInfo.activityId});
}
},
navigateToPrizeUserList: function () {
if (this.data.activityInfo.isDrawEnd) {
router.go('prizeUserList', {actId: this.data.activityInfo.activityId});
}
},
/**
/**
* 跳转到个人中心限购码页面
*/
navigateToUserCodePage: function() {
if (this.data.userInfo.isLucky) {
router.go('userCenter');
}
},
navigateToUserCodePage: function () {
if (this.data.userInfo.isLucky) {
router.go('userCenter');
}
},
/**
* 提交formId消息模板
*/
submitFormId: function (e) {
console.log(e);
commonModel.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getUnionID() || app.getOpenID() || '',
miniappType: app.getMiniappType()
});
},
/**
/**
* 处理接口返回的图片url
*/
formatImgUrl: function(url, mode, width, height) {
return url.replace(/{mode}/g, mode).replace(/{width}/g, width).replace(/{height}/g, height);
},
formatTimeText: function(time) {
let new_time;
if (time < 60) {
new_time = time + 'sec';
} else if (time >= 60 && time < 60 * 60) {
new_time = parseInt(time / 60, 10) + 'min';
} else if (time >= 60 * 60 && time < 60 * 60 * 24) {
new_time = parseInt(time / (60 * 60), 10) + 'hour';
} else if (time >= 60 * 60 * 24) {
new_time = parseInt(time / (60 * 60 * 24), 10) + 'day';
formatImgUrl: function (url, mode, width, height) {
return url.replace(/{mode}/g, mode).replace(/{width}/g, width).replace(/{height}/g, height);
},
formatTimeText: function (time) {
let new_time;
if (time < 60) {
new_time = time + 'sec';
} else if (time >= 60 && time < 60 * 60) {
new_time = parseInt(time / 60, 10) + 'min';
} else if (time >= 60 * 60 && time < 60 * 60 * 24) {
new_time = parseInt(time / (60 * 60), 10) + 'hour';
} else if (time >= 60 * 60 * 24) {
new_time = parseInt(time / (60 * 60 * 24), 10) + 'day';
}
return new_time;
}
return new_time;
}
}, Actionsheet));
... ...
... ... @@ -141,8 +141,10 @@
</view>
</block>
</view>
<view class='invite-button' hidden='{{hideInviteButton}}' bindtap='inviteFriends'>
邀请好友助力排队
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<button class='invite-button' hidden='{{hideInviteButton}}' form-type='submit' bindtap='inviteFriends'>
邀请好友助力排队
</button>
</form>
</view>
<template is="zan-actionsheet" data="{{...actionSheet}}" />
\ No newline at end of file
... ...
... ... @@ -198,6 +198,18 @@ Page(Object.assign({
inviteFriends: function(e) {
this.share();
},
/**
* 提交formId消息模板
*/
submitFormId: function (e) {
commonModel.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getUnionID() || app.getOpenID() || '',
miniappType: app.getMiniappType()
});
},
/**
* 获取排队列表
... ...
... ... @@ -30,8 +30,10 @@
</view>
</view>
</block>
<view class='invite-button' hidden='{{hideInviteButton}}' bindtap='inviteFriends'>
邀请好友助力排队
</view>
<form bindsubmit='submitFormId' report-submit='true'>
<button class='invite-button' hidden='{{hideInviteButton}}' form-type='submit' bindtap='inviteFriends'>
邀请好友助力排队
</button>
</form>
</view>
<template is="zan-actionsheet" data="{{...actionSheet}}" />
\ No newline at end of file
... ...
... ... @@ -33,7 +33,7 @@
"list": []
},
"miniprogram": {
"current": 8,
"current": 4,
"list": [
{
"id": 0,
... ...