123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- import {get,post} from "../../common/request.js"
- import stylemap from "../../common/stylemap"
- import pathmap from "../../common/pathmap"
- import bindTopSource from "../../common/topsource"
- import { retCartData} from "../../data/car"
- import bindSearch from "../../module/search/search.js"
- const app = getApp();
- Page({
- data: {
- windowh: app.globalData.windowh,
- banner:[],
- goodcars:[],
- recommended:[],
- like:[],
- searchfouce:false
- },
- onLoad: function () {
- var _self = this;
-
- this.setData(stylemap);
- this.loadBanner();
- this.loadBrandRecommend();
- this.loadGoodCar();
- this.loadRecommendedCar();
- this.loadLikeCar();
- bindSearch(this);
-
- },
- loadBanner: function () {
- var _self = this;
- get(pathmap.banner, {
- terminal: 0
- }, function (json) {
- _self.setData({
- banner: json.data
- })
- })
- },
- loadBrandRecommend:function(){
- var _self = this;
- get(pathmap.brandrecommend, {
- }, function (json) {
- _self.setData({
- brandrecommend:json.data
- })
- })
- },
- loadGoodCar:function(){
- var _self = this;
- get(pathmap.goodcar, {
- offset: 0,
- limit:3
- }, function (json) {
- var list = json.data.list;
- if(list.length==1){
- list = list.concat(list,list);
- }
- _self.setData({
- goodcars: list
- })
- })
- },
- loadRecommendedCar:function(e){
- var _self = this;
- get(pathmap.recommended, {
- offset: 0,
- limit: 9
- }, function (json) {
- var list = retCartData(json.data.list)
- _self.setData({
- recommended: list
- })
- })
- },
- loadLikeCar:function(){
- var _self = this;
- get(pathmap.like, {
- offset: 0,
- limit: 10
- }, function (json) {
- var list = retCartData(json.data.list)
- _self.setData({
- like: list
- })
- })
- },
-
- switchTab: function (e) {
- var banner = this.data.banner;
- banner.forEach(function(item,index){
- item.selected = e.detail.current == index;
- });
- this.setData({
- banner: banner
- });
- },
-
- switchReTab:function(e){
- var recommended = this.data.recommended;
-
-
-
-
- recommended.forEach(function(item,index){
- item.selected = e.detail.current == index;
- })
- this.setData({
- recommended: recommended
- });
- },
- submitsearchword:function(word){
- if(word){
- wx.navigateTo({ url: `../buy/buy?keys=${word}`});
- }
- },
- testPost:function(){
- post(pathmap.login,{
- mobile:17343011102,
- code:1234
- },{
- "Content-Type":"application/x-www-form-urlencoded"
- },function(){
- })
- }
-
-
-
-
-
-
-
-
-
-
-
-
- })
|