Skip to content

Commit

Permalink
开发版本测试
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzexia committed Jan 22, 2019
1 parent c6cff13 commit 42cd276
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,6 +1,7 @@
.DS_Store
node_modules/
dist/
.vscode/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand All @@ -10,4 +11,4 @@ yarn-error.log*
*.suo
*.ntvs*
*.njsproj
*.sln
*.sln
8 changes: 5 additions & 3 deletions server/controllers/detail.js
Expand Up @@ -4,13 +4,15 @@ module.exports = async (ctx) => {
console.log('ctx.request', ctx.request)
let {tid} = ctx.request.query
console.log('id::::::', tid)
let detail = await mysql('threads')
.select('threads.*')
let detail = await mysql('lists')
.select('threads.*', 'lists.titleurl', 'lists.author', 'lists.views', 'lists.release_date')
.join('threads', 'threads.tid', 'lists.id')
.where('tid', tid)
.first()
console.log('detail', detail)
ctx.state.data = Object.assign({}, detail, {
tags: JSON.parse(detail.tags)
tags: JSON.parse(detail.tags),
msg: 'success'
})
}

3 changes: 2 additions & 1 deletion server/controllers/lists.js
Expand Up @@ -5,7 +5,8 @@ module.exports = async (ctx) => {
console.log(page, size)
const mysqlSelect = mysql('lists')
.select('lists.*', 'threads.tid')
.join('threads', 'lists.title', 'threads.title')
.join('threads', 'lists.id', 'threads.tid')
.orderBy('release_date', 'desc')
console.log('mysqlselect', mysqlSelect)
let lists
lists = await mysqlSelect.limit(size).offset(Number(page) * 10)
Expand Down
11 changes: 11 additions & 0 deletions src/App.vue
Expand Up @@ -7,6 +7,17 @@ export default {
wx.setStorageSync('logs', logs)
console.log('app created and cache logs by setStorageSync')
},
onLaunch () {
wx.showShareMenu({
withShareTicket: true
})
},
onShareAppMessage () {
return {
title: 'w3cplus.com',
path: 'pages/index/main'
}
}
}
</script>
Expand Down
8 changes: 7 additions & 1 deletion src/app.json
Expand Up @@ -9,6 +9,12 @@
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "W3Cplus",
"navigationBarTextStyle": "black",
"onReachBottomDistance": 10
"onReachBottomDistance": 50
},
"plugins": {
"wxparserPlugin": {
"version": "0.2.1",
"provider": "wx9d4d4ffa781ff3ac"
}
}
}
37 changes: 23 additions & 14 deletions src/components/card.vue
Expand Up @@ -2,9 +2,9 @@
<div class="item">
<h3 class="item-title">{{list.title}}</h3>
<div class="item-header">
<span>作者:大漠</span>
<span>日期:2019-01-15</span>
<span>点击:1975</span>
<span v-show="list.author">作者:{{list.author}}</span>
<span v-show="list.release_date">日期:{{format}}</span>
<span v-show="list.views">浏览:{{list.views}}</span>
</div>
<div class="item-tags">
<span v-for="(itl, i) in list.tags" :key="i">{{itl}}</span>
Expand All @@ -22,6 +22,10 @@ export default {
computed: {
detailUrl () {
return `/pages/detail/main?id=${this.list.id}`
},
format () {
let d = this.list.release_date || ''
return d.slice(0, 10)
}
}
}
Expand All @@ -30,20 +34,21 @@ export default {
<style lang="scss">
$white: #fff;
$bg-color: #f7f7f7;
$text-main: #333;
$button-primary: #67c23a;
$text-default: #969fa9;
$button-primary: #409eff;
$text-sign: #999;
.item{
margin: 10px 0;
padding: 8px;
margin: 15px 0;
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,.5);
box-shadow: 0 0 10px rgba(0,0,0,.3);
.item-title{
font-size: 18px;
}
.item-header{
font-size: 14px;
font-size: 12px;
margin: 8px 0 5px;
opacity: 0.8;
color: $text-sign;
span{
display:inline-block;
margin: 0 5px;
Expand All @@ -56,13 +61,16 @@ $button-primary: #67c23a;
}
}
.item-tags{
font-size: 14px;
opacity: 0.5;
font-size: 12px;
color: $text-sign;
span{
display: inline-block;
margin: 0 5px;
height: 18px;
line-height: 18px;
padding: 1px 4px;
height: 16px;
line-height: 16px;
border: 1px solid $text-sign;
border-radius: 5px;
&:first-child{
margin-left: 0;
}
Expand All @@ -75,6 +83,7 @@ $button-primary: #67c23a;
margin: 5px 0 8px;
font-size: 16px;
word-wrap:break-word;
color: $text-default;
}
.item-button{
height: 35px;
Expand Down
3 changes: 2 additions & 1 deletion src/config.js
@@ -1,8 +1,9 @@
// 配置项

// const host = 'http://192.168.0.100:5757'
const host = 'http://localhost:5757'
const imgHost = 'https://www.w3cplus.com'
// const host = 'https://eeweou0j.qcloud.la' // 测试环境域名
// const host = 'https://5nk707kw.qcloud.la' // 测试环境域名

const config = {
imgHost,
Expand Down
118 changes: 97 additions & 21 deletions src/pages/detail/index.vue
Expand Up @@ -5,32 +5,53 @@
</div>
<div class="detail-header">
<div class="detail-basic">
<span>作者:大漠</span>
<span>日期:2019-01-15</span>
<span>点击:1975</span>
<span v-show="detail.author">作者:{{detail.author}}</span>
<span v-show="detail.release_date">日期:{{format}}</span>
<span v-show="detail.views">浏览:{{detail.views}}</span>
</div>
<div class="detail-tags">
<span v-for="itl in detail.tags" :key="itl">{{itl}}</span>
</div>
</div>
<div class="detail-content">
<!-- <div v-html="detail.message"></div> -->
<wxParse :content="formatMessage"></wxParse>
<wxParse className="detail-message" :content="detail.message" @preview="preview" @navigate="navigate" :imageProp="imageProp" :noData="noData"></wxParse>
<!-- <wxparser class="detail-message" :rich-text="formatMsg"></wxparser> -->
<div class="detail-share">
<button type="default" open-type="share">分享</button>
</div>
<div class="detail-signature">
<p>著作权归作者所有。</p>
<p>商业转载请联系作者获得授权,非商业转载请注明出处。</p>
<p>原文: <i>{{detail.titleurl}}</i> © w3cplus.com</p>
</div>
</div>
</div>
</template>
<script>
import { get } from '@/util'
import {formatTime} from '@/utils/index.js'
import config from '@/config'
import wxParse from 'mpvue-wxparse'
export default {
data () {
return {
tid: 0,
detail: {}
detail: {},
imageProp: {
mode: 'aspectFit',
padding: 0,
lazyLoad: false,
domain: 'www.w3cplus.com'
},
noData: '<div style="color: #00b7e9;text-align:center;">Loading...</div>'
}
},
computed: {
format () {
let d = this.detail.release_date || ''
return d.slice(0, 10)
},
// 格式化html片段
formatMessage () {
let msg = ''
Expand All @@ -39,28 +60,60 @@ export default {
msg = this.detail.message.replace(reg, (item, index, str) => {
// 给图片添加域名
return `src="${config.imgHost}${item.slice(5)}`
})
}).replace(/\\/g, '').replace(/\n/g, '')
}
console.log('msg:::', msg)
return msg
}
},
components: {
wxParse
},
mounted () {
console.log('config', config)
console.log('config', this.$root.$mp)
this.tid = this.$root.$mp.query.id
console.log('=====', this.tid)
this.getDetail()
},
beforeDestroy () {
this.detail = {}
console.log('销毁之前', this.detail)
},
onLoad () {
wx.showLoading({ title: '加载中...' })
wx.showShareMenu({
withShareTicket: true
})
},
onUnload () {
this.detail = {}
console.log('onUnload', this.detail)
},
onShareAppMessage () {
return {
title: this.detail.title,
path: this.$root.$mp
}
},
methods: {
formatTime,
// 获取详情
async getDetail () {
let detail = await get('/weapp/detail', { tid: this.tid })
console.log(detail)
if (Number(detail.code) === 0 && detail.data) {
this.detail = detail.data
console.log('this.detail:::', this.detail)
wx.hideLoading()
}
},
preview (src, e) {
console.log('previes:::', src)
console.log('previes:::', e)
},
navigate (href, e) {
console.log('navigate:::', href)
console.log('navigate:::', e)
}
}
}
Expand All @@ -72,7 +125,9 @@ $white: #fff;
$bg-color: #f7f7f7;
$title-color: #00b7e9;
$text-main: #333;
$button-primary: #67c23a;
$text-sign: #999;
$button-primary: #409eff;
$hover: #29B4F0;
.detail {
padding: 0 30rpx;
color: $text-main;
Expand All @@ -82,8 +137,8 @@ $button-primary: #67c23a;
}
.detail-header {
margin: 8px 0;
font-size: 14px;
opacity: 0.8;
font-size: 12px;
opacity: 0.5;
span {
display: inline-block;
margin: 0 5px;
Expand All @@ -99,23 +154,44 @@ $button-primary: #67c23a;
.detail-basic {
}
.detail-tags {
font-size: 12px;
margin-top: 5px;
opacity: 0.5;
span{
padding: 1px 4px;
display: inline-block;
height: 16px;
line-height: 16px;
border: 1px solid $text-sign;
border-radius: 5px;
}
}
}
.detail-content {
opacity: 0.75;
h1,
h2,
h3,
h4,
h5,
h6 {
color: $title-color;
padding-bottom: 50px;
.detail-message{
h1,
h2,
h3,
h4,
h5,
h6 {
color: $title-color;
}
img{
width: 100%;
height: auto;
}
}
img{
width: 100%;
height: auto;
.detail-signature{
font-size: 14px;
color: $text-sign;
p{
line-height: 28px;
i{
color: $hover;
}
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/detail/main.json
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "详情"
"navigationBarTitleText": "详情",
"usingComponents": {
"wxparser": "plugin://wxparserPlugin/wxparser"
}
}

0 comments on commit 42cd276

Please sign in to comment.