小程序开发-启动页和首页

微信小程序 配置启动页

在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)
            }
          })
        }
      })
    }

  },

这里写图片描述

微信小程序首页

点击进入店铺
这里写图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值