evaluate.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // pages/evaluate/evaluate.js
  2. import { get, postwithoutahth , upload } from "../../common/request.js"
  3. import pathmap from "../../common/pathmap"
  4. import stylemap from "../../common/stylemap"
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. getbrand:pathmap.getbrands,
  12. getseries:pathmap.carseries,
  13. windowh: app.globalData.windowh,
  14. area:{},
  15. areaselect:{},
  16. series:{},
  17. selectseries:{},
  18. date:"2018-01-01",
  19. datename:["2018","1"],
  20. detail:{},
  21. describe:[{
  22. dis:"无瑕疵\n无色差",
  23. int:"无磨损\n无异味",
  24. mil:"4万公里以内",
  25. maintain:"无事故维修"
  26. },{
  27. dis:"无色差\n个别瑕疵",
  28. int:"轻微磨损\n无异味",
  29. mil:"15万公里以内",
  30. maintain:"无事故\n少量维修"
  31. },{
  32. dis:"轻微色差\n少量瑕疵",
  33. int:"个别严重磨损",
  34. mil:"20万公里以内",
  35. maintain:"有碰撞事故\n少量维修"
  36. }],
  37. showeva:false
  38. },
  39. /**
  40. * 生命周期函数--监听页面加载
  41. */
  42. onLoad: function (options) {
  43. this.setData(stylemap);
  44. this.getCararea(0,0,0);
  45. //this.getCarSeries(0,0,0);
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面隐藏
  59. */
  60. onHide: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面卸载
  64. */
  65. onUnload: function () {
  66. },
  67. /**
  68. * 页面相关事件处理函数--监听用户下拉动作
  69. */
  70. onPullDownRefresh: function () {
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function () {
  76. },
  77. /**
  78. * 用户点击右上角分享
  79. */
  80. onShareAppMessage: function () {
  81. },
  82. getCararea:function(id,index,sel){
  83. var _self=this;
  84. sel = sel||0;
  85. get(pathmap.cararea,{pid:id},function(json){
  86. var obj = {},select={};
  87. obj[index] = json.data;
  88. select[index] = sel;
  89. _self.setData({
  90. area:Object.assign({},_self.data.area,obj),
  91. areaselect:Object.assign({},_self.data.areaselect,select)
  92. });
  93. if(index<1){
  94. _self.getCararea(obj[index][sel]['area_id'],1+parseInt(index),0);
  95. }
  96. })
  97. },
  98. changeArea:function(e){
  99. var index = e.currentTarget.dataset.index;
  100. var select = e.detail.value;
  101. var obj = {};
  102. obj[index]=select;
  103. this.setData({areaselect:Object.assign(this.data.areaselect,obj)});
  104. if(index<1){
  105. this.getCararea(this.data.area[index][select]['area_id'],1+parseInt(index),0);
  106. }
  107. },
  108. // getCarModel:function(){
  109. // var _self=this;
  110. // get(pathmap.carmodel,{pid:id},function(json){
  111. // var obj = {},select={};
  112. // obj[index] = json.data;
  113. // select[index] = sel;
  114. // _self.setData({
  115. // area:Object.assign({},_self.data.area,obj),
  116. // select:Object.assign({},_self.data.areaselect,select)
  117. // });
  118. // if(index<1){
  119. // _self.getCararea(obj[index][sel]['area_id'],1+parseInt(index),0);
  120. // }
  121. // })
  122. // },
  123. // getCarSeries:function(id,index,sel){
  124. // var _self=this;
  125. // sel = sel||0;
  126. // //resule 为借口返回数组对应的属性名
  127. // var path="",para={},key = "",resule="";
  128. // if(index==0){
  129. // path = pathmap.brandlist;
  130. // key = "brand_id";
  131. // resule = "brand";
  132. // }else if(index==1){
  133. // path = pathmap.serieslist;
  134. // para = {brand_id:id}; //this.data.series['0'][this.data.selectseries['0']].brand_id}
  135. // key = "car_series_id";
  136. // resule = "car_series";
  137. // }else if(index==2){
  138. // path = pathmap.carmodel;
  139. // para = {car_series_id:id}; //this.data.series['1'][this.data.selectseries['1']].car_series_id}
  140. // }
  141. // get(path,para,function(json){
  142. // var obj = {},select={};
  143. // obj[index] = json.data;
  144. // if(resule){
  145. // obj[index] = obj[index][resule];
  146. // }
  147. // select[index] = sel;
  148. // _self.setData({
  149. // series:Object.assign({},_self.data.series,obj),
  150. // selectseries:Object.assign({},_self.data.selectseries,select)
  151. // });
  152. // if(index<2){
  153. // _self.getCarSeries(obj[index][sel][key],1+parseInt(index),0);
  154. // }
  155. // })
  156. // },
  157. // bindSeriesChange:function(e){
  158. // var index = e.currentTarget.dataset.index;
  159. // var select = e.detail.value;
  160. // var obj = {};
  161. // var key=""
  162. // if(index==0){
  163. // key = "brand_id";
  164. // }else if(index==1){
  165. // key = "car_series_id";
  166. // }
  167. // obj[index]=select;
  168. // this.setData({selectseries:Object.assign(this.data.selectseries,obj)});
  169. // if(index<2){
  170. // this.getCarSeries(this.data.series[index][select][key],1+parseInt(index),0);
  171. // }
  172. // },
  173. getMileage:function(e){
  174. var mileage = e.detail.value;
  175. var sn = mileage.split(".")[1];
  176. if(mileage>=100||sn&&sn.length>1){
  177. wx.showToast({
  178. title:"行驶里程最多为一位整数和一位小数",
  179. icon:"none"
  180. })
  181. this.setData({mileage:this.data.mileage});
  182. }else{
  183. this.setData({mileage:mileage});
  184. }
  185. },
  186. initMileage:function(e){
  187. var mileage = e.detail.value;
  188. mileage = new Number(mileage).toFixed(1)
  189. this.setData({mileage:mileage});
  190. },
  191. bindDateChange: function(e) {
  192. var value = e.detail.value;
  193. var values = value.split("-")
  194. this.setData({
  195. date: e.detail.value,
  196. datename:values
  197. })
  198. },
  199. getMobile:function(e){
  200. var mobile = e.detail.value;
  201. this.setData({mobile:mobile});
  202. },
  203. subEvaluate:function(){
  204. var _self=this;
  205. var title = "";
  206. // if(!this.data.mobile&&/^[1][3|4|5|6|7|8|9][0-9]{9}$/.test(this.data.mobile)){
  207. // title="请填写有效手机号"
  208. // }
  209. if(!this.data.model){
  210. wx.showToast({
  211. title:"请选择车型!",
  212. icon:"none"
  213. });
  214. return;
  215. }
  216. postwithoutahth(pathmap.estimatedprice,{
  217. mobile:this.data.mobile,
  218. model_types:this.data.model.car_model_id,
  219. car_name:this.data.model.car_model_name,
  220. license_time:this.data.date,
  221. mileage:this.data.mileage,
  222. area:this.data.area['1'][this.data.areaselect['1']].area_id,
  223. city_name:`${this.data.area['0'][this.data.areaselect['0']].area_name} ${this.data.area['1'][this.data.areaselect['1']].area_name}`,
  224. },function(json){
  225. if(json.data.status==1){
  226. wx.showToast({
  227. title:"估价成功!"
  228. });
  229. var obj = {
  230. "excellent":0,
  231. "good":1,
  232. "normal":2
  233. }
  234. _self.setData({
  235. detail:json.data,
  236. showeva:true,
  237. currenteva:obj[json.data.default_car_condition]
  238. })
  239. }else{
  240. wx.showToast({
  241. title:"估价失败!",
  242. icon:"none"
  243. });
  244. }
  245. })
  246. },
  247. switchTab: function (e) {
  248. this.setData({
  249. currenteva:e.detail.current
  250. })
  251. },
  252. swatchEva:function(e){
  253. this.setData({
  254. currenteva:e.currentTarget.dataset.index
  255. })
  256. },
  257. evaluateBack:function(e){
  258. this.setData({
  259. showeva:false
  260. })
  261. },
  262. showSeriesSelect:function(){
  263. this.setData({brandlistshow:true});
  264. },
  265. closeBrandList:function(){
  266. this.setData({brandlistshow:false});
  267. },
  268. selectModel:function(e){
  269. var model = e.detail.model;
  270. this.setData({
  271. brandlistshow:false,
  272. model:model
  273. })
  274. }
  275. })