|
@@ -1,5 +1,9 @@
|
|
|
-import { shuoAPIClient } from '../../common/api/api.js';
|
|
|
-import { parseDate } from '../../lib/util/util.js';
|
|
|
+import {
|
|
|
+ shuoAPIClient
|
|
|
+} from '../../common/api/api.js';
|
|
|
+import {
|
|
|
+ parseDate
|
|
|
+} from '../../lib/util/util.js';
|
|
|
var bmap = require('../../lib/util/bmap-wx.min.js');
|
|
|
//index.js
|
|
|
//获取应用实例
|
|
@@ -36,7 +40,7 @@ Page({
|
|
|
duration: 300
|
|
|
})
|
|
|
},
|
|
|
- onLoad: function () {
|
|
|
+ onLoad: function() {
|
|
|
this.getWeather()
|
|
|
},
|
|
|
onShow(option) {
|
|
@@ -46,7 +50,7 @@ Page({
|
|
|
},
|
|
|
|
|
|
// 获取滚动条当前位置
|
|
|
- onPageScroll: function (e) {
|
|
|
+ onPageScroll: function(e) {
|
|
|
console.log(e)
|
|
|
if (e.scrollTop > 100) {
|
|
|
this.setData({
|
|
@@ -67,24 +71,24 @@ Page({
|
|
|
// 新建百度地图对象
|
|
|
var BMap = new bmap.BMapWX({
|
|
|
ak: '6aRTW16sZP3qEwanrMyQOU3xi2awXWIV'
|
|
|
- });
|
|
|
+ });
|
|
|
BMap.weather({
|
|
|
- fail: function (data) {
|
|
|
+ fail: function(data) {
|
|
|
|
|
|
},
|
|
|
- success: function (data) {
|
|
|
+ success: function(data) {
|
|
|
console.log('getWeather', data)
|
|
|
if (data && data.originalData && data.originalData.results && data.originalData.results[0].weather_data && data.originalData.results[0].weather_data.length > 1) {
|
|
|
let weatherData = data.originalData.results[0].weather_data[1]
|
|
|
let weather = weatherData.weather
|
|
|
if (weather.indexOf('多云') != -1) {
|
|
|
- weatherData.dayPictureUrl = '/img/天气图标/IOS/tianqi01@2x.png'
|
|
|
+ weatherData.dayPictureUrl = '/img/weather/tianqi01@2x.png'
|
|
|
} else if (weather.indexOf('晴') != -1) {
|
|
|
- weatherData.dayPictureUrl = '/img/天气图标/IOS/tianqi05@2x.png'
|
|
|
+ weatherData.dayPictureUrl = '/img/weather/tianqi05@2x.png'
|
|
|
} else if (weather.indexOf('雨') != -1) {
|
|
|
- weatherData.dayPictureUrl = '/img/天气图标/IOS/tianqi03@2x.png'
|
|
|
+ weatherData.dayPictureUrl = '/img/weather/tianqi03@2x.png'
|
|
|
} else if (weather.indexOf('阴') != -1) {
|
|
|
- weatherData.dayPictureUrl = '/img/天气图标/IOS/tianqi02@2x.png'
|
|
|
+ weatherData.dayPictureUrl = '/img/weather/tianqi02@2x.png'
|
|
|
}
|
|
|
that.setData({
|
|
|
weather: weatherData
|
|
@@ -92,7 +96,7 @@ Page({
|
|
|
console.log('that.data.weather', that.data.weather)
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -116,75 +120,73 @@ Page({
|
|
|
|
|
|
//获取主题
|
|
|
getThemes() {
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- shuoAPIClient.request('/api/minapp/ticket/themes',
|
|
|
- {
|
|
|
- startIndex: 0,
|
|
|
- resultNum: 5
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('主题', res)
|
|
|
- if (res.data.results && res.data.results.length) {
|
|
|
- let themes = res.data.results
|
|
|
- let themesDatas = []
|
|
|
- for (let theme of themes) {
|
|
|
- if (theme.catName == '迪士尼') {
|
|
|
- themesDatas[0] = theme
|
|
|
- } else if (theme.catName == '门票') {
|
|
|
- themesDatas[1] = theme
|
|
|
- } else if (theme.catName == '自由行') {
|
|
|
- themesDatas[2] = theme
|
|
|
- } else if (theme.catName == '亲子酒店') {
|
|
|
- themesDatas[3] = theme
|
|
|
- } else if (theme.catName == '演出展览') {
|
|
|
- themesDatas[4] = theme
|
|
|
- } else {
|
|
|
- themesDatas.push(theme)
|
|
|
- }
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ shuoAPIClient.request('/api/minapp/ticket/themes', {
|
|
|
+ startIndex: 0,
|
|
|
+ resultNum: 5
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('主题', res)
|
|
|
+ if (res.data.results && res.data.results.length) {
|
|
|
+ let themes = res.data.results
|
|
|
+ let themesDatas = []
|
|
|
+ for (let theme of themes) {
|
|
|
+ if (theme.catName == '迪士尼') {
|
|
|
+ themesDatas[0] = theme
|
|
|
+ } else if (theme.catName == '门票') {
|
|
|
+ themesDatas[1] = theme
|
|
|
+ } else if (theme.catName == '自由行') {
|
|
|
+ themesDatas[2] = theme
|
|
|
+ } else if (theme.catName == '亲子酒店') {
|
|
|
+ themesDatas[3] = theme
|
|
|
+ } else if (theme.catName == '演出展览') {
|
|
|
+ themesDatas[4] = theme
|
|
|
+ } else {
|
|
|
+ themesDatas.push(theme)
|
|
|
}
|
|
|
- let selectedTheme = themesDatas[1].catId
|
|
|
- this.setData({
|
|
|
- themesDatas,
|
|
|
- selectedTheme
|
|
|
- })
|
|
|
- //更新景点
|
|
|
- this.getViews()
|
|
|
}
|
|
|
- })
|
|
|
+ let selectedTheme = themesDatas[1].catId
|
|
|
+ this.setData({
|
|
|
+ themesDatas,
|
|
|
+ selectedTheme
|
|
|
+ })
|
|
|
+ //更新景点
|
|
|
+ this.getViews()
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
//获取城市
|
|
|
getAreas() {
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- shuoAPIClient.request('/api/minapp/common/areas',
|
|
|
- {
|
|
|
- areaType: 0, //周边地区
|
|
|
- treeId: 0
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('城市', res)
|
|
|
- if (res.data && res.data) {
|
|
|
- let currentRegion = wx.getStorageSync('currentRegion')
|
|
|
- let region = wx.getStorageSync('region')
|
|
|
- let selectedArea = wx.getStorageSync('selectedArea')
|
|
|
- console.log(currentRegion, region, selectedArea)
|
|
|
- this.setData({
|
|
|
- areas: res.data,
|
|
|
- currentRegion: currentRegion ? currentRegion : res.data[0].areaName,
|
|
|
- region: region ? region : 0,
|
|
|
- selectedArea: selectedArea ? selectedArea : res.data[0].areaId
|
|
|
- })
|
|
|
- //更新限时特惠
|
|
|
- this.getSpecialProduct(res.data[0].areaId)
|
|
|
- //更新资讯播报
|
|
|
- this.getInformations(res.data[0].areaId);
|
|
|
- }
|
|
|
- })
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ shuoAPIClient.request('/api/minapp/common/areas', {
|
|
|
+ areaType: 0, //周边地区
|
|
|
+ treeId: 0
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('城市', res)
|
|
|
+ if (res.data && res.data) {
|
|
|
+ let currentRegion = wx.getStorageSync('currentRegion')
|
|
|
+ let region = wx.getStorageSync('region')
|
|
|
+ let selectedArea = wx.getStorageSync('selectedArea')
|
|
|
+ console.log(currentRegion, region, selectedArea)
|
|
|
+ this.setData({
|
|
|
+ areas: res.data,
|
|
|
+ currentRegion: currentRegion ? currentRegion : res.data[0].areaName,
|
|
|
+ region: region ? region : 0,
|
|
|
+ selectedArea: selectedArea ? selectedArea : res.data[0].areaId
|
|
|
+ })
|
|
|
+ //更新限时特惠
|
|
|
+ this.getSpecialProduct(res.data[0].areaId)
|
|
|
+ //更新资讯播报
|
|
|
+ this.getInformations(res.data[0].areaId);
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
//限时特惠
|
|
|
getSpecialProduct(areaId) {
|
|
@@ -195,77 +197,75 @@ Page({
|
|
|
areaId = ''
|
|
|
}
|
|
|
console.log('areaId', areaId)
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
let date = parseDate(new Date())
|
|
|
- shuoAPIClient.request('/api/minapp/ticket/products',
|
|
|
- {
|
|
|
- areaId,
|
|
|
- orderBy: 3,//推荐值至高向低排序
|
|
|
- rushBuy: 1,
|
|
|
- themeId: 101038,
|
|
|
- travelDate: date.year + '-' + date.month + '-' + date.date,
|
|
|
- startIndex: 0,
|
|
|
- resultNum: 10
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('限时特惠', res)
|
|
|
+ shuoAPIClient.request('/api/minapp/ticket/products', {
|
|
|
+ areaId,
|
|
|
+ orderBy: 3, //推荐值至高向低排序
|
|
|
+ rushBuy: 1,
|
|
|
+ themeId: 101038,
|
|
|
+ travelDate: date.year + '-' + date.month + '-' + date.date,
|
|
|
+ startIndex: 0,
|
|
|
+ resultNum: 10
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('限时特惠', res)
|
|
|
+ this.setData({
|
|
|
+ current: 0,
|
|
|
+ specialProducts: []
|
|
|
+ })
|
|
|
+ if (res.data.results && res.data.results.length) {
|
|
|
+ let datas = res.data.results
|
|
|
+ for (let data of datas) {
|
|
|
+ data.startTime = Math.floor(data.startTime / 60)
|
|
|
+ // data.infoTitle = data.infoTitle.length > 16 ? data.infoTitle.substring(0, 16) + '...' : data.infoTitle
|
|
|
+ }
|
|
|
+ let result = []
|
|
|
+ for (var i = 0, len = datas.length; i < len; i += 2) {
|
|
|
+ result.push(datas.slice(i, i + 2));
|
|
|
+ }
|
|
|
+ console.log('限时特惠result', result)
|
|
|
this.setData({
|
|
|
- current: 0,
|
|
|
- specialProducts: []
|
|
|
+ specialProducts: result
|
|
|
})
|
|
|
- if (res.data.results && res.data.results.length) {
|
|
|
- let datas = res.data.results
|
|
|
- for (let data of datas) {
|
|
|
- data.startTime = Math.floor(data.startTime / 60)
|
|
|
- data.infoTitle = data.infoTitle.length > 16 ? data.infoTitle.substring(0, 16) + '...' : data.infoTitle
|
|
|
- }
|
|
|
- let result = []
|
|
|
- for (var i = 0, len = datas.length; i < len; i += 2) {
|
|
|
- result.push(datas.slice(i, i + 2));
|
|
|
- }
|
|
|
- console.log('限时特惠result', result)
|
|
|
- this.setData({
|
|
|
- specialProducts: result
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
//猜你喜欢(景点)
|
|
|
getViews() {
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- shuoAPIClient.request('/api/minapp/ticket/views',
|
|
|
- {
|
|
|
- themeId: this.data.selectedTheme,
|
|
|
- areaId: this.data.selectedArea,
|
|
|
- startIndex: 0,
|
|
|
- resultNum: 20
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('景点', res)
|
|
|
- if (res.data.results && res.data.results.length) {
|
|
|
- let datas = res.data.results
|
|
|
- //分割成两个景点一组
|
|
|
- var result = [];
|
|
|
- for (var i = 0, len = datas.length; i < len; i += 2) {
|
|
|
- result.push(datas.slice(i, i + 2));
|
|
|
- }
|
|
|
- console.log(result)
|
|
|
- this.setData({
|
|
|
- views: result
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.setData({
|
|
|
- views: null
|
|
|
- })
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ shuoAPIClient.request('/api/minapp/ticket/views', {
|
|
|
+ themeId: this.data.selectedTheme,
|
|
|
+ areaId: this.data.selectedArea,
|
|
|
+ startIndex: 0,
|
|
|
+ resultNum: 20
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('景点', res)
|
|
|
+ if (res.data.results && res.data.results.length) {
|
|
|
+ let datas = res.data.results
|
|
|
+ //分割成两个景点一组
|
|
|
+ var result = [];
|
|
|
+ for (var i = 0, len = datas.length; i < len; i += 2) {
|
|
|
+ result.push(datas.slice(i, i + 2));
|
|
|
}
|
|
|
- })
|
|
|
+ console.log(result)
|
|
|
+ this.setData({
|
|
|
+ views: result
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ views: null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
//获取资讯播报
|
|
@@ -273,45 +273,43 @@ Page({
|
|
|
if (!areaId || areaId == '0') {
|
|
|
areaId = ''
|
|
|
}
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- shuoAPIClient.request('/api/minapp/news/informationList',
|
|
|
- {
|
|
|
- areaId,
|
|
|
- startIndex: 0,
|
|
|
- resultNum: 5
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('资讯播报', res)
|
|
|
- if (res.data && res.data) {
|
|
|
- this.setData({
|
|
|
- informations: res.data
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ shuoAPIClient.request('/api/minapp/news/informationList', {
|
|
|
+ areaId,
|
|
|
+ startIndex: 0,
|
|
|
+ resultNum: 5
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('资讯播报', res)
|
|
|
+ if (res.data && res.data) {
|
|
|
+ this.setData({
|
|
|
+ informations: res.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
//获取营销内容
|
|
|
getInfos() {
|
|
|
- wx.showLoading({
|
|
|
- title: '加载中...',
|
|
|
- mask: true
|
|
|
- });
|
|
|
- shuoAPIClient.request('/api/minapp/news/infos',
|
|
|
- {
|
|
|
- page: 0,
|
|
|
- resultNum: 5
|
|
|
- }, false).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- console.log('营销内容', res)
|
|
|
- if (res.data.results && res.data.results.length) {
|
|
|
- this.setData({
|
|
|
- infos: res.data.results
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '加载中...',
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ shuoAPIClient.request('/api/minapp/news/infos', {
|
|
|
+ page: 0,
|
|
|
+ resultNum: 5
|
|
|
+ }, false).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ console.log('营销内容', res)
|
|
|
+ if (res.data.results && res.data.results.length) {
|
|
|
+ this.setData({
|
|
|
+ infos: res.data.results
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
//修改城市之后的回调
|
|
@@ -350,9 +348,9 @@ Page({
|
|
|
},
|
|
|
|
|
|
//搜索框事件
|
|
|
- bindSearch: function(e){
|
|
|
+ bindSearch: function(e) {
|
|
|
console.log(e)
|
|
|
- wx.navigateTo({ //保留当前页面,跳转到应用内的某个页面(最多打开5个页面,之后按钮就没有响应的)
|
|
|
+ wx.navigateTo({ //保留当前页面,跳转到应用内的某个页面(最多打开5个页面,之后按钮就没有响应的)
|
|
|
url: "/pages/menpiao/index?keyword=" + e.detail.value
|
|
|
})
|
|
|
}
|