|
@@ -1,227 +1,248 @@
|
|
|
-
|
|
|
-var BASEURL = require('../../utils/wxconstant.js')
|
|
|
-var baseUrl = BASEURL.BaseUrl()
|
|
|
-var baseutils = require('../../utils/baseUtils.js')
|
|
|
-var netUtil = require('../../utils/network.js')
|
|
|
-var dateutil = require('../../utils/DateTime.js')
|
|
|
-var isregistered
|
|
|
-
|
|
|
-Page({
|
|
|
-
|
|
|
-
|
|
|
- * 页面的初始数据
|
|
|
- */
|
|
|
- data: {
|
|
|
-
|
|
|
- idTypeRank:'idTypeRank',
|
|
|
- isregistered:false,
|
|
|
- idMyInfo:'idMyInfo',
|
|
|
- idCompanyInfo: 'idCompanyInfo',
|
|
|
- idAbout: 'idAbout',
|
|
|
- idgoBind:'idgoBind',
|
|
|
- idWxlogin:'idWxlogin',
|
|
|
- pointdata:{},
|
|
|
-
|
|
|
- "curmonth_points": 0,
|
|
|
- "curmonth_rank": '-',
|
|
|
- "lastmonth_points": 0,
|
|
|
- "lastmonth_rank": '-'
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
- onLoad: function (options) {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady: function () {
|
|
|
-
|
|
|
- },
|
|
|
- btnClick: function (event) {
|
|
|
- var that = this
|
|
|
- var id = event.currentTarget.id
|
|
|
- if (id == that.data.idAbout) {
|
|
|
- wx.navigateTo({
|
|
|
- url: '../about/about',
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- isregistered = wx.getStorageSync('isregistered')
|
|
|
- console.log('isregistered', isregistered)
|
|
|
- if (id == that.data.idWxlogin){
|
|
|
- return
|
|
|
- }
|
|
|
- if (!wx.getStorageSync('wxnickName')) {
|
|
|
- that.comToast('您当前尚未进行微信授权登录')
|
|
|
- return
|
|
|
- }
|
|
|
- if (id == that.data.idgoBind) {
|
|
|
- wx.navigateTo({
|
|
|
- url: '../bindphone/bindphone',
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (id == that.data.idTypeRank){
|
|
|
- wx.navigateTo({
|
|
|
- url: '../pointRank/pointRank',
|
|
|
- })
|
|
|
- }
|
|
|
- if (!isregistered) {
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '您当前尚未与企业关联绑定,是否立即去绑定?',
|
|
|
- success: function (res) {
|
|
|
- if (res.confirm) {
|
|
|
- wx.navigateTo({
|
|
|
- url: '../bindphone/bindphone',
|
|
|
- })
|
|
|
- } else if (res.cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if (id == that.data.idMyInfo){
|
|
|
- wx.navigateTo({
|
|
|
- url: '../perinfo/perinfo',
|
|
|
- })
|
|
|
- } else if (id == that.data.idCompanyInfo){
|
|
|
- wx.navigateTo({
|
|
|
- url: '../corporateInfo/corporateInfo',
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow: function () {
|
|
|
- var that = this
|
|
|
- this.setData({
|
|
|
- isregistered: wx.getStorageSync('isregistered'),
|
|
|
- isLogin: wx.getStorageSync('wxnickName') ? true : false,
|
|
|
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
|
- headerImg: wx.getStorageSync('wxavatarUrl'),
|
|
|
- wxNickname: wx.getStorageSync('wxnickName'),
|
|
|
- })
|
|
|
- isregistered = wx.getStorageSync('isregistered')
|
|
|
- if (!isregistered){
|
|
|
- return
|
|
|
- }
|
|
|
- that.getMyRank()
|
|
|
- },
|
|
|
-
|
|
|
- getMyRank:function(){
|
|
|
- var that = this
|
|
|
- var data = {
|
|
|
- openid: wx.getStorageSync('openid'),
|
|
|
- }
|
|
|
- var url = baseUrl + BASEURL.getUrl.getRank
|
|
|
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
|
|
|
- if (res.data.success){
|
|
|
- wx.setStorageSync('isregistered', res.data.data.isregistered)
|
|
|
- if (res.data.data.pointdata){
|
|
|
- var pointdata = res.data.data.pointdata
|
|
|
- that.setData({
|
|
|
- isregistered: res.data.data.isregistered,
|
|
|
- pointdata: pointdata,
|
|
|
- "curmonth_points": pointdata.curmonth_points == null ? '0' : pointdata.curmonth_points,
|
|
|
- "curmonth_rank": pointdata.curmonth_rank == null ? '0' : pointdata.curmonth_rank,
|
|
|
- "lastmonth_points": pointdata.lastmonth_points == null ? '0' : pointdata.lastmonth_points,
|
|
|
- "lastmonth_rank": pointdata.lastmonth_rank == null ? '-' : pointdata.lastmonth_rank
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }, function (res) {
|
|
|
- wx.showToast({
|
|
|
- title: '加载数据失败',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
- bindGetUserInfo: function (e) {
|
|
|
- var that = this
|
|
|
- var userInfo = e.detail.userInfo
|
|
|
- if (!userInfo) return
|
|
|
- console.log('bindGetUserInfo', userInfo)
|
|
|
- var nickName = userInfo.nickName
|
|
|
- var avatarUrl = userInfo.avatarUrl
|
|
|
- var gender = userInfo.gender
|
|
|
- var province = userInfo.province
|
|
|
- var city = userInfo.city
|
|
|
- var country = userInfo.country
|
|
|
- if (nickName && avatarUrl) {
|
|
|
- baseutils.getPersonlEmp()
|
|
|
- baseutils.judgeisReg()
|
|
|
- that.getMyRank()
|
|
|
- that.setData({
|
|
|
- wxNickname: nickName,
|
|
|
- wxHeader: avatarUrl,
|
|
|
- isLogin: true
|
|
|
- })
|
|
|
- try {
|
|
|
- wx.setStorageSync('wxavatarUrl', userInfo.avatarUrl)
|
|
|
- wx.setStorageSync('wxnickName', userInfo.nickName)
|
|
|
- } catch (e) {
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- comToast: function (title) {
|
|
|
- wx.showToast({
|
|
|
- title: title,
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
- onHide: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
- onPullDownRefresh: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage: function () {
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+var BASEURL = require('../../utils/wxconstant.js')
|
|
|
+var baseUrl = BASEURL.BaseUrl()
|
|
|
+var baseutils = require('../../utils/baseUtils.js')
|
|
|
+var netUtil = require('../../utils/network.js')
|
|
|
+var dateutil = require('../../utils/DateTime.js')
|
|
|
+var isregistered
|
|
|
+
|
|
|
+Page({
|
|
|
+
|
|
|
+
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+
|
|
|
+ idTypeRank:'idTypeRank',
|
|
|
+ isregistered:false,
|
|
|
+ idMyInfo:'idMyInfo',
|
|
|
+ idCompanyInfo: 'idCompanyInfo',
|
|
|
+ idAbout: 'idAbout',
|
|
|
+ idgoBind:'idgoBind',
|
|
|
+ idWxlogin:'idWxlogin',
|
|
|
+ pointdata:{},
|
|
|
+
|
|
|
+ "curmonth_points": 0,
|
|
|
+ "curmonth_rank": '-',
|
|
|
+ "lastmonth_points": 0,
|
|
|
+ "lastmonth_rank": '-'
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+ btnClick: function (event) {
|
|
|
+ var that = this
|
|
|
+ var id = event.currentTarget.id
|
|
|
+ if (id == that.data.idAbout) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../about/about',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isregistered = wx.getStorageSync('isregistered')
|
|
|
+ console.log('isregistered', isregistered)
|
|
|
+ if (id == that.data.idWxlogin){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!wx.getStorageSync('wxnickName')) {
|
|
|
+ that.comToast('您当前尚未进行微信授权登录')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (id == that.data.idgoBind) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../bindphone/bindphone',
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (id == that.data.idTypeRank){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../pointRank/pointRank',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (!isregistered) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '您当前尚未与企业关联绑定,是否立即去绑定?',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../bindphone/bindphone',
|
|
|
+ })
|
|
|
+ } else if (res.cancel) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == that.data.idMyInfo){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../perinfo/perinfo',
|
|
|
+ })
|
|
|
+ } else if (id == that.data.idCompanyInfo){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../corporateInfo/corporateInfo',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+ var that = this
|
|
|
+ this.setData({
|
|
|
+ isregistered: wx.getStorageSync('isregistered'),
|
|
|
+ isLogin: wx.getStorageSync('wxnickName') ? true : false,
|
|
|
+ canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
|
+ headerImg: wx.getStorageSync('wxavatarUrl'),
|
|
|
+ wxNickname: wx.getStorageSync('wxnickName'),
|
|
|
+ })
|
|
|
+ isregistered = wx.getStorageSync('isregistered')
|
|
|
+ if (!isregistered){
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ that.getMyRank()
|
|
|
+ that.getEmp()
|
|
|
+ },
|
|
|
+
|
|
|
+ getEmp:function(){
|
|
|
+ var that = this
|
|
|
+ var data = {
|
|
|
+ openid: wx.getStorageSync('openid'),
|
|
|
+ }
|
|
|
+ var url = baseUrl + BASEURL.getUrl.getEmp
|
|
|
+ netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
|
|
|
+ if (res.data.success && res.data.data.empId) {
|
|
|
+ wx.setStorageSync('empId', res.data.data.empId)
|
|
|
+ console.log("empId", wx.getStorageSync('empId'))
|
|
|
+ }
|
|
|
+ }, function (res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '加载数据失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getMyRank:function(){
|
|
|
+ var that = this
|
|
|
+ var data = {
|
|
|
+ openid: wx.getStorageSync('openid'),
|
|
|
+ }
|
|
|
+ var url = baseUrl + BASEURL.getUrl.getRank
|
|
|
+ netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
|
|
|
+ if (res.data.success){
|
|
|
+ wx.setStorageSync('isregistered', res.data.data.isregistered)
|
|
|
+ if (res.data.data.pointdata){
|
|
|
+ var pointdata = res.data.data.pointdata
|
|
|
+ that.setData({
|
|
|
+ isregistered: res.data.data.isregistered,
|
|
|
+ pointdata: pointdata,
|
|
|
+ "curmonth_points": pointdata.curmonth_points == null ? '0' : pointdata.curmonth_points,
|
|
|
+ "curmonth_rank": pointdata.curmonth_rank == null ? '0' : pointdata.curmonth_rank,
|
|
|
+ "lastmonth_points": pointdata.lastmonth_points == null ? '0' : pointdata.lastmonth_points,
|
|
|
+ "lastmonth_rank": pointdata.lastmonth_rank == null ? '-' : pointdata.lastmonth_rank
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, function (res) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '加载数据失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ bindGetUserInfo: function (e) {
|
|
|
+ var that = this
|
|
|
+ var userInfo = e.detail.userInfo
|
|
|
+ if (!userInfo) return
|
|
|
+ console.log('bindGetUserInfo', userInfo)
|
|
|
+ var nickName = userInfo.nickName
|
|
|
+ var avatarUrl = userInfo.avatarUrl
|
|
|
+ var gender = userInfo.gender
|
|
|
+ var province = userInfo.province
|
|
|
+ var city = userInfo.city
|
|
|
+ var country = userInfo.country
|
|
|
+ if (nickName && avatarUrl) {
|
|
|
+ baseutils.getPersonlEmp()
|
|
|
+ baseutils.judgeisReg()
|
|
|
+ that.getMyRank()
|
|
|
+ that.setData({
|
|
|
+ wxNickname: nickName,
|
|
|
+ wxHeader: avatarUrl,
|
|
|
+ isLogin: true
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ wx.setStorageSync('wxavatarUrl', userInfo.avatarUrl)
|
|
|
+ wx.setStorageSync('wxnickName', userInfo.nickName)
|
|
|
+ } catch (e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ comToast: function (title) {
|
|
|
+ wx.showToast({
|
|
|
+ title: title,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
})
|