123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- import { get,post,postwithoutahth,upload } from "../../common/request.js"
- import pathmap from "../../common/pathmap"
- import stylemap from "../../common/stylemap"
- const app = getApp();
- Page({
-
- data: {
- windowh: app.globalData.windowh,
- area:{},
- areaselect:{},
- series:{},
- selectseries:{},
- imgs:[
- "",
- "",
- "",
- ""
- ],
- date:"2018-01-01"
- },
-
- onLoad: function (options) {
-
- this.setData(stylemap);
- this.getCararea(0,0,0);
- this.getCarSeries(0,0,0);
- try{
- var authorization = wx.getStorageSync("authorization");
- }catch(e){
- }
-
-
-
- },
-
- onReady: function () {
-
- },
-
- onShow: function () {
-
- },
-
- onHide: function () {
-
- },
-
- onUnload: function () {
-
- },
-
- onPullDownRefresh: function () {
-
- },
-
- onReachBottom: function () {
-
- },
-
- onShareAppMessage: function () {
-
- },
- getCararea:function(id,index,sel){
- var _self=this;
- sel = sel||0;
- get(pathmap.cararea,{pid:id},function(json){
- var obj = {},select={};
- obj[index] = json.data;
- select[index] = sel;
- _self.setData({
- area:Object.assign({},_self.data.area,obj),
- areaselect:Object.assign({},_self.data.areaselect,select)
- });
- if(index<1){
- _self.getCararea(obj[index][sel]['area_id'],1+parseInt(index),0);
- }
- })
- },
- changeArea:function(e){
- var index = e.currentTarget.dataset.index;
- var select = e.detail.value;
- var obj = {};
- obj[index]=select;
- this.setData({areaselect:Object.assign(this.data.areaselect,obj)});
- if(index<1){
- this.getCararea(this.data.area[index][select]['area_id'],1+parseInt(index),0);
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getCarSeries:function(id,index,sel){
- var _self=this;
- sel = sel||0;
-
- var path="",para={},key = "",resule="";
- if(index==0){
- path = pathmap.brandlist;
- key = "brand_id";
- resule = "brand";
- }else if(index==1){
- path = pathmap.serieslist;
- para = {brand_id:id};
- key = "car_series_id";
- resule = "car_series";
- }else if(index==2){
- path = pathmap.carmodel;
- para = {car_series_id:id};
- }
- get(path,para,function(json){
- var obj = {},select={};
- obj[index] = json.data;
- if(resule){
- obj[index] = obj[index][resule];
- }
- select[index] = sel;
- _self.setData({
- series:Object.assign({},_self.data.series,obj),
- selectseries:Object.assign({},_self.data.selectseries,select)
- });
- if(index<2){
- _self.getCarSeries(obj[index][sel][key],1+parseInt(index),0);
- }
- })
- },
- bindSeriesChange:function(e){
- var index = e.currentTarget.dataset.index;
- var select = e.detail.value;
- var obj = {};
- var key=""
- if(index==0){
- key = "brand_id";
- }else if(index==1){
- key = "car_series_id";
- }
- obj[index]=select;
- this.setData({selectseries:Object.assign(this.data.selectseries,obj)});
- if(index<2){
- this.getCarSeries(this.data.series[index][select][key],1+parseInt(index),0);
- }
- },
- uploadImg:function(e){
- var _self=this;
- var index = e.currentTarget.dataset.index;
- wx.chooseImage({
- success: function(res) {
- var tempFilePaths = res.tempFilePaths[0];
- upload(pathmap.uploadimg,tempFilePaths,function(json){
- var imgs = _self.data.imgs;
- imgs.splice(index,1,JSON.parse(json.data).url);
- _self.setData({imgs:imgs});
- })
- }
- })
- },
- getMileage:function(e){
- var mileage = e.detail.value;
- this.setData({mileage:mileage});
- },
- bindDateChange: function(e) {
- this.setData({
- date: e.detail.value
- })
- },
- bindMobile:function(e){
- var mobile = e.detail.value;
- this.setData({mobile:mobile});
- },
- subSell:function(){
- var _self=this;
-
- postwithoutahth(pathmap.sellingcar,{
- mobile:this.data.mobile,
- car_name:this.data.series['2'][this.data.selectseries['2']].car_model_name,
- plate_at:this.data.date,
- mileage:this.data.mileage,
- city_name:`${this.data.area['0'][this.data.areaselect['0']].area_name} ${this.data.area['1'][this.data.areaselect['1']].area_name}`,
- imgs:this.data.imgs
- },function(json){
- var obj = {
- title:json.data.message
- }
- if(json.statusCode!=200){
- obj.icon="none"
- }
- wx.showToast(obj);
- })
- }
- })
|