all.js 11 KB

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