| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- //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 = []
- const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0';
- Page({
- data: {
- userInfo: {},
- balance: 0,
- integral:0,
- silver:0,
- bindTel: false,
- checkData: {},
- merchant: {},
- info: {},
- show: 0,
- checkhead:true,
- wxlogincode:'',
- bindTelfirst:0,
- cashbalance:0,
- kfqr:'',//客服二维码
- showqr:false,
- avatarUrl: defaultAvatarUrl,
- nickname:''
- },
- 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
- this.checkLogin();
- this.info();
- },
- onShow: function () {
- var that = this;
- // that.checkLogin();
- this.info();
- that.getBalanceInfo()
- that.getCashBalanceInfo()
- this.getqcode()
- // that.getIntegralInfo()
- // if (this.data.bindTel) {
- // this.getBalanceInfo()
- // this.getIntegralInfo()
- // if (that.data.checkData.merchant_id > 0) {
- // that.getmerchant()
- // }
- // } else {
- // // this.check()
- // // this.info()
- // }
-
-
- //原登陆检测
- },
- checkLogin:function(){
- var that = this;
- //2020登陆检测
- wx.login({
- success: res => {
- getApp().globalData.try_login = true;
- console.log('checkLogin',res.code)
- var url = 'xcx/login';
- invite = wx.getStorageSync('invite');
- var params = {
- code: res.code,
- invite_id: invite//新token模式
- }
- that.setData({
- wxlogincode: res.code
- })
- var success = function (res) {
- console.log('pageLogin',res);
- wx.setStorageSync('lbt_session_key', res.data.session_key)
- wx.setStorageSync('lbt_session_time', Date.now())
- wx.setStorageSync('lbt_token_key', res.data.token)
- console.log('nowtoken',res.data.token);
-
- if(res.data.wx_user && res.data.wx_user.head != ''){
- var userInfo = res.data.wx_user;
-
- that.setData({
- userInfo: userInfo
- })
- that.info()
- that.getBalanceInfo()
- that.getCashBalanceInfo()
- // that.getIntegralInfo()
-
- // if (that.data.checkData.merchant_id > 0) {
- // that.getmerchant()
- // }
- //checkwxhead---start
- // console.log('that.data.checkhead',that.data.checkhead);
-
-
- if(res.data.wx_user.head == '' ){
- that.setData({
- checkhead: false
- })
-
- that.setData({
- userInfo: 'nologin'
- })
-
- /*
- wx.getSetting({
- success: res => {
- var auth = res.authSetting
- if (auth['scope.userInfo']) {
- console.log('wxhead none')
- // wx.getUserInfo({
- // success: function(res3) {
- // console.log('userinfo',res3)
- // var url = 'xcx/save_wx_user/info'
- // var params = {
- // userinfo: JSON.stringify(res3)
- // }
- // var success = function (res4) {
- // console.log('authorize',res4)
- // that.onShow()
- // }
- // _request.$post(url, params, success)
- // }
- // })
- //新授权
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: function(res3) {
- console.log('userinfo',res3)
- var url = 'xcx/save_wx_user/info'
- var params = {
- userinfo: JSON.stringify(res3.userInfo)
- }
- var success = function (res4) {
- console.log('authorize',res4);
- that.onLoad()
- }
- _request.$post(url, params, success)
- }
- })
- }else{
- that.setData({
- userInfo: 'nologin'
- })
- }
- }
- })
-
- */
- }
-
- //checkwxhead---end
- }else{
- that.setData({
- userInfo: 'nologin'
- })
- }
- }
- _request.$get(url, params, success)
-
- }
- })
- },
- 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: '加载中'
- })
- console.log('val',val)
- // _request.sendInfo(val, channel_id, invite, that)
-
- that.onLoad();
-
-
- // wx.showToast({
- // title: '请绑定手机号~',
- // icon: 'none',
- // duration: 2000
- // })
- // wx.navigateTo({
- // url: '/packageUser/pages/user/bind/bind'
- // })
- }
- },
- getUserProfile:function(){
- console.log('tap')
- var that = this
- console.log('getUserProfile')
- const app = this
-
- //增加判断昵称和头像是否设置
- if(app.data.avatarUrl == defaultAvatarUrl){
- wx.showToast({
- title: '请设置头像',
- icon: 'none',
- duration: 2000
- });
- return;
- }
-
- if(app.data.nickname == ''){
- wx.showToast({
- title: '请设置昵称',
- icon: 'none',
- duration: 2000
- });
- return;
- }
-
- console.log('用户同意了授权');
- // wx.getUserProfile({
- // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- // success: (res) => {
- // this.setData({
- // userInfo: res.userInfo,
- // hasUserInfo: true
- // })
-
- // var channel_id = 0;
- // invite = wx.getStorageSync('invite');
- // if (channel && Number(channel.parent_id) > 0) {
- // channel_id = Number(channel.parent_id)
- // }
- // var that = this
- // console.log('res',res);
- // if (res.errMsg === "getUserProfile:ok") {
- // wx.showLoading({
- // title: '加载中'
- // })
- // res['wxlogincode'] = that.data.wxlogincode;
- // _request.sendInfo(res, channel_id, invite, that)
-
- // that.onShow();
- // }
- // }
- // })
-
-
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: function(res3) {
-
- res3.userInfo.avatarUrl = that.data.avatarUrl;
- res3.userInfo.nickName = that.data.nickname;
- console.log('userinfo',res3)
- var url = 'xcx/save_wx_user/info'
- var params = {
- userinfo: JSON.stringify(res3.userInfo)
- }
- var success = function (res4) {
- console.log('authorize',res4)
- that.onLoad()
- }
- _request.$post(url, params, success)
- }
- })
- },
- getVersion: function (val) {
- // this.check()
- },
- info(){
- console.log('oninfo');
- 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?res.data.wx_user.show_invite_mode:'',
- bindTel: res.data.user.tel ? true : false
- })
- console.log('untel',res.data.user.tel)
-
- console.log('res.data.wx_user',res.data.wx_user)
- if(res.data.wx_user.head == ''){
- console.log('indddddddddddddddddddddddd')
- that.setData({
- userInfo: 'nologin'
- })
- }
- if(that.data.userInfo != 'nologin' && res.data.user.tel == '' && that.data.bindTelfirst == 0){
- that.setData({
- bindTelfirst:1
- })
- wx.navigateTo({
- url: '/packageUser/pages/user/bind/bind'
- })
-
- wx.showToast({
- title: '请先绑定手机号~',
- icon: 'none',
- duration: 2000
- })
- }
-
-
- }
- _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.getCashBalanceInfo()
- // that.getIntegralInfo()
- that.info()
- }
- }
- }
- _request.$get(url, params, success)
- },
- buyVoucher(){
- if(this.data.info.user.tel == ''){//未绑定手机号
- wx.navigateTo({
- url: '/packageUser/pages/user/bind/bind'
- })
-
- wx.showToast({
- title: '请先绑定手机号~',
- icon: 'none',
- duration: 2000
- })
-
- //2020
- wx.setStorageSync('bindbackurl', '/packageUser/pages/user/buy/buy'); //存入手机绑定后跳转页面
- }else{
- wx.navigateTo({
- url: '/packageUser/pages/user/buy/buy'
- })
- }
- },
- 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,
- silver: res.data.silver_total
- })
- }
- _request.$get(url, params, success)
- },
- getCashBalanceInfo () {
- var that = this
- var url = 'v1/user/cash/balance/info'
- var params = {
- }
- var success = function (res) {
- var result = res.data.total
- that.setData({
- cashbalance: result
- })
- }
- _request.$get(url, params, success)
- },
- getSilverInfo () {
- var that = this
- var url = 'v1/user/cent/info'
- var params = {
- }
- var success = function (res) {
- var result = res.data.total
- that.setData({
- integral: result
- })
- }
- _request.$get(url, params, success)
- },
- toInviteList () {
- var that = this;
- if(that.data.info.user.tel == ''){
- wx.navigateTo({
- url: '/packageUser/pages/user/bind/bind'
- })
-
- wx.showToast({
- title: '请先绑定手机号~',
- icon: 'none',
- duration: 2000
- })
- }else{
- wx.navigateTo({
- url: '/packageUser/pages/user/invite/invite'
- })
- }
-
- },
- // checkbindtel(){
- // var that = this;
- // if(that.data.info.user.tel == ''){
- // setTimeout(function(){
- // wx.navigateTo({
- // url: '/packageUser/pages/user/bind/bind'
- // })
-
- // wx.showToast({
- // title: '请先绑定手机号~',
- // icon: 'none',
- // duration: 2000
- // })
- // },500)
-
- // }
- // },
- toCashList () {
- if(this.data.info.user.tel == ''){//未绑定手机号
- wx.navigateTo({
- url: '/packageUser/pages/user/bind/bind'
- })
-
- wx.showToast({
- title: '请先绑定手机号~',
- icon: 'none',
- duration: 2000
- })
-
- //2020
- wx.setStorageSync('bindbackurl', '/packageUser/pages/user/fund/fund'); //存入手机绑定后跳转页面
- }else{
- wx.navigateTo({
- url: '/packageUser/pages/user/fund/fund'
- })
- }
- },
- toUserInfo() {
- wx.navigateTo({
- url: '/packageUser/pages/user/userInfo/userInfo'
- })
- },
- toBindOldSys () {
- let that = this;
- wx.navigateTo({
- url: '/packageUser/pages/user/bindoldsys/bindoldsys?id='+that.data.userInfo.id
- })
- },
- toPromotion () {
- wx.navigateTo({
- url: '/packageUser/pages/user/promotion/promotion'
- })
- },
- 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'
- })
- },
- toCanteen () {
- wx.navigateTo({
- url: '/pages/canteen/canteen'
- })
- },
- toRadish () {
- wx.navigateTo({
- url: '/packageUser/pages/user/radish/radish'
- })
- },
- toCash () {
- wx.navigateTo({
- url: '/packageUser/pages/user/cash/cash'
- })
- },
- toCommission () {
- wx.navigateTo({
- url: '/packageUser/pages/user/commission/commission'
- })
- },
- toIntegral () {
- wx.navigateTo({
- url: '/packageUser/pages/user/integral/integral'
- })
- },
- toSilver () {
- wx.navigateTo({
- url: '/packageUser/pages/user/silver/silver'
- })
- },
- toSafe () {
- wx.navigateTo({
- url: '/packageUser/pages/user/safe/safe'
- })
- },
- toCustom () {
- wx.reLaunch({
- url: '/pages/customservice/customservice'
- })
- },
- toProxy () {
- wx.navigateTo({
- url: '/packageUser/pages/user/proxyList/proxyList'
- })
- },
- toApplyLeader () {
- wx.navigateTo({
- url: '/packageUser/pages/user/applyLeader/applyLeader'
- })
- },
- toAreaCart () {
- wx.navigateTo({
- url: '/pages/areacart/areacart'
- })
- },
- 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'
- })
- },
- getqcode: function () {
- var that = this
- var url = 'v1/customer_service/qrcode'
- var params = {}
- var success = function (res) {
- that.setData({
- kfqr: res.data
- })
- }
- _request.$get(url, params, success)
- },
- tiggerQR:function(){
- this.setData({
- showqr: !this.data.showqr
- })
- },
- catchtapQR:function(){
- console.log('catchtapQR');
- },
-
-
- /**
- * 用户头像设置
- */
- onChooseAvatar(e) {
- const { avatarUrl } = e.detail
- this.setData({
- avatarUrl,
- })
- },
-
- /**
- * 用户昵称设置
- */
- changeNickName(e) {
- console.log(e.detail);
- this.setData({
- nickname: e.detail.value
- })
- },
-
- savebtn(){
- var that = this;
-
- //增加判断昵称和头像是否设置
- if(that.data.avatarUrl == defaultAvatarUrl){
- wx.showToast({
- title: '请设置头像',
- icon: 'none',
- duration: 2000
- });
- return;
- }
-
- if(that.data.nickname == ''){
- wx.showToast({
- title: '请设置昵称',
- icon: 'none',
- duration: 2000
- });
- return;
- }
-
- var url = 'v1/user/update/info'
- var params = {
- nickname:that.data.nickname,
- birthday:'',
- sex:0,
- }
- var success = function (res) {
- console.log(res);
- wx.showToast({
- title: '更新成功',
- icon: 'none',
- duration: 2000
- })
- }
- var fail = function (res) {
- console.log(res);
- }
-
- _request.$uploadFile(url,'head',that.data.avatarUrl, params, success,fail)
- that.onLoad()
-
- },
- })
|