all.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. //logs.js
  2. const util = require('../../../utils/util.js')
  3. var _request = require('../../../utils/request.js')
  4. var version = getApp().globalData.version
  5. var channel // 渠道二维码信息
  6. var scene // 渠道二维码id
  7. var url = '' // 分享或模板落地页
  8. var invite = 0 //邀请id
  9. var poster = []
  10. var project = []
  11. Page({
  12. data: {
  13. userInfo: {},
  14. balance: 0,
  15. integral:0,
  16. silver:0,
  17. bindTel: false,
  18. checkData: {},
  19. merchant: {},
  20. info: {},
  21. show: 0,
  22. checkhead:true,
  23. wxlogincode:'',
  24. bindTelfirst:0
  25. },
  26. onLoad: function () {
  27. //// console.log(options)
  28. // url = 0
  29. // if (options.scene) {
  30. // scene = decodeURIComponent(options.scene)
  31. // if (scene.indexOf('invite_wx_') > -1) {
  32. // invite = scene.slice(10)
  33. // } else if (scene.indexOf('poster') > -1) {
  34. // this.getPoster(scene)
  35. // } else if (scene.indexOf('project') > -1) {
  36. // this.getPosterProject(scene)
  37. // } else {
  38. // this.getScene(scene)
  39. // }
  40. // } else if (options.url) {
  41. // this.urlHandle(options)
  42. // }
  43. // if (options.invite) {
  44. // invite = options.invite
  45. // }
  46. // var that = this
  47. this.checkLogin();
  48. this.info();
  49. },
  50. onShow: function () {
  51. var that = this;
  52. // that.checkLogin();
  53. this.info();
  54. that.getBalanceInfo()
  55. // that.getIntegralInfo()
  56. // if (this.data.bindTel) {
  57. // this.getBalanceInfo()
  58. // this.getIntegralInfo()
  59. // if (that.data.checkData.merchant_id > 0) {
  60. // that.getmerchant()
  61. // }
  62. // } else {
  63. // // this.check()
  64. // // this.info()
  65. // }
  66. //原登陆检测
  67. },
  68. checkLogin:function(){
  69. var that = this;
  70. //2020登陆检测
  71. wx.login({
  72. success: res => {
  73. getApp().globalData.try_login = true;
  74. console.log('checkLogin',res.code)
  75. var url = 'xcx/login';
  76. invite = wx.getStorageSync('invite');
  77. var params = {
  78. code: res.code,
  79. invite_id: invite//新token模式
  80. }
  81. that.setData({
  82. wxlogincode: res.code
  83. })
  84. var success = function (res) {
  85. console.log('pageLogin',res);
  86. wx.setStorageSync('lbt_session_key', res.data.session_key)
  87. wx.setStorageSync('lbt_session_time', Date.now())
  88. wx.setStorageSync('lbt_token_key', res.data.token)
  89. console.log('nowtoken',res.data.token);
  90. if(res.data.wx_user && res.data.wx_user.head != ''){
  91. var userInfo = res.data.wx_user;
  92. that.setData({
  93. userInfo: userInfo
  94. })
  95. that.info()
  96. that.getBalanceInfo()
  97. // that.getIntegralInfo()
  98. // if (that.data.checkData.merchant_id > 0) {
  99. // that.getmerchant()
  100. // }
  101. //checkwxhead---start
  102. // console.log('that.data.checkhead',that.data.checkhead);
  103. if(res.data.wx_user.head == '' ){
  104. that.setData({
  105. checkhead: false
  106. })
  107. wx.getSetting({
  108. success: res => {
  109. var auth = res.authSetting
  110. if (auth['scope.userInfo']) {
  111. console.log('wxhead none')
  112. // wx.getUserInfo({
  113. // success: function(res3) {
  114. // console.log('userinfo',res3)
  115. // var url = 'xcx/save_wx_user/info'
  116. // var params = {
  117. // userinfo: JSON.stringify(res3)
  118. // }
  119. // var success = function (res4) {
  120. // console.log('authorize',res4)
  121. // that.onShow()
  122. // }
  123. // _request.$post(url, params, success)
  124. // }
  125. // })
  126. //新授权
  127. wx.getUserProfile({
  128. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  129. success: function(res3) {
  130. console.log('userinfo',res3)
  131. var url = 'xcx/save_wx_user/info'
  132. var params = {
  133. userinfo: JSON.stringify(res3.userInfo)
  134. }
  135. var success = function (res4) {
  136. console.log('authorize',res4);
  137. that.onLoad()
  138. }
  139. _request.$post(url, params, success)
  140. }
  141. })
  142. }else{
  143. that.setData({
  144. userInfo: 'nologin'
  145. })
  146. }
  147. }
  148. })
  149. }
  150. //checkwxhead---end
  151. }else{
  152. that.setData({
  153. userInfo: 'nologin'
  154. })
  155. }
  156. }
  157. _request.$get(url, params, success)
  158. }
  159. })
  160. },
  161. getPoster: function (val) {
  162. poster = val.split('$')
  163. if (poster.length > 0) {
  164. invite = poster[2]
  165. }
  166. },
  167. getPosterProject: function (val) {
  168. project = val.split('$')
  169. if (project.length > 0) {
  170. invite = project[2]
  171. }
  172. },
  173. urlHandle: function (val) {
  174. if (val.url) {
  175. url = val.url + '?'
  176. for (var i in val) {
  177. if (i !== 'url') {
  178. url += i + '=' + val[i] + '&'
  179. }
  180. }
  181. }
  182. },
  183. getScene: function () {
  184. var that = this
  185. var url = 'v1/xcx/channel/info/' + scene
  186. var params = {}
  187. var success = function (res) {
  188. channel = res.data
  189. }
  190. _request.$get(url, params, success)
  191. },
  192. getUserInfo: function (val) {
  193. var channel_id = 0;
  194. invite = wx.getStorageSync('invite');
  195. if (channel && Number(channel.parent_id) > 0) {
  196. channel_id = Number(channel.parent_id)
  197. }
  198. var that = this
  199. if (val.detail.errMsg === 'getUserInfo:ok') {
  200. wx.showLoading({
  201. title: '加载中'
  202. })
  203. console.log('val',val)
  204. // _request.sendInfo(val, channel_id, invite, that)
  205. that.onLoad();
  206. // wx.showToast({
  207. // title: '请绑定手机号~',
  208. // icon: 'none',
  209. // duration: 2000
  210. // })
  211. // wx.navigateTo({
  212. // url: '/packageUser/pages/user/bind/bind'
  213. // })
  214. }
  215. },
  216. getUserProfile:function(){
  217. console.log('tap')
  218. var that = this
  219. // wx.getUserProfile({
  220. // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  221. // success: (res) => {
  222. // this.setData({
  223. // userInfo: res.userInfo,
  224. // hasUserInfo: true
  225. // })
  226. // var channel_id = 0;
  227. // invite = wx.getStorageSync('invite');
  228. // if (channel && Number(channel.parent_id) > 0) {
  229. // channel_id = Number(channel.parent_id)
  230. // }
  231. // var that = this
  232. // console.log('res',res);
  233. // if (res.errMsg === "getUserProfile:ok") {
  234. // wx.showLoading({
  235. // title: '加载中'
  236. // })
  237. // res['wxlogincode'] = that.data.wxlogincode;
  238. // _request.sendInfo(res, channel_id, invite, that)
  239. // that.onShow();
  240. // }
  241. // }
  242. // })
  243. wx.getUserProfile({
  244. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  245. success: function(res3) {
  246. console.log('userinfo',res3)
  247. var url = 'xcx/save_wx_user/info'
  248. var params = {
  249. userinfo: JSON.stringify(res3.userInfo)
  250. }
  251. var success = function (res4) {
  252. console.log('authorize',res4)
  253. that.onLoad()
  254. }
  255. _request.$post(url, params, success)
  256. }
  257. })
  258. },
  259. getVersion: function (val) {
  260. // this.check()
  261. },
  262. info(){
  263. console.log('oninfo');
  264. var that = this
  265. var url = 'v1/user/info'
  266. var params = {}
  267. var success = function (res) {
  268. console.log(res)
  269. that.setData({
  270. info: res.data,
  271. show: res.data.wx_user?res.data.wx_user.show_invite_mode:'',
  272. bindTel: res.data.user.tel ? true : false
  273. })
  274. console.log('untel',res.data.user.tel)
  275. console.log('res.data.wx_user',res.data.wx_user)
  276. if(res.data.wx_user.head == ''){
  277. console.log('indddddddddddddddddddddddd')
  278. that.setData({
  279. userInfo: 'nologin'
  280. })
  281. }
  282. if(that.data.userInfo != 'nologin' && res.data.user.tel == '' && that.data.bindTelfirst == 0){
  283. that.setData({
  284. bindTelfirst:1
  285. })
  286. wx.navigateTo({
  287. url: '/packageUser/pages/user/bind/bind'
  288. })
  289. wx.showToast({
  290. title: '请先绑定手机号~',
  291. icon: 'none',
  292. duration: 2000
  293. })
  294. }
  295. }
  296. _request.$get(url, params, success)
  297. },
  298. check () {
  299. var that = this
  300. var url = 'v1/user/check'
  301. var params = {
  302. cache: false
  303. }
  304. var success = function (res) {
  305. if (res.data.wx_user_id <= 0) {
  306. wx.login({
  307. success: res => {
  308. _request.login(res)
  309. }
  310. })
  311. } else {
  312. that.setData({
  313. checkData: res.data
  314. })
  315. if (that.data.checkData.merchant_id > 0) {
  316. that.getmerchant()
  317. }
  318. if (res.data.user_id > 0 && !that.data.bindTel) {
  319. // that.setData({
  320. // bindTel: true
  321. // })
  322. that.getBalanceInfo()
  323. // that.getIntegralInfo()
  324. that.info()
  325. }
  326. }
  327. }
  328. _request.$get(url, params, success)
  329. },
  330. buyVoucher(){
  331. if(this.data.info.user.tel == ''){//未绑定手机号
  332. wx.navigateTo({
  333. url: '/packageUser/pages/user/bind/bind'
  334. })
  335. wx.showToast({
  336. title: '请先绑定手机号~',
  337. icon: 'none',
  338. duration: 2000
  339. })
  340. //2020
  341. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/buy/buy'); //存入手机绑定后跳转页面
  342. }else{
  343. wx.navigateTo({
  344. url: '/packageUser/pages/user/buy/buy'
  345. })
  346. }
  347. },
  348. getmerchant () {
  349. var that = this
  350. var url = 'v1/merchant/orders/count'
  351. var params = {
  352. merchant_id: that.data.checkData.merchant_id
  353. }
  354. var success = function (res) {
  355. var result = res.data
  356. that.setData({
  357. merchant: result
  358. })
  359. console.log(that.data.merchant)
  360. }
  361. _request.$get(url, params, success)
  362. },
  363. getBalanceInfo () {
  364. var that = this
  365. var url = 'v1/user/balance/info'
  366. var params = {
  367. }
  368. var success = function (res) {
  369. var result = res.data.total
  370. that.setData({
  371. balance: result,
  372. silver: res.data.silver_total
  373. })
  374. }
  375. _request.$get(url, params, success)
  376. },
  377. getSilverInfo () {
  378. var that = this
  379. var url = 'v1/user/cent/info'
  380. var params = {
  381. }
  382. var success = function (res) {
  383. var result = res.data.total
  384. that.setData({
  385. integral: result
  386. })
  387. }
  388. _request.$get(url, params, success)
  389. },
  390. toInviteList () {
  391. var that = this;
  392. if(that.data.info.user.tel == ''){
  393. wx.navigateTo({
  394. url: '/packageUser/pages/user/bind/bind'
  395. })
  396. wx.showToast({
  397. title: '请先绑定手机号~',
  398. icon: 'none',
  399. duration: 2000
  400. })
  401. }else{
  402. wx.navigateTo({
  403. url: '/packageUser/pages/user/invite/invite'
  404. })
  405. }
  406. },
  407. // checkbindtel(){
  408. // var that = this;
  409. // if(that.data.info.user.tel == ''){
  410. // setTimeout(function(){
  411. // wx.navigateTo({
  412. // url: '/packageUser/pages/user/bind/bind'
  413. // })
  414. // wx.showToast({
  415. // title: '请先绑定手机号~',
  416. // icon: 'none',
  417. // duration: 2000
  418. // })
  419. // },500)
  420. // }
  421. // },
  422. toCashList () {
  423. if(this.data.info.user.tel == ''){//未绑定手机号
  424. wx.navigateTo({
  425. url: '/packageUser/pages/user/bind/bind'
  426. })
  427. wx.showToast({
  428. title: '请先绑定手机号~',
  429. icon: 'none',
  430. duration: 2000
  431. })
  432. //2020
  433. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/fund/fund'); //存入手机绑定后跳转页面
  434. }else{
  435. wx.navigateTo({
  436. url: '/packageUser/pages/user/fund/fund'
  437. })
  438. }
  439. },
  440. toUserInfo() {
  441. wx.navigateTo({
  442. url: '/packageUser/pages/user/userInfo/userInfo'
  443. })
  444. },
  445. toBindOldSys () {
  446. let that = this;
  447. wx.navigateTo({
  448. url: '/packageUser/pages/user/bindoldsys/bindoldsys?id='+that.data.userInfo.id
  449. })
  450. },
  451. toPromotion () {
  452. wx.navigateTo({
  453. url: '/packageUser/pages/user/promotion/promotion'
  454. })
  455. },
  456. toIdentity () {
  457. wx.navigateTo({
  458. url: '/packageUser/pages/user/identity/identity'
  459. })
  460. },
  461. toBankInfo () {
  462. wx.navigateTo({
  463. url: '/packageUser/pages/user/bankinfo/bankinfo'
  464. })
  465. },
  466. toAddressList () {
  467. wx.navigateTo({
  468. url: '/packageUser/pages/user/address/address'
  469. })
  470. },
  471. toRadish () {
  472. wx.navigateTo({
  473. url: '/packageUser/pages/user/radish/radish'
  474. })
  475. },
  476. toIntegral () {
  477. wx.navigateTo({
  478. url: '/packageUser/pages/user/integral/integral'
  479. })
  480. },
  481. toSilver () {
  482. wx.navigateTo({
  483. url: '/packageUser/pages/user/silver/silver'
  484. })
  485. },
  486. toSafe () {
  487. wx.navigateTo({
  488. url: '/packageUser/pages/user/safe/safe'
  489. })
  490. },
  491. toCustom () {
  492. wx.reLaunch({
  493. url: '/pages/customservice/customservice'
  494. })
  495. },
  496. toProxy () {
  497. wx.navigateTo({
  498. url: '/packageUser/pages/user/proxyList/proxyList'
  499. })
  500. },
  501. toApplyLeader () {
  502. wx.navigateTo({
  503. url: '/packageUser/pages/user/applyLeader/applyLeader'
  504. })
  505. },
  506. toAreaCart () {
  507. wx.navigateTo({
  508. url: '/pages/areacart/areacart'
  509. })
  510. },
  511. toBindTel () {
  512. wx.navigateTo({
  513. url: '/packageUser/pages/user/bind/bind'
  514. })
  515. },
  516. toAbout () {
  517. var host = getApp().globalData.d5c
  518. if (host === 'tm.d5ct.com') {
  519. wx.navigateTo({
  520. url: '/pages/parse/parse?id=2'
  521. })
  522. } else if (host === 'm.d5ct.com') {
  523. wx.navigateTo({
  524. url: '/pages/parse/parse?id=1'
  525. })
  526. }
  527. },
  528. toMerchant () {
  529. wx.navigateTo({
  530. url: '/packageMerchant/pages/merchant/orders/orders?id=' + this.data.checkData.merchant_id + '&is_super_admin=' + this.data.checkData.is_super_admin
  531. })
  532. },
  533. toMerchant1 () {
  534. wx.navigateTo({
  535. url: '/packageMerchant/pages/merchant/accounts/accounts?id=' + this.data.checkData.merchant_id
  536. })
  537. },
  538. onShareAppMessage: function (val) {
  539. return _request.share({
  540. sc: 'xcx_user'
  541. })
  542. }
  543. })