|
|
|
// pages/user/user.js
|
|
|
|
var app = getApp()
|
|
|
|
var WXAPI = require('../../utils/server.js');
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
// 状态栏高度
|
|
|
|
statusBarHeight: wx.getStorageSync('statusBarHeight') + 'px',
|
|
|
|
// 胶囊按钮高度
|
|
|
|
menuBtnHeight: wx.getStorageSync('menuBtnHeight') + 'px',
|
|
|
|
// 导航栏和状态栏高度
|
|
|
|
navBarHeight: wx.getStorageSync('statusBarHeight') + wx.getStorageSync('navBarHeight') + 'px',
|
|
|
|
pop: null,
|
|
|
|
list: [
|
|
|
|
// {
|
|
|
|
// icon: 'zj.png',
|
|
|
|
// text: '历史记录',
|
|
|
|
// url: 'footprint/footprint'
|
|
|
|
// },
|
|
|
|
{
|
|
|
|
icon: 'grzl.png',
|
|
|
|
text: '个人资料',
|
|
|
|
url: 'userinfo/userinfo'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'dz.png',
|
|
|
|
text: '地址管理',
|
|
|
|
url: 'address/index'
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// icon: 'fp.png',
|
|
|
|
// text: '发票管理',
|
|
|
|
// url: 'address/index'
|
|
|
|
// }
|
|
|
|
],
|
|
|
|
cont: 1,
|
|
|
|
remind: '加载中',
|
|
|
|
tjr: false,
|
|
|
|
user:'',
|
|
|
|
xxnum: 0,
|
|
|
|
accessId: app.globalData.accessId,
|
|
|
|
},
|
|
|
|
//下拉刷新
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
|
|
this.requestMyData();
|
|
|
|
wx.hideNavigationBarLoading() //完成停止加载
|
|
|
|
wx.stopPullDownRefresh() //停止下拉刷新
|
|
|
|
},
|
|
|
|
copyText: function (t) {
|
|
|
|
var a = t.currentTarget.dataset.text;
|
|
|
|
wx.setClipboardData({
|
|
|
|
data: a,
|
|
|
|
success: function () {
|
|
|
|
wx.showToast({
|
|
|
|
title: "已复制"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.requestMyData();
|
|
|
|
},
|
|
|
|
//页面加载完成函数
|
|
|
|
onReady: function () {
|
|
|
|
var that = this;
|
|
|
|
this.pop = this.selectComponent("#pop")
|
|
|
|
that.setData({
|
|
|
|
remind: ''
|
|
|
|
});
|
|
|
|
},
|
|
|
|
//会员中心
|
|
|
|
navToMemberCenter() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/member/member'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navToCoupon() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/coupon/index'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navToScore() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/user/score'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navToWallet() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/user/wallet'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//我的收藏
|
|
|
|
navToCollection() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/collection/collection'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onShow: function () {
|
|
|
|
var that = this;
|
|
|
|
// var cont = that.data.cont;
|
|
|
|
// if (cont > 1) {
|
|
|
|
that.requestMyData();
|
|
|
|
// } else {
|
|
|
|
// that.setData({
|
|
|
|
// cont: cont + 1
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
requestMyData: function () {
|
|
|
|
var that = this;
|
|
|
|
WXAPI.userIndex({
|
|
|
|
accessId: app.globalData.accessId,
|
|
|
|
storeId: 239,
|
|
|
|
storeType: 1,
|
|
|
|
mobile:'',
|
|
|
|
}).then(res => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
var data = res.data;
|
|
|
|
if (data.data) {
|
|
|
|
that.setData({
|
|
|
|
collection_num: data.data.collection_num,
|
|
|
|
xxnum: data.data.xxnum,
|
|
|
|
user: data.data.user,
|
|
|
|
logo: data.data.logo,
|
|
|
|
company: data.data.company,
|
|
|
|
th: data.data.th,
|
|
|
|
dfh_num: data.data.dfh_num,
|
|
|
|
dfk_num: data.data.dfk_num,
|
|
|
|
dpj_num: data.data.dpj_num,
|
|
|
|
dsh_num: data.data.dsh_num,
|
|
|
|
// plug_ins: data.data.plug_ins,
|
|
|
|
// tjr: data.data.tjr,
|
|
|
|
// support: data.data.support
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
that.setData({
|
|
|
|
xxnum: '',
|
|
|
|
user: '',
|
|
|
|
logo: '',
|
|
|
|
company: '',
|
|
|
|
th: '',
|
|
|
|
dfh_num: '',
|
|
|
|
dfk_num: '',
|
|
|
|
dpj_num: '',
|
|
|
|
dsh_num: '',
|
|
|
|
});
|
|
|
|
wx.removeStorageSync('accessId')
|
|
|
|
wx.removeStorageSync('isLogin');
|
|
|
|
wx.removeStorageSync('userInfo');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: '访问失败!',
|
|
|
|
duration: 2000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
go: function (e) {
|
|
|
|
console.log(e)
|
|
|
|
var url = e.currentTarget.dataset.url
|
|
|
|
wx.navigateTo({
|
|
|
|
url: url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
login: function () {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
jumpgo: function (event) {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
let url = event.currentTarget.dataset.id
|
|
|
|
wx.navigateTo({
|
|
|
|
url: url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navToNotice() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/notice/notice'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navToSetup() {
|
|
|
|
var isLogin = wx.getStorageSync('isLogin')
|
|
|
|
if (!isLogin) {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/set/set'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|