Commit 8863f108 by ArronYR

add api

parent d19e1013
......@@ -12,8 +12,7 @@
"pages/me/vip/index",
"pages/me/collection/index",
"pages/guide/index",
"pages/guide/detail/index",
"components/navs/index"
"pages/detail/index"
],
"window": {
"backgroundTextStyle": "light",
......
......@@ -4,7 +4,8 @@ module.exports = Behavior({
behaviors: [],
properties: {},
data: {
formApi: 'user/save_formid'
formApi: 'user/save_formid',
formEnable: false
},
attached: function() {},
methods: {
......@@ -13,7 +14,9 @@ module.exports = Behavior({
*/
__collectFormId: function(event) {
let formId = event.detail.formId
if (this.formEnable) {
this.__postFormId(formId)
}
},
/**
......
// pages/guide/detail/index.js
// pages/detail/index.js
import api from '../../utils/Api.js'
import Schedule from '../../utils/Schedule.js'
const {
$Toast
} = require('../../iview/base/index');
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
id: 0,
detail: {},
currentPage: 1,
loading: true,
hasMore: true,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
if (options.id) {
this.setData({
id: options.id
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
let that = this
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中...',
})
new Schedule().task(this.getDetailData).delay(1200).task(() => {
wx.hideNavigationBarLoading()
wx.hideLoading()
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
},
getDetailData: function() {
api.project.detail({
id: this.data.id
}).then(res => {
console.log(res)
})
}
})
\ No newline at end of file
{
"navigationBarTitleText": "详情",
"enablePullDownRefresh": true,
"usingComponents": {
"i-toast": "/iview/toast/index"
}
}
\ No newline at end of file
<!--pages/detail/index.wxml-->
<view class='v-page'>
<i-toast id="toast" />
</view>
\ No newline at end of file
/* pages/detail/index.wxss */
\ No newline at end of file
{
"navigationBarTitleText": "攻略详情"
}
\ No newline at end of file
<!--pages/guide/detail/index.wxml-->
<text>pages/guide/detail/index.wxml</text>
/* pages/guide/detail/index.wxss */
\ No newline at end of file
......@@ -83,6 +83,13 @@ Page({
},
handleDetail: function(event) {
const url = event.currentTarget.dataset.url
wx.navigateTo({
url: '/pages/webview/index?url=' + url,
})
},
getListData: function(callback) {
const p = this.data.currentPage
api.guide.list({
......
<!--pages/guide/index.wxml-->
<view class='v-page'>
<view class='guides-container'>
<view class="guide-wrapper" wx:for="{{guides}}" wx:for-item="n" wx:key="n.id">
<view class="guide-wrapper" wx:for="{{guides}}" wx:for-item="n" wx:key="n.id" catchtap='handleDetail' data-url="{{n.content}}">
<image class='image' src="{{n.poster}}" mode='aspectFill'></image>
<view class='info'>
<view class='text-small intro'>{{n.intro ? n.intro : 'aaa测试'}}</view>
<view class='text-small intro'>{{n.intro ? n.intro : ''}}</view>
<view class='text-small text-hint'>
<text class='tag' wx:for="{{n.tags}}" wx:for-index="idx" wx:key="idx" wx:for-item="t">{{t}}</text>
</view>
......
......@@ -12,6 +12,7 @@ page {
.section-wrapper {
margin-top: 10px;
background-color: #fff;
padding-bottom: 10px;
}
.col-wrapper {
......@@ -67,6 +68,11 @@ page {
justify-content: space-between;
}
.guide-item:last-child {
border-bottom: none;
padding-bottom: 0;
}
.guide-item image {
display: inline-block;
width: 130px;
......
......@@ -20,7 +20,7 @@ Page({
title: options.t
})
wx.setNavigationBarTitle({
title: options.t ? options.t : 'KT精选推荐',
title: options.t ? options.t : '详情',
})
}
},
......
......@@ -37,7 +37,7 @@
"list": []
},
"miniprogram": {
"current": 7,
"current": 8,
"list": [
{
"id": 0,
......@@ -86,6 +86,12 @@
"name": "资料",
"pathName": "pages/me/profile/index",
"query": ""
},
{
"id": -1,
"name": "详情",
"pathName": "pages/detail/index",
"query": "id=1"
}
]
}
......
......@@ -67,6 +67,27 @@ export const saveFormId = params => {
return req.post('user/save_formid', params).then(res => res.data)
}
export const project = {
detail: params => {
return req.post('project/detail', params).then(res => res.data)
},
comments: params => {
return req.post('comment/getCommentByPid', params).then(res => res.data)
},
reservate: params => {
return req.post('project/reservations', params).then(res => res.data)
},
order: params => {
return req.post('order/projectOrder', params).then(res => res.data)
},
enroll: params => {
return req.post('project/getEnrollInfo', params).then(res => res.data)
},
collect: params => {
return req.post('project/collect', params).then(res => res.data)
}
}
export default {
login,
shareTicket,
......@@ -75,5 +96,6 @@ export default {
guide,
search,
saveFormId,
me
me,
project
}
\ 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