123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- var app = getApp();
- Page({
- data: {
- open: true,
- user: '',
- balance: '', //我的钱包
- actionSheetHidden: true,
- state: '',
- arr: [],
- show: '',
- screenHeight: '',
- adHeight: '',
- img: app.globalData.imgUrl,
- title: app.globalData.title,
- identity:''
- },
- onGotUserInfo: function (e) {
- console.log(e)
- var that = this;
- wx.showLoading({
- title: '登陆中请稍等...',
- mask: true
- })
- if (e.detail.userInfo) {
- var data = e.detail.userInfo;
- wx.request({
- url: 'https://yutang.web.ximengnaikang.com/api/syncUserInfo',
- method: 'POST',
- data: data,
- header: {
- 'content-type': 'application/x-www-form-urlencoded',
- 'Authorization': wx.getStorageSync('token')
- },
- success: function (res) {
- console.log(res)
- if (res.statusCode == 200) {
- wx.showToast({
- title: '授权成功',
- icon: 'none'
- })
- wx.setStorageSync('userInfo', res.data.data.user)
- that.setData({
- user: res.data.data.user
- })
- } else {
- wx.showToast({
- title: '登陆失败请重试',
- icon: 'none'
- })
- }
- }
- })
- } else {
- wx.showToast({
- title: '授权失败',
- icon: 'none'
- })
- }
- },
- tap: function (e) {
- console.log(e)
- var url = e.currentTarget.dataset.url;
- console.log(url)
- var userInfo = wx.getStorageSync('userInfo');
- console.log(userInfo)
- if (userInfo == undefined || userInfo == '') {
- wx.showModal({
- title: '用户授权',
- content: '此功能需要获取您的昵称等公开信息,请到小程序的设置中打开用户权限!',
- cancelText: '下次再说',
- confirmText: '去授权',
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '../login/login',
- })
- }
- }
- })
- } else {
- wx.navigateTo({
- url: '/pages/' + url + '/' + url
- })
- }
- },
- onLoad: function (options) {
- this.setData({
- screenHeight: app.globalData.screenHeight
- })
- //获取实名认证状态
- },
- buy: function () {
- wx.navigateTo({
- url: '/pages/recharge/recharge',
- })
- },
- look() {
- wx.navigateTo({
- url: '/pages/riding_card/riding_card',
- })
- },
- onReady: function () {
- },
- onShow: function () {
- var that = this;
- that.setData({
- user: wx.getStorageSync('userInfo'),
- identity:wx.getStorageSync('userInfo').role
- })
- console.log(this.data.identity)
- // app.request("/card_riding/user_card", '', "GET").then(res => {
- // console.log(res)
- // that.setData({ arr: res.data.user_card,show:res.data.is_card_begin })
- // })
- // app.request("/user/status", '', "GET").then(res => {
- // console.log(res)
- // if (res.statusCode == 200) {
- // if (res.data.is_card_certified == 1) {
- // this.setData({
- // state: '已实名'
- // })
- // } else {
- // this.setData({
- // state: '未实名'
- // })
- // }
- // wx.setStorageSync('userState', res.data)
- // }
- // })
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- wx.showNavigationBarLoading();
- var that = this;
- // app.request("/me", '', "GET").then(res => {
- // 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({
- // user: res.data
- // })
- // wx.hideNavigationBarLoading()
- // wx.stopPullDownRefresh();
- // })
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|