123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- // pages/mine/index.js
- const util = require('../../utils/util.js');
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- userInfo:{},
- modal: false,
- toastButton: [{
- text: "确定",
- type: '#5677fc'
- }],
- isLogin:false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- userInfo: app.globalData.userInfo,
- isLogin:app.globalData.isLogin
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (typeof this.getTabBar === 'function' &&
- this.getTabBar()) {
- this.getTabBar().setData({
- current: 2 // 根据tab的索引值设置
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- logout(){
- util.request(util.api.logout, {}, "GET", false, true,app.globalData.token).then((res)=>{
- if (res.code == 200) {
- wx.showToast({
- title: '退出登录成功!',
- })
- setTimeout(()=>{
- wx.navigateTo({
- url: '/pages/login/index',
- })
- },500)
- }
- }).catch((res) => {})
- },
- withdrawal:function(e){
- console.log(app.globalData.userInfo)
- if(app.globalData.userInfo.money<100){
- util.toast("金额大于1元才能提现")
- return;
- }
- wx.showModal({
- title: '提示',
- content: '是否确认提现到微信零钱?',
- success: function (res) {
- if (res.confirm) {
- util.request(util.api.withdrawMoney, {}, "POST", true, true,app.globalData.token).then((res)=>{
- console.log(res)
- if (res.code == 200) {
- // this.setData({
- // userInfo: res.result.userInfo,
- // })
- // app.globalData.userInfo = res.result.userInfo
- //存入缓存
- // wx.setStorage({
- // data: res.result.userInfo,
- // key: 'birthdayUserInfo',
- // })
- util.toast('提现申请已提交,请留意微信收款通知')
- }else{
- util.toast(res.message)
- }
- });
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
-
- },
- handleClick(e) {
- let index = e.detail.index;
- this.hideToast()
- },
- showToast() {
- this.setData({
- modal: true
- })
- },
- hideToast() {
- this.setData({
- modal: false
- })
- },
- toInvite(){
- wx.navigateTo({
- url: '/pages/accountRecord/index',
- })
- },
- toRouter(e){
- if(app.globalData.isLogin){
- wx.navigateTo({
- url: e.currentTarget.dataset.url,
- })
- }else{
- wx.reLaunch({
- url: '/pages/login/index',
- })
- }
- },
- })
|