一、app.js
// app.jslet userInfo =wx.getStorageSync("userInfo") || {} //用户信息let isLogin = JSON.stringify(userInfo) != "{}" //用户登录状态App({ onLaunch: function () { if (!wx.cloud) { console.error('请使用 2.2.3 或以上的基础库以使用云能力'); } else { wx.cloud.init({ // env 参数说明: // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // 如不填则使用默认环境(第一个创建的环境) env: 'cloud1-0g26459e75827aa8', traceUser: true, }); } this.globalData = { // 购物车商品数量 totalCartCount: 0, userInfo: userInfo, isLogin: isLogin } console.log(this.globalData) //this.globalData = {}; }});
二、修改json
1、新建页面
目前主要的有首页、预约、关于、个人中心
"pages": [ "pages/index/index", "pages/reservation/reservation", "pages/about/about", "pages/mine/mine" ],
2、修改tab设置
"tabBar": { "selectedColor": "#ff4444", "color": "#808080", "list": [ { "pagePath": "pages/index/index", "text": "首页", "iconPath": "images/tabbar/homepage.png", "selectedIconPath": "images/tabbar/homepage-sel.png" }, { "pagePath": "pages/reservation/reservation", "text": "预约", "iconPath": "images/tabbar/order.png", "selectedIconPath": "images/tabbar/order-sel.png" }, { "pagePath": "pages/about/about", "text": "关于", "iconPath": "images/tabbar/about.png", "selectedIconPath": "images/tabbar/about-sel.png" }, { "pagePath": "pages/mine/mine", "text": "我的", "iconPath": "images/tabbar/user.png", "selectedIconPath": "images/tabbar/user-sel.png" } ] },
3、修改 app.json全局的默认窗口配置
"window": { "backgroundColor": "#F6F6F6", "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#F6F6F6", "navigationBarTitleText": "贝贝和亲亲", "navigationBarTextStyle": "black" }
三、修改全局样式app.wxss
/**app.wxss**/page{ width:100%; padding: 0; margin: 0; height: 100%; font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; background-color: #f2f2f2;}.container { display: flex; flex-direction: column; align-items: center; box-sizing: border-box;}
版权声明:内容来源于互联网和用户投稿 如有侵权请联系删除