Commit bc0add54 by null

init

parent 03f143ca
No preview for this file type
...@@ -3,6 +3,7 @@ App({ ...@@ -3,6 +3,7 @@ App({
globalData: { globalData: {
app_id: 'wx3722cae0d0b62fff', app_id: 'wx3722cae0d0b62fff',
url: 'https://test-es.checheng.com/api/', url: 'https://test-es.checheng.com/api/',
name: '爱车估价助手',
width: 0, width: 0,
height: 0, height: 0,
session_key: '', session_key: '',
......
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
"pages/car-select/specification", "pages/car-select/specification",
"pages/advantage/advantage", "pages/advantage/advantage",
"pages/guide/guide", "pages/guide/guide",
"pages/submit/submit" "pages/submit/submit",
"pages/article/article",
"pages/article-detail/article-detail",
"pages/forum-comment/forum-comment"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
...@@ -43,6 +46,12 @@ ...@@ -43,6 +46,12 @@
"text": "卖车指南", "text": "卖车指南",
"iconPath": "images/guide.png", "iconPath": "images/guide.png",
"selectedIconPath": "images/guide-active.png" "selectedIconPath": "images/guide-active.png"
},
{
"pagePath": "pages/article/article",
"text": "文章",
"iconPath": "images/article.png",
"selectedIconPath": "images/article-active.png"
} }
] ]
}, },
......

14.4 KB | W: | H:

16.1 KB | W: | H:

images/guide-active.png
images/guide-active.png
images/guide-active.png
images/guide-active.png
  • 2-up
  • Swipe
  • Onion skin

649 Bytes | W: | H:

16.8 KB | W: | H:

images/guide.png
images/guide.png
images/guide.png
images/guide.png
  • 2-up
  • Swipe
  • Onion skin
