//logs.js const util = require('../../../utils/util.js') var _request = require('../../../utils/request.js') var version = getApp().globalData.version var channel // 渠道二维码信息 var scene // 渠道二维码id var url = '' // 分享或模板落地页 var invite = 0 //邀请id var poster = [] var project = [] Page({ data: { userInfo: {}, balance: 0, bindTel: false, checkData: {}, merchant: {}, info: {}, show: 0 }, onLoad: function () { //// console.log(options) // url = 0 // if (options.scene) { // scene = decodeURIComponent(options.scene) // if (scene.indexOf('invite_wx_') > -1) { // invite = scene.slice(10) // } else if (scene.indexOf('poster') > -1) { // this.getPoster(scene) // } else if (scene.indexOf('project') > -1) { // this.getPosterProject(scene) // } else { // this.getScene(scene) // } // } else if (options.url) { // this.urlHandle(options) // } // if (options.invite) { // invite = options.invite // } // var that = this }, onShow: function () { var that = this if (this.data.bindTel) { this.getBalanceInfo() if (that.data.checkData.merchant_id > 0) { that.getmerchant() } } else { this.check() // this.info() } //2020登陆检测 wx.login({ success: res => { getApp().globalData.try_login = true; var url = 'xcx/login' var params = { code: res.code } var success = function (res) { console.log('pageLogin',res); if(res.data.wx_user){ var userInfo = res.data.wx_user that.setData({ userInfo: userInfo }) }else{ that.setData({ userInfo: 'nologin' }) } } _request.$get(url, params, success) } }) //原登陆检测 // wx.getSetting({ // success: res => { // var auth = res.authSetting // if (auth['scope.userInfo']) { // wx.getUserInfo({ // success: function (res) { // var userInfo = res.userInfo // that.setData({ // userInfo: userInfo // }) // } // }) // }else{ // that.setData({ // userInfo: 'nologin' // }) // } // } // }) }, getPoster: function (val) { poster = val.split('$') if (poster.length > 0) { invite = poster[2] } }, getPosterProject: function (val) { project = val.split('$') if (project.length > 0) { invite = project[2] } }, urlHandle: function (val) { if (val.url) { url = val.url + '?' for (var i in val) { if (i !== 'url') { url += i + '=' + val[i] + '&' } } } }, getScene: function () { var that = this var url = 'v1/xcx/channel/info/' + scene var params = {} var success = function (res) { channel = res.data } _request.$get(url, params, success) }, getUserInfo: function (val) { var channel_id = 0; invite = wx.getStorageSync('invite'); if (channel && Number(channel.parent_id) > 0) { channel_id = Number(channel.parent_id) } var that = this if (val.detail.errMsg === 'getUserInfo:ok') { wx.showLoading({ title: '加载中' }) _request.sendInfo(val, channel_id, invite, that) that.onShow(); // wx.showToast({ // title: '请绑定手机号~', // icon: 'none', // duration: 2000 // }) // wx.navigateTo({ // url: '/packageUser/pages/user/bind/bind' // }) } }, getVersion: function (val) { this.check() }, info(){ var that = this var url = 'v1/user/info' var params = {} var success = function (res) { console.log(res) that.setData({ info: res.data, show: res.data.wx_user.show_invite_mode }) } _request.$get(url, params, success) }, check () { var that = this var url = 'v1/user/check' var params = { cache: false } var success = function (res) { if (res.data.wx_user_id <= 0) { wx.login({ success: res => { _request.login(res) } }) } else { that.setData({ checkData: res.data }) if (that.data.checkData.merchant_id > 0) { that.getmerchant() } if (res.data.user_id > 0 && !that.data.bindTel) { that.setData({ bindTel: true }) that.getBalanceInfo() that.info() } } } _request.$get(url, params, success) }, getmerchant () { var that = this var url = 'v1/merchant/orders/count' var params = { merchant_id: that.data.checkData.merchant_id } var success = function (res) { var result = res.data that.setData({ merchant: result }) console.log(that.data.merchant) } _request.$get(url, params, success) }, getBalanceInfo () { var that = this var url = 'v1/user/balance/info' var params = { } var success = function (res) { var result = res.data.total that.setData({ balance: result }) } _request.$get(url, params, success) }, toInviteList () { wx.navigateTo({ url: '/packageUser/pages/user/invite/invite' }) }, toCashList () { wx.navigateTo({ url: '/packageUser/pages/user/fund/fund' }) }, toIdentity () { wx.navigateTo({ url: '/packageUser/pages/user/identity/identity' }) }, toBankInfo () { wx.navigateTo({ url: '/packageUser/pages/user/bankinfo/bankinfo' }) }, toAddressList () { wx.navigateTo({ url: '/packageUser/pages/user/address/address' }) }, toRadish () { wx.navigateTo({ url: '/packageUser/pages/user/radish/radish' }) }, toSafe () { wx.navigateTo({ url: '/packageUser/pages/user/safe/safe' }) }, toCustom () { wx.reLaunch({ url: '/pages/customservice/customservice' }) }, toBindTel () { wx.navigateTo({ url: '/packageUser/pages/user/bind/bind' }) }, toAbout () { var host = getApp().globalData.d5c if (host === 'tm.d5ct.com') { wx.navigateTo({ url: '/pages/parse/parse?id=2' }) } else if (host === 'm.d5ct.com') { wx.navigateTo({ url: '/pages/parse/parse?id=1' }) } }, toMerchant () { wx.navigateTo({ url: '/packageMerchant/pages/merchant/orders/orders?id=' + this.data.checkData.merchant_id + '&is_super_admin=' + this.data.checkData.is_super_admin }) }, toMerchant1 () { wx.navigateTo({ url: '/packageMerchant/pages/merchant/accounts/accounts?id=' + this.data.checkData.merchant_id }) }, onShareAppMessage: function (val) { return _request.share({ sc: 'xcx_user' }) } })