Authored by lea guo

yohood原价购

// page/subPackage/pages/zeroSell/components/action-bar.js
import ZeroSellService from '../../service/zero-sell';
import CommonService from '../../service/common';
const event = global.event;
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
status: {
type: Number,
value: 1,
},
num: {
type: Number,
value: 0,
},
shareUid: {
type: Number,
value: 0,
},
actPrizeId: {
type: Number,
value: 0,
},
copyText: {
type: String,
value: '',
},
text: {
type: String,
value: '',
},
type: {
type: Number,
value: 0,
},
},
/**
* 组件的初始数据
*/
data: {
show: false,
code: '',
error: false,
fellow: false,
},
ready() {
this.service = new ZeroSellService();
this.commonService = new CommonService();
},
/**
* 组件的方法列表
*/
methods: {
fetchCode() {
wx.showLoading({
mask: true,
});
event.emit('user-is-login', {
logged: this.logged.bind(this),
loginSuccess: function() {},
});
},
logged(userInfo) {
this.service
.fetchCode({
shareUid: this.properties.shareUid,
uid: app.getUid(),
actPrizeId: this.properties.actPrizeId,
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.actPrizeId);
} 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('getcode');
},
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('getcode');
},
openFellowAlert() {
this.setData({
fellow: true,
});
},
hiddenAlert(e) {
this.setData({
show: false,
error: false,
fellow: false,
});
this.triggerEvent('getcode');
},
submitFormId(e) {
return this.commonService.addWechatFormId({
formId: e.detail.formId,
uid: app.getUid() || 0,
openId: app.getOpenID() || '',
miniapp_type: app.getMiniappType(),
});
},
},
});
... ...
{
"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">
<block wx:if="{{status === 1}}">
<view class="action-item over">即将开始</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}}">
<view class="action-item ok" bindtap="goShare">邀请好友参加,增加中奖率</view>
</block>
<block wx:elif="{{status === 4}}">
<view class="action-item confirm" bindtap="goMyList">我的抽奖码({{num}})</view>
</block>
<block wx:elif="{{status === 5}}">
<view class="action-item confirm" bindtap="goMyList">我的抽奖码({{num}})</view>
<view class="action-item ok" bindtap="openFellowAlert">查看开奖结果</view>
</block>
<block wx:elif="{{status === 6}}">
<view class="action-item over">活动已结束</view>
</block>
<block wx:elif="{{status === 7}}">
<block wx:if="{{num > 0}}">
<view class="action-item confirm" bindtap="goMyList">我的抽奖码({{num}})</view>
</block>
<block wx:else>
<view class="action-item over">活动已结束</view>
</block>
</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 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';
.ok {
background-color: #132f48;
}
... ...
... ... @@ -9,7 +9,7 @@
"avatars": "./components/avatar-swiper",
"help": "./components/help",
"fellow-bar": "./components/fellow-bar",
"action-bar": "./components/action-bar",
"action-bar": "./components/yohoodLottery/action-bar",
"zero-alert": "./components/alert",
"group-recommend": "./components/group-recommend"
}
... ...
... ... @@ -46,14 +46,11 @@
<action-bar 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">
<view class="action-item action-list" bindtap="goList">
<image class="action-image" src="./images/list_icon@2x.png"></image>
</view>
<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">0元参加抽奖</button>
<button class="action-item confirm" bindtap="goLogin">参加抽奖</button>
</block>
<block wx:if="{{product.status === 3}}">
<button class="action-item over" bindtap="goLogin">待开奖</button>
... ...
... ... @@ -33,7 +33,7 @@
"list": []
},
"miniprogram": {
"current": 6,
"current": 5,
"list": [
{
"id": 0,
... ... @@ -74,7 +74,7 @@
"id": 5,
"name": "YOLUCK DETAIL",
"pathName": "pages/zeroSell/detail",
"query": "actPrizeId=16",
"query": "actPrizeId=224",
"scene": null
},
{
... ...