var app = getApp();
var url = app.globalData.url;
var { wxParse } = require('../../wxParse/wxParse.js');
Page({
data: {
title: '',
date: '',
content: ''
},
onLoad: function (options) {
var id = options.id;
this.getDetail(id);
// 监听页面加载的生命周期函数
},
getDetail(id) {
var _this = this;
wx.request({
url: url + 'bbs-articles/' + id,
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data;
wxParse('article', 'html', data.content, _this, 15)
_this.setData({
title: data.name,
date: data.updated_at,
})
}
}
});
},
onReady: function () {
// 监听页面初次渲染完成的生命周期函数
},
onShow: function () {
// 监听页面显示的生命周期函数
},
onPullDownRefresh: function () {
// 监听用户下拉动作
},
onReachBottom: function () {
// 页面上拉触底事件的处理函数
},
onShareAppMessage: function () {
// 用户点击右上角转发
}
});
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#fe9527",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "文章详情",
"backgroundTextStyle": "light"
}
\ No newline at end of file
<import src="../../wxParse/wxParse.wxml" />
<view class="container">
<view class="title">{{title}}</view>
<view class="date">{{date}}</view>
<template class="content-view" is="wxParse" data="{{wxParseData:article.nodes}}"/>
</view>
\ No newline at end of file
.container {
padding: 30rpx;
}
.title {
margin-bottom: 20rpx;
font-size: 38rpx;
font-weight: bold;
}
.date {
font-size: 24rpx;
color: rgba(57,66,77,0.40);
margin-bottom: 36rpx;
}
.WxEmojiView {
font-size: 28rpx;
}
view {
width: 100%;
}
var app = getApp();
var url = app.globalData.url;
var name = app.globalData.name;
Page({
data: {
activeIndex: 0,
list: [],
content: [],
showFlag: false,
itemId: '',
page: 1,
pages: ''
},
onLoad: function () {
wx.showLoading({
title: '正在加载...',
mask: true
});
this.getList();
// 监听页面加载的生命周期函数
},
onShow: function () {
// 监听页面显示的生命周期函数
},
getList: function (init = true) {
var _this = this;
wx.request({
url: url + 'bbs-channels',
data: {
name
},
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data && res.data.data[0];
if (data) {
var tabs = data.categories;
}
_this.setData({
list: tabs,
itemId: tabs[_this.data.activeIndex].id
}, () => {
if (init) {
_this.getItem(_this.data.itemId, 1);
}
wx.hideLoading();
})
}
}
});
},
getItem(id, pageNo, override = false) {
var _this = this;
wx.showLoading({
title: '正在加载...',
mask: true
});
if (pageNo === 1) {
this.setData({
showFlag: false
}, () => {
_this.getDataList(id, pageNo, override, true)
})
} else {
_this.getDataList(id, pageNo, override)
}
},
getDataList: function (id, pageNo, override, showFlag) {
var _this = this;
wx.request({
url: url + 'bbs-articles',
data: {
category_id: id,
page: pageNo,
status: 1
},
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data;
var pages = res.data.meta && res.data.meta.last_page;
_this.setData({
showFlag: showFlag,
page: pageNo, //当前的页号
pages, //总页数
content: override ? [..._this.data.content, ...data] : data
}, () => {
wx.hideLoading();
_this.loading = false;
})
}
}
});
},
tabclick: function (e) {
var index = e.currentTarget.dataset.index;
var id = e.currentTarget.dataset.id;
this.setData({
activeIndex: index,
page: 1
}, () => {
this.setData({
itemId: id
}, () => {
this.getItem(id, 1);
})
})
},
itemclick: function (e) {
var id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/article-detail/article-detail?id=' + id
});
},
onPullDownRefresh: function () {
// 监听用户下拉动作
},
onReachBottom: function () {
// 页面上拉触底事件的处理函数
if (!this.loading && this.data.page < this.data.pages) {
this.getItem(this.data.itemId, this.data.page + 1, true)
}
},
onShareAppMessage: function () {
// 用户点击右上角转发
}
});
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#fe9527",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "养车宝典",
"backgroundTextStyle": "light"
}
\ No newline at end of file
<view class="container">
<scroll-view
scroll-x
class="scroll-view"
scroll-with-animation
>
<view class="item-nav {{activeIndex === index ? 'active': ''}}"
wx:for="{{list}}"
wx:key="{{index}}"
wx:for-item="item"
data-id="{{item.id}}"
data-index="{{index}}"
bindtap="tabclick">
{{item.name}}
</view>
</scroll-view>
<scroll-view scroll-y scroll-with-animation enable-back-to-top class="content-box" wx:if="{{showFlag}}">
<view class="content"
wx:for="{{content}}"
wx:key="{{index}}"
data-index="{{index}}"
data-id="{{item.id}}"
bindtap="itemclick"
wx:if="{{content.length > 0}}">
<image class="content-img" src="{{item.thumb_url}}"></image>
<view class="content-text">
<view class="content-title">{{item.name}}</view>
<view class="content-date">{{item.updated_at}}}</view>
</view>
</view>
<view wx:if="{{content.length === 0}}" class="no-data">暂无数据</view>
</scroll-view>
</view>
\ No newline at end of file
.container {
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.scroll-view {
background-color: #eee;
white-space: nowrap;
position: fixed;
top: 0;
z-index: 99;
}
.scroll-view .item-nav {
display: inline-block;
position: relative;
padding: 28rpx 30rpx;
color: #999;
font-size: 30rpx;
cursor: pointer;
}
.scroll-view .active {
color: #f43838;
}
.scroll-view .active::after {
content: "";
position: absolute;
left: 32rpx;
right: 32rpx;
bottom: 16rpx;
height: 0;
border-bottom: 4rpx solid #f43838;
border-radius: 4rpx;
}
.content-box {
margin-top: 100rpx;
}
.content {
display: flex;
align-items: center;
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #eee;
}
.content-img {
flex: 0 0 200rpx;
height: 140rpx;
}
.content-text {
margin-left: 30rpx;
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
overflow: hidden;
}
.content-title {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
overflow: hidden;
font-size: 32rpx;
font-weight: 500;
}
.content-date {
margin-top: 15rpx;
font-size: 24rpx;
color: rgba(57,66,77,0.40);
}
.no-data {
padding: 30rpx;
text-align: center;
font-size: 28rpx;
color: rgba(57,66,77,0.40);
}
\ No newline at end of file
var app = getApp();
var url = app.globalData.url;
Page({
data: {
item: {},
comments: []
},
onLoad: function (options) {
var id = options.id;
var item = wx.getStorageSync('forumItem');
for (var key in item) {
item[key] = item[key].toString().replace(/\s+/g, '')
}
this.setData({
item
})
this.getComments(id);
},
getComments: function (id) {
var _this = this;
wx.request({
url: url + 'bbs-posts/comments',
data: {
post_id: id
},
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data;
data.forEach((item) => {
for (var key in item) {
item[key] = item[key].toString().replace(/\s+/g, '')
}
})
_this.setData({
comments: data
})
}
}
});
},
onReady: function () {
// 监听页面初次渲染完成的生命周期函数
},
onShow: function () {
// 监听页面显示的生命周期函数
},
onHide: function () {
// 监听页面隐藏的生命周期函数
},
onUnload: function () {
// 监听页面卸载的生命周期函数
},
onPullDownRefresh: function () {
// 监听用户下拉动作
},
onReachBottom: function () {
// 页面上拉触底事件的处理函数
},
onShareAppMessage: function () {
// 用户点击右上角转发
}
});
\ No newline at end of file
{
"usingComponents": {},
"navigationBarBackgroundColor": "#fe9527",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "详情",
"backgroundTextStyle": "light"
}
\ No newline at end of file
<view class="container-forum-comment">
<view class="forum-item">
<view class="forum-item-title">{{item.name}}</view>
<view class="forum-item-content">{{item.name}}</view>
</view>
<scroll-view scroll-y scroll-with-animation enable-back-to-top class="comments">
<view class="comments-item" s-for="comments">
<view class="author">{{item.name}}</view>
<view class="time">回答时间:{{item.updated_at}}</view>
<view class="content">{{item.content}}</view>
</view>
</scroll-view>
</view>
\ No newline at end of file
page {
background: #f2f2f2;
}
.container-forum-comment {
background: #f2f2f2;
padding: 20rpx;
}
.forum-item {
padding: 20rpx 20rpx 20rpx;
border-radius: 10rpx;
background: #fff;
}
.forum-item-title {
padding-bottom: 30rpx;
font-size: 36rpx;
font-weight: 500;
}
.forum-item-content {
font-size: 24rpx;
color: #333;
}
.comments {
margin-top: 20rpx;
}
.comments-item {
padding: 20rpx;
margin-bottom: 20rpx;
border-radius: 10rpx;
background: #fff;
}
.author {
margin-bottom: 12rpx;
font-size: 26rpx;
font-weight: 500;
}
.time {
padding-bottom: 30rpx;
font-size: 24rpx;
color: rgba(57, 66, 77, 0.40);
}
.content {
padding: 30rpx 0 20rpx 0;
border-top: 1rpx solid #eee;
font-size: 28rpx;
color: #333;
}
var app = getApp();
var url = app.globalData.url;
var name = app.globalData.name;
Page({ Page({
data: { data: {
lists: [{ list: [],
page: 1,
pages: 1,
id: '',
guideList: [{
title: "卖车需要准备什么?", title: "卖车需要准备什么?",
txts: "1.身份证 \n 2.行驶证 \n 3.车辆登记证\n 4.车辆钥匙\n 5.车示标(环保标、检字标、交强险标)\n 6.交强险单\n 7.购置税本及购置税发票\n 8.购车发票/最近一次过户发票", txts: "1.身份证 \n 2.行驶证 \n 3.车辆登记证\n 4.车辆钥匙\n 5.车示标(环保标、检字标、交强险标)\n 6.交强险单\n 7.购置税本及购置税发票\n 8.购车发票/最近一次过户发票",
status: false status: false
...@@ -18,11 +26,98 @@ Page({ ...@@ -18,11 +26,98 @@ Page({
status: false status: false
}] }]
}, },
showStatus: function(e) { onLoad: function () {
// 监听页面加载的生命周期函数
this.getChannel()
},
onReady: function () {
// 监听页面初次渲染完成的生命周期函数
},
onShow: function () {
// 监听页面显示的生命周期函数
},
getChannel: function () {
var _this = this;
wx.request({
url: url + 'bbs-forums',
data: {
channel_name: name
},
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data;
// var id = data && data[0].id
var id = 1 // 默认查询养车宝典
_this.setData({
id
}, () => {
_this.getList(id, 1)
})
}
}
});
},
getList(id, pageNo, override = false) {
var _this = this;
this.loading = true;
wx.showLoading({
title: '正在加载...',
mask: true
});
wx.request({
url: url + 'bbs-posts',
data: {
forum_id: id,
page: pageNo,
status: 1
},
success: function (res) {
if (res.statusCode === 200) {
var data = res.data.data;
var pages = res.data.meta && res.data.meta.last_page;
_this.setData({
page: pageNo, //当前的页号
pages, //总页数
list: override ? [..._this.data.list, ...data] : data
}, () => {
wx.hideLoading();
_this.loading = false;
})
}
}
});
},
itemClick: function (e) {
var id = e.currentTarget.dataset.id;
var item = e.currentTarget.dataset.item;
wx.setStorageSync('forumItem', item);
wx.navigateTo({
url: '/pages/forum-comment/forum-comment?id=' + id
});
},
showStatus: function (e) {
let index = e.currentTarget.dataset.index; let index = e.currentTarget.dataset.index;
this.data.lists[index].status = !this.data.lists[index].status; this.data.guideList[index].status = !this.data.guideList[index].status;
this.setData({ this.setData({
lists: this.data.lists guideList: this.data.guideList
}); });
},
onHide: function () {
// 监听页面隐藏的生命周期函数
},
onUnload: function () {
// 监听页面卸载的生命周期函数
},
onPullDownRefresh: function () {
// 监听用户下拉动作
},
onReachBottom: function () {
// 页面上拉触底事件的处理函数
if (!this.loading && this.data.page < this.data.pages) {
this.getList(this.data.id, this.data.page + 1, true)
}
},
onShareAppMessage: function () {
// 用户点击右上角转发
} }
}); });
\ No newline at end of file
<view class="guide-banner"> <view class='container-guide'>
<view class="guide-banner">
<image mode="widthFix" src="../../images/guide-bg.png"></image> <image mode="widthFix" src="../../images/guide-bg.png"></image>
</view> </view>
<view class='guide-content'> <view class='guide-content'>
<view class="guide-item" wx:for="{{lists}}" wx:key="index"> <view class="guide-item" wx:for="{{guideList}}" wx:key="index">
<view catchtap="showStatus" class="title" data-index="{{index}}"> <view catchtap="showStatus" class="title" data-index="{{index}}">
<view> <view>
<text>0{{index + 1}}</text> {{item.title}}</view> <text>0{{index + 1}}</text> {{item.title}}</view>
...@@ -12,4 +13,16 @@ ...@@ -12,4 +13,16 @@
</view> </view>
<view class="txts" wx:if="{{item.status}}">{{item.txts}}</view> <view class="txts" wx:if="{{item.status}}">{{item.txts}}</view>
</view> </view>
</view>
<scroll-view scroll-y scroll-with-animation enable-back-to-top class="forum">
<view class="forum-item" wx:for="{{list}}" wx:key="{{index}}"
wx:for-item="item" data-id="{{item.id}}" data-item="{{item}}" catchtap="itemClick">
<view class="forum-item-title">{{item.name}}</view>
<view class="forum-content">
<view class="view">{{item.read_count}} 查看</view>
<view class="date">{{item.updated_at}}</view>
</view>
</view>
</scroll-view>
</view> </view>
\ No newline at end of file
/* pages/guide/guide.wxss */ /* pages/guide/guide.wxss */
.container-guide {
-webkit-tap-highlight-color:rgba(0,0,0,0);
}
.guide-banner { .guide-banner {
width: 100%; width: 100%;
height: 180rpx; height: 180rpx;
...@@ -13,6 +16,10 @@ ...@@ -13,6 +16,10 @@
font-size: 28rpx; font-size: 28rpx;
} }
.guide-item:last-child {
border-width: 30rpx;
}
.guide-item .title { .guide-item .title {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
...@@ -44,3 +51,30 @@ ...@@ -44,3 +51,30 @@
color: rgb(102,102,102); color: rgb(102,102,102);
background-color: rgb(251,251,251); background-color: rgb(251,251,251);
} }
.forum-item{
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #eee;
}
.forum-item-title {
margin: 20rpx 0 60rpx 0;
font-size: 32rpx;
font-weight: 500;
}
.forum-content {
overflow: hidden;
color: rgba(57,66,77,0.40);
font-weight: normal;
font-size: 24rpx;
}
.forum-content .view {
float: left;
}
.forum-content .date {
float: right;
}
\ 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 sign in to comment