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
d15cdf1d
Commit
d15cdf1d
authored
May 14, 2020
by
ziyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improvement: 移动原有代码到当前项目
parent
c591a6d4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
499 additions
and
547 deletions
+499
-547
app.wpy
src/app.wpy
+14
-6
videolist.wpy
src/components/custom/videolist.wpy
+132
-0
auth.wpy
src/pages/auth.wpy
+15
-270
index.wpy
src/pages/index.wpy
+333
-255
index.js
src/store/index.js
+5
-16
test1.jpg
static/images/test1.jpg
+0
-0
test2.png
static/images/test2.png
+0
-0
No files found.
src/app.wpy
View file @
d15cdf1d
...
@@ -2,15 +2,15 @@
...
@@ -2,15 +2,15 @@
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import eventHub from './common/eventHub';
import eventHub from './common/eventHub';
import vuex from '@wepy/x';
import vuex from '@wepy/x';
wepy.use(vuex);
wepy.use(vuex);
//import store from './store';
wepy.app({
wepy.app({
hooks: {
hooks: {
// App 级别 hook,对整个 App 生效
// App 级别 hook,对整个 App 生效
// 同时存在 Page hook 和 App hook 时,优先执行 Page hook,返回值再交由 App hook 处
// 同时存在 Page hook 和 App hook 时,优先执行 Page hook,返回值再交由 App hook 处
},
},
globalD
ata: {
d
ata: {
userInfo: null
userInfo: null
},
},
...
@@ -23,19 +23,26 @@ wepy.app({
...
@@ -23,19 +23,26 @@ wepy.app({
wx.getUserInfo({
wx.getUserInfo({
success: res => {
success: res => {
// 可以将 res 发送给后台解码出 unionId
// 可以将 res 发送给后台解码出 unionId
that.globalData.userInfo = res.userInfo
// store.dispatch('setUserInfo',res.userInfo);
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
// 所以此处加入 callback 以防止这种情况
if (that.userInfoReadyCallback) {
if (that.userInfoReadyCallback) {
that.userInfoReadyCallback(res)
that.userInfoReadyCallback(res => {
// store.dispatch('setUserInfo',res.userInfo);
})
}
}
},
fail: ()=> {
wx.reLaunch({
url: '/pages/auth',
})
}
}
})
})
}else{
}else{
// 未授权,跳转到授权页面
// 未授权,跳转到授权页面
wx.reLaunch({
wx.reLaunch({
url: '/pages/auth
/auth
',
url: '/pages/auth',
})
})
}
}
}
}
...
@@ -47,7 +54,8 @@ wepy.app({
...
@@ -47,7 +54,8 @@ wepy.app({
<config>
<config>
{
{
pages: [
pages: [
'pages/index'
'pages/index',
'pages/auth'
],
],
window: {
window: {
navigationStyle: "custom",
navigationStyle: "custom",
...
...
src/components/custom/videolist.wpy
0 → 100644
View file @
d15cdf1d
<style lang="less">
page {
width: 100%;
height: 100%;
}
.container{
width:100%;
height:100%
}
.video-swiper{
width:100%;
height:100%
}
.video_item{
height:100%;
width:100%;
position: absolute;
z-index: 1;
}
</style>
<template>
<view class="container">
<swiper
class="video-swiper"
:duration= "800"
circular="{{circular}}"
vertical
current="1"
bindanimationfinish="animationfinish"
>
<!-- curQueue 循环会导致video重新插入,objectFit 不可变更 -->
<swiper-item wx:for="{{currentVideo}}" wx:key="index">
<view class="video-wrapper">
<video
id="video_{{index}}"
class="video_item"
loop
enable-play-gesture
enable-progress-gesture
autoplay
show-center-play-btn="{{false}}"
controls="{{false}}"
src="{{item.url}}"
data-id="{{item.id}}"
object-fit="{{item.objectFit || 'contain'}}"
data-index="{{index}}"
binderror="onError"
bindwaiting="onWaiting"
bindloadedmetadata="onLoadedMetaData"
>
</video>
<slot></slot>
</view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import wepy from '@wepy/core';
wepy.component({
props:{
videoList: {
type: Array,
value: []
},
duration: {
type: Number,
value: 800
},
},
data: {
circular: false,
currentVideo: [],
_videoContexts: [],
},
watch: {
videoList () {
var newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
this._videoListChanged(newVal);
}
},
methods: {
_videoListChanged (newVal) {
var _this = this;
let currentVideo = this.currentVideo;
let _videoContexts = this._videoContexts;
let first = currentVideo.length === 0;
let length = this.currentVideo.length;
newVal.forEach(function (item,index) {
currentVideo.push(item);
_videoContexts.push(wx.createVideoContext('video_'+length+index, _this))
});
this.currentVideo = currentVideo;
this._videoContexts = _videoContexts;
first && this.playCurrent(1);
/*this.setData({
currentVideo: data.currentVideo,
_videoContexts: data._videoContexts,
}, function () {
_this.playCurrent(1);
});*/
},
animationfinish(e) {
console.log(e.$wx.detail)
var current = e.$wx.detail.current;
this.playCurrent(current);
let curQueue = this.currentVideo;
this.$emit('change', { activeId: curQueue[current].id });
},
onWaiting (e) {
this.trigger(e, 'wait');
},
onLoadedMetaData (e) {
this.trigger(e, 'loadedmetadata');
},
onError(e) {
this.trigger(e, 'error');
},
playCurrent(current) {
this._videoContexts.forEach(function (ctx, index) {
index !== current ? ctx.pause() : ctx.play();
});
},
trigger(e, type) {
var ext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var detail = e.$wx.detail;
var activeId = e.target.dataset.id;
this.$emit(type, Object.assign(Object.assign(Object.assign({}, detail), { activeId: activeId }), ext));
}
},
});
</script>
src/pages/auth.wpy
View file @
d15cdf1d
<style lang="less">
<style lang="less">
input {
.contain {
border: 1rpx solid #ccc;
padding:200rpx 0;
display: inline-block;
width: 200rpx;
border-radius: 5rpx;
}
.info {
padding-right: 10rpx;
}
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.slide {
width: 640rpx;
display: flex;
border: 1rpx solid #ccc;
font-size: 28rpx;
align-items: center;
box-sizing: border-box;
.left {
width: 750rpx;
padding: 20rpx;
}
.right {
display: flex;
.right-item {
padding: 20rpx 30rpx;
background-color: red;
color: #fff;
}
}
}
</style>
<wxs module="m1" lang="babel">
const getTime = (time) => {
let date = getDate(time);
let hour = date.getHours();
let mins = date.getMinutes();
let sec = date.getSeconds();
let milli = date.getMilliseconds();
return `${hour}:${mins}:${sec}.${milli}`;
}
}
module.exports.getTime = getTime;
</style>
</wxs>
<template>
<template>
<div class="container">
<div class="contain">
<div class="userinfo" @tap="handleViewTap">
<p>需要进行微信授权</p>
<image class="userinfo-avatar" src="{{ userInfo.avatarUrl }}" background-size="cover"/>
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">授权登录</button>
<div class="userinfo-nickname">{{ userInfo.nickName }}</div>
</div>
<div>
<div class="title" slot="title">测试数据绑定</div>
<text class="info" @tap="currentTime = +new Date()">{{m1.getTime(currentTime)}}</text>
<text class="info">{{setTimeoutTitle}}</text>
<text class="info" @tap="mixintap">{{mixin}}</text>
<text class="info">{{testcomputed}}</text>
<text class="info">{{counter}}</text>
</div>
<div>
<div class="title" slot="title">其它测试</div>
<!--button @tap="toast" size="mini">第三方组件</button-->
<button @tap="communicate" size="mini">组件通信</button>
<button @tap="tap" size="mini">混合TAP事件</button>
</div>
<div>
<div class="title" slot="title">测试并发网络请求</div>
<div>返回结果: <text>{{netrst}}</text></div>
<button @tap="request" size="mini"> 点我发起10个请求 </button>
</div>
<div>
<div class="title" slot="title">测试 v-model</div>
<div style="display: flex; align-items: center;">
<input v-model="inputmodel" />
<text style="margin-left: 30rpx;">Value: {{inputmodel}}</text>
</div>
</div>
<div>
<div class="title" slot="title">测试组件</div>
<text class="testcounter">全局计数器:</text>
<div class="counterview">
<button @tap="mynum++" size="mini">全局计数器: {{mynum}}</button>
</div>
<text class="testcounter">计数组件1 - num: </text>
<div class="counterview">
// <counter @index-emit.user="counterEmit" />
</div>
<text class="testcounter">计数组件2 - num.sync: </text>
<div class="counterview">
// <counter :num.sync="mynum"></counter>
</div>
</div>
<div>
<div class="title" slot="title">测试组件Repeat</div>
<div v-for="(item, index) in groupList">
<text>{{item.name}}</text>
//<group :grouplist="item" :index="index"></group>
</div>
</div>
<div>
<div class="title" slot="title">测试列表</div>
// <list></list>
</div>
<div>
<div class="title" slot="title">测试引用vant组件</div>
<van-button type="danger">默认按钮</van-button>
</div>
<!--toast /-->
</div>
</div>
</template>
</template>
<script>
<script>
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import eventHub from '../common/eventHub';
import { mapState } from '@wepy/x';
import store from '../store';
import store from '../store';
import testMixin from '../mixins/test';
wepy.page({
wepy.page({
store,
config: {
navigationBarTitleText: 'test'
},
hooks: {
hooks: {
// Page 级别 hook, 只对当前 Page 的 setData 生效。
'before-setData': function (dirty) {
'before-setData': function (dirty) {
if (Math.random() < 0.2) {
console.log('setData canceled');
return false; // Cancel setData
}
dirty.time = +new Date();
return dirty;
}
}
},
},
mixins: [testMixin],
data: {
data: {
inputmodel: 'v-model',
canIUse: wx.canIUse('button.open-type.getUserInfo')
mynum: 20,
userInfo: {
nickName: '加载中...'
},
currentTime: +new Date(),
setTimeoutTitle: '标题三秒后会被修改',
count: 0,
netrst: '',
groupList: [
{
id: 1,
name: '点击改变',
list: [
{
childid: '1.1',
childname: '子项,点我改变'
}, {
childid: '1.2',
childname: '子项,点我改变'
}, {
childid: '1.3',
childname: '子项,点我改变'
}
]
},
{
id: 2,
name: '点击改变',
list: [
{
childid: '2.1',
childname: '子项,点我改变'
}, {
childid: '2.2',
childname: '子项,点我改变'
}, {
childid: '2.3',
childname: '子项,点我改变'
}
]
},
{
id: 3,
name: '点击改变',
list: [
{
childid: '3.1',
childname: '子项,点我改变'
}
]
}
]
},
},
computed: {
computed: {
...mapState([ 'counter' ]),
testcomputed () {
return 'computed - ' + this.mynum;
}
},
},
methods: {
methods: {
handleViewTap () {
getUserInfo (e) {
console.log('handleVieTap clicked');
store.dispatch('setUserInfo',e.$wx.detail.userInfo);
},
wx.reLaunch({
tap () {
url: '/pages/index',
throw new Error('can not go here');
})
},
plus () {
this.mynum++;
},
toast () {
let promise = this.$invoke('toast', 'show', {
title: '自定义标题',
img: 'https://raw.githubusercontent.com/kiinlam/wetoast/master/images/star.png'
});
promise.then((d) => {
console.log('toast done');
});
},
mixintap () {
console.log('do noting from ' + this.$is);
},
communicate () {
let counters = this.$children.filter((com) => com.$is === 'components/counter');
// Get children counter
counters[0].num++;
counters[1].num--;
eventHub.$emit('app-launch', {a: 1}, {b: 2});
},
request () {
let self = this;
let i = 10;
let map = ['MA==', 'MQo=', 'Mg==', 'Mw==', 'NA==', 'NQ==', 'Ng==', 'Nw==', 'OA==', 'OQ=='];
while (i--) {
wx.request({
url: 'https://www.madcoder.cn/tests/sleep.php?time=1&t=css&c=' + map[i] + '&i=' + i,
success: function (d) {
if (d.statusCode !== 200) {
self.netrst += d.statusCode + '.';
} else {
self.netrst += d.data + '.';
}
}
});
}
},
counterEmit (num) {
console.log(`${this.$is} receive event, the number is: ${num}`);
}
}
},
},
created () {
created () {
let self = this;
self.currentTime = +new Date();
self.setTimeoutTitle = '标题三秒后会被修改';
setTimeout(() => {
self.setTimeoutTitle = '到三秒了';
}, 3000);
wx.getUserInfo({
success (res) {
self.userInfo = res.userInfo;
}
});
}
}
});
});
</script>
</script>
<config>
<config>
{
{
navigationBarTitleText: '
WePY 2.0 Feature Demo
',
navigationBarTitleText: '
微信授权
',
usingComponents: {
usingComponents: {
'van-button': '../components/vant/button/index'
'van-button': '../components/vant/button/index'
}
}
...
...
src/pages/index.wpy
View file @
d15cdf1d
<style lang="less">
<style lang="less">
input {
page{
border: 1rpx solid #ccc;
height: 100%;
display: inline-block;
width: 200rpx;
border-radius: 5rpx;
}
}
.info {
.video-wrapper{
padding-right: 10rpx;
width: 100%;
height: 100%;
}
}
.userinfo {
#myvideo{
display: flex;
width: 100%;
flex-direction: column;
height: 100%;
align-items: center;
position: absolute;
z-index: 2;
background-color:rgba(0, 0, 0, 0.7);
}
}
.userInfo{
.userinfo-avatar {
position: fixed;
width: 80rpx;
z-index: 9;
height: 80rpx;
top:100rpx;
left: 30rpx;
color: #fff;
}
.userimage{
width: 100rpx;
height: 100rpx;
border-radius: 50%;
border-radius: 50%;
}
}
.content{
position: absolute;
z-index: 9;
bottom: 250px;
width: 100%;
color: white;
clear: both;
}
.leftcont {
font-size: 12px;
width: 42%;
float: left;
margin-left: 20rpx;
color: #fff;
margin-top:10px;
}
.rightcont {
width: 44%;
float: right;
font-size: 12px;
}
.imgwrap{
margin:8px 0;
}
.list-wrapper {
height: 70px;
}
.rightcont .img {
width: 20px;
height: 20px;
border-radius: 50%;
vertical-align: middle;
}
.rightcont .text {
margin-left: 5px;
vertical-align: middle;
border-radius: 20rpx;
display: inline-block;
font-size: 10px;
box-sizing: border-box;
padding:6rpx 15rpx;
background-color:rgba(255, 255, 255, 0.2);
}
.userinfo-nickname {
.footer {
color: #aaa;
position: absolute;
z-index: 9;
bottom: 50px;
width: 100%;
}
}
.
slide
{
.
list-item
{
width:
640rpx
;
width:
100%
;
display: fle
x;
height: 120p
x;
b
order: 1rpx solid #ccc
;
b
ackground-color:#fff
;
font-size: 28rpx
;
position: absolute
;
align-items: center
;
bottom:5px
;
box-sizing: border-box;
box-sizing: border-box;
.left {
border-radius: 5rpx;
width: 750rpx;
transform: scale(0.7,0.7) translateY(28px);
padding: 20rpx;
transition: all 0.5s;
}
padding:10rpx;
.right {
margin-top: 2rpx;
display: flex;
}
.right-item {
.list-item image {
padding: 20rpx 30rpx;
width: 100%;
background-color: red;
max-height: 102px;
color: #fff;
}
}
.list-item .text {
}
font-size: 10px;
margin-top: -5px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.list-item .goods {
width: 100%;
margin-top: -8px;
position: relative;
}
.goods .price{
color:darkorange;
font-size: 10px;
}
.goods .buy{
text-align: right;
color: gainsboro;
font-size: 8px;
position: absolute;
right:0;
top:8px;
}
.list-item.subright {
transform: scale(0.85,0.85) translateY(12px) translateX(15rpx);
}
.list-item.subleft {
transform: scale(0.85,0.85) translateY(12px) translateX(-15rpx);
}
.list-item.select{
transform: scale(1,1);
border-radius: 5rpx;
}
.list-item.delete {
opacity:0;
transform:translateY(-100px)
}
.leftcont{
position: absolute;
z-index: 7;
}
}
</style>
</style>
<wxs module="m1" lang="babel">
<wxs module="tools" lang="babel">
const getTime = (time) => {
function computClass (current,index,length) {
let date = getDate(time);
var allclass = "";
let hour = date.getHours();
if(current-1==index)
let mins = date.getMinutes();
allclass='subleft';
let sec = date.getSeconds();
let milli = date.getMilliseconds();
return `${hour}:${mins}:${sec}.${milli}`;
}
module.exports.getTime = getTime;
</wxs>
<template>
<div class="container">
<div class="userinfo" @tap="handleViewTap">
<image class="userinfo-avatar" src="{{ userInfo.avatarUrl }}" background-size="cover"/>
<div class="userinfo-nickname">{{ userInfo.nickName }}</div>
</div>
<div>
<div class="title" slot="title">测试数据绑定</div>
<text class="info" @tap="currentTime = +new Date()">{{m1.getTime(currentTime)}}</text>
<text class="info">{{setTimeoutTitle}}</text>
<text class="info" @tap="mixintap">{{mixin}}</text>
<text class="info">{{testcomputed}}</text>
<text class="info">{{counter}}</text>
</div>
<div>
<div class="title" slot="title">其它测试</div>
<!--button @tap="toast" size="mini">第三方组件</button-->
<button @tap="communicate" size="mini">组件通信</button>
<button @tap="tap" size="mini">混合TAP事件</button>
</div>
<div>
<div class="title" slot="title">测试并发网络请求</div>
<div>返回结果: <text>{{netrst}}</text></div>
<button @tap="request" size="mini"> 点我发起10个请求 </button>
</div>
<div>
<div class="title" slot="title">测试 v-model</div>
<div style="display: flex; align-items: center;">
<input v-model="inputmodel" />
<text style="margin-left: 30rpx;">Value: {{inputmodel}}</text>
</div>
</div>
<div>
if(current==index) allclass = "select";
<div class="title" slot="title">测试组件</div>
<text class="testcounter">全局计数器:</text>
if(current+1==index)
<div class="counterview">
allclass='subright';
<button @tap="mynum++" size="mini">全局计数器: {{mynum}}</button>
</div>
<text class="testcounter">计数组件1 - num: </text>
return allclass;
<div class="counterview">
};
module.exports = {
// <counter @index-emit.user="counterEmit" />
computClass:computClass
</div>
}
</wxs>
<text class="testcounter">计数组件2 - num.sync: </text>
<template>
<view class="video-wrapper">
<div class="counterview">
<!-- <video autoplay class="video" id="myvideo" controls="{{false}}" direction="{{90}}" loop="{{true}}" src="https://xyqblogo.lkbang.net/VID_20200508_171710.mp4"></video> -->
// <counter :num.sync="mynum"></counter>
<view id="myvideo">
</div>
<video-list videoList="{{videoList}}" bindchange="changeVideo"></video-list>
</div>
</view>
<view class="userInfo">
<div>
<image src="{{userInfo.avatarUrl}}" mode="cover" class="userimage"></image>
<div class="title" slot="title">测试组件Repeat</div>
</view>
<div v-for="(item, index) in groupList">
<view class="content">
<text>{{item.name}}</text>
<view class="leftcont">
//<group :grouplist="item" :index="index"></group>
<view>零售价:¥190003.00元</view>
</div>
<view>开奖时间:15:20</view>
</div>
<view>中奖概率1/3000</view>
</view>
<div>
<view class="rightcont">
<div class="title" slot="title">测试列表</div>
<swiper class="list-wrapper" vertical="true" circular="true" display-multiple-items="2" autoplay="true" interval="1500">
// <list></list>
<swiper-item wx:for="{{adlist}}" wx:key="index" catchtouchmove="forbidMove">
</div>
<view class="imgwrap">
<image class="img" src="{{item.imgsrc}}"></image>
<div>
<view class="text">{{item.text}}</view>
<div class="title" slot="title">测试引用vant组件</div>
</view>
<van-button type="danger">默认按钮</van-button>
</swiper-item>
</div>
</swiper>
<!--toast /-->
</view>
</div>
</view>
<view class="footer">
<swiper
display-multiple-items="{{swiperItem}}"
current="{{current}}"
bindchange="moveSwiper"
previous-margin="120rpx" next-margin="90rpx"
catch:touchmove
>
<swiper-item></swiper-item>
<swiper-item wx:for="{{list}}" wx:key="index">
<view
data-itemid="{{index}}"
bindtap="toViewPage"
bindtouchstart="touchStart"
bindtouchend="touchEnd"
class="list-item {{item.select?'delete':''}} {{tools.computClass(current,index,list.length)}}"
>
<image src="../static/images/test2.png" mode="widthFix"></image>
<view class="text">{{item.text}}</view>
<view class="goods">
<text class="price">¥99.9</text><text class="buy">2200人购买</text>
</view>
</view>
</swiper-item>
<swiper-item></swiper-item>
</swiper>
</view>
</view>
</template>
</template>
<script>
<script>
let touchDotX = 0, touchDotY = 0;
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import eventHub from '../common/eventHub';
import { mapState } from '@wepy/x';
import store from '../store';
import store from '../store';
import testMixin from '../mixins/test';
wepy.page({
wepy.page({
store,
config: {
navigationBarTitleText: 'test'
},
hooks: {
hooks: {
// Page 级别 hook, 只对当前 Page 的 setData 生效。
'before-setData': function (dirty) {
if (Math.random() < 0.2) {
console.log('setData canceled');
return false; // Cancel setData
}
dirty.time = +new Date();
return dirty;
}
},
mixins: [testMixin]
,
}
,
data: {
data: {
inputmodel: 'v-model',
list:[],
mynum: 20,
adlist:[],
userInfo: {
current:2,
nickName: '加载中...'
userInfo: {},
},
swiperItem:3,
currentTime: +new Date(),
videoList:[],
setTimeoutTitle: '标题三秒后会被修改',
count: 0,
netrst: '',
groupList: [
{
id: 1,
name: '点击改变',
list: [
{
childid: '1.1',
childname: '子项,点我改变'
}, {
childid: '1.2',
childname: '子项,点我改变'
}, {
childid: '1.3',
childname: '子项,点我改变'
}
]
},
{
id: 2,
name: '点击改变',
list: [
{
childid: '2.1',
childname: '子项,点我改变'
}, {
childid: '2.2',
childname: '子项,点我改变'
}, {
childid: '2.3',
childname: '子项,点我改变'
}
]
},
{
id: 3,
name: '点击改变',
list: [
{
childid: '3.1',
childname: '子项,点我改变'
}
]
}
]
},
},
computed: {
computed: {
...mapState([ 'counter' ]),
testcomputed () {
return 'computed - ' + this.mynum;
}
},
},
methods: {
methods: {
handleViewTap () {
moveSwiper:function(e){
console.log('handleVieTap clicked');
if(e.$wx.detail.source === 'touch') {
this.current = e.$wx.detail.current;
// this.setData({
// current: e.$wx.detail.current,
// })
}
},
},
tap () {
toViewPage: function() {
throw new Error('can not go here');
wx.navigateTo({
url: '../index/index'
})
},
},
plus () {
touchStart (event) {
this.mynum++;
touchDotX = event.touches[0].pageX; // 获取触摸时的原点
touchDotY = event.touches[0].pageY;
// console.log("起始点的坐标X:" + touchDotX);
// console.log("起始点的坐标Y:" + touchDotY);
},
},
toast () {
// 移动结束处理动画
let promise = this.$invoke('toast', 'show', {
touchEnd(event) {
title: '自定义标题',
// console.log(event.currentTarget.dataset,2)
img: 'https://raw.githubusercontent.com/kiinlam/wetoast/master/images/star.png'
// 手指离开屏幕时记录的坐标
});
let touchMoveX = event.changedTouches[0].pageX;
let touchMoveY = event.changedTouches[0].pageY;
// 起始点的坐标(x0,y0)和手指离开时的坐标(x1,y1)之差
let tmX = touchMoveX - touchDotX;
let tmY = touchMoveY - touchDotY;
// 两点横纵坐标差的绝对值
let absX = Math.abs(tmX);
let absY = Math.abs(tmY);
//起始点的坐标(x0,y0)和手指离开时的坐标(x1,y1)之间的距离
let delta = Math.sqrt(absX * absX + absY * absY);
// console.log('起始点和离开点距离:' + delta + 'px');
// 如果delta超过60px(可以视情况自己微调),判定为手势触发
if (delta >= 40) {
// 如果 |x0-x1|<|y0-y1|,即absX<abxY,判定为上下滑动
if (absX < absY) {
// 如更tmX<0,即(离开点的X)-(起始点X)小于0 ,判定为下滑
if (tmY < 0) {
this.deleteAnimation(event.currentTarget.dataset);
// console.log("上滑=====");
// 执行左滑动画
// 如更tmX>0,即(离开点的X)-(起始点X)大于0 ,判定为上滑
} else {
// console.log("下滑=====");
}
promise.then((d) => {
}
console.log('toast done');
} else {
});
// console.log("手势未触发=====");
}
},
},
mixintap ()
{
forbidMove()
{
console.log('do noting from ' + this.$is)
;
return
;
},
},
communicate () {
changeVideo(e){
let counters = this.$children.filter((com) => com.$is === 'components/counter');
if(e && e.activeId == 6) {
let that = this;
setTimeout(function(){
let obj = {
id:7,
url:'https://xyqblogo.lkbang.net/VID_20200508_171710.mp4'
};
that.videoList = [obj];
// that.$apply();
},1000)
// Get children counter
}
counters[0].num++;
counters[1].num--;
eventHub.$emit('app-launch', {a: 1}, {b: 2});
},
},
request () {
deleteAnimation:function(current) {
let self = this;
if(current && current.itemid != undefined) {
let i = 10;
let list = this.list;
let map = ['MA==', 'MQo=', 'Mg==', 'Mw==', 'NA==', 'NQ==', 'Ng==', 'Nw==', 'OA==', 'OQ=='];
list = list.map((item,index)=>{
while (i--) {
item.select = '';
wx.request({
if(index==current.itemid){
url: 'https://www.madcoder.cn/tests/sleep.php?time=1&t=css&c=' + map[i] + '&i=' + i,
item.select = true;
success: function (d) {
}
if (d.statusCode !== 200) {
return item;
self.netrst += d.statusCode + '.';
})
} else {
this.list = list;
self.netrst += d.data + '.';
let that = this;
}
setTimeout(function(){
let newlist = that.list.filter((item,index)=>index!=current.itemid);
// 正常情况下,current.itemid都会比current大一个,因为current有个隐藏元素,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if(current.itemid <= that.current) {
that.current = Math.max(that.current-1,0)
}
}
});
that.list = newlist;
},500)
}
}
},
counterEmit (num) {
console.log(`${this.$is} receive event, the number is: ${num}`);
}
}
},
},
created () {
created () {
let self = this;
let self = this;
self.currentTime = +new Date();
if(store.state.userInfo) {
this.userInfo = store.state.userInfo;
self.setTimeoutTitle = '标题三秒后会被修改';
} else {
setTimeout(() => {
wx.getUserInfo({
self.setTimeoutTitle = '到三秒了';
success (res) {
}, 3000);
self.userInfo = res.userInfo;
store.dispatch('setUserInfo',res.userInfo);
wx.getUserInfo({
},
success (res) {
fail () {
self.userInfo = res.userInfo;
wx.reLaunch({
}
url: '/pages/auth',
});
})
}
});
}
this.list = [
{value:1,text:'这是测试的文字1'},
{value:2,text:'这是测试的文字2'},
{value:3,text:'这是测试的文字3'},
{value:4,text:'这是测试的文字4'},
{value:5,text:'这是测试的文字5'},
{value:6,text:'这是测试的文字6'},
{value:7,text:'这是测试的文字7'},
{value:8,text:'这是测试的文字8'},
{value:9,text:'这是测试的文字9'},
{value:10,text:'这是测试的文字10'},
];
this.adlist = [
{imgsrc:'../../static/images/test1.jpg',text:'小明刚刚参与了抽奖'},
{imgsrc:'../../static/images/test1.jpg',text:'小2刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小3刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小4刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小5刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小6刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小7刚刚参与了抽奖'},
{imgsrc:'../../images/test1.jpg',text:'小8刚刚参与了抽奖'},
];
let urls = [
'https://xyqblogo.lkbang.net/VID_20200508_171710.mp4',
'https://vdept.bdstatic.com/4668655278575131635578744a355671/6453433744785466/b5393b0ee87409000a401b6f608ccc794c8eb3c5829f3b7d2b3289bfdcff2ab2d89987516c0b7f193da3845400eeca3e.mp4?auth_key=1589361002-0-0-8c85a0fcd6b08a3e0415e0e60ca52a70',
'https://xyqblogo.lkbang.net/VID_20200508_171710.mp4',
'https://xyqblogo.lkbang.net/VID_20200508_171710.mp4',
'https://vdept.bdstatic.com/53316b757439717a3478597341586b73/6274595367777152/217252290ac7caceebd942d49930f7ef02d14b37687383a950d1d04e5371dbc673374b990168369a03e371720fd9ec297467e814578c0d389c52018ec32199b2.mp4?auth_key=1589363984-0-0-ebb9745f286fe623f7dfe68a5cb9c993',
'https://vdept.bdstatic.com/4668655278575131635578744a355671/6453433744785466/b5393b0ee87409000a401b6f608ccc794c8eb3c5829f3b7d2b3289bfdcff2ab2d89987516c0b7f193da3845400eeca3e.mp4?auth_key=1589361002-0-0-8c85a0fcd6b08a3e0415e0e60ca52a70',
];
this.videoList = urls.map((url, index) => ({ id: index + 1, url }))
}
}
});
});
</script>
</script>
<config>
<config>
{
{
navigationBarTitleText: '
WePY 2.0 Feature Demo
',
navigationBarTitleText: '
主页
',
usingComponents: {
usingComponents: {
// panel: '~@/components/panel',
'van-button': '../components/vant/button/index',
// counter: '~counter',
'video-list': '~@/components/custom/videolist'
// list: '../components/list',
// group: '../components/group',
'van-button': '../components/vant/button/index'
}
}
}
}
</config>
</config>
src/store/index.js
View file @
d15cdf1d
...
@@ -2,27 +2,16 @@ import Vuex from '@wepy/x';
...
@@ -2,27 +2,16 @@ import Vuex from '@wepy/x';
export
default
new
Vuex
.
Store
({
export
default
new
Vuex
.
Store
({
state
:
{
state
:
{
counter
:
0
userInfo
:
null
,
},
},
mutations
:
{
mutations
:
{
increment
(
state
)
{
setInfo
(
state
,
info
)
{
state
.
counter
++
;
state
.
userInfo
=
info
;
},
decrement
(
state
)
{
state
.
counter
--
;
}
}
},
},
actions
:
{
actions
:
{
increment
({
commit
})
{
setUserInfo
({
commit
},
info
)
{
commit
(
'
increment
'
);
commit
(
'
setInfo
'
,
info
);
},
decrement
({
commit
})
{
commit
(
'
decrement
'
);
},
},
incrementAsync
({
commit
})
{
setTimeout
(()
=>
{
commit
(
'
increment
'
);
},
1000
);
}
}
}
});
});
static/images/test1.jpg
0 → 100644
View file @
d15cdf1d
8.65 KB
static/images/test2.png
0 → 100644
View file @
d15cdf1d
461 KB
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