(function () { var page = { isScroll: true, init: function ($page) { var userinfo = renlian.storage.get('userinfo'); /*renlian.http.get("http://czapp.rltest.cn/?s=api/get_user_platenumber&userid="+userinfo.baseinfo.userId,{}, function (res) { if (res) { var platedata = []; $.each(res.data, function (_index, _item) { platedata.push({value:_index,text:_item.LicensePlate}); $page.find('#plateselect').lrpicker({ placeholder: '请选择(必填)', data: platedata }); }); } });*/ //var platedata = [{value:"123123122223",text:"bj123123"},{value:"123123122223",text:"bj123124"},{value:"1231122223",text:"bj123125"}]; renlian.httpget(config.webapi + "/?s=api/get_cityinfo_by_cityid&cityid="+userinfo.baseinfo.cityid, {}, function(res) { //console.log(userinfo.baseinfo.cityid); $page.find('#select3').lrpickerSet(res.data); //$page.find('#select3').lrpickerSet('20,331,2012'); }); $page.find('#plate').val(userinfo.baseinfo.plate); $page.find('#mobile').val(userinfo.baseinfo.mobile); //console.log(userinfo); // renlian.httpget(config.webapi + "/?s=api/getCityInfo&cityid="+userinfo.baseinfo.cityid, {}, function(res) { // console.log(res); // }); //console.log(userinfo); $page.find('#select3').lrpicker({ placeholder: '请选择', data: cityData, level: 3 }); $page.find('#select4').lrpicker({ placeholder: '请选择', data: bjTypeData, level: 3 }); $page.find('#date2').lrdate({ type: 'date' }); $page.find('.lr-btn-block').on('tap', function () { //var plate = $('#plateselect').children("div").text(); var mobile = $('#mobile').val(); var date = $('#date2').children("div").text(); var bjtp = $('#select4').children("div").text(); var stolencityid = $page.find('#select3').lrpickerGet('vaule'); var bjtypeid = $page.find('#select4').lrpickerGet('vaule'); //console.log(bjtypeid); if(!mobile){ renlian.layer.toast('手机号不能为空'); return; } var myreg=/^[1][3,4,5,7,8][0-9]{9}$/; if (!myreg.test(mobile)) { renlian.layer.toast('手机号格式不正确!'); return; } if(date == '请选择'){ renlian.layer.toast('请选择被盗日期'); return; } if(bjtp == '请选择'){ renlian.layer.toast('请选择报警种类'); return; } var stolenaddress = $('#address').val(); if(!stolenaddress){ renlian.layer.toast('事发地址不能为空'); return; } var reason = $('#textarea').val(); var reasons = reason.replace(/(^\s*)|(\s*$)/g, ""); if(!reasons){ renlian.layer.toast('请填写报警原因'); return; } var policedata = { userid: userinfo.baseinfo.userId, LicensePlate: userinfo.baseinfo.plate, UserPhone: mobile, StolenDate: date, StolenCityId:stolencityid, bjtypeid:bjtypeid, StolenAddress:stolenaddress, WoContent: reason }; //console.log(policedata); renlian.httppost(config.webapi + "/?s=api/submit_add_baojing", policedata, function(res) { //console.log(res); if(res.success == true){ renlian.layer.toast('提交成功'); renlian.nav.go({ path: 'amap', title: '地图', type: 'right', isBack: false }); }else{ renlian.layer.warning(res.message, function () { }, '提示', '关闭'); } }) }) } }; return page; })();