|
楼主 |
发表于 2016-4-12 15:37:55
|
显示全部楼层
本帖最后由 zhouge 于 2016-4-12 15:39 编辑
- define(function(require){
- var $ = require("jquery");
- var justep = require("$UI/system/lib/justep");
-
- var Model = function(){
- this.callParent();
- };
- Model.prototype.modelParamsReceive = function(event){
- if (this.params != undefined) {
- //用户编号
- if(localStorage.getItem("userid")){
- this._userId=localStorage.getItem("userid");
- }else{
- justep.Shell.showPage("login");
- }
- var vmadData = this.comp("vmadData");
- vmadData.filters.setVar("user", this._userId);
- var vokData = this.comp("VokData");
- vokData.filters.setVar("user", this._userId);
- vokData.filters.setVar("username", localStorage.getItem("username"));
- //广告位编号
- this._aid=this.params.id;
- vmadData.filters.setVar("id",this._aid);
- vokData.filters.setVar("id",this._aid);
- vmadData.refreshData();
- }
- };
- Model.prototype.modelLoad = function(event){
- localStorage.setItem("userid","12345");
- localStorage.setItem("username","zhouge");
- };
- //完成浏览广告任务
- Model.prototype.Vok = function(){
- $(".vpr").addClass("d")
- //向服务器发送完成任务数据
- $(".v-faq").html("恭喜您,已经成功领取现金红包!")
- var vokdata = this.comp("VokData");
- vokdata.refreshData();
-
- }
- //生成问答
- Model.prototype.Mfaq = function(fc){
- var Fn = 0;
- var t = this;
- if(localStorage.getItem("Fn")){
- Fn= localStorage.getItem("Fn")
- Fn = Fn>=(fc.length-1)?0:(parseInt(Fn)+1);
- }else{
- Fn=Math.floor(Math.random()*10)%fc.length;
- }
- localStorage.setItem("Fn",Fn)
- var tf=fc[Fn].split(";")
- $(".v-faq").html(tf[0]+"<br>")
- for(var i=1;i<tf.length-1;i++){
- $(".v-faq").append("<li>"+tf[i]+"</li>")
- }
- $(".v-faq li").click(function(){
- t.Mfaq(fc)
- $(".x-panel-content").animate({scrollTop:0}, 'slow');
- justep.Util.hint("选错了,请在广告内容里找答案!");
- })
- $(".v-faq li:eq("+tf[tf.length-1]+")").unbind("click").click(function(){
- t.Vok()
- })
- }
- Model.prototype.vmadDataAfterRefresh = function(event){
- //显示广告
- var vmadData=this.comp("vmadData");
- var Im = vmadData.getValue("img");
- var t = this;
- var Img=Im.split(",");
- var Imgs="";
- for(var i=0;i<Img.length;i++){
- Imgs=Imgs+"<img src='"+Img[i]+"'>";
- }
- $(".v-con").html(Imgs)
-
- //显示问答
- if(vmadData.getValue("rd")=="d"){
- $(".v-faq").html("您已经领取本广告现金红包!")
- }else{
- var faq=vmadData.getValue("faq");
- if(faq!=""){
- t.Mfaq(faq.split("|"));
- }else{
- if(Img.length>1){
- if(faq==""){
- //判断滚动到页底
- $(".x-panel-content").scroll(function(){
- viewH =$(this).height(),//可见高度
- contentH =$(this).get(0).scrollHeight,//内容高度
- scrollTop =$(this).scrollTop();//滚动高度
- if(contentH - viewH - scrollTop <= 20) { //到达底部100px时,加载新内容
- alert("456")
- t.Vok();
- }
- })
- }
- }else{
- alert("123")
- t.Vok();
- }
- }
- }
- };
- return Model;
- });
复制代码
|
|