| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- //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'
- })
- }
- })
|