起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1256|回复: 3

[结贴] 新手,在内置浏览器运行中,下单按钮设置 出错啦

[复制链接]

8

主题

44

帖子

90

积分

初级会员

Rank: 2

积分
90
QQ
发表于 2017-1-6 22:44:20 | 显示全部楼层 |阅读模式
本帖最后由 争取 于 2017-1-6 22:54 编辑

define(function(require){
        var $ = require("jquery");
        var justep = require("$UI/system/lib/justep");
        require("cordova!cordova-plugin-device");
        var Model = function(){
                this.callParent();
                this.userID;
                this.loadUser=true;
                this.loadOrder=true;
        };

        Model.prototype.modelLoad = function(event){
        var me=this;
        this.userID="user1";
        this.comp("userData").setFilter("filter1","fID='"+this.userID+"'");
        this.comp("orderData").setFilter("filter1","fUserID='"+this.userID+"'");
   if(justep.Browser.isX5App){
        document.addEventListener("deviceready",function(){
        me.userID=window.device.uuid;
        });
    }   
        };
    Model.prototype.getImgUrl = function(imgUrl){
    return require.toUrl("./img/")+imgUrl;
        };
        Model.prototype.addCartBtnClick = function(event){
    var row=event.bindingContext.$object;
    var rows=this.comp("cartData").find(["fMenuID"],[row.getID()]);
    if(rows.length===0){
        this.comp("cartData").newData({
                  defaultValues:[{
             "fMenuID":row.getID(),
             "fMenuName":row.val("fName"),
             "fPrice":row.val("fPrice"),
             "fCount":1         
                  }]
        });
        }else{
        rows[0].val("fCount",rows[0].val("fCount")+1);
        }
        };
        Model.prototype.addBtnClick = function(event){
    var row=event.bindingContext.$object;
        row.val("fCount",row.val("fCount")+1);  
        };
        Model.prototype.subBtnClick = function(event){
    var row=event.bindingContext.$object;
    if(row.val("fCount")>0){
        row.val("fCount",row.val("fCount")-1);
        }
        };
        Model.prototype.loadUserData = function(){
        if(this.loadUser){
        this.comp("userData").refreshData();
    if(this.comp("userData").getCount()===0){
        this.comp("userData").newData({
             defaultValues:[{
        "fID":this.userID,
        "fuserName":"新用户"     
             }]
        });
    }
    this.loadUser=false;
    }
        };
        
        Model.prototype.cartContentActive = function(event){
        this.loadUserData();
        };
        Model.prototype.ownContentActive = function(event){
            this.loadUserData();
        };
        Model.prototype.saveBtnClick = function(event){
        this.comp("userData").saveData({
             "onSuccess":function(){
        justep.Util.hint("用户信息保存成功");
         }
    });
        };
        Model.prototype.orderContentActive = function(event){
        if(this.loadOrder){
            this.comp("orderData").clear();
        this.comp("orderList").refresh(true);
        this.loadOrder=false;
        }
        };
        Model.prototype.orderBtnClick = function(event){
        var content="";
        var me=this;
           this.comp("cartData").each(function(options){
           content=content+options.row.val("fMenuName")+"("+options.row.val("fCount")+")";
           });
        this.comp("orderData").newData({
             index:0,
             defaultValues:[{
               "fID":justep.UUID.createUUID(),
               "fCreateTime":justep.Date.toString(new Date(), justep.Date.STANDART_FORMAT),
               "fContent":content,
               "fUserID":this.comp("userData").val("fID"),
               "fUserName":this.comp("userData").val("fName"),
               "fPhoneNumber":this.comp("userData").val("fPhoneNumber"),
               "fAddress":this.comp("userData").val("fAddress"),
               "fSum":this.comp("calcData").val("fSumMoney"),
               
               
             }]
        });
       this.comp("orderData").savaData({
             "onSuccess":function(){
             justep.Util.hint("下单成功");
         me.comp("cartData").clear();   
         me.comp("contents").to("orderContent");  
         
           
             }
        });
        };
        Model.prototype.orderDataSaveCreateParam = function(event){
    event.param.tables.push(this.comp("userData").toJson(true));
        };
        Model.prototype.orderDataSaveCommit = function(event){
    this.comp("userData").applyUpdates();
        };
        
        return Model;
});

8

主题

44

帖子

90

积分

初级会员

Rank: 2

积分
90
QQ
 楼主| 发表于 2017-1-6 22:47:45 | 显示全部楼层
我在浏览器运行的时候,出现如图的错误 x.png
回复 支持 反对

使用道具 举报

发表于 2017-1-9 10:13:31 | 显示全部楼层
争取 发表于 2017-1-6 22:47
我在浏览器运行的时候,出现如图的错误

单词写错了,应该是
this.comp("orderData").saveData({

你写成了savaData
应该是saveData
qq:1912779713
WeX5教程--WeX5下载
回复 支持 反对

使用道具 举报

8

主题

44

帖子

90

积分

初级会员

Rank: 2

积分
90
QQ
 楼主| 发表于 2017-1-10 12:57:42 来自手机 | 显示全部楼层
一个单词真要命,谢谢版主,
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-3 23:40 , Processed in 0.061639 second(s), 26 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表