cutProductDetail.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. $(function(){
  2. pushHistory();
  3. window.addEventListener("popstate", function(e) {
  4. location.href=base+"/mobile/index.jsp";
  5. }, false);
  6. });
  7. function pushHistory() {
  8. var state = {
  9. title: "title",
  10. url: "#"
  11. };
  12. if(window.history.length==1){
  13. window.history.pushState(state, "title", "#");
  14. }
  15. }
  16. var id=mobile.getUrlVars("id");
  17. var cutId=mobile.getUrlVars("cutId");
  18. var help=mobile.getUrlVars("help");
  19. var data;
  20. var custom;
  21. var pageNumber = 1;
  22. var pageSize=10;
  23. mui.init();
  24. /**
  25. *初始化、添加监听
  26. */
  27. mui.ready(function(){
  28. getCustom();
  29. if (cutId){
  30. getCutInfo();
  31. $(".cut-info").removeClass("mui-hidden");
  32. $("#cut-list-div").removeClass("mui-hidden");
  33. }else{
  34. getProductDetail();
  35. }
  36. $("#sendCode").html(Math.floor(Math.random()*9000)+1000);
  37. $(".header").on("tap",".guanzhu",function(e){
  38. var html=[];
  39. html.push('<img src="'+imgUrl+custom.wechat_qrcode+'" style="width:100%">');
  40. mui.alert(html.join(""), '关注“<span class="main-color">'+custom.wechat_name+'</span>”');
  41. });
  42. $(".footer").on("tap",function(e){
  43. var html=[];
  44. html.push('<img src="'+imgUrl+custom.custom_qrcode+'" style="width:100%">' +
  45. '<a class="fs16" href="tel:'+custom.custom_mobile+'">电话:'+custom.custom_mobile+'</a>');
  46. mui.alert(html.join(""), '长按二维码联系客服');
  47. });
  48. $(".merchant").on("tap",function(){
  49. location.href=base+'/mobile/merchantDetail.jsp?id='+data.merchant.id;
  50. });
  51. $(".tel").on("tap",function(){
  52. location.href = 'tel:'+data.merchant.mobile;
  53. });
  54. $(".map").on("tap",function(){
  55. var locations=bd09togcj02(data.merchant.longitude,data.merchant.latitude);
  56. wx.ready(function(){
  57. wx.openLocation({
  58. latitude: locations[1], // 纬度,浮点数,范围为90 ~ -90
  59. longitude: locations[0], // 经度,浮点数,范围为180 ~ -180。
  60. name: data.merchant.merchant_name, // 位置名
  61. address: data.merchant.address, // 地址详情说明
  62. scale: 25, // 地图缩放级别,整形值,范围从1~28。默认为最大
  63. infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
  64. });
  65. });
  66. });
  67. $(".comment").on("tap",function(){
  68. location.href = base+'/mobile/merchantComment.jsp?id='+data.merchant.id;
  69. });
  70. $("#login").on("tap",'.mui-icon-left-nav',function(){
  71. $('#login').removeClass('mui-active');
  72. });
  73. $("#sendCode").on("tap",function(e){
  74. $("#sendCode").html(Math.floor(Math.random()*9000)+1000);
  75. });
  76. $("#login-btn").on("tap",function(e){
  77. var mobilePhone = $.trim($('#mobile').val());
  78. var code = $.trim($('#code').val());
  79. if(!mobile.checkMobile(mobilePhone)){
  80. layer.open({content:'请输入正确手机号码',time:3});
  81. return;
  82. }
  83. if(code!=$("#sendCode").html()){
  84. layer.open({content:'验证码错误',time:3});
  85. return;
  86. }
  87. user.mobile = mobilePhone;
  88. mobile.ajaxPost(base+'/users/save',user, function(json) {
  89. layer.open({content: '登录成功', time: 3});
  90. setTimeout(function() {
  91. $("#toOrder").html("立即抢购");
  92. $('#login').removeClass('mui-active');
  93. }, 1000);
  94. });
  95. });
  96. $(".btns").on("tap",".baoming",function () {
  97. if(!user.mobile){
  98. $('#login').addClass('mui-active');
  99. }else{
  100. baoming();
  101. }
  102. });
  103. //我的砍价
  104. $(".btns").on("tap",".my",function () {
  105. if (!cutId){
  106. location.href=base+"/mobile/cutProductDetail.jsp?id="+id+"&cutId="+data.cutInfo.id;
  107. }else{
  108. location.href=base+"/mobile/cutProductDetail.jsp?id="+id+"&cutId="+data.myCutInfo.id;
  109. }
  110. });
  111. //其他砍价
  112. $(".btns").on("tap",".qita",function () {
  113. location.href=base+"/mobile/cutProductList.jsp";
  114. });
  115. //帮好友减价
  116. $(".btns").on("tap",".cut",function () {
  117. cut();
  118. });
  119. //邀请
  120. $(".btns").on("tap",".yaoqing",function () {
  121. $("#share").show();
  122. });
  123. //购买
  124. $(".btns").on("tap",".buy",function () {
  125. saveOrder();
  126. });
  127. //分享
  128. $(".share-bg").on('tap',function(){
  129. $("#share").hide();
  130. });
  131. //分享
  132. $(".share-img").on('tap',function(){
  133. $("#share").hide();
  134. });
  135. });
  136. //获取商品信息
  137. function getCustom(){
  138. mobile.ajaxPost(base+"/sysCustom/getById",{},function(json){
  139. custom = json.data;
  140. });
  141. }
  142. //获取商品信息
  143. function getProductDetail(){
  144. mobile.ajaxPost(base+"/product/getProduct",{id:id},function(json){
  145. if(json.success){
  146. data = json.data;
  147. if(data.time_status==0){
  148. var interval= setInterval(function() {
  149. var leftTime = (new Date(data.end_time.replace(/-/g, "/"))) - (new Date());
  150. var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //计算剩余的天数
  151. var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时
  152. var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  153. var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数
  154. hours = checkTime(hours);
  155. minutes = checkTime(minutes);
  156. seconds = checkTime(seconds);
  157. $(".time").html("减价剩余<span class='time-tip'>"+days+"</span>天<span class='time-tip'>" + hours+"</span>小时" +
  158. "<span class='time-tip'>" + minutes+"</span>分<span class='time-tip'>"+seconds+"</span>秒");
  159. }, 1000);
  160. if (data.cutInfo){
  161. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 my">去我的减价>></div>');
  162. }else{
  163. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 baoming">我要报名</div>');
  164. }
  165. }else if(data.time_status==1){
  166. $(".time").html("已抢完");
  167. }else{
  168. $(".time").html("已结束");
  169. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 qita">活动已结束,查询其他活动>></div>');
  170. }
  171. share.title=data.product_name;
  172. share.imgUrl=imgUrl+data.product_main_img;
  173. var arr = [];
  174. if(data.product_img_1){
  175. arr.push(data.product_img_1);
  176. $(".pic-box img").attr("src",imgUrl+data.product_img_1);
  177. }
  178. if(data.product_img_2){
  179. arr.push(data.product_img_2);
  180. }
  181. if(data.product_img_3){
  182. arr.push(data.product_img_3);
  183. }
  184. var unit = mobile.getDictVal("product_unit",data.product_unit);
  185. $(".productName").html(data.product_name);
  186. $(".product-price").html('<span class="color1 fs14">底价 </span><span class="fs14">¥ </span><span class="fs24">'+data.product_price+'</span>');
  187. $(".old_price").html("原价 ¥"+data.product_old_price+"元");
  188. $(".visit_num").html(data.visit_num+"人查看");
  189. $(".share_num").html(data.shareNum+"人分享");
  190. $(".user_num").html(data.userNum+"人参与");
  191. $(".use_time").html("兑换有效期至:"+data.use_time);
  192. $(".product_num").html("仅剩"+(data.product_num-data.sale_num)+"/"+data.product_num+unit+"");
  193. if(data.sale_num!=0){
  194. $('.sale-num').html('已售'+data.sale_num+'份');
  195. getOrderUser();
  196. }else{
  197. $('.sale-num-div').hide();
  198. }
  199. $(".merchant_name").html(data.merchant.merchant_name);
  200. $(".merchant img").attr("src", imgUrl+data.merchant.merchant_img1);
  201. $(".address").html(data.merchant.address);
  202. if(data.merchant.comment_num!=0){
  203. $(".comment_num").html(data.merchant.comment_num+"人评价")
  204. }
  205. if(data.product_detail){
  206. $("#detail").html(data.product_detail);
  207. $("img.lazy").lazyload({
  208. threshold : 50,
  209. effect: "fadeIn",
  210. placeholder: base+'/static/mobile/image/500.gif',
  211. skip_invisible : false
  212. });
  213. }else{
  214. $("#detail").html('<span class="fs14 color2">暂无信息</span>');
  215. }
  216. $('.mui-content').removeClass('mui-hidden');
  217. $('.mui-bar-tab').removeClass('mui-hidden');
  218. initSlider(arr);
  219. //获取评价
  220. getUserMsg();
  221. wx.ready(function(){
  222. wx.getLocation({
  223. type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  224. success: function (res) {
  225. $.ajax({
  226. url:'http://api.map.baidu.com/geoconv/v1/?coords='+res.longitude+','+res.latitude+'&from=1&to=5&ak=3Q4laSROftZI4chFMPVUno90',
  227. dataType:'jsonp',
  228. processData: false,
  229. type:'get',
  230. success:function(json){
  231. if (json.status=='0'){
  232. var latitude=json.result[0].y;
  233. var longitude=json.result[0].x;
  234. var map = new BMap.Map("allmap");
  235. var pointA = new BMap.Point(longitude,latitude);
  236. var pointB = new BMap.Point(data.merchant.longitude,data.merchant.latitude);
  237. var distance = parseInt(map.getDistance(pointA,pointB));
  238. $(".distance").html(getDistance(distance));
  239. }
  240. },
  241. error:function(XMLHttpRequest, textStatus, errorThrown) {
  242. layer.msg('坐标转换失败');
  243. }
  244. });
  245. }
  246. });
  247. });
  248. }else{
  249. layer.open({content: json.msg,time: 3});
  250. }
  251. });
  252. }
  253. //获取商品信息
  254. function getCutInfo(){
  255. mobile.ajaxPost(base+"/product/getCutInfo",{cutId:cutId},function(json){
  256. if(json.success){
  257. data = json.data;
  258. if(data.time_status==0){
  259. var interval= setInterval(function() {
  260. var leftTime = (new Date(data.end_time.replace(/-/g, "/"))) - (new Date());
  261. var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //计算剩余的天数
  262. var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时
  263. var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟
  264. var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数
  265. hours = checkTime(hours);
  266. minutes = checkTime(minutes);
  267. seconds = checkTime(seconds);
  268. $(".time").html("减价剩余<span class='time-tip'>"+days+"</span>天<span class='time-tip'>" + hours+"</span>小时" +
  269. "<span class='time-tip'>" + minutes+"</span>分<span class='time-tip'>"+seconds+"</span>秒");
  270. }, 1000);
  271. if(data.myCutInfo&&data.myCutInfo!=null){
  272. if (data.myCutInfo.id==data.cutInfo.id){
  273. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 cut">自己减价</div>');
  274. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 yaoqing">邀请好友减价</div>');
  275. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 buy">立即购买</div>');
  276. }else{
  277. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 cut">帮好友减价</div>');
  278. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 my">去我的减价>></div>');
  279. }
  280. }else{
  281. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 cut">帮好友减价</div>');
  282. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 baoming">我要报名</div>');
  283. }
  284. }else if(data.time_status==1){
  285. $(".time").html("已抢完");
  286. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 qita">活动已经抢光,查询其他活动>></div>');
  287. }else{
  288. $(".time").html("已结束");
  289. $(".btns").append('<div class="mui-btn mui-btn-primary ml10 qita">活动已结束,查询其他活动>></div>');
  290. }
  291. share.title=data.product_name;
  292. share.imgUrl=imgUrl+data.product_main_img;
  293. var arr = [];
  294. if(data.product_img_1){
  295. arr.push(data.product_img_1);
  296. $(".pic-box img").attr("src",imgUrl+data.product_img_1);
  297. }
  298. if(data.product_img_2){
  299. arr.push(data.product_img_2);
  300. }
  301. if(data.product_img_3){
  302. arr.push(data.product_img_3);
  303. }
  304. var unit = mobile.getDictVal("product_unit",data.product_unit);
  305. $(".productName").html(data.product_name);
  306. $(".product-price").html('<span class="color1 fs14">底价 </span><span class="fs14">¥ </span><span class="fs24">'+data.product_price+'</span>');
  307. $(".cut-price").html(data.cutInfo.product_price+"元");
  308. $("#userImg").attr("src",data.user.headimgurl);
  309. $("#userName").html(data.user.nickname);
  310. $(".old_price").html("原价 ¥"+data.product_old_price+"元");
  311. $(".visit_num").html(data.visit_num+"人查看");
  312. $(".share_num").html(data.shareNum+"人分享");
  313. $(".user_num").html(data.userNum+"人参与");
  314. $(".use_time").html("兑换有效期至:"+data.use_time);
  315. $(".product_num").html("仅剩"+(data.product_num-data.sale_num)+"/"+data.product_num+unit+"");
  316. if(data.sale_num!=0){
  317. $('.sale-num').html('已售'+data.sale_num+'份');
  318. getOrderUser();
  319. }else{
  320. $('.sale-num-div').hide();
  321. }
  322. if (data.cutDetail){
  323. $(".help-num").html(data.cutDetail.length+"人");
  324. $(".cut-list").empty();
  325. if (data.cutDetail.length>0){
  326. $.each(data.cutDetail,function (id,item) {
  327. $(".cut-list").append('<img class="comment-avatar mr5" src="'+item.headimgurl+'">');
  328. })
  329. }else{
  330. $(".cut-list").append('暂无');
  331. }
  332. }
  333. $(".merchant_name").html(data.merchant.merchant_name);
  334. $(".merchant img").attr("src", imgUrl+data.merchant.merchant_img1);
  335. $(".address").html(data.merchant.address);
  336. if(data.merchant.comment_num!=0){
  337. $(".comment_num").html(data.merchant.comment_num+"人评价")
  338. }
  339. if(data.product_detail){
  340. $("#detail").html(data.product_detail);
  341. $("img.lazy").lazyload({
  342. threshold : 50,
  343. effect: "fadeIn",
  344. placeholder: base+'/static/mobile/image/500.gif',
  345. skip_invisible : false
  346. });
  347. }else{
  348. $("#detail").html('<span class="fs14 color2">暂无信息</span>');
  349. }
  350. $('.mui-content').removeClass('mui-hidden');
  351. $('.mui-bar-tab').removeClass('mui-hidden');
  352. initSlider(arr);
  353. //获取评价
  354. getUserMsg();
  355. wx.ready(function(){
  356. wx.getLocation({
  357. type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  358. success: function (res) {
  359. $.ajax({
  360. url:'http://api.map.baidu.com/geoconv/v1/?coords='+res.longitude+','+res.latitude+'&from=1&to=5&ak=3Q4laSROftZI4chFMPVUno90',
  361. dataType:'jsonp',
  362. processData: false,
  363. type:'get',
  364. success:function(json){
  365. if (json.status=='0'){
  366. var latitude=json.result[0].y;
  367. var longitude=json.result[0].x;
  368. var map = new BMap.Map("allmap");
  369. var pointA = new BMap.Point(longitude,latitude);
  370. var pointB = new BMap.Point(data.merchant.longitude,data.merchant.latitude);
  371. var distance = parseInt(map.getDistance(pointA,pointB));
  372. $(".distance").html(getDistance(distance));
  373. }
  374. },
  375. error:function(XMLHttpRequest, textStatus, errorThrown) {
  376. layer.msg('坐标转换失败');
  377. }
  378. });
  379. }
  380. });
  381. });
  382. }else{
  383. layer.open({content: json.msg,time: 3});
  384. }
  385. });
  386. }
  387. function initSlider(arr){
  388. $("#slider .mui-slider-group").append('<div class="mui-slider-item mui-slider-item-duplicate">'+
  389. '<a href="javascript:void(0)">'+
  390. '<img class="slider-lazy" data-original="'+imgUrl+arr[arr.length-1]+'" >'+
  391. '</a>'+
  392. '</div>');
  393. if(arr.length>1){//数量大于1定时滚动
  394. for(var i=0;i<arr.length;i++){
  395. $("#slider .mui-slider-group").append('<div class="mui-slider-item">'+
  396. '<a href="javascript:void(0)">'+
  397. '<img class="slider-lazy" data-original="'+imgUrl+arr[i]+'" >'+
  398. '</a>'+
  399. '</div>');
  400. if(i==0){
  401. $("#slider .mui-slider-indicator").append('<div class="mui-indicator mui-active"></div>');
  402. }else{
  403. $("#slider .mui-slider-indicator").append('<div class="mui-indicator"></div>');
  404. }
  405. }
  406. }else{//数量等于1
  407. $("#slider .mui-slider-group").append('<div class="mui-slider-item">'+
  408. '<a href="javascript:void(0)">'+
  409. '<img class="slider-lazy" data-original="'+imgUrl+arr[0]+'" >'+
  410. '</a>'+
  411. '</div>');
  412. }
  413. $("#slider .mui-slider-group").append('<div class="mui-slider-item mui-slider-item-duplicate">'+
  414. '<a href="javascript:void(0)">'+
  415. '<img src="'+imgUrl+arr[0]+'" >'+
  416. '</a>'+
  417. '</div>');
  418. if(arr.length>1){
  419. var slider = mui("#slider");
  420. slider.slider({
  421. interval: 3000
  422. });
  423. }
  424. $("img.slider-lazy").lazyload({
  425. threshold : 200,
  426. placeholder: base+'/static/mobile/image/500.gif',
  427. skip_invisible : false
  428. });
  429. }
  430. function getOrderUser() {
  431. mobile.ajaxPost(base+'/userOrder/getUserMsgList',{
  432. productId: id,
  433. pageSize: pageSize,
  434. pageNumber: 1
  435. },function(json){
  436. if(json.list&&json.list.length>0){
  437. $.each(json.list,function (id,item) {
  438. if (id<9){
  439. $(".sale-num-div").append('<img class="comment-avatar mr5" src="'+item.headimgurl+'">');
  440. }
  441. });
  442. }
  443. });
  444. }
  445. //获取评价
  446. function getUserMsg(){
  447. $('.userMsg-content').dropload({
  448. scrollArea : window,
  449. loadDownFn : function(me){
  450. mobile.ajaxPost(base+'/userOrder/getUserMsgList',{
  451. productId: id,
  452. pageSize: pageSize,
  453. pageNumber: pageNumber
  454. },function(json){
  455. if(json.list&&json.list.length>0){
  456. if(pageNumber==json.totalPage){
  457. me.lock();
  458. me.noData();
  459. }else{
  460. pageNumber++;
  461. }
  462. var html=[];
  463. jQuery.each(json.list,function(id,item){
  464. html.push('<li class="mui-table-view-cell">');
  465. html.push('<div class="mui-table">');
  466. html.push('<div class="mui-table-cell mui-col-xs-3 mui-ellipsis">'+getName(item.nickname)+'</div>');
  467. if (item.order_amt==data.product_price){
  468. html.push('<div class="mui-table-cell mui-col-xs-6 main-color">减到低价</div>');
  469. }else{
  470. html.push('<div class="mui-table-cell mui-col-xs-6 main-color">'+item.order_amt+'元</div>');
  471. }
  472. html.push('<div class="mui-table-cell mui-col-xs-3">'+new Date(item.create_time.replace(/-/g, "/")).format("MM-dd hh:mm")+'</div>');
  473. html.push('</div>');
  474. html.push('</li>');
  475. })
  476. $("#userMsg").append(html.join(""));
  477. me.resetload();
  478. }else{
  479. me.lock();
  480. me.noData();
  481. me.resetload();
  482. }
  483. },"");
  484. }
  485. });
  486. }
  487. function checkTime(i){ // 将0-9的数字前面加上0,例1变为01
  488. if(i<10) {
  489. i = "0" + i;
  490. }
  491. return i;
  492. }
  493. function getName(name){
  494. if(name){
  495. if(name.length==1){
  496. return "*";
  497. }else if(name.length==2){
  498. return name.substring(0,1)+"*";
  499. }else{
  500. return name.substring(0,1)+"*"+name.substring(name.length-1);
  501. }
  502. }else{
  503. return "*";
  504. }
  505. }
  506. function baoming() {
  507. mobile.ajaxPost(base+'/cutInfo/save',{
  508. productId: id
  509. },function(json){
  510. if(json.success){
  511. layer.open({content:'报名成功',time:3});
  512. setTimeout(function() {
  513. location.href=base+"/mobile/cutProductDetail.jsp?id="+id+"&cutId="+json.data.id;
  514. }, 1000);
  515. }else{
  516. layer.open({content:json.msg,time:3});
  517. }
  518. });
  519. }
  520. function cut() {
  521. mobile.ajaxPost(base+'/cutDetail/save',{
  522. cutId: cutId
  523. },function(json){
  524. if(json.success){
  525. mui.alert('减价成功,帮忙减了'+mobile.toDecimal(json.data.cut_price)+'元', '提示信息');
  526. $(".cut-price").html(mobile.toDecimal(json.data.product_price)+"元");
  527. if (json.data.cutDetail){
  528. $(".help-num").html(json.data.cutDetail.length+"人");
  529. $(".cut-list").empty();
  530. if (json.data.cutDetail.length>0){
  531. $.each(json.data.cutDetail,function (id,item) {
  532. $(".cut-list").append('<img class="comment-avatar mr5" src="'+item.headimgurl+'">');
  533. })
  534. }else{
  535. $(".cut-list").append('暂无');
  536. }
  537. }
  538. }else{
  539. layer.open({content:json.msg,time:3});
  540. }
  541. });
  542. }
  543. function saveOrder(){
  544. mobile.ajaxPost(base+'/userOrder/saveCut',{
  545. productId: id,
  546. cutId:cutId,
  547. company: sessionStorage.getItem("company"),
  548. shareUser: sessionStorage.getItem("shareUser")
  549. },function(json){
  550. if(json.success){
  551. location.href=base+"/mobile/userOrderDetail.jsp?id="+json.data.id;
  552. }else{
  553. layer.open({content:json.msg,time:3});
  554. }
  555. });
  556. }
  557. function getDistance(distance){
  558. var i= parseInt(distance);
  559. if(i<1000){
  560. return i+"米";
  561. }else{
  562. var f = parseFloat(i/1000);
  563. if (isNaN(f)) {
  564. return;
  565. }
  566. f = Math.round(i/1000 * 10) / 10;
  567. return f+"公里";
  568. }
  569. }