Commit f5ac842b1b82ab899cfbab22775fae37ce1cd1fc

Authored by vking
1 parent d5ca6391

master-activity

1 // components/activity/enter.js 1 // components/activity/enter.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
2 Component({ 4 Component({
3 /** 5 /**
4 * 组件的属性列表 6 * 组件的属性列表
5 */ 7 */
6 properties: { 8 properties: {
7 - 9 + hasInHome:Boolean,
8 }, 10 },
9 11
10 /** 12 /**
@@ -29,21 +31,24 @@ Component({ @@ -29,21 +31,24 @@ Component({
29 this.getActivity() 31 this.getActivity()
30 }, 32 },
31 getActivity(){ 33 getActivity(){
32 - //  
33 - this.setData({  
34 - displayType:1,  
35 - activity:{  
36 - id:1,  
37 - background:'#F04866',  
38 - banner:'http://qn.colorcun.com/activity/images/banner.png',  
39 - task:{  
40 - id:1,  
41 - name:'开工专享红包',  
42 - desc:'开工福利,胡吃海喝',  
43 - money:'18.8',  
44 - icon:'http://qn.colorcun.com/activity/images/icon.png',  
45 - status:0,  
46 - }, 34 + //hasInHome 金额少于1000 只显示小图
  35 + App.Task.GetTaskInfo({pos:'home'}).then(res=>{
  36 + let time=new Date()/1000
  37 + let activity=res.data.activity
  38 + activity.task=res.data.task
  39 + let displayType=0//浮层
  40 + if(activity.status==1 && activity.starttime<time && time<activity.endtime){
  41 + if(activity.balance>1000 && activity.task.status!=2){
  42 + displayType=1//弹框
  43 + App.Task.SetTaskInfo({//领取任务
  44 + aid:activity.id,
  45 + tid:activity.task.id,
  46 + })
  47 + }
  48 + this.setData({
  49 + displayType:displayType,
  50 + activity:activity
  51 + })
47 } 52 }
48 }) 53 })
49 }, 54 },
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 <view class="money"> 15 <view class="money">
16 <view class="money-tip flex-cc">订包间,消费抵现金</view> 16 <view class="money-tip flex-cc">订包间,消费抵现金</view>
17 <view class="money-views flex-bc"> 17 <view class="money-views flex-bc">
18 - <view class="money-number">18.8</view> 18 + <view class="money-number">{{activity.task.price}}</view>
19 <view class="money-dw">元</view> 19 <view class="money-dw">元</view>
20 </view> 20 </view>
21 <navigator url="/pack-activity/pages/index?id={{activity.id}}" hover-class="navigator-hover"> 21 <navigator url="/pack-activity/pages/index?id={{activity.id}}" hover-class="navigator-hover">
  1 +// pack-activity/pages/index.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +Page({
  5 +
  6 + /**
  7 + * 页面的初始数据
  8 + */
  9 + data: {
  10 + activity:null,
  11 + count:0,
  12 + },
  13 +
  14 + /**
  15 + * 生命周期函数--监听页面加载
  16 + */
  17 + onLoad: function (options) {
  18 + this.options=options
  19 + },
  20 +
  21 + /**
  22 + * 生命周期函数--监听页面初次渲染完成
  23 + */
  24 + onReady: function () {
  25 +
  26 + },
  27 +
  28 + /**
  29 + * 生命周期函数--监听页面显示
  30 + */
  31 + onShow: function () {
  32 + this.GetTaskInfos()
  33 + },
  34 +
  35 + /**
  36 + * 生命周期函数--监听页面隐藏
  37 + */
  38 + onHide: function () {
  39 +
  40 + },
  41 +
  42 + /**
  43 + * 生命周期函数--监听页面卸载
  44 + */
  45 + onUnload: function () {
  46 +
  47 + },
  48 +
  49 + /**
  50 + * 页面相关事件处理函数--监听用户下拉动作
  51 + */
  52 + onPullDownRefresh: function () {
  53 +
  54 + },
  55 +
  56 + /**
  57 + * 页面上拉触底事件的处理函数
  58 + */
  59 + onReachBottom: function () {
  60 +
  61 + },
  62 +
  63 + /**
  64 + * 用户点击右上角分享
  65 + */
  66 + onShareAppMessage: function () {
  67 + return {
  68 + title:this.data.activity.title,
  69 + path:'/pages/reserve/index',
  70 + imageUrl:this.data.activity.bgurl,
  71 + }
  72 + },
  73 + GetTaskInfos(){
  74 + App.Task.GetTaskInfos({
  75 + aid:this.options.aid,
  76 + }).then(res=>{
  77 + let activity=res.data.activity
  78 + activity.list=res.data.task
  79 + let count=0
  80 + activity.list.forEach(t=>{
  81 + if(t.status==2){
  82 + count+=(t.price*1)
  83 + }
  84 + })
  85 + this.setData({
  86 + count:count.toFixed(2),
  87 + activity:activity
  88 + })
  89 + })
  90 + },
  91 + taskNextDo(e){
  92 + let index=util.attr(e,'index')
  93 + let task=this.data.activity.list[index]
  94 + let tid=task.id
  95 + ,path=util.http_build_query({aid:this.data.activity.id,tid:tid},task.task_url||'pack-activity/pages/demo')
  96 + if(task.status==0){
  97 + App.Task.SetTaskInfo({//领取任务
  98 + aid:this.data.activity.id,
  99 + tid:tid,
  100 + }).then(()=>{
  101 + this.GetTaskInfos()
  102 + })
  103 + }else if(task.status==1){
  104 + wx.navigateTo({
  105 + url: path
  106 + })
  107 + }else{
  108 + wx.navigateTo({
  109 + url: 'pack-activity/pages/money'
  110 + })
  111 + }
  112 + },
  113 +})
  1 +{
  2 + "backgroundTextStyle":"light",
  3 + "navigationBarBackgroundColor": "#fff",
  4 + "navigationBarTextStyle":"black",
  5 + "usingComponents": {
  6 + "nav":"/components/nav/nav"
  7 + }
  8 +}
  1 +<!--pack-activity/pages/index.wxml-->
  2 +<nav hasHome>周到安排</nav>
  3 +<view class="pages" style="background-color: {{activity.element}}">
  4 + <view class="content">
  5 + <view class="share-but">
  6 + <button class="button-none" open-type="share">D E M O</button>
  7 + </view>
  8 + </view>
  9 +</view>
  1 +/* pack-activity/pages/index.wxss */
  2 +.pages{
  3 +
  4 +}
  5 +.content{
  6 + padding-top: 840rpx;
  7 + height: 1020rpx;
  8 + width: calc(100% - 40rpx);
  9 + margin: 0 20rpx 0;
  10 +}
  11 +.share-but{
  12 + width:400rpx;
  13 + height:80rpx;
  14 + background:linear-gradient(180deg,rgba(252,190,38,1) 0%,rgba(255,233,128,1) 100%);
  15 + box-shadow:0rpx 4rpx 8rpx 0rpx rgba(182,43,68,1);
  16 + border-radius:40rpx;
  17 +
  18 + font-size:32rpx;
  19 + font-weight:600;
  20 + color:rgba(230,34,57,1);
  21 + line-height:80rpx;
  22 + text-align: center;
  23 + margin-left: calc(50% - 200rpx);
  24 +}
  25 +.share-but .button-none{
  26 + height: 80rpx;
  27 + line-height:80rpx;
  28 +}
@@ -15,7 +15,7 @@ Page({ @@ -15,7 +15,7 @@ Page({
15 * 生命周期函数--监听页面加载 15 * 生命周期函数--监听页面加载
16 */ 16 */
17 onLoad: function (options) { 17 onLoad: function (options) {
18 - 18 + this.options=options
19 }, 19 },
20 20
21 /** 21 /**
@@ -29,20 +29,7 @@ Page({ @@ -29,20 +29,7 @@ Page({
29 * 生命周期函数--监听页面显示 29 * 生命周期函数--监听页面显示
30 */ 30 */
31 onShow: function () { 31 onShow: function () {
32 - App.Task.GetTaskInfos().then(res=>{  
33 - let activity=res.data.activity  
34 - activity.list=res.data.task  
35 - let count=0  
36 - activity.list.forEach(t=>{  
37 - if(t.status==2){  
38 - count+=(t.price*1)  
39 - }  
40 - })  
41 - this.setData({  
42 - count:count.toFixed(2),  
43 - activity:activity  
44 - })  
45 - }) 32 + this.GetTaskInfos()
46 }, 33 },
47 34
48 /** 35 /**
@@ -82,5 +69,45 @@ Page({ @@ -82,5 +69,45 @@ Page({
82 path:'/pages/reserve/index', 69 path:'/pages/reserve/index',
83 imageUrl:this.data.activity.bgurl, 70 imageUrl:this.data.activity.bgurl,
84 } 71 }
85 - } 72 + },
  73 + GetTaskInfos(){
  74 + App.Task.GetTaskInfos({
  75 + aid:this.options.id,
  76 + }).then(res=>{
  77 + let activity=res.data.activity
  78 + activity.list=res.data.task
  79 + let count=0
  80 + activity.list.forEach(t=>{
  81 + if(t.status==2){
  82 + count+=(t.price*1)
  83 + }
  84 + })
  85 + this.setData({
  86 + count:count.toFixed(2),
  87 + activity:activity
  88 + })
  89 + })
  90 + },
  91 + taskNextDo(e){
  92 + let index=util.attr(e,'index')
  93 + let task=this.data.activity.list[index]
  94 + let tid=task.id
  95 + ,path=util.http_build_query({aid:this.data.activity.id,tid:tid},task.task_url||'demo')
  96 + if(task.status==0){
  97 + App.Task.SetTaskInfo({//领取任务
  98 + aid:this.data.activity.id,
  99 + tid:tid,
  100 + }).then(()=>{
  101 + this.GetTaskInfos()
  102 + })
  103 + }else if(task.status==1){
  104 + wx.navigateTo({
  105 + url: path
  106 + })
  107 + }else{
  108 + wx.navigateTo({
  109 + url: '/pack-activity/pages/money'
  110 + })
  111 + }
  112 + },
86 }) 113 })
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 <view class="item-title">{{item.title}}</view> 27 <view class="item-title">{{item.title}}</view>
28 <view class="item-desc">{{item.desc}}</view> 28 <view class="item-desc">{{item.desc}}</view>
29 </view> 29 </view>
30 - <view class="opt"> 30 + <view class="opt" bindtap="taskNextDo" data-index="{{index}}">
31 <view class="opt-button status{{item.status}}">{{['领取奖励','去完成','去查看'][item.status]}}</view> 31 <view class="opt-button status{{item.status}}">{{['领取奖励','去完成','去查看'][item.status]}}</view>
32 <view class="opt-money">{{item.price}}元红包</view> 32 <view class="opt-money">{{item.price}}元红包</view>
33 </view> 33 </view>
@@ -140,4 +140,4 @@ @@ -140,4 +140,4 @@
140 bindactive="caixiActive" id="caixi" 140 bindactive="caixiActive" id="caixi"
141 ></caixi> 141 ></caixi>
142 <fb></fb> 142 <fb></fb>
143 -<activity-enter></activity-enter>  
  143 +<activity-enter hasInHome></activity-enter>