evaluate.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // pages/evaluate/evaluate.js
  2. import { get,post,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. windowh: app.globalData.windowh,
  12. area:{},
  13. areaselect:{},
  14. series:{},
  15. selectseries:{},
  16. date:"2018-01-01",
  17. detail:{"status":"1","default_car_condition":"good","eval_prices":[{"condition":"excellent","dealer_low_buy_price":13.78,"dealer_buy_price":14.44,"individual_low_sold_price":14.97,"individual_price":15.3,"dealer_low_sold_price":15.43,"dealer_price":15.79,"dealer_high_sold_price":16.58},{"condition":"good","dealer_low_buy_price":12.94,"dealer_buy_price":13.56,"individual_low_sold_price":14.06,"individual_price":14.37,"dealer_low_sold_price":14.49,"dealer_price":14.83,"dealer_high_sold_price":15.57},{"condition":"normal","dealer_low_buy_price":12.12,"dealer_buy_price":12.7,"individual_low_sold_price":13.17,"individual_price":13.46,"dealer_low_sold_price":13.57,"dealer_price":13.89,"dealer_high_sold_price":14.59}],"discharge_standard":"\u56fd4","model_price":"27.28","detail_report_url":"https:\/\/www.che300.com\/pinggu\/v1c1m1r2013-10g7.5?from=zxhc&_s=72771012f6c3e623"},
  18. describe:[{
  19. dis:"无瑕疵无色差",
  20. int:"无磨损无异味",
  21. mil:"4万公里以内",
  22. maintain:"无事故维修"
  23. },{
  24. dis:"无色差个别瑕疵",
  25. int:"轻微磨损无异味",
  26. mil:"15万公里以内",
  27. maintain:"无事故少量维修"
  28. },{
  29. dis:"轻微色差少量瑕疵",
  30. int:"个别严重磨损",
  31. mil:"20万公里以内",
  32. maintain:"有碰撞事故少量维修"
  33. }]
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. this.setData(stylemap);
  40. this.getCararea(0,0,0);
  41. this.getCarSeries(0,0,0);
  42. },
  43. /**
  44. * 生命周期函数--监听页面初次渲染完成
  45. */
  46. onReady: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage: function () {
  77. },
  78. getCararea:function(id,index,sel){
  79. var _self=this;
  80. sel = sel||0;
  81. get(pathmap.cararea,{pid:id},function(json){
  82. var obj = {},select={};
  83. obj[index] = json.data;
  84. select[index] = sel;
  85. _self.setData({
  86. area:Object.assign({},_self.data.area,obj),
  87. areaselect:Object.assign({},_self.data.areaselect,select)
  88. });
  89. if(index<1){
  90. _self.getCararea(obj[index][sel]['area_id'],1+parseInt(index),0);
  91. }
  92. })
  93. },
  94. changeArea:function(e){
  95. var index = e.currentTarget.dataset.index;
  96. var select = e.detail.value;
  97. var obj = {};
  98. obj[index]=select;
  99. this.setData({areaselect:Object.assign(this.data.areaselect,obj)});
  100. if(index<1){
  101. this.getCararea(this.data.area[index][select]['area_id'],1+parseInt(index),0);
  102. }
  103. },
  104. // getCarModel:function(){
  105. // var _self=this;
  106. // get(pathmap.carmodel,{pid:id},function(json){
  107. // var obj = {},select={};
  108. // obj[index] = json.data;
  109. // select[index] = sel;
  110. // _self.setData({
  111. // area:Object.assign({},_self.data.area,obj),
  112. // select:Object.assign({},_self.data.areaselect,select)
  113. // });
  114. // if(index<1){
  115. // _self.getCararea(obj[index][sel]['area_id'],1+parseInt(index),0);
  116. // }
  117. // })
  118. // },
  119. getCarSeries:function(id,index,sel){
  120. var _self=this;
  121. sel = sel||0;
  122. //resule 为借口返回数组对应的属性名
  123. var path="",para={},key = "",resule="";
  124. if(index==0){
  125. path = pathmap.brandlist;
  126. key = "brand_id";
  127. resule = "brand";
  128. }else if(index==1){
  129. path = pathmap.serieslist;
  130. para = {brand_id:id}; //this.data.series['0'][this.data.selectseries['0']].brand_id}
  131. key = "car_series_id";
  132. resule = "car_series";
  133. }else if(index==2){
  134. path = pathmap.carmodel;
  135. para = {car_series_id:id}; //this.data.series['1'][this.data.selectseries['1']].car_series_id}
  136. }
  137. get(path,para,function(json){
  138. var obj = {},select={};
  139. obj[index] = json.data;
  140. if(resule){
  141. obj[index] = obj[index][resule];
  142. }
  143. select[index] = sel;
  144. _self.setData({
  145. series:Object.assign({},_self.data.series,obj),
  146. selectseries:Object.assign({},_self.data.selectseries,select)
  147. });
  148. if(index<2){
  149. _self.getCarSeries(obj[index][sel][key],1+parseInt(index),0);
  150. }
  151. })
  152. },
  153. bindSeriesChange:function(e){
  154. var index = e.currentTarget.dataset.index;
  155. var select = e.detail.value;
  156. var obj = {};
  157. var key=""
  158. if(index==0){
  159. key = "brand_id";
  160. }else if(index==1){
  161. key = "car_series_id";
  162. }
  163. obj[index]=select;
  164. this.setData({selectseries:Object.assign(this.data.selectseries,obj)});
  165. if(index<2){
  166. this.getCarSeries(this.data.series[index][select][key],1+parseInt(index),0);
  167. }
  168. },
  169. getMileage:function(e){
  170. var mileage = e.detail.value;
  171. this.setData({mileage:mileage});
  172. },
  173. bindDateChange: function(e) {
  174. this.setData({
  175. date: e.detail.value
  176. })
  177. },
  178. getMobile:function(e){
  179. var mobile = e.detail.value;
  180. this.setData({mobile:mobile});
  181. },
  182. subEvaluate:function(){
  183. var _self=this;
  184. post(pathmap.estimatedprice,{
  185. mobile:this.data.mobile,
  186. model_types:this.data.series['2'][this.data.selectseries['2']].car_model_id,
  187. car_name:this.data.series['2'][this.data.selectseries['2']].car_model_name,
  188. license_time:this.data.date,
  189. mileage:this.data.mileage,
  190. area:this.data.area['1'][this.data.areaselect['1']].area_id,
  191. city_name:`${this.data.area['0'][this.data.areaselect['0']].area_name} ${this.data.area['1'][this.data.areaselect['1']].area_name}`,
  192. },function(json){
  193. var obj = {
  194. title:json.data.message||"估价成功!"
  195. }
  196. if(json.statusCode!=200){
  197. obj.icon="none"
  198. }
  199. wx.showToast(obj);
  200. })
  201. }
  202. })