baojing.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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: bjTypeData,
  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 bjtp = $('#select4').children("div").text();
  49. var stolencityid = $page.find('#select3').lrpickerGet('vaule');
  50. var bjtypeid = $page.find('#select4').lrpickerGet('vaule');
  51. //console.log(bjtypeid);
  52. if(!mobile){
  53. renlian.layer.toast('手机号不能为空');
  54. return;
  55. }
  56. var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
  57. if (!myreg.test(mobile)) {
  58. renlian.layer.toast('手机号格式不正确!');
  59. return;
  60. }
  61. if(date == '请选择'){
  62. renlian.layer.toast('请选择被盗日期');
  63. return;
  64. }
  65. if(bjtp == '请选择'){
  66. renlian.layer.toast('请选择报警种类');
  67. return;
  68. }
  69. var stolenaddress = $('#address').val();
  70. if(!stolenaddress){
  71. renlian.layer.toast('事发地址不能为空');
  72. return;
  73. }
  74. var reason = $('#textarea').val();
  75. var reasons = reason.replace(/(^\s*)|(\s*$)/g, "");
  76. if(!reasons){
  77. renlian.layer.toast('请填写报警原因');
  78. return;
  79. }
  80. var policedata = {
  81. userid: userinfo.baseinfo.userId,
  82. LicensePlate: userinfo.baseinfo.plate,
  83. UserPhone: mobile,
  84. StolenDate: date,
  85. StolenCityId:stolencityid,
  86. bjtypeid:bjtypeid,
  87. StolenAddress:stolenaddress,
  88. WoContent: reason
  89. };
  90. //console.log(policedata);
  91. renlian.httppost(config.webapi + "/?s=api/submit_add_baojing", policedata, function(res) {
  92. //console.log(res);
  93. if(res.success == true){
  94. renlian.layer.toast('提交成功');
  95. renlian.nav.go({ path: 'amap', title: '地图', type: 'right', isBack: false });
  96. }else{
  97. renlian.layer.warning(res.message, function () { }, '提示', '关闭');
  98. }
  99. })
  100. })
  101. }
  102. };
  103. return page;
  104. })();