// index.js // 获取应用实例 const app = getApp() const link = app.globalData.url Page({ data: { grids1: [{ image: 'order', text: '我的订单' }, { image: 'user', text: '好友列表' }, { image: 'help', text: '帮助中心' }, { image: 'add', text: '邀请好友' }, { image: 'to-top', text: '手动同步订单' }, { image: 'customer-service', text: '联系客服' }, { image: 'setting', text: '设置' }, { image: 'success', text: '体现' }, //{ // image: 'eye', // text: '我的足迹' // }, { // image: 'scan', // text: '扫一扫' // }, ], // grids2: [{ // image: 'cart', // text: '我的购物车' // }, { // image: 'help', // text: '帮助中心' // }, { // image: 'address', // text: '地址管理' // }, { // image: 'order', // text: '我的订单' // }, { // image: 'customer-service', // text: '联系客服' // }, ], motto: 'Hello World', userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo'), canIUseGetUserProfile: false, canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false }, // 事件处理函数 bindViewTap() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad() { var that = this var opneId = wx.getStorageSync('openId') if (wx.getUserProfile) { this.setData({ canIUseGetUserProfile: true }) } //获取金额 wx.request( { url: link + "/v1/user/wallet/get", header: { "Content-Type": "application/json" }, method: "POST", data: { openId: opneId }, success (res) { console.log(res) // if (res.data.code == 200){ // pid = res.data.data.pid // } that.setData({ wallet: res.data.data.wallet }) } }) }, clickGrid(e) { if (e.detail.cell.text == "我的订单"){ wx.navigateTo({ url:"/pages/order/order" }) } else if (e.detail.cell.text == "体现") { wx.showToast({ title: "结算金额:0元", icon: 'none' }); } else { wx.showToast({ title: "功能开发中...", icon: 'none' }); } }, getUserProfile(e) { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 wx.getUserProfile({ desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { console.log(res) this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } }) }, getUserInfo(e) { // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 console.log(e) this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) } })