Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini-program-wepy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mini-program-wepy
Commits
e1c74aad
Commit
e1c74aad
authored
Jun 28, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improvement: bug及优化
parent
44be38d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
27 deletions
+24
-27
common.wxs
src/common/common.wxs
+1
-11
goodsList.wpy
src/components/custom/goodsList.wpy
+7
-2
video.wpy
src/components/custom/video.wpy
+8
-6
search.wpy
src/pages/search.wpy
+8
-8
No files found.
src/common/common.wxs
View file @
e1c74aad
...
@@ -13,20 +13,10 @@ function computClass (current,index,length,circular) {
...
@@ -13,20 +13,10 @@ function computClass (current,index,length,circular) {
function getClass (status) {
function getClass (status) {
var cls=['','green','grey','','red','red'];
var cls=['','green','grey','','red','red'];
var index = status.value || 0;
var index = status.value || 0;
console.log(status)
return cls[index]
return cls[index]
};
};
function showVideo(item,current,index) {
if(item.showType && item.showType.value ==2) {
if(current === index) {
return true
} else {
return false;
}
}
}
module.exports = {
module.exports = {
computClass:computClass,
computClass:computClass,
getClass:getClass,
getClass:getClass,
showVideo:showVideo
}
}
src/components/custom/goodsList.wpy
View file @
e1c74aad
...
@@ -24,7 +24,10 @@
...
@@ -24,7 +24,10 @@
data-item="{{item}}"
data-item="{{item}}"
class="list-item {{tools.computClass(currentIndex,index,list.length,circular)}}"
class="list-item {{tools.computClass(currentIndex,index,list.length,circular)}}"
>
>
<image src="{{item.images}}" class="img"></image>
<van-image use-loading-slot src="{{item.images}}" class="img" width="220rpx" height="210rpx" radius="10rpx" fit="cover">
<van-loading slot="loading" type="spinner" size="20" vertical />
</van-image>
<!--<image src="{{item.images}}" class="img"></image>-->
<view class="title">{{item.title}}</view>
<view class="title">{{item.title}}</view>
<p class="price">¥{{item.price}}</p>
<p class="price">¥{{item.price}}</p>
<p class="buy">{{item.saleCount}}人购买</p>
<p class="buy">{{item.saleCount}}人购买</p>
...
@@ -271,7 +274,9 @@
...
@@ -271,7 +274,9 @@
<config>
<config>
{
{
"usingComponents": {
"usingComponents": {
"go-loading": "~@/components/custom/goloading"
"go-loading": "~@/components/custom/goloading",
"van-image": "~@/components/vant/image/index",
"van-loading": "~@/components/vant/loading/index",
}
}
}
}
</config>
</config>
src/components/custom/video.wpy
View file @
e1c74aad
<!--<wxs module="video" src="../../common/common.wxs"></wxs>-->
<template>
<template>
<view class="container">
<view class="container">
<swiper
<swiper
...
@@ -18,11 +17,12 @@
...
@@ -18,11 +17,12 @@
enable-progress-gesture="{{false}}"
enable-progress-gesture="{{false}}"
show-center-play-btn="{{false}}"
show-center-play-btn="{{false}}"
controls="{{false}}"
controls="{{false}}"
src="{{
item.videoUr
l}}"
src="{{
currentIndex == index ?item.videoUrl :nul
l}}"
data-id="{{item.id}}"
data-id="{{item.id}}"
object-fit="contain"
object-fit="contain"
data-index="{{index}}"
data-index="{{index}}"
@tap="videoTap"
@tap="videoTap"
custom-cache="{{false}}"
wx:if="{{item.showType && item.showType.value ==2}}"
wx:if="{{item.showType && item.showType.value ==2}}"
>
>
<video-pause :pause="videoPause"></video-pause>
<video-pause :pause="videoPause"></video-pause>
...
@@ -113,6 +113,8 @@
...
@@ -113,6 +113,8 @@
const _this = this;
const _this = this;
if (this.curQueue.length === 0) {
if (this.curQueue.length === 0) {
//因为列表默认展示1的位置,而后端逻辑会把要展示的放在0的位置,所以交换位置,展示出来
//因为列表默认展示1的位置,而后端逻辑会把要展示的放在0的位置,所以交换位置,展示出来
//同时展示的元素只有三个,curQueue中始终只有三个元素,用来解决吧video过多时,资源加载问题
//当前的资源加载解决方案是参考小程序的video-swiper源码
newVal.forEach(function (item,index) {
newVal.forEach(function (item,index) {
if(index === 1) {
if(index === 1) {
_this.curQueue[0] = item;
_this.curQueue[0] = item;
...
@@ -126,7 +128,7 @@
...
@@ -126,7 +128,7 @@
});
});
this.playCurrent(1);
this.playCurrent(1);
}else{
}else{
//新进入的数组要去重
//新进入的数组要去重
,新进入的数组去重是需求的逻辑
const curIds = this.curQueue.map(item => item.id);
const curIds = this.curQueue.map(item => item.id);
const nextIds = _this.nextQueue.map(item => item.id);
const nextIds = _this.nextQueue.map(item => item.id);
const allIds = [...curIds, ...nextIds];
const allIds = [...curIds, ...nextIds];
...
@@ -140,6 +142,7 @@
...
@@ -140,6 +142,7 @@
moveSwiper(e) {
moveSwiper(e) {
this.videoPause = false;
this.videoPause = false;
if (e.$wx.detail.source === 'touch') {
if (e.$wx.detail.source === 'touch') {
//增加一个透明遮罩层,控制用户滑动速度,500ms内只能滑动一次,解决用户滑动过快,不触发animationfinish的bug
this.showPopup = true;
this.showPopup = true;
setTimeout(()=>{
setTimeout(()=>{
this.showPopup = false
this.showPopup = false
...
@@ -159,8 +162,8 @@
...
@@ -159,8 +162,8 @@
curQueue = this.curQueue,
curQueue = this.curQueue,
prevQueue = this.prevQueue,
prevQueue = this.prevQueue,
nextQueue = this.nextQueue;
nextQueue = this.nextQueue;
//一共三个数组,curQueue是要显示的数组,
其中只有三个元素prevQueue,放上滑过去的元素
nextQueue放即将进入的元素
//一共三个数组,curQueue是要显示的数组,
prevQueue放上滑过去的元素,
nextQueue放即将进入的元素
//一次最多只展示3个video标签,
每次只有当滑动到当前元素时才把视频的url赋值上,这样
提高加载视频的速度
//一次最多只展示3个video标签,提高加载视频的速度
const current = e.$wx.detail.current;
const current = e.$wx.detail.current;
const diff = current - _last;
const diff = current - _last;
if (diff === 0) return;
if (diff === 0) return;
...
@@ -220,7 +223,6 @@
...
@@ -220,7 +223,6 @@
if(index !== current) {
if(index !== current) {
ctx.pause()
ctx.pause()
}else {
}else {
ctx.seek(0);
ctx.play();
ctx.play();
}
}
}
}
...
...
src/pages/search.wpy
View file @
e1c74aad
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
<view>
<view>
<view class="search-head">
<view class="search-head">
<view class="search-wrapper">
<view class="search-wrapper">
<van-field clearable left-icon="search" placeholder="搜索" bind:confirm="search"></van-field>
<van-field clearable left-icon="search" placeholder="搜索" bind:confirm="search"
value="{{value}}" bind:input ="setValue"
></van-field>
</view>
</view>
<view class="search-cancel" bindtap="
backUrl">取消
</view>
<view class="search-cancel" bindtap="
search">搜索
</view>
</view>
</view>
<view class="search-list" v-show="list.length">
<view class="search-list" v-show="list.length">
<view class="search-item" wx:for="{{list}}" wx:key="index" bindtap="toJingdong" data-item="{{item}}">
<view class="search-item" wx:for="{{list}}" wx:key="index" bindtap="toJingdong" data-item="{{item}}">
...
@@ -39,21 +39,21 @@
...
@@ -39,21 +39,21 @@
isDone:false,
isDone:false,
isLoading:false,
isLoading:false,
showLoading:false,
showLoading:false,
value:''
},
},
methods:{
methods:{
backUrl(
) {
setValue(event
) {
wx.navigateBack({delta: 1})
this.value = event.$wx.detail || '';
},
},
search(event) {
search() {
const val = event.$wx.detail;
if(keyword !== '') {
if(keyword !== '') {
page = 1;
page = 1;
}
}
keyword =
val
;
keyword =
this.value
;
if(page === 1) {
if(page === 1) {
this.list = [];
this.list = [];
}
}
this.getList(
val
);
this.getList(
this.value
);
},
},
getList(val) {
getList(val) {
this.isLoading = true;
this.isLoading = true;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment