Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix: Fixed some Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonleex committed Apr 19, 2018
1 parent 2987a61 commit 91fd54e
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 94 deletions.
13 changes: 8 additions & 5 deletions src/components/FeedCard/FeedCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
<span>{{ time | time2tips }}</span>
</div>
</header>
<article class="m-text-box m-card-body" @click="handelView">
<div class="m-text-box m-card-con m-text-cut-4" v-if="body.length > 0">
<span class="m-text-cut-4" v-html="replaceURI(body)"></span>
<span class="m-text-shadow" v-if="needPay"> 付费节点,购买后方可查看原文详情</span>
<article class="m-card-body" @click="handelView">
<div class="m-card-con" v-if="body.length > 0">
<p
class="m-text-box m-text-cut-4"
:class="{needPay}"
v-html="replaceURI(body)"></p>
</div>
<feed-image
v-if="images.length > 0"
Expand Down Expand Up @@ -393,7 +395,8 @@ export default {
color: @text-color2;
display: -webkit-box;
margin-bottom: 20px;
.m-text-shadow {
.needPay:after {
content: "付费节点,购买后方可查看原文详情";
text-shadow: 0 0 10px @text-color2;
color: rgba(255, 255, 255, 0);
// filter: DXImageTransform.Microsoft.Blur(pixelradius=2);
Expand Down
7 changes: 5 additions & 2 deletions src/components/FeedCard/v-async-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (!Array.prototype.remove) {
}
};
}
export default (Vue, options = {}) => {
export default Vue => {
const listenList = [];
const imageFileCatch = [];
const imageCatcheList = [];
Expand All @@ -46,10 +46,11 @@ export default (Vue, options = {}) => {
);
};
const isCanShow = item => {
const { el, src, file, q = 40 } = item;
const { el, file, q = 40 } = item;
const isIMG = el.nodeName === "IMG";
if (checkInView(el)) {
let image = new Image();
el.classList.add("loading");
http.get(`/files/${file}?q=${q}&json=true`).then(({ data: { url } }) => {
image.src = url;
image.onload = () => {
Expand All @@ -58,9 +59,11 @@ export default (Vue, options = {}) => {
imageFileCatch.push(file);
imageCatcheList.push(url);
image = null;
el.classList.remove("loading");
};
image.onerror = () => {
listenList.remove(item);
el.classList.remove("loading");
};
});
return true;
Expand Down
6 changes: 6 additions & 0 deletions src/components/common/svgIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<path class="st0" d="M12,1C5.9,1,1,5.9,1,12c0,6.1,4.9,11,11,11s11-4.9,11-11C23,5.9,18.1,1,12,1L12,1z M18.1,9l-7.3,7.4 c0,0,0,0,0,0c0,0,0,0,0,0c-0.1,0.1-0.1,0.1-0.2,0.1c0,0-0.1,0-0.1,0.1c-0.1,0-0.2,0.1-0.3,0.1c-0.1,0-0.2,0-0.3-0.1 c0,0-0.1,0-0.1-0.1c-0.1,0-0.1-0.1-0.2-0.1c0,0,0,0,0,0c0,0,0,0,0,0l-3.6-3.7c-0.4-0.4-0.3-0.9,0-1.3c0.4-0.3,0.9-0.3,1.3,0l2.9,3 l6.6-6.7c0.4-0.4,0.9-0.4,1.3,0C18.4,8,18.4,8.6,18.1,9L18.1,9z" /> </symbol>
<symbol viewBox='0 0 24 24' fill='#FE8F90' id='msg-error'>
<path d="M11.9,1c-6.1,0-11,4.9-11,11s4.9,11,11,11s11-4.9,11-11S18,1,11.9,1z M11.4,6h1.3c0.3,0,0.5,0.1,0.5,0.6 L12.8,14c0,0.2-0.2,0.4-0.4,0.4h-0.9c-0.2,0-0.4-0.2-0.4-0.4l-0.3-7.4C10.8,6.1,11,6,11.4,6L11.4,6z M12,18.2 c-0.7,0-1.3-0.6-1.3-1.3s0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3C13.3,17.6,12.7,18.2,12,18.2L12,18.2z" /> </symbol>
<symbol viewBox='0 0 24 24' fill='#61CAB2' id='message-success'>
<path class="st0" d="M12,1C5.9,1,1,5.9,1,12c0,6.1,4.9,11,11,11s11-4.9,11-11C23,5.9,18.1,1,12,1L12,1z M18.1,9l-7.3,7.4 c0,0,0,0,0,0c0,0,0,0,0,0c-0.1,0.1-0.1,0.1-0.2,0.1c0,0-0.1,0-0.1,0.1c-0.1,0-0.2,0.1-0.3,0.1c-0.1,0-0.2,0-0.3-0.1 c0,0-0.1,0-0.1-0.1c-0.1,0-0.1-0.1-0.2-0.1c0,0,0,0,0,0c0,0,0,0,0,0l-3.6-3.7c-0.4-0.4-0.3-0.9,0-1.3c0.4-0.3,0.9-0.3,1.3,0l2.9,3 l6.6-6.7c0.4-0.4,0.9-0.4,1.3,0C18.4,8,18.4,8.6,18.1,9L18.1,9z"></path>
</symbol>
<symbol viewBox='0 0 24 24' fill='#FE8F90' id='message-error'>
<path d="M11.9,1c-6.1,0-11,4.9-11,11s4.9,11,11,11s11-4.9,11-11S18,1,11.9,1z M11.4,6h1.3c0.3,0,0.5,0.1,0.5,0.6 L12.8,14c0,0.2-0.2,0.4-0.4,0.4h-0.9c-0.2,0-0.4-0.2-0.4-0.4l-0.3-7.4C10.8,6.1,11,6,11.4,6L11.4,6z M12,18.2 c-0.7,0-1.3-0.6-1.3-1.3s0.6-1.3,1.3-1.3c0.7,0,1.3,0.6,1.3,1.3C13.3,17.6,12.7,18.2,12,18.2L12,18.2z"></path>
</symbol>
<!-- msg tool icon End -->
<!-- feed tool icon -->
<symbol viewBox="0 0 24 24" id="feed-more">
Expand Down
101 changes: 36 additions & 65 deletions src/components/loadMore.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<template lang="html">
<div
:style="{transform: translate,transitionDuration: transition}"
:style="{ transform: translate, transitionDuration: transition }"
@mousedown='startDrag'
@touchstart='startDrag'
@mousemove.stop='onDrag'
@touchmove.stop='onDrag'
@mouseup='stopDrag'
@touchend='stopDrag'
@mouseleave='stopDrag'
@transitionend='transitionEnd'
>
<div class="load-more-tips">
<slot name='head'>
Expand All @@ -26,15 +25,11 @@
<span></span>
<span></span>
</div>
<i
v-else
:class="{up: (dragging && dY > topDistance)}"
>↓</i>
<i v-else :class="{up: (dragging && dY > topDistance)}">↓</i>
<span v-if='showText'>{{ status }}</span>
</slot>
</div>
<slot>
</slot>
<slot></slot>
<div class="load-more-tips" v-if='onLoadMore'>
<template v-if='loading'>
<div class="load-more-loading">
Expand Down Expand Up @@ -76,29 +71,9 @@ const getScrollTarget = el => {
}
return document.documentElement;
};
/**
* 节流函数
* @auth: jsonleex <[email protected]>
* @param {Function} fn
* @param {Number} delay
*/
function throttle(fn, delay, scrolling = () => {}) {
let timer = null;
return function(event) {
if (scrolling instanceof Function) {
scrolling(event);
}
const context = this;
const args = arguments;
clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(context, args);
}, delay);
};
}
import _ from "lodash";
export default {
name: "loadMore",
name: "load-more",
props: {
noTranslateAnimation: {
type: Boolean,
Expand Down Expand Up @@ -135,10 +110,6 @@ export default {
onLoadMore: {
type: Function,
default: null
},
scrolling: {
type: Function,
default: () => () => {}
}
},
data() {
Expand Down Expand Up @@ -190,7 +161,9 @@ export default {
},
watch: {
loading(val) {
this.scEl.onscroll = val ? null : this.handleScrolling();
val
? this.scEl.removeEventListener("scroll", this.handleScrolling)
: this.scEl.addEventListener("scroll", this.handleScrolling);
},
requesting(val) {
val || (this.dY = 0);
Expand All @@ -203,18 +176,14 @@ export default {
* @return {Function}
* @author Seven Du <[email protected]>
*/
handleScrolling() {
const timeout = 300;
const fn = () => {
if (this.noMore) return;
if (this.loading) return;
if (!this.bottomReached()) return;
// 加载...
this.loading = true;
this.onLoadMore();
};
return throttle(fn, timeout, this.scrolling);
},
handleScrolling: _.throttle(function() {
if (this.noMore) return;
if (this.loading) return;
if (!this.bottomReached()) return;
// 加载...
this.loading = true;
this.onLoadMore();
}, 300),
bottomReached() {
const elBottom = this.$el.getBoundingClientRect().bottom;
return elBottom - this.visibleHeight <= this.distance && !this.loading;
Expand Down Expand Up @@ -300,31 +269,33 @@ export default {
this.dY = 0;
}
},
// 过渡
transitionEnd() {},
// 初始化
init() {
this.$nextTick(() => {
this.topBarHeight = this.$el.children[0].clientHeight;
this.scrollTarget = getScrollTarget(this.$el);
if (typeof this.onLoadMore === "function") {
this.scEl.onscroll = this.handleScrolling();
}
if (this.canPulldown && !this.fulled()) {
this.beforeRefresh();
}
});
bindEvent() {
if (typeof this.onLoadMore === "function") {
this.scEl.addEventListener("scroll", this.handleScrolling);
}
},
autoLoad() {
if (this.canPulldown && !this.fulled()) {
this.beforeRefresh();
}
}
},
// 挂载时 触发一次刷新
mounted() {
this.init();
this.scrollTarget = getScrollTarget(this.$el);
this.topBarHeight = this.$el.children[0].clientHeight;
this.bindEvent();
this.autoLoad();
},
activated() {
this.$nextTick(this.bindEvent);
},
deactivated() {
this.scEl.onscroll = null;
this.scEl.removeEventListener("scroll", this.handleScrolling);
},
destroyed() {
this.scEl.onscroll = null;
this.scEl.removeEventListener("scroll", this.handleScrolling);
}
};
</script>
Expand Down
7 changes: 1 addition & 6 deletions src/components/pages/Topic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
:class="[classNameBuilder('questions')]"
:on-refresh="handleRefresh"
:on-load-more="handleLoadQuestions"
:scrolling="handleScrolling"
>
<question-item
v-for="question in questions"
Expand Down Expand Up @@ -226,11 +225,7 @@ export default {
},
mounted() {
this.typeNavOffsetTop = this.$refs.types.offsetTop;
if (!(this.loadContainer.onLoadMore instanceof Function)) {
document.onscroll = () => {
this.handleScrolling();
};
}
document.addEventListener("scroll", this.handleScrolling);
}
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pswp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
checkImage() {
if (!this.photoswipe) return;
const currItem = this.photoswipe.currItem;
const { paid_node, paid, amount, file, index } = currItem;
const { paid_node, paid, index } = currItem;
paid_node > 0 &&
(paid
? !currItem.updated && this.updateImage(index)
Expand Down
6 changes: 5 additions & 1 deletion src/page/UserHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</svg>
</div>
<div class="m-box m-flex-grow1 m-aln-center m-flex-base0 m-justify-center m-trans-y">
<span>{{ user.name }}</span>
<span class="m-text-cut">{{ user.name }}</span>
</div>
<div class="m-box m-flex-grow1 m-aln-center m-flex-base0 m-justify-end">
<svg class="m-style-svg m-svg-def">
Expand Down Expand Up @@ -630,6 +630,10 @@ export default {
padding: 25px 20px;
color: @text-color3;
font-size: 26px;
position: sticky;
top: 88px;
z-index: 9;
background-color: #f4f5f6;
.m-style-svg {
margin-left: 20px;
}
Expand Down
4 changes: 2 additions & 2 deletions src/page/discover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
{
title: "找人",
icon: "find",
path: "/find",
path: "/find/pop",
new_tips: true,
tips: "500米内有一大波玩家赶来"
}
Expand All @@ -82,7 +82,7 @@ export default {
},
methods: {
to(path) {
this.$router.push({ path });
this.$router.push(path);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/page/feed/feedDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export default {
activated() {
if (this.feedID) {
this.feedID !== this.oldID
? this.fetchFeed()
? ((this.components = []), (this.rewardList = []), this.fetchFeed())
: setTimeout(() => {
this.loading = false;
}, 600);
Expand Down
15 changes: 7 additions & 8 deletions src/page/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,30 @@ export default {
return this.user.extra || {};
},
new_wallet() {
return this.user.new_wallet || {};
return this.user.new_wallet || { balance: 0 };
},
new_balance() {
return this.new_wallet.balance.toFixed(2);
return (this.new_wallet.balance / 100).toFixed(2);
},
currency() {
return this.user.currency || {};
return this.user.currency || { sum: 0 };
},
sum() {
return this.currency.sum.toFixed(2);
return this.currency.sum;
},
verified() {
return this.user.verified;
}
},
methods: {
RefreshUserData() {
const id = this.user.id;
this.$http.get(`users/${id}`).then(({ data = {} }) => {
this.$http.get(`/user`).then(({ data = {} }) => {
data &&
data.id === id &&
(this.$store.commit("SAVE_USER", Object.assign(this.user, data)),
this.$store.commit(
"SAVE_CURRENTUSER",
Object.assign({}, this.user, data)
);
));
});
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/style/reset.less
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ section {
}

body {
line-height: 1;
line-height: normal;
}

ol,
Expand Down Expand Up @@ -173,7 +173,7 @@ select:-webkit-autofill {

textarea::-webkit-input-placeholder,
input::-webkit-input-placeholder {
font-size: 30px;
font-size: inherit;
color: #ccc;
}
input[type="text"]:focus,
Expand Down
4 changes: 3 additions & 1 deletion src/util/rem.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
let clientWidth = docEl.clientWidth;
if (!clientWidth) return;
clientWidth = clientWidth > 780 ? 780 : clientWidth;
docEl.style.fontSize = 100 * (clientWidth / 750) + "px";
const rem = 100 * (clientWidth / 750);
win.$REM = rem;
docEl.style.fontSize = `${rem}px`;
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
Expand Down

0 comments on commit 91fd54e

Please sign in to comment.