提交 e9d33106 编写于 作者: DCloud_JSON's avatar DCloud_JSON

添加文件说明注释

上级 b306ac06
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
export default { export default {
globalData: { globalData: {
searchText: '', searchText: '',
appVersion: {} appVersion: {},
config:{}
}, },
onLaunch: function() { onLaunch: function() {
console.log('App Launch') console.log('App Launch')
......
//这是应用的配置页面,App.vue挂载到getApp().globalData.config
module.exports = { module.exports = {
"h5": { "h5": {
"url": "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com", // 前端网页托管的域名 "url": "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com", // 前端网页托管的域名
"openApp": { // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改 // 在h5端全局悬浮引导用户下载app的功能 更多自定义要求在/common/openApp.js中修改
"openApp": {
//点击悬浮下载栏后打开的网页链接
"openUrl": 'https://sj.qq.com/myapp/detail.htm?apkName=com.tencent.android.qqdownloader&info=6646FD239A6EBA9E2DEE5DFC7E18D867', "openUrl": 'https://sj.qq.com/myapp/detail.htm?apkName=com.tencent.android.qqdownloader&info=6646FD239A6EBA9E2DEE5DFC7E18D867',
//左侧显示的应用名称
"appname": 'base-app', "appname": 'base-app',
//应用的图标
"logo": './static/logo.png', "logo": './static/logo.png',
} }
}, },
"mp": { "mp": {
"weixin": { "weixin": {
//微信小程序原始id,微信小程序分享时
"id": "gh_33446d7f7a26" "id": "gh_33446d7f7a26"
} }
}, },
"router": { "router": {
"needLogin": [ //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等 //配置需要路由拦截的页面地址,在打开这些页面之前会自动检查(不联网)uni_id_token的值是否存在/过期等
"/pages/ucenter/edit/edit", "needLogin": [
"/pages/ucenter/userinfo/userinfo",
"/uni_modules/uni-news-favorite/pages/uni-news-favorite/list", "/uni_modules/uni-news-favorite/pages/uni-news-favorite/list",
"/pages/ucenter/edit/uploadCutImageToUnicloud" "/pages/ucenter/edit/uploadCutImageToUnicloud"
], ],
"login": [ "smsCode","uniVerify", "username", "weixin", "apple"], "login": [ "smsCode","uniVerify", "username", "weixin", "apple"],
/* /*
根据数组的第0项,决定登陆方式的第一优先级。 根据数组的第0项,决定登陆方式的第一优先级。
为完全列举到的或设备环境不支持的选项,将被隐藏。 未列举到的,或设备环境不支持的选项,将被隐藏。
快捷登陆按钮,在任意一页面都存在。 快捷登陆按钮,在任意一页面都存在。
所以只有三种情况: 所以只有三种情况:
一键登录(uniVerify)、账号(username)、验证码登陆(其他值为第一项都为验证码登陆) 一键登录(uniVerify)、账号(username)、验证码登陆(其他值为第一项都为验证码登陆)
如果你需要在不同平台有不同的配置,直接用条件编译即可
*/ */
}, },
"about": { "about": {
...@@ -43,7 +51,8 @@ module.exports = { ...@@ -43,7 +51,8 @@ module.exports = {
], ],
"download": "https://m3w.cn/uniapp" "download": "https://m3w.cn/uniapp"
}, },
"marketId":{//用于打开应用市场评分界面 //用于打开应用市场评分界面
"marketId":{
"ios":"id1417078253", "ios":"id1417078253",
"android":"123456" "android":"123456"
} }
......
//应用初始化页
import baseappConfig from '@/baseapp.config.js'; import baseappConfig from '@/baseapp.config.js';
// #ifdef APP-PLUS // #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
...@@ -8,8 +9,27 @@ export default function() { ...@@ -8,8 +9,27 @@ export default function() {
initAppVersion(); initAppVersion();
// baseappConfig挂载到getApp(). // baseappConfig挂载到getApp().
getApp({allowDefault: true}).config = baseappConfig; getApp({allowDefault: true}).globalData.config = baseappConfig;
/*
这里应用拦截器实现了,路由拦截。当应用无访问摄像头/相册权限,引导跳到设置界面
1.添加拦截器说明如下:
uni.addInterceptor(item, {
invoke(e) { // 调用前拦截
},
success() { // 成功回调拦截
},
fail(err) { // 失败回调拦截
console.log(err);
},
complete(e) { // 完成回调拦截
//console.log(e);
},
returnValue() { // 返回结果拦截
}
})
2.移除拦截器API removeInterceptor('request')
*/
//自定义路由拦截 //自定义路由拦截
const { const {
"router": { "router": {
...@@ -17,7 +37,6 @@ export default function() { ...@@ -17,7 +37,6 @@ export default function() {
login login
} }
} = baseappConfig //需要登陆的页面 } = baseappConfig //需要登陆的页面
//uni.addInterceptor的写法
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]; let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"];
list.forEach(item => { list.forEach(item => {
uni.addInterceptor(item, { uni.addInterceptor(item, {
...@@ -61,6 +80,7 @@ export default function() { ...@@ -61,6 +80,7 @@ export default function() {
}) })
}) })
//当应用无访问摄像头/相册权限,引导跳到设置界面 //当应用无访问摄像头/相册权限,引导跳到设置界面
uni.addInterceptor('chooseImage', { uni.addInterceptor('chooseImage', {
fail(e) { // 失败回调拦截 fail(e) { // 失败回调拦截
...@@ -96,8 +116,25 @@ export default function() { ...@@ -96,8 +116,25 @@ export default function() {
}) })
// #ifdef APP-PLUS // #ifdef APP-PLUS
// 设备网络状态变化事件 // 监听并提示设备网络状态变化
eventListenerNetwork() uni.onNetworkStatusChange(res=> {
console.log(res.isConnected);
console.log(res.networkType);
if(res.networkType!='none'){
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}else{
showNetworkErrPage()
uni.showToast({
title:'网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
// #endif // #endif
} }
...@@ -132,97 +169,3 @@ function initAppVersion() { ...@@ -132,97 +169,3 @@ function initAppVersion() {
checkUpdate(); checkUpdate();
// #endif // #endif
} }
\ No newline at end of file
// 设备网络状态变化事件
function eventListenerNetwork() {
/*
//网络掉线
uni.getNetworkType({
success:res=>{
console.log(res);
if(res.networkType=='none'){
showNetworkErrPage()
}
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
//监听网络变化
uni.onNetworkStatusChange(res=> {
console.log(res.isConnected);
console.log(res.networkType);
if(res.networkType!='none'){
uni.showToast({
title:'当前网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}else{
showNetworkErrPage()
uni.showToast({
title:'网络类型:'+res.networkType,
icon:'none',
duration:3000
})
}
});
function showNetworkErrPage(){
let pages = getCurrentPages();
console.log('pages.length',pages.length);
if(pages.length===0 || pages[pages.length - 1].route!='/pages/networkErr/networkErr.vue'){
uni.navigateTo({
url:'/pages/networkErr/networkErr'
})
}else{
console.log('已经打开');
}
}
}
function openAppPermissionSetting(){
// 跳转到**应用**的权限页面
if (uni.getSystemInfoSync().platform == "ios") {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
// console.log(plus.device.vendor);
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
*/
}
/*
uni.addInterceptor(item, {
invoke(e) { // 调用前拦截
},
success() { // 成功回调拦截
},
fail(err) { // 失败回调拦截
console.log(err);
},
complete(e) { // 完成回调拦截
//console.log(e);
},
returnValue() { // 返回结果拦截
}
}) // 移除拦截器API removeInterceptor('request')
*/
\ No newline at end of file
/*
创建在h5端全局悬浮引导用户下载app的功能,
如不需要本功能直接移除配置文件baseapp.config.js下的h5/openApp即可
*/
import CONFIG from '../baseapp.config.js'; import CONFIG from '../baseapp.config.js';
const CONFIG_OPEN = CONFIG?.h5?.openApp?.openUrl ? CONFIG.h5.openApp : {}; const CONFIG_OPEN = CONFIG?.h5?.openApp?.openUrl ? CONFIG.h5.openApp : {};
......
<template>
<view :class="[flex?'flex':'null']">
<slot></slot>
</view>
</template>
<script>
export default {
props: {
flex: {
default(){
return false
}
},
},
data() {
return {
}
},
watch: {
},
methods: {
},
}
</script>
<style lang="scss" scoped>
.null{
display: inline-flex;
width: auto;
}
.flex{
display: flex;
}
</style>
此差异已折叠。
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
name:"uni-agreements", name:"uni-agreements",
computed:{ computed:{
agreements(){ agreements(){
return getApp().config.about.agreements return getApp().globalData.config.about.agreements
} }
}, },
methods:{ methods:{
......
<template>
<view class="box" v-if="networkType == 'none'">
<image class="icon-image" src="../../static/uni-network/disconnection.png" mode="widthFix"></image>
<text class="tip-text">网络异常</text>
<view class="btn btn-default" v-if="networkType!='none'" @click="retry">
<text class="btn-text">重试</text>
</view>
<view class="btn btn-default" v-if="networkType=='none'" @click="openSettings">
<text class="btn-text">前往设置</text>
</view>
</view>
</template>
<script>
export default {
name: "uni-network",
data() {
return {
"networkType": ""
};
},
mounted() {
uni.onNetworkStatusChange(({
networkType
}) => {
if(this.networkType == 'none' && networkType != 'none'){
this.change()
}
this.networkType = networkType;
});
uni.getNetworkType({
success: ({
networkType
}) => {
this.networkType = networkType;
}
});
},
methods:{
openSettings(){
if (uni.getSystemInfoSync().platform == "ios") {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-prefs:root=General");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent(Settings.ACTION_SETTINGS);
mainActivity.startActivity(intent);
}
},
change(){
this.$emit('change')
}
}
}
</script>
<style scoped>
.box{
margin:100rpx 0;
flex-direction: column;
align-items: center;
justify-content: center;
}
.icon-image{
width: 300rpx;
}
.tip-text{
color: #999999;
font-size: 32rpx;
margin-bottom: 30rpx;
}
.btn {
padding: 5px 10px;
width: 128px;
flex-direction: row;
align-items: center;
justify-content: center;
text-align: center;
}
.btn-text {
color: #999999;
font-size: 15px;
}
.btn-default {
border-color: #999999;
border-style: solid;
border-width: 1px;
border-radius: 3px;
}
</style>
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
"prompt" : "template", "prompt" : "template",
"template" : { "template" : {
"title" : "服务协议和隐私政策", "title" : "服务协议和隐私政策",
"message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"\">《服务协议》</a>和<a href=\"\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。", "message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"https://ask.dcloud.net.cn/protocol.html\">《服务协议》</a>和<a href=\"https://ask.dcloud.net.cn/protocol.html\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "我知道了", "buttonAccept" : "同意",
"buttonRefuse" : "暂不同意" "buttonRefuse" : "暂不同意"
} }
}, },
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
"es6" : false "es6" : false
}, },
"usingComponents" : true "usingComponents" : true
// "betterScopedSlots" : true
}, },
// "betterScopedSlots" : true
"mp-alipay" : { "mp-alipay" : {
"usingComponents" : true "usingComponents" : true
}, },
......
...@@ -3,23 +3,17 @@ ...@@ -3,23 +3,17 @@
{ {
"path": "pages/list/list", "path": "pages/list/list",
"style": { "style": {
// #ifdef APP-NVUE
"enablePullDownRefresh": false,
// #endif
// #ifdef H5
"navigationStyle":"custom", "navigationStyle":"custom",
// #endif "enablePullDownRefresh": true,
"app-plus":{ "app-plus":{
// #ifdef APP-PLUS // "titleNView":{ /*排除了H5*/
"titleNView":{ /*排除了H5*/ // "searchInput":{
"searchInput":{ // "placeholder":"请输入搜索的内容",
"placeholder":"请输入搜索的内容", // "backgroundColor":"#efefef",
"backgroundColor":"#efefef", // "disabled":true,
"disabled":true, // "borderRadius":"30px"
"borderRadius":"30px" // }
} // }
}
// #endif
} }
} }
}, },
...@@ -73,7 +67,7 @@ ...@@ -73,7 +67,7 @@
"navigationBarTitleText": "文章详情" "navigationBarTitleText": "文章详情"
} }
}, { }, {
"path": "pages/ucenter/edit/bind-mobile/bind-mobile", "path": "pages/ucenter/userinfo/bind-mobile/bind-mobile",
"style": { "style": {
"navigationBarTitleText": "绑定手机号码" "navigationBarTitleText": "绑定手机号码"
} }
...@@ -162,12 +156,12 @@ ...@@ -162,12 +156,12 @@
} }
}, { }, {
"path": "pages/ucenter/edit/edit", "path": "pages/ucenter/userinfo/userinfo",
"style": { "style": {
"navigationBarTitleText": "个人资料" "navigationBarTitleText": "个人资料"
} }
}, { }, {
"path": "pages/ucenter/edit/uploadCutImageToUnicloud", "path": "pages/ucenter/userinfo/uploadCutImageToUnicloud",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
</template> </template>
<script> <script>
import baseappConfig from '@/baseapp.config.js';
import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
const db = uniCloud.database(); const db = uniCloud.database();
...@@ -79,7 +78,10 @@ ...@@ -79,7 +78,10 @@
...mapGetters({ ...mapGetters({
'userInfo': 'user/info', 'userInfo': 'user/info',
'hasLogin': 'user/hasLogin' 'hasLogin': 'user/hasLogin'
}) }),
baseappConfig(){
return getApp().globalData.config
}
}, },
onLoad(event) { onLoad(event) {
//获取真实新闻id,通常 id 来自上一个页面 //获取真实新闻id,通常 id 来自上一个页面
......
<template> <template>
<view> <view>
<!-- 搜索功能 小程序用绘制的且带原生导航,h5和app用原生自带绘制 --> <!-- #ifdef APP-PLUS -->
<!-- #ifndef APP-PLUS --> <uni-nav-bar :border="false"></uni-nav-bar>
<view class="uni-search-box">
<uni-search-bar class="uni-search-bar" v-model="keyword" ref="searchBar" radius="100"
@click.native="searchClick" cancelButton="none" disabled />
</view>
<!-- #endif --> <!-- #endif -->
<!-- 搜索功能 -->
<uni-search-bar class="uni-search-box" v-model="keyword" ref="searchBar" radius="100"
@click.native="searchClick" cancelButton="none" disabled />
<unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @load="handleLoad" <unicloud-db ref='udb' v-slot:default="{data,pagination,hasMore, loading, error, options}" @load="handleLoad" @error="onqueryerror"
:where="where" collection="opendb-news-articles,uni-id-users" :where="where" collection="opendb-news-articles,uni-id-users"
field="avatar,title,last_modify_date,user_id{username}"> field="avatar,title,last_modify_date,user_id{username}">
<!-- 基于 uni-list 的页面布局 --> <!-- 基于 uni-list 的页面布局 -->
<uni-list class="uni-list" :border="false" :style='{height:windowHeight+"px"}' :bounce="true" <uni-list class="uni-list" :border="false" :bounce="true" :alwaysScrollableVertical="true"
:alwaysScrollableVertical="true">
<!-- #ifdef APP-NVUE --> <!-- #ifdef APP-NVUE -->
<refresh @refresh="refresh" @pullingdown="onpullingdown" :display="!loading ? 'show' : 'hide'"> :style='{height:listHight+"px"}'
<refreshBox :state="refreshState"></refreshBox>
</refresh>
<!-- #endif --> <!-- #endif -->
>
<cell v-if="error">
<template slot="body">
<!-- 设置网络 -->
<uni-network @change="refresh" @retry="refresh"></uni-network>
</template>
</cell>
<template v-else>
<cell class="get-data-state" v-if="data.length===0&&pagination.current===1"> <cell class="get-data-state" v-if="data.length===0&&pagination.current===1">
<!-- 刷新页面后的顶部提示框 当前弹出内容没有实际逻辑 ,可根据当前业务修改弹出提示 -->
<text class="refresh-tip"
:class="{ 'show-refresh-tip':showRefreshTip }">为您更新了{{data.length}}条内容</text>
<!-- 数据为空 当前页码为1,且正在加载中;这里为了演示,更加直观的表达内部逻辑。商用项目建议将这部分封装为组件,更好的让业务逻辑与功能分离--> <!-- 数据为空 当前页码为1,且正在加载中;这里为了演示,更加直观的表达内部逻辑。商用项目建议将这部分封装为组件,更好的让业务逻辑与功能分离-->
<template v-if="loading"> <uni-load-more v-if="loading" status="loading"></uni-load-more>
<image class="get-data-state-img" src="@/static/getDataState/loading.png" mode="widthFix">
</image>
<text class="get-data-state-text">加载中...</text>
</template>
<template v-else> <template v-else>
<image class="get-data-state-img" src="@/static/getDataState/nodata.png" mode="widthFix"> <image class="get-data-state-img" src="@/static/getDataState/nodata.png" mode="widthFix">
</image> </image>
<text class="get-data-state-text">内容为空</text> <text class="get-data-state-text">内容为空</text>
</template> </template>
</cell> </cell>
<uni-list-item v-if="error">{{error.message}}</uni-list-item> <uni-list-item :to="'./detail?id='+item._id+'&title='+item.title"
<uni-list-item v-else :to="'./detail?id='+item._id+'&title='+item.title"
v-for="(item,index) in testData(data)" :key="index"> v-for="(item,index) in testData(data)" :key="index">
<!-- 通过header插槽定义列表左侧图片 --> <!-- 通过header插槽定义列表左侧图片 -->
<template v-slot:header> <template v-slot:header>
...@@ -47,19 +44,22 @@ ...@@ -47,19 +44,22 @@
<text class="title">{{ item.title }}</text> <text class="title">{{ item.title }}</text>
<view class="info"> <view class="info">
<text class="author">{{item.user_id[0].username}}</text> <text class="author">{{item.user_id[0].username}}</text>
<uni-dateformat class="last_modify_date" :date="item.last_modify_date" format="yyyy-MM-dd" <uni-dateformat class="last_modify_date" :date="item.last_modify_date"
:threshold="[60000, 2592000000]" /> format="yyyy-MM-dd" :threshold="[60000, 2592000000]" />
</view> </view>
</view> </view>
</uni-list-item> </uni-list-item>
<!-- 存在下一页数据,且不在加载中 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 --> <!-- 存在下一页数据,且不在加载中 通过 loadMore 组件实现上拉加载效果,如需自定义显示内容,可参考:https://ext.dcloud.net.cn/plugin?id=29 -->
<template v-if="!loading">
<cell v-if="hasMore"> <cell v-if="hasMore">
<uni-load-more v-if="!error &&!loading&&hasMore" :status="options.status"></uni-load-more> <uni-load-more :status="options.status"></uni-load-more>
</cell> </cell>
<cell v-else> <cell v-else>
<text class="noMore">- 没有更多数据了 -</text> <text class="noMore">- 没有更多数据了 -</text>
</cell> </cell>
</template>
</template>
</uni-list> </uni-list>
</unicloud-db> </unicloud-db>
</view> </view>
...@@ -70,42 +70,34 @@ ...@@ -70,42 +70,34 @@
export default { export default {
data() { data() {
return { return {
showRefreshTip: true,
where: "", where: "",
keyword: "", keyword: "",
refreshState: 0, refreshState: 0,
windowHeight: 0 //窗口的高 listHight: 0
} }
}, },
onReady() { onReady() {
this.windowHeight = uni.getSystemInfoSync().windowHeight this.listHight = uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 65
this.showRefreshTip = false
cdbRef = this.$refs.udb cdbRef = this.$refs.udb
console.log(cdbRef); console.log(cdbRef);
}, },
onShow() { onShow() {
try{
this.keyword = getApp().globalData.searchText this.keyword = getApp().globalData.searchText
console.log(this.keyword); console.log(this.keyword);
getApp().globalData.searchText = '' getApp().globalData.searchText = ''
this.setInputText() if(this.keyword){
}catch(e){
console.log(e);
//TODO handle the exception
}
},
methods: {
setInputText() {
// 设置 searchInput的 text
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (!currentWebview) { if (!currentWebview) {
let pages = getCurrentPages(); let pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview(); currentWebview = pages[pages.length - 1].$getAppWebview();
} }
// 设置 searchInput的 text
currentWebview.setTitleNViewSearchInputText(this.keyword) currentWebview.setTitleNViewSearchInputText(this.keyword)
// #endif // #endif
}
}, },
testData(data) { methods: {
testData(data) { //复制同一个数据多遍方便测试,正式项目中不要带
var testData = [] var testData = []
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
testData.push(...data) testData.push(...data)
...@@ -116,7 +108,6 @@ ...@@ -116,7 +108,6 @@
// `data` 当前查询结果 `ended` 是否有更多数据 `pagination` 分页信息 HBuilderX 3.1.5+ 支持 // `data` 当前查询结果 `ended` 是否有更多数据 `pagination` 分页信息 HBuilderX 3.1.5+ 支持
console.log(9527, data, ended, pagination); console.log(9527, data, ended, pagination);
//上拉加载成功 //上拉加载成功
this.loadMoreEnd()
}, },
searchClick() { searchClick() {
uni.hideKeyboard(); uni.hideKeyboard();
...@@ -130,65 +121,28 @@ ...@@ -130,65 +121,28 @@
} }
}); });
}, },
refresh() { retry(){
this.refresh()
},
refresh(){
cdbRef.loadData({ cdbRef.loadData({
clear: true clear: true
}, () => { }, () => {
this.showRefreshTip = true
setTimeout(() => {
this.showRefreshTip = false
}, 1000)
this.refreshEnd()
})
},
loadMore() {
cdbRef.loadMore({
clear: true
})
},
refreshEnd() {
// #ifdef APP-NVUE
this.refreshState = 0
// #endif
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
}, })
loadMoreEnd() { console.log('refresh');
console.log('loadMoreEnd');
},
// #ifdef APP-NVUE
onpullingdown({
pullingDistance,
viewHeight
}) {
if (pullingDistance > viewHeight) {
this.refreshState = 1
} }
}, },
// #endif
},
// #ifndef APP-NVUE
onPullDownRefresh() { onPullDownRefresh() {
this.refresh() this.refresh()
console.log('refresh');
}, },
// #endif
onReachBottom() { onReachBottom() {
this.loadMore() cdbRef.loadMore({clear: true})
console.log('触底了');
},
onNavigationBarSearchInputClicked() {
this.searchClick()
},
onNavigationBarSearchInputChanged(e) {
console.log('变了', e);
if (e.text) {
this.where = 'title == ' + e.text
}
} }
} }
</script> </script>
<style> <style scoped>
.avatar { .avatar {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
...@@ -201,6 +155,7 @@ ...@@ -201,6 +155,7 @@
.title { .title {
width: 480rpx; width: 480rpx;
font-size: 32rpx;
} }
.info { .info {
...@@ -232,7 +187,7 @@ ...@@ -232,7 +187,7 @@
top: 0; top: 0;
left: 0; left: 0;
/* #ifndef APP-PLUS */ /* #ifndef APP-PLUS */
z-index:9; z-index: 9;
/* #endif */ /* #endif */
} }
...@@ -260,8 +215,7 @@ ...@@ -260,8 +215,7 @@
text-align: center; text-align: center;
} }
.uni-list { .uni-list {}
}
.noMore { .noMore {
width: 750rpx; width: 750rpx;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
</view> </view>
</template> </template>
<script> <script>
import baseappConfig from '@/baseapp.config.js';
import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
export default { export default {
onLoad() { onLoad() {
...@@ -27,6 +26,12 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ...@@ -27,6 +26,12 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
this.version = plus.runtime.version this.version = plus.runtime.version
// #endif // #endif
}, },
computed:{
baseappConfig(){
console.log(getApp());
return getApp().globalData.config
}
},
data() { data() {
return { return {
version:"V1.0.0", version:"V1.0.0",
...@@ -35,7 +40,8 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ...@@ -35,7 +40,8 @@ import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
}; };
}, },
created() { created() {
this.about = baseappConfig.about console.log();
this.about = this.baseappConfig.about
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:'关于'+this.about.appName title:'关于'+this.about.appName
}) })
......
...@@ -18,7 +18,7 @@ var univerify_first,currentWebview;//是否一键登陆优先 ...@@ -18,7 +18,7 @@ var univerify_first,currentWebview;//是否一键登陆优先
export default { export default {
data() { data() {
return { return {
phone:"17769516081" phone:""
} }
}, },
computed: { computed: {
......
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
} }
// #endif // #endif
,appConfig(){ ,appConfig(){
return getApp().config return getApp().globalData.config
} }
}, },
methods: { methods: {
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
}, },
toUserInfo() { toUserInfo() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/ucenter/edit/edit' url: '/pages/ucenter/userinfo/userinfo'
}) })
}, },
tapGrid(index) { tapGrid(index) {
......
static/getDataState/nodata.png

44.7 KB | W: | H:

static/getDataState/nodata.png

33.5 KB | W: | H:

static/getDataState/nodata.png
static/getDataState/nodata.png
static/getDataState/nodata.png
static/getDataState/nodata.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -61,7 +61,7 @@ $uni-spacing-row-lg: 30rpx; ...@@ -61,7 +61,7 @@ $uni-spacing-row-lg: 30rpx;
/* 垂直间距 */ /* 垂直间距 */
$uni-spacing-col-sm: 8rpx; $uni-spacing-col-sm: 8rpx;
$uni-spacing-col-base: 16rpx; $uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 24rpx; $uni-spacing-col-lg: 24rpx;
/* 透明度 */ /* 透明度 */
......
# uni-image-menu # uni-image-menu
使用示例:
```
import uniImageMenu from 'uni_modules/uni-image-menu/js_sdk/uni-image-menu.js';
uniImageMenu.show({
list:[{
"img": "/static/sharemenu/wechatfriend.png",
"text": "微信好友"
},
{
"img": "/static/sharemenu/wechatmoments.png",
"text": "微信朋友圈"
}],
cancelText:param.cancelText
}, e => {
console.log(e)
})
```
\ No newline at end of file
<template>
<view class="nodata">
<view class="nodata-content">
<view class="text-view a-i-c j-c-c t-a-c">
<text class="title">{{textTypes[networkType]}}</text>
</view>
<view class="icon-view">
<!-- 无数据 icon -->
<image v-if="!isLoading" src="/uni_modules/uni-nodata/static/nodata.png" class="icon-image"></image>
<!-- 加载中 icon -->
<image v-else src="/uni_modules/uni-nodata/static/loading.png" class="icon-loading"></image>
<text class="title">{{isLoading ? '加载中...' : ''}}</text>
</view>
<view class="opera-view" v-if="!isLoading">
<view class="btn btn-default" v-if="networkType!='none'" @click="retry">
<text class="btn-text">重试</text>
</view>
<view class="btn btn-default" v-if="networkType=='none'" @click="openSettings">
<text class="btn-text">设置</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'uni-nodata',
props:{
isLoading:{
type:Boolean,
default:false
}
},
data() {
return {
textTypes: {
none: "暂无网络"
},
isConnected: false,
networkType: "none"
}
},
mounted() {
this.isIOS = (uni.getSystemInfoSync().platform === 'ios');
uni.onNetworkStatusChange((res) => {
this.isConnected = res.isConnected;
this.networkType = res.networkType;
});
uni.getNetworkType({
success: (res) => {
this.networkType = res.networkType;
}
});
},
methods: {
retry() {
this.$emit('retry');
},
async openSettings() {
if (this.networkType == "none") {
this.openSystemSettings();
return;
}
},
openAppSettings() {
this.gotoAppSetting();
},
openSystemSettings() {
if (this.isIOS) {
this.gotoiOSSetting();
} else {
this.gotoAndroidSetting();
}
},
network() {
var result = null;
var cellularData = plus.ios.newObject("CTCellularData");
var state = cellularData.plusGetAttribute("restrictedState");
if (state == 0) {
result = null;
console.log("StateUnknown");
} else if (state == 2) {
result = 1;
console.log("已经开启了互联网权限:NotRestricted");
} else if (state == 1) {
result = 2;
console.log("Restricted");
}
plus.ios.deleteObject(cellularData);
return result;
},
gotoAppSetting() {
if (this.isIOS) {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("app-settings:");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var Uri = plus.android.importClass("android.net.Uri");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
mainActivity.startActivity(intent);
}
},
gotoiOSSetting() {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-prefs:root=General");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
},
gotoAndroidSetting() {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent(Settings.ACTION_SETTINGS);
mainActivity.startActivity(intent);
}
}
}
</script>
<style>
.a-i-c {
align-items: center;
}
.j-c-c {
justify-content: center;
}
.t-a-c {
text-align: center;
}
.nodata {
flex: 1;
flex-direction: column;
/* #ifndef APP-PLUS */
display: flex;
/* #endif */
align-items: center;
justify-content: center;
padding: 30px;
background-color: #f8f8f8;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
/* #ifndef APP-NVUE */
margin: auto;
z-index:9;
/* #endif */
}
.nodata-content {
transform: translateY(-50px);
}
.text-view {
margin-bottom: 40px;
}
.title {
color: #999999;
font-size: 18px;
}
.opera-view {
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn {
padding: 5px 10px;
width: 128px;
flex-direction: row;
align-items: center;
justify-content: center;
text-align: center;
}
.btn-text {
color: #999999;
font-size: 15px;
}
.btn-default {
border-color: #999999;
border-style: solid;
border-width: 1px;
border-radius: 3px;
}
.icon-view{
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
border-width: 1rpx;
border-color: #DD524D;
}
.icon-loading{
width: 500rpx;
height: 300rpx;
}
.icon-image{
width: 640rpx;
height: 640rpx;
}
</style>
{
"id": "uni-nodata",
"displayName": "uni-nodata",
"version": "1.0.0",
"description": "uni-nodata",
"keywords": [
"uni-nodata"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"category": [
"前端组件",
"通用组件"
],
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
\ No newline at end of file
# uni-nodata
\ No newline at end of file
...@@ -78,6 +78,4 @@ export default async (param,callback) => { ...@@ -78,6 +78,4 @@ export default async (param,callback) => {
callback(e) callback(e)
}); });
} }
} }
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
"id": "uni-share", "id": "uni-share",
"displayName": "uni-share", "displayName": "uni-share",
"version": "1.0.0", "version": "1.0.0",
"description": "uni-share", "description": "底部弹出宫格图标式的分享菜单,可覆盖原生组件。",
"keywords": [ "keywords": [
"uni-share" "分享菜单"
], ],
"repository": "", "repository": "",
"engines": { "engines": {
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"dcloudext": { "dcloudext": {
"category": [ "category": [
"JS SDK", "JS SDK",
"JS SDK" "通用 SDK"
], ],
"sale": { "sale": {
"regular": { "regular": {
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
"qq": "" "qq": ""
}, },
"declaration": { "declaration": {
"ads": "", "ads": "",
"data": "", "data": "",
"permissions": "" "permissions": ""
}, },
"npmurl": "" "npmurl": ""
}, },
...@@ -38,37 +38,37 @@ ...@@ -38,37 +38,37 @@
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "u", "tcb": "y",
"aliyun": "u" "aliyun": "y"
}, },
"client": { "client": {
"App": { "App": {
"app-vue": "u", "app-vue": "y",
"app-nvue": "u" "app-nvue": "y"
}, },
"H5-mobile": { "H5-mobile": {
"Safari": "u", "Safari": "n",
"Android Browser": "u", "Android Browser": "n",
"微信浏览器(Android)": "u", "微信浏览器(Android)": "n",
"QQ浏览器(Android)": "u" "QQ浏览器(Android)": "n"
}, },
"H5-pc": { "H5-pc": {
"Chrome": "u", "Chrome": "n",
"IE": "u", "IE": "n",
"Edge": "u", "Edge": "n",
"Firefox": "u", "Firefox": "n",
"Safari": "u" "Safari": "n"
}, },
"小程序": { "小程序": {
"微信": "u", "微信": "n",
"阿里": "u", "阿里": "n",
"百度": "u", "百度": "n",
"字节跳动": "u", "字节跳动": "n",
"QQ": "u" "QQ": "n"
}, },
"快应用": { "快应用": {
"华为": "u", "华为": "n",
"联盟": "u" "联盟": "n"
} }
} }
} }
......
# uni-share #### 本功能基于[底部图标菜单](https://ext.dcloud.net.cn/plugin?id=4858)封装而成。
例子 ### 示例代码
import uniShare from 'uni_modules/uni-share/js_sdk/uni-share.js'; ```
uniShare({ uniShare({
menus:[ content: { //公共的分享参数配置 类型(type)、链接(herf)、标题(title)、summary(描述)、imageUrl(缩略图)
{ type: 0,
"img": "/static/sharemenu/wechatfriend.png", href: 'https://uniapp.dcloud.io/',
title: '标题',
summary: '描述',
imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": "微信好友", "text": "微信好友",
"share": { "share": { //当前项的分享参数配置。可覆盖公共的配置如下:分享到微信小程序,配置了type=5
"provider": "weixin", "provider": "weixin",
"scene": "WXSceneSession" "scene": "WXSceneSession"
} }
}, },
{ {
"img": "/static/sharemenu/wechatmoments.png", "img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": "微信朋友圈", "text": "微信朋友圈",
"share": { "share": {
"provider": "weixin", "provider": "weixin",
"scene": "WXSceneSession" "scene": "WXSenceTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/mp_weixin.png",
"text": "微信小程序",
"share": {
provider: "weixin",
scene: "WXSceneSession",
type: 5,
miniProgram: {
id: baseappConfig.mp.weixin.id,
path: `/pages/list/detail?id=${_id}&title=${title}`,
webUrl: baseappConfig.h5.url +
`/#/pages/list/detail?id=${_id}&title=${title}`,
type: 0
},
} }
}, },
{ {
"img": "/static/sharemenu/weibo.png", "img": "/static/app-plus/sharemenu/weibo.png",
"text": "微博", "text": "微博",
"share": { "share": {
"provider": "sinaweibo" "provider": "sinaweibo"
} }
}, },
{ {
"img": "/static/sharemenu/qq.png", "img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ", "text": "QQ",
"share": { "share": {
"provider": "qq" "provider": "qq"
} }
}, },
{ {
"img": "/static/sharemenu/copyurl.png", "img": "/static/app-plus/sharemenu/copyurl.png",
"text": "复制", "text": "复制",
"share": "copyurl" "share": "copyurl"
}, },
{ {
"img": "/static/sharemenu/more.png", "img": "/static/app-plus/sharemenu/more.png",
"text": "更多", "text": "更多",
"share": "shareSystem" "share": "shareSystem"
} }
], ],
cancelText:"取消分享", cancelText: "取消分享",
content:{ }, e => { //callback
type: 0,
href: "https://uniapp.dcloud.io/api/plugins/share?id=share",
title: "主标题",
summary: "分享内容的摘要",
imageUrl: "https://uniapp.dcloud.io/api/plugins/share?id=share",
}
},e=>{ //callback
console.log(e); console.log(e);
}) })
\ No newline at end of file ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册