var auth = require("../../../utils/auth.js"), rq = require("../../../utils/request.js");
var e = getApp(), app = e, s = e.globalData.setting, os = s, app_d = e.globalData;
var regeneratorRuntime = require('../../../utils/runtime.js');
var  ut = require("../../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    iurl: s.imghost,
	user:app_d.userInfo,
	zl_act:null, //助力活动
	s_num:0,     //分享的人数
	taskId:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     var helpid=options.helpid;
	   var taskId = options.taskId;
	  	this.data.taskId = taskId;
     this.init(helpid);
     var nav_b = this.selectComponent("#nav_b"); //组件的id
     nav_b.set_name("助力", "/pages/user/assistance/assistance");

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function (e) {

  },

  // ----初始化----
  init:function(helpid) {
    var user_id = getApp().globalData.user_id;
    var store_id = os.stoid;
	var th=this;

	//链式调用接口,先获取活动,在获取参与活动的人数
    getApp().request.promiseGet("/api/weshop/marketing/help/help/act/get", {
      data: {
        storeId: store_id,
		helpId: helpid
      }
    }).then(res => {
        if(res.data.code==0){
			th.setData({zl_act:res.data.data});
			return getApp().request.promiseGet("/api/weshop/marketing/help/involve/help/act/people/count", {
				 data: {
				 	 storeId: store_id,
				   helpId: helpid,
					 taskId:th.data.taskId
				 }
			})
		}
		return  ut.null_promise();

    }).then(res=>{
		if(res.data.code==0){
			 th.setData({s_num:res.data.data.countAll});
		}
	})

  },


  cklie_button:function(){
	  getApp().goto("/pages/user/assistance/assistance")
  }
})
