/*****
 *
 * Assuming a HTML like
 *
 * <... id="test-app-1">
 *     <... v-for="oneuser in userlist">
 *         {{oneuser.id}} , name: {{oneuser.name}}
 *     </...>
 *
 * </...>
 *
 */
var test_vue_app = new Vue({
    el : "test-app-1",
    data : {
        userlist : [{id:1, name:"hello"}]
    }
});

/******************************************************************************
 //
 // To load directly from JS(jQuery)
 //
 /*****************************************************************************/

function js_load_something(){
    var uid = 5; //for test.
    BasicFunction.get_data("smartUsers/list"+"?userId="+uid,
        /**
         * 下面的function是访问网络成功后的结果回调，obj 类似
         *
         * http://south.niimei.com:8866/server/smartUsers/list
         * {
         *   "ret":"10000","detail":null,"field":null,"model":
         *   {"page":1,"pageSize":15,"totalPage":1,"totalResult":15,
         *    "list":
         *      [
         *        {
         *       "uid":3,"usn":"cell_13520583918","pss":"64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
         *       "name":"HelloWorld","title":"","priv":"view,order,deliver,pay","state":0,"sess":"iOgxGPkFIV3JxBlBfCv",
         *       "phone":"13520583918","schoolDistrict":null,"userExpPts":null,"userGroup":null,"userVcoin":null,"registerTime":null,
         *       "lastLoginTime":null,"wxUnionid":null,"wxEngineid":null,"wxOpenid":null,"note":null
         *        },
         *        {..第二条数据..},
         *        {..第三条数据..}
         *      ]
         *    }
         * }
         * @param obj
         */
        function (obj) {
            var parsedObj = first_parse(this, obj);
            if(parsedObj != null && parsedObj != undefined) {
                test_vue_app = parsedObj.list;
            } else {
                // error
            }
        } //end of f (obj, status)
    ); // end of get_data
}


/******************************************************************************
 //
 // To load using DataObject + DataService + Module stuff
 //
 *****************************************************************************/

//Module means some component (need only to draw);
var test_vue_module = new Module("nothing", "smartUsers");
test_vue_module.drawData = function (data) {
    test_vue_app.data.userlist.pop();
    for(let i = 0; i < data.len(); i++) {
        test_vue_app.data.userlist.push(data.getSorted(i));
    }
} ;

var loader = new (function(){

    /* this is the main data service that is auto-updating your data*/
    this.userListServ = new DataObjectService("smartUsers", AUTO, "?ext=1");

    // Optional for setting up self-defined interval
    // this.userListServ.autoInterval = 300;
    // this.userListServ.setUpInterval();

    /**
     * load Once, as is.
     */
    this.loadOnce = function(){
        var list = this.userListServ.list;
        test_vue_module.setData(list);
    };

    /***
     * loadOften : to auto-load some data
     */
    this.loadOften = function(){
        // Binding Intervals to DataService
        this.userListServ.bind(function (data) {
            // auto call
            test_vue_module.setData(data);
        });
    };
})();

//To load once
loader.loadOnce();

//To auto-refresh
// loader.loadOften();


// 上传货品信息

