123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- const App = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- isLogin: false,
- userInfo: {}, // 用户信息
- orderCount: {}, // 订单数量
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- let _this = this;
- _this.setData({
- isLogin: App.checkIsLogin()
- });
- // 获取当前用户信息
- _this.getUserDetail();
- // 更新购物车角标
- App.setCartTabBadge()
- },
- /**
- * 获取当前用户信息
- */
- getUserDetail() {
- let _this = this;
- App._get('user.index/detail', {}, function (result) {
- _this.setData(result.data);
- });
- },
- /**
- * 订单导航跳转
- */
- onTargetOrder(e) {
- let _this = this;
- if (!_this.onCheckLogin()) {
- return false;
- }
- let urls = {
- all: '/pages/order/index?type=all',
- payment: '/pages/order/index?type=payment',
- received: '/pages/order/index?type=received',
- refund: '/pages/order/refund/index',
- };
- // 转跳指定的页面
- wx.navigateTo({
- url: urls[e.currentTarget.dataset.type]
- })
- },
- /**
- * 菜单列表导航跳转
- */
- onTargetMenus(e) {
- let _this = this;
- if (!_this.onCheckLogin()) {
- return false;
- }
- wx.navigateTo({
- url: '/' + e.currentTarget.dataset.url
- })
- },
- /**
- * 跳转我的钱包页面
- */
- onTargetWallet(e) {
- let _this = this;
- if (!_this.onCheckLogin()) {
- return false;
- }
- wx.navigateTo({
- url: './wallet/index'
- })
- },
- /**
- * 跳转积分明细页
- */
- onTargetPoints(e) {
- let _this = this;
- if (!_this.onCheckLogin()) {
- return false;
- }
- wx.navigateTo({
- url: '../points/log/index'
- });
- },
- /**
- * 跳转到登录页
- */
- onLogin() {
- // wx.navigateTo({
- // url: '../login/login',
- // });
- App.doLogin();
- },
- /**
- * 验证是否已登录
- */
- onCheckLogin() {
- let _this = this;
- if (!_this.data.isLogin) {
- App.showError('很抱歉,您还没有登录');
- return false;
- }
- return true;
- },
- })
|