Authored by lea guo

yohood原价购

... ... @@ -59,6 +59,14 @@ Component({
});
},
},
isLogin: {
type: Boolean,
value: false,
},
activityStatus: {
type: Number,
status: 1,
},
},
/**
... ... @@ -193,5 +201,17 @@ Component({
miniapp_type: app.getMiniappType(),
});
},
goLogin() {
const event = global.event;
event.emit('user-is-login', {
logged: this.logged,
loginSuccess: this.loginSuccess,
});
},
logged() {},
loginSuccess() {},
},
});
... ...
<!-- page/subPackage/pages/zeroSell/components/action-bar.wxml -->
<view class="action-bar">
<view class="action-bar" wx:if="{{isLogin}}">
<block wx:if="{{status === 1}}">
<view class="action-item over">
<text>距开始</text>
... ... @@ -20,6 +20,20 @@
<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 || activityStatus === 4 || activityStatus === 5}}">
<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>
... ...
@import '../action-bar.wxss';
.ok {
.ok,
.confirm {
background-color: #132f48;
}
.remaining-time {
... ... @@ -12,3 +13,6 @@
.share {
background-color: #64ad88;
}
.action-item {
border-radius: unset;
}
... ...
import ZeroSellService from './service/zero-sell'
import CommonService from './service/common'
import ZeroSellService from './service/zero-sell';
import CommonService from './service/common';
import {
decodePhoneNumber,
getUnionID,
decodeUnionId,
openAuthorizeSettings
openAuthorizeSettings,
} from '../../utils/login';
import {
getQRCodeSource
} from '../../libs/miniQRCodeRoute'
import {
Actionsheet,
Toast
} from '../../vendors/zanui/index';
import router from './router/router'
import {wrapperName} from './helper'
import {formatImageUrl} from '../../utils/util'
import {jumpByUrl} from '../../libs/urlRoute';
import { getQRCodeSource } from '../../libs/miniQRCodeRoute';
import { Actionsheet, Toast } from '../../vendors/zanui/index';
import router from './router/router';
import { wrapperName } from './helper';
import { formatImageUrl } from '../../utils/util';
import { jumpByUrl } from '../../libs/urlRoute';
import {
yasReport,
YB_PAGE_OPEN_L,
YB_LUCK_DT_GDS_C,
YB_LUCK_DT_JOIN_C
YB_LUCK_DT_JOIN_C,
} from '../../libs/yas';
const ACTIVITY = {
... ... @@ -30,8 +25,8 @@ const ACTIVITY = {
START: 2, // 活动开始
END: 3, // 活动结束
LUCK: 4, // 活动已开奖、抽奖结束
END_LESS_PEOPLE: 5 // 人数不足
}
END_LESS_PEOPLE: 5, // 人数不足
};
const ACTION_BAR_STATUS = {
UNKNOWN: 0,
... ... @@ -41,611 +36,663 @@ const ACTION_BAR_STATUS = {
WAIT: 4, // 等待抽奖中
LUCK: 5, // 抽奖结束
END: 6, // 活动结束
PEOPLE_LIMIT_WAIT: 7 // 人数达到活动限制、已满员、人数不足统一为待开奖状态
}
PEOPLE_LIMIT_WAIT: 7, // 人数达到活动限制、已满员、人数不足统一为待开奖状态
};
let app = getApp();
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: [],
actionsheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
isNewShareStyle: true,
// unionUserImageUrl: 'http://img12.static.yhbimg.com/sns/2018/08/02/15/029b6acc4f8bc0620ecd7ec2133fcf900c.png',
unionUserImageUrl: './images/share_tip@2x.png',
actions: [{
name: '分享给好友',
className: 'action-class',
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,
openType: 'share',
image_src: '../../images/share_wechat@2x.png',
page: 1,
codeList: [],
actionsheet: {
componentId: 'shareActionSheet',
show: false,
closeOnClickOverlay: true,
cancelText: '取消',
isNewShareStyle: true,
// unionUserImageUrl: 'http://img12.static.yhbimg.com/sns/2018/08/02/15/029b6acc4f8bc0620ecd7ec2133fcf900c.png',
unionUserImageUrl: './images/share_tip@2x.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',
},
],
},
animation: null,
shareFlag: false,
notice: {},
lottery: {},
remainingTime: '',
},
{
name: '生成海报分享',
className: 'action-class',
loading: false,
image_src: '../../images/share_wxpeng@2x.png'
/**
* 生命周期函数--监听页面加载
*/
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;
}
]
},
animation: null,
shareFlag: false,
notice: {},
lottery: {}
},
/**
* 生命周期函数--监听页面加载
*/
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._getMineCode();
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();
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,
});
} else {
this._init();
}
}, 1100)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
wx.hideLoading();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.showLoading({
mask: true
});
this._init().then(() => {
wx.stopPullDownRefresh();
})
this._getMineCode()
},
/**
* 页面上拉触底事件的处理函数
*/
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) {
yasReport(YB_LUCK_DT_GDS_C, {
ACTIVITY_ID: this.data.actPrizeId,
PRD_SKN: e.detail.product_skn,
TAB_ID: this.data.tabIdx
});
wx.navigateToMiniProgram({
appId: 'wx207f18be42db9028',
path: `pages/group/detail?productSkn=${e.detail.product_skn}&activityId=${e.detail.activity_id}&page_param=${e.detail.activity_id}`
})
},
goLogin() {
const event = global.event;
event.emit('user-is-login', {logged: this.logged, loginSuccess: this.loginSuccess});
},
logged() {
},
loginSuccess() {
},
_getMineCode() {
if (this.data.uid) {
this.service.fetchMyPrizeList({uid: this.data.uid, actPrizeId: this.data.actPrizeId}).then(res => {
let len = res.data.length > 3 ? 3 : res.data.length;
if (len) {
res.data.map((value) => {
value.user_thumb = formatImageUrl(value.user_thumb, 60, 60);
})
setTimeout(() => {
app = app || getApp();
let uid = app.getUid();
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()
hasUnionID:
app.globalData.WXUnion_ID !== null &&
app.globalData.WXUnion_ID !== '' &&
app.globalData.WXUnion_ID !== undefined
? true
: false,
isLogin: app.isLogin(),
uid,
});
this._getMineCode();
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,
});
this._init().then(() => {
wx.stopPullDownRefresh();
});
this._getMineCode();
},
/**
* 页面上拉触底事件的处理函数
*/
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) {
yasReport(YB_LUCK_DT_GDS_C, {
ACTIVITY_ID: this.data.actPrizeId,
PRD_SKN: e.detail.product_skn,
TAB_ID: this.data.tabIdx,
});
wx.navigateToMiniProgram({
appId: 'wx207f18be42db9028',
path: `pages/group/detail?productSkn=${
e.detail.product_skn
}&activityId=${e.detail.activity_id}&page_param=${
e.detail.activity_id
}`,
});
},
_getMineCode() {
if (this.data.uid) {
this.service
.fetchMyPrizeList({
uid: this.data.uid,
actPrizeId: this.data.actPrizeId,
})
.then(res => {
let len = res.data.length > 3 ? 3 : 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,
});
}
})
}.bind(this), 800);
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,
});
}
});
},
}
})
}
},
_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,
_loadGroupList(page) {
this.commonService
.getGroupList({
limit: 20,
page,
})
} else {
this.setData({
loading: false
.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,
};
return Promise.all([
this.service.getDetail(params),
this.service.getRecommend(params),
this.service.getRecentAvatars(params),
])
.then(([r1, r2, r3]) => {
wx.hideLoading();
if (r1.code === 200 && r1.data) {
let product = r1.data;
let qrcode = this.service.getQrCode({
shareUid: app.getUid(),
actPrizeId: this.data.actPrizeId,
});
let snapData = {
product_name: product.name,
default_image: product.cover_img,
product_price: product.price,
product_qrCode: qrcode,
};
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;
}),
myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
snapData,
notice: JSON.parse(product.notice || '{}'),
lottery: JSON.parse(product.lottery_info || '{}'),
});
this._setActionStatus();
} else {
return Promise.reject();
}
})
.catch(e => {
wx.hideLoading();
console.error(e);
});
},
_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;
}
}
}
}).catch(error => {
this.setData({
loading: false
});
});
},
_init() {
let params = {
actPrizeId: this.data.actPrizeId
};
return Promise.all([
this.service.getDetail(params),
this.service.getRecommend(params),
this.service.getRecentAvatars(params)
]).then(([r1, r2, r3]) => {
wx.hideLoading();
if (r1.code === 200 && r1.data) {
let product = r1.data;
let qrcode = this.service.getQrCode({
shareUid: app.getUid(),
actPrizeId: this.data.actPrizeId
this.setData({
actionStatus: status,
});
},
let snapData = {
product_name: product.name,
default_image: product.cover_img,
product_price: product.price,
product_qrCode: qrcode
};
_isInActivity() {
return this.data.myPrizeCount > 0;
},
changeActionStatus() {
wx.showLoading({
mask: true,
});
this._init();
this._getMineCode();
},
share(event) {
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;
}),
myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
snapData,
notice: JSON.parse(product.notice || '{}'),
lottery: JSON.parse(product.lottery_info || '{}')
'actionsheet.show': true,
});
},
this._setActionStatus();
} else {
return Promise.reject();
}
}).catch((e) => {
wx.hideLoading();
console.error(e);
});
},
_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;
_jumpBanner() {
if (this.data.bannerUrl == null) {
return;
}
} else {
if (activityStatus === ACTIVITY.END_LESS_PEOPLE || activityStatus === ACTIVITY.END) {
status = ACTION_BAR_STATUS.PEOPLE_LIMIT_WAIT;
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 {
status = ACTION_BAR_STATUS.END;
return Promise.resolve();
}
}
} 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() {
wx.showLoading({
mask: true
});
this._init();
this._getMineCode();
},
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 => {
},
handleZanActionsheetCancel({ componentId }) {
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: `【0元抽奖】点一下,免费拿走${this.data.product.name}`,
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看1吧!'
};
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/detail?actPrizeId=${this.data.product.id}`
};
} else if (res.from === 'button') {
// 用户点击分享按钮
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/zeroSell/detail?actPrizeId=${this.data.product.id}&shareUid=${app.getUid()}`,
};
}
},
goList(e) {
let tab = e.target.dataset.index
router.go('index', {tabIndex: tab || 0, reload: 0});
},
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,
});
'actionsheet.show': false,
});
},
handleZanActionsheetClick({ componentId, index }) {
this.setData({
'actionsheet.show': false,
});
if (index === 1) {
router.go('snapShare', this.data.snapData);
}
});
} else {
openAuthorizeSettings(function (response) {
if (response.isHaveUnionID) {
that.setData({
hasUnionID: true,
})
},
onShareAppMessage(res) {
let params = {
TITLE: `【0元抽奖】点一下,免费拿走${this.data.product.name}`,
DESC: '我在YO!LUCK发现一个不错的商品赶快来看看1吧!',
};
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/detail?actPrizeId=${this.data.product.id}`,
};
} else if (res.from === 'button') {
// 用户点击分享按钮
return {
title: params.TITLE, // 分享标题
desc: params.DESC, // 分享描述
path: `/pages/zeroSell/detail?actPrizeId=${
this.data.product.id
}&shareUid=${app.getUid()}`,
};
}
;
});
}
},
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)
},
goList(e) {
let tab = e.target.dataset.index;
router.go('index', { tabIndex: tab || 0, reload: 0 });
},
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 {
if (result.is_register) {
that.showZanToast({
title: '欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',
success: function () {
let uid = app.globalData.userInfo.uid > 0 ? app.globalData.userInfo.uid : 0;
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(),
});
}
}, 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',
});
}
})
} 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) {
})
}
},
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.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber',
});
}
})
} else {
wx.navigateTo({
url: '/pages/bindPhoneNumber/bindPhoneNumber'
});
}
},
});
} else {
wx.showModal({
title: '提示',
content:
'当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
});
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
},
}, Actionsheet, Toast))
\ No newline at end of file
},
},
Actionsheet,
Toast,
),
);
... ...
... ... @@ -31,7 +31,7 @@
</view>
</view>
<view class="fellow-bar" wx:if="{{product.status && !shareFlag}}">
<block wx:if="{{product.status === 3}}">
<block wx:if="{{product.status === 3 || product.status === 4 || product.status === 5}}">
<view class="endTip">
<text>{{notice.content || '本场活动已结束,请关注开奖消息通知'}}</text>
</view>
... ... @@ -41,26 +41,7 @@
</block>
</view>
<view class="action-bar">
<action-bar start-time="{{product.end_time}}" wx:if="{{isLogin}}" status="{{actionStatus}}" num="{{myPrizeCount}}" share-uid="{{shareUid}}" act-prize-id="{{actPrizeId}}" bindgetcode="changeActionStatus" bindshare="share" copyText="{{lottery.miniappCopy}}" text="{{lottery.miniappTip}}" bindgaincodesuccess="reportSuccess" type="{{lottery.miniappType}}"></action-bar>
<block wx:else>
<view class="action-bar2">
<block wx:if="{{product.status === 1}}">
<button class="action-item over" bindtap="goLogin">距开始</button>
</block>
<block wx:if="{{product.status === 2}}">
<button class="action-item confirm" bindtap="goLogin">参加抽奖</button>
</block>
<block wx:if="{{product.status === 3}}">
<button class="action-item over" bindtap="goLogin">待开奖</button>
</block>
<block wx:if="{{product.status === 4}}">
<button class="action-item over" bindtap="goLogin">活动已结束</button>
</block>
<block wx:if="{{product.status === 5}}">
<button class="action-item over" bindtap="goLogin">待开奖</button>
</block>
</view>
</block>
<action-bar activity-status="{{product.status}}" start-time="{{product.end_time}}" is-login="{{isLogin}}" status="{{actionStatus}}" num="{{myPrizeCount}}" share-uid="{{shareUid}}" act-prize-id="{{actPrizeId}}" bindgetcode="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/actionsheet/index.wxml" />
... ...
... ... @@ -49,14 +49,6 @@
border-radius: unset;
}
.confirm {
background-color: #d0021b;
}
.over {
background-color: #b0b0b0;
}
.action-list {
flex: 0;
position: relative;
... ...