123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- import request from '../../utils/request'
- Page({
-
- data: {
- bannerList:[],
- naxiImgUrl:'',
- macunImgUrl:'',
- hotScenicList:[],
- hotCountList:[],
- leftImg:[],
- rightImg:[],
- hotFoodList:[],
- swiperImgPath:[]
- },
-
- onLoad:async function(options) {
-
- let banners = await request('/front/banner')
-
- this.setData({
- bannerList:banners
- })
-
-
- let naxiImg = await request('/front/introduce/files/1')
-
- this.setData({
- naxiImgUrl:naxiImg[0].iconPath
- })
-
- let macunImg = await request('/front/introduce/files/2')
-
- this.setData({
- macunImgUrl:macunImg[0].iconPath
- })
-
- let sceneryImgList = await request('/front/scenicSpotAndCallout')
-
-
-
- for(let i = 0;i < sceneryImgList.length - 1;i++){
- for(let j = 0;j < sceneryImgList.length - 1 - i;j++){
- if(sceneryImgList[j].viewCount < sceneryImgList[j+1].viewCount){
- let temp = sceneryImgList[j]
- sceneryImgList[j] = sceneryImgList[j+1]
- sceneryImgList[j+1] = temp
- }
- }
- }
- this.setData({
- hotScenicList:sceneryImgList
- })
-
- let leftImg = this.data.leftImg
- let rightImg = this.data.rightImg
- let hotScenicList = this.data.hotScenicList
- for(let i = 0;i < hotScenicList.length;i++){
- if(i % 2 == 0 && leftImg.length < 2){
- leftImg.push(hotScenicList[i])
- }else if(i % 2 != 0 && rightImg.length < 2){
- rightImg.push(hotScenicList[i])
- }
- }
- this.setData({
- leftImg,
- rightImg
- })
-
-
- let foodList = await request('/front/merchantAndCallout')
- console.log(foodList);
-
- for(let i = 0;i < foodList.length - 1;i++){
- for(let j = 0;j < foodList.length - 1 - i;j++){
- if(foodList[j].viewCount < foodList[j+1].viewCount){
- let temp = foodList[j]
- foodList[j] = foodList[j+1]
- foodList[j+1] = temp
- }
- }
- }
-
- let hotFoodList = this.data.hotFoodList
- for(let i = 0;i <foodList.length;i++){
- if(hotFoodList.length < 4){
- hotFoodList.push(foodList[i])
- }
- }
- this.setData({
- hotFoodList
- })
- console.log(this.data.hotFoodList);
-
- },
-
- toPreviewImage(){
- let imgUrl = this.data.bannerList
- let swiperImgPath = this.data.swiperImgPath
- for(let i = 0;i < imgUrl.length;i++){
- swiperImgPath[i] = imgUrl[i].iconPath
- }
-
- wx.previewImage({
- urls: swiperImgPath,
- })
- },
-
- toMainIntro() {
- wx.navigateTo({
- url: '/pages/naxiIntro/naxiIntro',
- })
- },
-
- toSecondIntro() {
- wx.navigateTo({
- url: '/pages/macunIntro/macunIntro',
- })
- },
-
- toScenicList() {
- wx.navigateTo({
- url: '/pages/scenicList/scenicList',
- })
- },
-
-
- toRecommendFood(){
- wx.navigateTo({
- url: '/pages/recommendFood/recommendFood',
- })
- },
-
- toNavMap(){
- wx.switchTab({
- url: '/pages/map/map',
- })
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- }
- })
|