Commit 55c1f732 by ArronYR

add home page

parent 2fc5e4a0
//app.js
import req from './utils/Request.js'
import api from './utils/Api.js'
App({
onLaunch: function(options) {
this.options = options
// 请求配置
this.configReq()
// 用户登录
this.checkUserLogin()
},
......@@ -19,13 +17,6 @@ App({
})
},
configReq() {
//配置baseUrl和拦截器,baseUrl例如 /api
req.baseUrl(this.globalData.apiPath).interceptor(res => {
console.log(res)
})
},
/**
* 用户资料授权
*/
......@@ -126,14 +117,14 @@ App({
*/
requestServerLogin: function(wxcode, data, callback) {
let _app = this
req.post('user/login', {
api.login({
code: wxcode,
signature: data.signature,
rawData: data.rawData,
encryptedData: data.encryptedData,
iv: data.iv,
scene: _app.options.query && _app.options.query.scene ? decodeURIComponent(_app.options.query.scene) : ''
}).then(res => res.data).then(res => {
}).then(res => {
if (!res.code) {
_app.globalData.userInfo = res.user
_app.globalData.token = res.token
......@@ -152,7 +143,7 @@ App({
*/
requestServerWithShareData(wxcode, data, callback) {
let _app = this
req.post('user/get_groupid', {
api.shareTicket({
token: _app.globalData.token,
code: wxcode,
encryptedData: data.encryptedData,
......@@ -164,7 +155,6 @@ App({
globalData: {
userInfo: null,
token: '',
apiPath: "https://kt.imgondar.com/api/"
token: ''
}
})
\ No newline at end of file
......@@ -12,12 +12,43 @@
"pages/me/vip/index",
"pages/me/collection/index",
"pages/guide/index",
"pages/guide/detail/index"
"pages/guide/detail/index",
"components/navs/index"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
}
},
"tabBar": {
"color": "#333333",
"selectedColor": "#2BA3D7",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/tabs/icon_home.png",
"selectedIconPath": "images/tabs/icon_home_active.png"
},
{
"pagePath": "pages/search/index",
"text": "搜索",
"iconPath": "images/tabs/icon_search.png",
"selectedIconPath": "images/tabs/icon_search_active.png"
},
{
"pagePath": "pages/me/index",
"text": "我的",
"iconPath": "images/tabs/icon_me.png",
"selectedIconPath": "images/tabs/icon_me_active.png"
}
]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true
}
\ No newline at end of file
const Util = require('../utils/Util.js')
const app = getApp()
module.exports = Behavior({
behaviors: [],
properties: {},
data: {
formApi: 'user/save_formid'
},
attached: function () { },
methods: {
/**
* 绑定页面中收集 formId 的 submit 事件
*/
__collectFormId: function (event) {
let formId = event.detail.formId
let token = app.globalData ? app.globalData.token : ''
this.__postFormId(formId, token)
},
/**
* 提交 formId 到服务器
*/
__postFormId: function (formId, token) {
let that = this
app.requestData(that.data.formApi, Util.sign({
token: token,
formid: formId
}), 'POST', function (res) {
console.log('colletion formid: ', res)
})
}
}
})
\ No newline at end of file
const Util = require('../utils/util.js')
const Util = require('../utils/Util.js')
const app = getApp()
module.exports = Behavior({
......
// components/banners/index.js
const Util = require('../../utils/util')
import api from '../../utils/Api.js'
const Util = require('../../utils/Util.js')
const formBehavior = require('../../behaviors/form.js')
const app = getApp()
......@@ -12,10 +13,11 @@ Component({
properties: {
api: {
type: String,
value: 'course/banners'
value: 'banner/index'
},
banners: {
type: Object,
value: {}
}
},
......@@ -31,13 +33,24 @@ Component({
},
attached() {
// this._getBannerData()
if (!this.data.banners.length) {
this._getBannerData()
}
},
/**
* 组件的方法列表
*/
methods: {
_getBannerData() {
api.home.banner({
token: app.globalData.token
}).then(res => {
this.setData({
banners: res.data
})
})
},
_tapBanner(event) {
let oid = event.currentTarget.dataset.oid
let type = event.currentTarget.dataset.type
......@@ -60,8 +73,6 @@ Component({
url: '/pages/webview/index?url=' + url + '&t=' + type_text,
})
}
},
}
}
})
})
\ No newline at end of file
/* components/banners/index.wxss */
@import "/styles/form.wxss";
.banners-wrapper {
width: 100%;
......
// components/navs/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
"i-grid": "../../iview/grid/index",
"i-grid-item": "../../iview/grid-item/index",
"i-grid-icon": "../../iview/grid-icon/index",
"i-grid-label": "../../iview/grid-label/index"
}
}
\ No newline at end of file
<!--components/navs/index.wxml-->
<view class='v-navs'>
<i-grid i-class="nav-grid">
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_1.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">品牌酒店</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_2.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">精品民宿</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_3.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">亲子乐园</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_4.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">亲子餐厅</i-grid-label>
</i-grid-item>
</i-grid>
<i-grid i-class="nav-grid">
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_5.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">线下活动</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_6.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">美行攻略</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_7.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">儿童教育</i-grid-label>
</i-grid-item>
<i-grid-item i-class="nav-grid-item">
<i-grid-icon i-class="nav-icon">
<image src="/images/navs/icon_nav_8.png" />
</i-grid-icon>
<i-grid-label i-class="nav-label">商家合作</i-grid-label>
</i-grid-item>
</i-grid>
</view>
\ No newline at end of file
/* components/navs/index.wxss */
.v-navs {
padding: 10px 0;
background-color: #fff;
}
.nav-grid {
border-top: none;
border-left: none;
}
.nav-grid-item {
border-right: none;
border-bottom: none;
padding: 7px 10px;
}
.nav-icon {
width: 40px;
height: 40px;
}
.nav-label {
color: #000;
font-size: 12px;
margin-top: 0px;
}
// pages/index.js
import api from '../../utils/Api.js'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
news: [],
heats: [],
businesses: [],
guides: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
this.getHomeData()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
},
getHomeData: function() {
api.home.all({
token: app.globalData.token
}).then(res => {
this.setData({
news: res.data.newProjects,
heats: res.data.heatProjects,
businesses: res.data.businessProjects,
guides: res.data.guides
})
})
}
})
\ No newline at end of file
{}
\ No newline at end of file
{
"navigationBarTitleText": "首页",
"backgroundColor": "#f5f5f5",
"enablePullDownRefresh": true,
"usingComponents": {
"banner": "/components/banners/index",
"navs": "/components/navs/index"
}
}
\ No newline at end of file
<!--pages/index.wxml-->
<text>pages/index.wxml</text>
<view class='v-page'>
<banner />
<navs />
</view>
\ No newline at end of file
......@@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
......@@ -13,7 +13,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.3.0",
"appid": "wx014e1af15c2a641e",
"appid": "wx1b834552a7d49bb3",
"projectname": "qz-tour",
"debugOptions": {
"hidedInDevtools": []
......
import req from './Request.js'
import config from './Config.js'
// 配置baseUrl和拦截器,baseUrl例如 /api
req.baseUrl(config.apiPath).interceptor(res => {
return true
})
export const login = params => {
return req.post('user/login', params).then(res => res.data)
}
export const shareTicket = params => {
return req.post('user/get_groupid', params).then(res => res.data)
}
export const home = {
banner: params => {
return req.post('banner/index', params).then(res => res.data)
},
all: (params) => {
return req.post('project/homeall', params).then(res => res.data)
}
}
export default {
login,
shareTicket,
home
}
\ No newline at end of file
export const Config = {
apiPath: "http://app.maveler.com/api/"
}
export default Config
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment