标签:文件名 container exp 程序启动 settime mpi 属性 and select
数据的访问:
使用getApp()访问,在需要访问的页面的js中加上 var app=getAPP(),就可以app.XX来访问数据,app.xxx()访问函数
举例:
//app.js App({ cookie: {}, onLaunch: function () { }, globalData: { userInfo: null, version: "1.0", shopName: "商店", //sdomain:"http://192.168.0.119:8999/api", domain:"https://xx/api", static_domain:"https://xx.cn/static/images/mina", }, tip:function( params ){ var that = this; var title = params.hasOwnProperty(‘title‘)?params[‘title‘]:‘提示您‘; var content = params.hasOwnProperty(‘content‘)?params[‘content‘]:‘‘; wx.showModal({ title: title, content: content, success: function(res) { if ( res.confirm ) {//点击确定 if( params.hasOwnProperty(‘cb_confirm‘) && typeof( params.cb_confirm ) == "function" ){ params.cb_confirm(); } }else{//点击否 if( params.hasOwnProperty(‘cb_cancel‘) && typeof( params.cb_cancel ) == "function" ){ params.cb_cancel(); } } } }) }, alert:function( params ){ var title = params.hasOwnProperty(‘title‘)?params[‘title‘]:‘提示您‘; var content = params.hasOwnProperty(‘content‘)?params[‘content‘]:‘‘; wx.showModal({ title: title, content: content, showCancel:false, success: function(res) { if (res.confirm) {//用户点击确定 if( params.hasOwnProperty(‘cb_confirm‘) && typeof( params.cb_confirm ) == "function" ){ params.cb_confirm(); } }else{ if( params.hasOwnProperty(‘cb_cancel‘) && typeof( params.cb_cancel ) == "function" ){ params.cb_cancel(); } } } }) }, console:function( msg ){ console.log( msg); },
在其他js中引用
/login.js //获取应用实例 var app = getApp(); Page({ data: { remind: ‘加载中‘, angle: 0, userInfo: {}, regFlag:true }, onLoad: function () { wx.setNavigationBarTitle({ title: app.globalData.shopName }); this.checkLogin(); }, onShow: function () { }, onReady: function () { var that = this; setTimeout(function () { that.setData({ remind: ‘‘ }); }, 1000); }, checkLogin:function(){ var that = this; wx.login({ success:function( res ){ if( !res.code ){ app.alert( { ‘content‘:‘登录失败,请再次点击~~‘ } ); return; } wx.request({ url:app.buildUrl( ‘/member/check-reg‘ ), header:app.getRequestHeader(), method:‘POST‘, data:{ code:res.code }, success:function( res ){ if( res.data.code != 200 ){ that.setData({ regFlag:false }); return; } app.setCache( "token",res.data.data.token ); //that.goToIndex(); } }); } }); }, login:function( e ){ var that = this; if( !e.detail.userInfo ){ app.alert( { ‘content‘:‘登录失败,请再次点击~~‘ } ); return; } var data = e.detail.userInfo; wx.login({ success:function( res ){ if( !res.code ){ app.alert( { ‘content‘:‘登录失败,请再次点击~~‘ } ); return; } data[‘code‘] = res.code; wx.request({ url:app.buildUrl( ‘/member/login‘ ), header:app.getRequestHeader(), method:‘POST‘, data:data, success:function( res ){ if( res.data.code != 200 ){ app.alert( { ‘content‘:res.data.msg } ); return; } app.setCache( "token",res.data.data.token ); that.goToIndex(); } }); } }); } });
全局配置文件,可以配置页面路径、窗口样式、设置网络超时和底部导航。
.json
, .js
, .wxml
, .wxss
四个文件进行处理举例:
pages
"pages": [ "pages/my/my", "pages/index/index", "pages/logs/logs" ],
window:
属性 | 类型 | 默认值 | 描述 | 最低版本 |
---|---|---|---|---|
navigationBarBackgroundColor | HexColor | #000000 | 导航栏背景颜色,如 #000000 |
|
navigationBarTextStyle | string | white | 导航栏标题颜色,仅支持 black / white |
|
navigationBarTitleText | string | 导航栏标题文字内容 | ||
backgroundColor | HexColor | #ffffff | 窗口的背景色 | |
backgroundTextStyle | string | dark | 下拉 loading 的样式,仅支持 dark / light |
"window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#405f80", "navigationBarTitleText": "WeChat", "navigationBarTextStyle": "white" },
color | HexColor | 是 | tab 上的文字默认颜色,仅支持十六进制颜色 | ||
selectedColor | HexColor | 是 | tab 上的文字选中时的颜色,仅支持十六进制颜色 | ||
backgroundColor | HexColor | 是 | tab 的背景色,仅支持十六进制颜色 | ||
borderStyle | string | 否 | black | tabbar 上边框的颜色, 仅支持 black / white |
|
list | Array | 是 |
tab 的列表,详见
|
其中 list 接受一个数组,只能配置最少 2 个、最多 5 个 tab。tab 按数组的顺序排序,每个项都是一个对象,其属性值如下:
"tabBar": { "color": "#6e6d6b", "selectedColor": "#e64340", "borderStyle": "black", "backgroundColor": "#fff", "list": [ { "pagePath": "pages/index/index", "iconPath": "images/tabbar/ic_menu_choice_nor.png", "selectedIconPath": "images/tabbar/ic_menu_choice_pressed.png", "text": "首页" }, { "pagePath": "pages/my/my", "iconPath": "images/tabbar/ic_menu_me_nor.png", "selectedIconPath": "images/tabbar/ic_menu_me_pressed.png", "text": "我的" } ] },
/**app.wxss**/ .container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; box-sizing: border-box; }
{ "description": "项目配置文件。", "setting": { "urlCheck": true, "es6": true, "postcss": true, "minified": true, "newFeature": true, "coverView": true, "autoAudits": false, "showShadowRootInWxmlPanel": true, "scopeDataCheck": false, "checkInvalidKey": true, "checkSiteMap": true, "uploadWithSourceMap": true, "babelSetting": { "ignore": [], "disablePlugins": [], "outputPath": "" } }, "compileType": "miniprogram", "libVersion": "1.9.94", "appid": "wx953fxxxxxxxxxx", "projectname": "test_mina", "isGameTourist": false, "simulatorType": "wechat", "simulatorPluginLibVersion": {}, "condition": { "search": { "current": -1, "list": [] }, "conversation": { "current": -1, "list": [] }, "game": { "currentL": -1, "list": [] }, "miniprogram": { "current": -1, "list": [] } } }
标签:文件名 container exp 程序启动 settime mpi 属性 and select
原文地址:https://www.cnblogs.com/xiao-apple36/p/12785691.html