baojing.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. (function () {
  2. var page = {
  3. isScroll: true,
  4. init: function ($page) {
  5. var userinfo = renlian.storage.get('userinfo');
  6. /*renlian.http.get("http://czapp.rltest.cn/?s=api/get_user_platenumber&userid="+userinfo.baseinfo.userId,{}, function (res) {
  7. if (res) {
  8. var platedata = [];
  9. $.each(res.data, function (_index, _item) {
  10. platedata.push({value:_index,text:_item.LicensePlate});
  11. $page.find('#plateselect').lrpicker({
  12. placeholder: '请选择(必填)',
  13. data: platedata
  14. });
  15. });
  16. }
  17. });*/
  18. //var platedata = [{value:"123123122223",text:"bj123123"},{value:"123123122223",text:"bj123124"},{value:"1231122223",text:"bj123125"}];
  19. renlian.httpget(config.webapi + "/?s=api/get_cityinfo_by_cityid&cityid="+userinfo.baseinfo.cityid, {}, function(res) {
  20. //console.log(userinfo.baseinfo.cityid);
  21. $page.find('#select3').lrpickerSet(res.data);
  22. //$page.find('#select3').lrpickerSet('20,331,2012');
  23. });
  24. $page.find('#plate').val(userinfo.baseinfo.plate);
  25. $page.find('#mobile').val(userinfo.baseinfo.mobile);
  26. //console.log(userinfo);
  27. // renlian.httpget(config.webapi + "/?s=api/getCityInfo&cityid="+userinfo.baseinfo.cityid, {}, function(res) {
  28. // console.log(res);
  29. // });
  30. //console.log(userinfo);
  31. $page.find('#select3').lrpicker({
  32. placeholder: '请选择',
  33. data: cityData,
  34. level: 3
  35. });
  36. $page.find('#select4').lrpicker({
  37. placeholder: '请选择',
  38. data: cityData,
  39. level: 3
  40. });
  41. $page.find('#date2').lrdate({
  42. type: 'date'
  43. });
  44. $page.find('.lr-btn-block').on('tap', function () {
  45. //var plate = $('#plateselect').children("div").text();
  46. var mobile = $('#mobile').val();
  47. var date = $('#date2').children("div").text();
  48. var stolencityid = $page.find('#select3').lrpickerGet('vaule');
  49. //console.log($page.find('#select3').lrpickerGet('vaule'));
  50. if(!mobile){
  51. renlian.layer.toast('手机号不能为空');
  52. return;
  53. }
  54. var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
  55. if (!myreg.test(mobile)) {
  56. renlian.layer.toast('手机号格式不正确!');
  57. return;
  58. }
  59. if(date == '请选择'){
  60. renlian.layer.toast('请选择被盗日期');
  61. return;
  62. }
  63. var stolenaddress = $('#address').val();
  64. if(!stolenaddress){
  65. renlian.layer.toast('事发地址不能为空');
  66. return;
  67. }
  68. var reason = $('#textarea').val();
  69. var reasons = reason.replace(/(^\s*)|(\s*$)/g, "");
  70. if(!reasons){
  71. renlian.layer.toast('请填写报警原因');
  72. return;
  73. }
  74. var policedata = {
  75. userid: userinfo.baseinfo.userId,
  76. LicensePlate: userinfo.baseinfo.plate,
  77. UserPhone: mobile,
  78. StolenDate: date,
  79. StolenCityId:stolencityid,
  80. StolenAddress:stolenaddress,
  81. WoContent: reason
  82. };
  83. //console.log(policedata);
  84. renlian.httppost(config.webapi + "/?s=api/submit_add_baojing", policedata, function(res) {
  85. //console.log(res);
  86. if(res.success == true){
  87. renlian.layer.toast('提交成功');
  88. renlian.nav.go({ path: 'amap', title: '地图', type: 'right', isBack: false });
  89. }else{
  90. renlian.layer.warning(res.message, function () { }, '提示', '关闭');
  91. }
  92. })
  93. })
  94. }
  95. };
  96. return page;
  97. })();