/*

BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
                console.log("------ Data Rcvd in PresentReg --------");
                console.log(response);
                if(response.ret === "10000"){
                    this.$router.push('index');
                } else {
                    // 注册失败的处理
                    Toast.fail("上传失败，请检查网络");
                }
            }, [{"reviewId":1,"userId":1,"dormDistrict":10,
                "userSex":1,"userSchoolCard":20123333222,
                "userReviewStatus":1000,
                "reviewerId":1,"reviewerNote":"nmo",
                "reviewerNoteToUser":"noo"}]);


基本格式


登录  转义密码 就是 encodeURIComponent("实际密码")
BasicFunction.get_data("ajaxloginu=手机号&p=(转义密码)", 回调函数, {})

注册
BasicFunction.get_data("ajaxregister?u=手机号&p=转义密码", 回调函数, {})

发送验证码
BasicFunction.get_data("ajaxsendotp?u=手机号", 回调函数, {})

新建 (数据列表就是 [{...实际数据...}])
BasicFunction.get_data("数据接口名称/saveBatch", 回调函数, 数据列表)

修改
BasicFunction.get_data("数据接口名称/updateBatch", 回调函数, 数据列表)

搜索（获取）
BasicFunction.get_data("数据接口名称/list?条件1=数据1&条件2=数据2&.....", 回调函数, {})

新建货品：
smartGoods/saveBatch
[{"goodid":"","name":"萌犬毛绒抱枕","goodsNo":"A2","modelId":"1","ownerId":"18","goodFirstKind":"1000","goodSecondKind":"2000","sellPrice":"0.0","marketPrice":"0.0","costPrice":"0.0","upTime":"2018-12-10 01:01:01","downTime":"2018-12-10 01:01:01","createTime":"2018-12-10 01:01:01","storeNums":"1","img":"attachment/simple/acsac089e1nnsaxx72190dm.jpg","isDel":"0","content":"none","keywords":"none","description":"绒毛玩具或填充玩具，中国大陆较常用“毛绒玩具”、香港为“毛公仔”，是以毛绒面料及其他纺织材料包裹各种填充物而制成的，具有软绵绵、毛绒绒可爱造形的填充玩具。通常做成动物的形象，但也有人形的绒毛玩具。 动画、卡通和漫画人物都是受欢迎的题材。泰迪熊可能被视为是一种绒毛玩具，但因制造材质而异并不是所有的泰迪熊都是绒毛玩具","searchWords":"毛绒,玩具","weight":"0.4","point":"4","unit":"10","brandId":"1","visit":"1","favorite":"1","sort":"1","listImg":"attachment/simple/acsac089e1nnsaxx72190dm.jpg","smallImg":"attachment/simple/bicno912nounx7xsg28d1nidx.jpg","specArray":"{}","exp":"0"}]' --compressed


新建货品审核单
smartGoodReview/saveBatch
[{"reviewId":"","goodId":"3","applicantId":"19","reviewerId":"0","reviewResult":"0","applyTime":"2018-12-10 01:01:01","reviewTime":"2018-12-10 01:01:01","previousReview":"0","reviewNote":"暂未审核","displayNote":"暂未审核"}]


新建货品池内条目（入池）
smartGoodPool/saveBatch
[{"poolItemId":"","goodId":"3","goodSenderId":"5","goodQuantity":"1","goodQuality":"100","goodFirstKind":"1000","reviewStatus":"1000","goodTargetRole":"1","goodTargetKind":"2","inpoolStatus":"1000"}]

新建评论
smartOrderFeedback/saveBatch
[{"feedbackId":"","orderId":"13","goodId":"3","ratingStatus":"1000","ratingMajor":"5000","ratingMinor":"4500","content":"还不错，5颗星","ratingTime":"2018-12-10 01:01:01"}]


新建用户身份审核单（校园卡审核）
smartIdentity/saveBatch
{"reviewId":"","userId":18,"dormDistrict":10,"userSex":1,"userSchoolCard":20123333222,"userReviewStatus":1000,"reviewerId":1,"reviewerNote":"nmo","reviewerNoteToUser":"noo"}]


新建订单（配对成功）
*** 前端不用操作 ***
smartOrder/saveBatch
[{"id":"","userId":"18","paymentId":"0","deliveryId":"0","merchandise":"{}","status":"1","payStatus":"0","distributionStatus":"0","dueAmount":"0.0","paidAmount":"0.0","taxes":"0","payableFreight":"0","realFreight":"0","payFee":"0","promotions":"0","discount":"1","orderAmount":"0","payTime":"2018-12-10 01:01:01","sendTime":"","createTime":"","completionTime":"","acceptTime":"","invoice":"0","invoiceTitle":"","postscript":"","note":"内部匹配","prop":"{}","exp":"0","point":"0","type":"0"}]

统计用（用户点击信息，页面位置+页面按钮/区域代码=clickEvent）

[{"clickId":"","clickEvent":"100001","clickTime":"1544443423082","clickIdentity":"18"}]



****************
***** 查找：*****
****************


查找已经准备接收的礼物
smartOrder/list
[{"id":28,"userId":3,"paymentId":0,"deliveryId":0,"merchandise":"[{\"q\":1,\"model\":1,\"id\":\"3\",\"spec\":[{\"v\":\"100\",\"i\":1002}]},{\"q\":1,\"model\":1,\"id\":\"6\",\"spec\":[{\"v\":\"350\",\"i\":1002}]}]","status":2,"payStatus":2,"distributionStatus":0,"dueAmount":25.11,"paidAmount":0.0,"taxes":0.0,"payableFreight":0.0,"realFreight":0.0,"payFee":0.0,"promotions":0.49,"discount":1.0,"orderAmount":25.6,"payTime":"2017-12-23 10:38:20","sendTime":"2017-12-23 10:38:20","createTime":"2017-12-23 10:38:20","completionTime":"2017-12-23 10:38:20","acceptTime":"0","invoice":0,"invoiceTitle":"empty","postscript":"","note":"","prop":"{\"wechat\":1}","exp":0,"point":0,"type":1}]


 */

