微信小程序 配置启动页
在app.json文件中配置,该文件还可以配置首页进入的底部导航栏
app.js 是整个项目的全部js 优先加载app.js中的事件
app.wxss 也是全局的 如果要引入其他css文件 import 改文件的路径和全名导入
{
"pages":[
"pages/start/start",
"pages/index/index",
"pages/goods-details/index",
"pages/shop-cart/index",
"pages/to-pay-order/index",
"pages/select-address/index",
"pages/address-add/index",
"pages/order-list/index",
"pages/order-details/index",
"pages/wuliu/index",
"pages/mycoupons/index",
"pages/my/index",
"pages/notice/show",
"pages/recharge/index",
"pages/withdraw/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
},
"tabBar": {
"color": "#6e6d6b",
"selectedColor": "#e64340",
"borderStyle": "white",
"backgroundColor": "#fff",
"box-shadow":"0 0 6px 0",
"list": [{
"pagePath": "pages/index/index",
"iconPath": "images/nav/home-off.png",
"selectedIconPath": "images/nav/home-on.png",
"text": "首页"
}, {
"pagePath": "pages/shop-cart/index",
"iconPath": "images/nav/cart-off.png",
"selectedIconPath": "images/nav/cart-on.png",
"text": "购物车"
},
{
"pagePath": "pages/my/index",
"iconPath": "images/nav/my-off.png",
"selectedIconPath": "images/nav/my-on.png",
"text": "我的"
}]
}
}
"pages/start/start", 第一个就是配置启动页。
微信小程序登录
授权登录
在start/index.js 页面的onLoad生命周期中
onLoad:function(){
var that = this
wx.setNavigationBarTitle({
title: wx.getStorageSync('mallName')
})
app.getUserInfo(function(userInfo){
that.setData({
userInfo: userInfo
})
})
},
getUserInfo: function (cb) {
var that = this
if (this.globalData.userInfo) {
typeof cb == "function" && cb(this.globalData.userInfo)
} else {
//调用登陆接口
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
}
})
}
})
}
},
微信小程序首页
点击进入店铺