wepy-cli基于wepy2.0,在官方脚手架上进行二次封装及改造
下载
git clone xxx
安装依赖
npm install
启动
npm run dev
生成weapp文件夹后请使用小程序开发者工具导入此文件夹预览.
wepy-cli
├─ src
│ ├─ app.wpy --入口文件
│ ├─ assets --静态资源文件
│ │ ├─ css --css文件
│ │ └─ images --图片文件
│ │ ├─ loading_bottom.gif
│ │ ├─ empty.png
│ ├─ common --eventHub
│ │ └─ eventHub.js
│ ├─ components --组件目录
│ │ ├─ axios-progress --axios进度条封装
│ │ │ ├─ axios-progress.wpy
│ │ │ └─ progress.js
│ │ ├─ scroll --滚动封装
│ │ │ └─ scroll.wpy
│ ├─ mixins --mixins
│ │ ├─ pagination.js --分页mixins
│ │ └─ test.js --测试
│ ├─ models --接口文件夹
│ │ ├─ list
│ │ │ └─ List.js
│ │ ├─ login
│ │ │ └─ Login.js
│ │ └─ test
│ │ └─ test.js
│ ├─ pages
│ │ ├─ index
│ │ │ └─ index.wpy
│ │ ├─ list
│ │ │ └─ list.wpy
│ │ ├─ login
│ │ │ └─ login.wpy
│ │ └─ me
│ │ └─ me.wpy
│ ├─ store --vuex
│ │ ├─ index.js --入口文件
│ │ └─ modules
│ │ └─ user.js --文件分类
│ └─ utils --工具类
│ ├─ auth.js --cookie改造缓存
│ ├─ config.js --接口路径
│ ├─ index.js
│ ├─ permission.js --路由监听
│ ├─ request.js --axios封装
├─ static
│ └─ .gitignore
├─ .gitignore
├─ .prettierrc
├─ .wepycache
├─ .wepyignore
├─ package-lock.json
├─ package.json
├─ project.config.json
├─ README.md
└─ wepy.config.js
import request from '@/utils/request';
// 获取模拟列表
export function getList(pageIndex) {
return request({
url: '/getList',
method: 'post',
data: {
pageIndex: pageIndex
},
showLoading: true, //是否显示loading
showLoadingType: 'progress', //可选值:loading(loading弹窗) progress(顶部进度条)
})
}
if (config.showLoading) {
if (config.showLoadingType == "loading") {
loadingType = "loading";
Toast.loading({
message: '加载中...',
forbidClick: true,
loadingType: 'spinner',
duration: 0
});
} else if (config.showLoadingType == "progress") {
console.log("进度条加载")
loadingType = "progress";
ProgressStart();
}
}// 路由白名单
const whiteList = ['pages/index/index']
// 全局路由监听器
wx.onAppRoute(async function(res) {
if (whiteList.indexOf(res.path) !== -1) {
// 白名单中,无需验证
// wx[res.openType]({
// url: res.path
// })
console.log("白名单中,无需验证")
} else {
// other pages that do not have permission to access are redirected to the login page.
// wx[res.openType]({
// url: res.path
// })
// 应该去授权
console.log("应该去授权")
// next(`/login?redirect=${to.path}`)
}
});//页面引入或全局引入
usingComponents: {
"scroll": "components/scroll/scroll"
}
import pagination from '@/mixins/pagination.js';
wepy.page({
data: {
list: []
},
mixins: [pagination],
...
}).list-scroll-div {
height: 100vh;
}<!-- 列表示例 -->
<template>
<div class="list-scroll-div">
<scroll
:scrollOption="scrollJd"
bindrefresh="refreshJd"
bindloadMore="loadMoreJd"
bindrefreshPulling="refreshPulling"
bindrestore="restore"
>
<!-- 自定义内容 -->
<div
class="refresh"
slot="refresh"
>
<div class="wapper">
<van-loading color="#1989fa" />
</div>
<div class="text">{{scrollJd.upTitle}}</div>
</div>
<div slot="inner">
<van-cell-group>
<van-cell
:title="item.title"
value="内容"
label="描述信息"
:border="false"
v-for="(item,index) in list"
:key="index"
/>
</van-cell-group>
</div>
</scroll>
<progress id="axios-progress"></progress>
<van-toast id="van-toast" />
</div>
</template>如果好用的话,请给个小星星哦~~