123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- allowNext:false,
- searchValue:'',
- searchList:[],
- searchfileList:[],
- searchFilevalue:'',
- show:false,
- showFile:false,
- productList:[],
- title:'',
- fileTitle:'',
- carFilesList:[],
- is_big:'',
- is_set:'',
- set_status:''
- },
- handleCancel(){
- this.setData({
- show:false
- })
- },
- handleCancelFile(){
- this.setData({
- showFile:false
- })
- },
- onSearch(event){
- let arr = this.data.productList.filter(v=>v.title.indexOf(event.detail)!=-1);
- this.setData({
- searchList:arr
- })
- },
- onSearchFile(event){
- let arr = this.data.carFilesList.filter(v=>v.name.indexOf(event.detail)!=-1);
- this.setData({
- searchFileList:arr
- })
- },
- onChoose(){
- this.setData({
- show:true,
- searchList:this.data.productList
- })
- },
- onChooseFile(){
- let app = getApp();
- let list = [];
- if(app.globalData.car_type){
- list = this.data.carFilesList.filter(v=>v.car_type_id==app.globalData.car_type);
- }else{
- list = this.data.carFilesList
- }
- this.setData({
- showFile:true,
- searchFileList:list
- })
- },
- handleNext(){
- let app = getApp();
- let openid = app.globalData.openID;
- if(!app.globalData.car_file_id||!app.globalData.car_type){
- return wx.showToast({
- icon:'none',
- title: '请选择!',
- })
- }
- if(this.data.set_status){
- wx.redirectTo({
- url: '../fifth/fifth',
- })
- }else{
- app.globalData.stepData = app.globalData.stepData.filter(v=>v.sort!=5);
- app.globalData.stepData.push({
- sort:5,
- data:{
- title:this.data.title,
- fileTitle:this.data.fileTitle,
- is_big:this.data.is_big
- }
- })
- wx.p.request({
- url: `${app.globalData.url}wx/saveWxConstructionData`,
- method:'POST',
- data:{
- openid,
- type:1,
- data:JSON.stringify(app.globalData)
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.redirectTo({
- url: '../fifth/fifth',
- })
- }
-
- })
- }
- },
- handleChoose(item){
- let app = getApp();
- app.globalData.car_type = item.target.dataset.item.id;
- app.globalData.car_file_id = '';
- app.globalData.car_type_name = item.target.dataset.item.title;
- app.globalData.car_file_name = '';
- this.setData({
- searchFilevalue:'',
- title:item.target.dataset.item.title,
- fileTitle:'',
- show:false,
- is_big:''
- })
- },
- handleChooseFile(item){
- let app = getApp();
- app.globalData.car_file_id = item.target.dataset.item.id;
- app.globalData.car_type = item.target.dataset.item.car_type_id;
- app.globalData.is_big = item.target.dataset.item.is_big;
- app.globalData.car_file_name = item.target.dataset.item.name;
- app.globalData.car_type_name = item.target.dataset.item.car_type_name;
- this.setData({
- fileTitle:item.target.dataset.item.name,
- showFile:false,
- title:item.target.dataset.item.car_type_name,
- is_big:item.target.dataset.item.is_big?'是':'否'
- })
- },
- handleReturn(){
- let app = getApp();
- let openid = app.globalData.openID;
- if(this.data.set_status){
- wx.redirectTo({
- url: '../writeVIN/writeVIN',
- })
- }else{
- app.globalData.stepData.forEach((v,index)=>{
- if(v.sort == '5'){
- app.globalData.stepData.splice(index,1);
- }
- })
- wx.p.request({
- url: `${app.globalData.url}wx/saveWxConstructionData`,
- method:'POST',
- data:{
- openid,
- type:1,
- data:JSON.stringify(app.globalData)
- }
- }).then(res=>{
- if(res.data.code==200){
- wx.redirectTo({
- url: '../writeVIN/writeVIN',
- })
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(option) {
- let app = getApp();
- let openid = app.globalData.openID;
- wx.p.request({
- url: `${app.globalData.url}wx/carTypeList`,
- method:'POST',
- data:{
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- this.setData({
- productList:this.getArr(res.data.data)
- })
- }
-
- })
- wx.p.request({
- url: `${app.globalData.url}wx/carFilesList`,
- method:'POST',
- data:{
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- this.setData({
- carFilesList:res.data.data.data
- })
- if(app.globalData.own_id){
- this.setData({
- is_set:false
- })
- }else{
- this.setData({
- is_set:true
- })
- }
- if(app.globalData.car_file_id&&app.globalData.car_type){
- app.globalData.is_big = this.data.carFilesList.find(v=>v.id==app.globalData.car_file_id).is_big;
- this.setData({
- title:app.globalData.car_type_name,
- fileTitle:app.globalData.car_file_name,
- is_big:app.globalData.is_big?'是':'否',
- })
- }
- }
-
- })
- if(app.globalData.set_status){
- this.setData({
- set_status:app.globalData.set_status
- })
- }else{
- wx.p.request({
- url: `${app.globalData.url}wx/getWxConstructionData`,
- method:'POST',
- data:{
- type:1,
- openid
- }
- }).then(res=>{
- if(res.data.code==200){
- if(res.data.data.data){
- let data = JSON.parse(res.data.data.data);
- let box = data.stepData.find(v=>v.sort==5);
- app.globalData = data;
- app.globalData.set_status = '';
- if(box){
- this.setData({
- title:box.data.title,
- fileTitle:box.data.fileTitle,
- is_big:box.data.is_big,
- set_status:''
- })
- }else{
- this.setData({
- set_status:''
- })
- }
- }
- }
- })
- }
- },
- getArr(arr){
- let data = [];
- arr.forEach(v=>{
- if(v.children.length==0){
- data.push(v);
- }else{
- data = [...data,this.getArr(v.children)]
- }
- })
- return data;
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|