all.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. })
  240. }
  241. _request.$get(url, params, success)
  242. },
  243. check () {
  244. var that = this
  245. var url = 'v1/user/check'
  246. var params = {
  247. cache: false
  248. }
  249. var success = function (res) {
  250. if (res.data.wx_user_id <= 0) {
  251. wx.login({
  252. success: res => {
  253. _request.login(res)
  254. }
  255. })
  256. } else {
  257. that.setData({
  258. checkData: res.data
  259. })
  260. if (that.data.checkData.merchant_id > 0) {
  261. that.getmerchant()
  262. }
  263. if (res.data.user_id > 0 && !that.data.bindTel) {
  264. that.setData({
  265. bindTel: true
  266. })
  267. that.getBalanceInfo()
  268. that.getIntegralInfo()
  269. that.info()
  270. }
  271. }
  272. }
  273. _request.$get(url, params, success)
  274. },
  275. buyVoucher(){
  276. if(this.data.info.user.tel == ''){//未绑定手机号
  277. wx.navigateTo({
  278. url: '/packageUser/pages/user/bind/bind'
  279. })
  280. wx.showToast({
  281. title: '请先绑定手机号~',
  282. icon: 'none',
  283. duration: 2000
  284. })
  285. //2020
  286. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/buy/buy'); //存入手机绑定后跳转页面
  287. }else{
  288. wx.navigateTo({
  289. url: '/packageUser/pages/user/buy/buy'
  290. })
  291. }
  292. },
  293. getmerchant () {
  294. var that = this
  295. var url = 'v1/merchant/orders/count'
  296. var params = {
  297. merchant_id: that.data.checkData.merchant_id
  298. }
  299. var success = function (res) {
  300. var result = res.data
  301. that.setData({
  302. merchant: result
  303. })
  304. console.log(that.data.merchant)
  305. }
  306. _request.$get(url, params, success)
  307. },
  308. getBalanceInfo () {
  309. var that = this
  310. var url = 'v1/user/balance/info'
  311. var params = {
  312. }
  313. var success = function (res) {
  314. var result = res.data.total
  315. that.setData({
  316. balance: result
  317. })
  318. }
  319. _request.$get(url, params, success)
  320. },
  321. getIntegralInfo () {
  322. var that = this
  323. var url = 'v1/user/cent/info'
  324. var params = {
  325. }
  326. var success = function (res) {
  327. var result = res.data.total
  328. that.setData({
  329. integral: result
  330. })
  331. }
  332. _request.$get(url, params, success)
  333. },
  334. toInviteList () {
  335. wx.navigateTo({
  336. url: '/packageUser/pages/user/invite/invite'
  337. })
  338. },
  339. toCashList () {
  340. if(this.data.info.user.tel == ''){//未绑定手机号
  341. wx.navigateTo({
  342. url: '/packageUser/pages/user/bind/bind'
  343. })
  344. wx.showToast({
  345. title: '请先绑定手机号~',
  346. icon: 'none',
  347. duration: 2000
  348. })
  349. //2020
  350. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/fund/fund'); //存入手机绑定后跳转页面
  351. }else{
  352. wx.navigateTo({
  353. url: '/packageUser/pages/user/fund/fund'
  354. })
  355. }
  356. },
  357. toBindOldSys () {
  358. let that = this;
  359. wx.navigateTo({
  360. url: '/packageUser/pages/user/bindoldsys/bindoldsys?id='+that.data.userInfo.id
  361. })
  362. },
  363. toIdentity () {
  364. wx.navigateTo({
  365. url: '/packageUser/pages/user/identity/identity'
  366. })
  367. },
  368. toBankInfo () {
  369. wx.navigateTo({
  370. url: '/packageUser/pages/user/bankinfo/bankinfo'
  371. })
  372. },
  373. toAddressList () {
  374. wx.navigateTo({
  375. url: '/packageUser/pages/user/address/address'
  376. })
  377. },
  378. toRadish () {
  379. wx.navigateTo({
  380. url: '/packageUser/pages/user/radish/radish'
  381. })
  382. },
  383. toIntegral () {
  384. wx.navigateTo({
  385. url: '/packageUser/pages/user/integral/integral'
  386. })
  387. },
  388. toSafe () {
  389. wx.navigateTo({
  390. url: '/packageUser/pages/user/safe/safe'
  391. })
  392. },
  393. toCustom () {
  394. wx.reLaunch({
  395. url: '/pages/customservice/customservice'
  396. })
  397. },
  398. toProxy () {
  399. wx.navigateTo({
  400. url: '/packageUser/pages/user/proxyList/proxyList'
  401. })
  402. },
  403. toApplyLeader () {
  404. wx.navigateTo({
  405. url: '/packageUser/pages/user/applyLeader/applyLeader'
  406. })
  407. },
  408. toAreaCart () {
  409. wx.navigateTo({
  410. url: '/pages/areacart/areacart'
  411. })
  412. },
  413. toBindTel () {
  414. wx.navigateTo({
  415. url: '/packageUser/pages/user/bind/bind'
  416. })
  417. },
  418. toAbout () {
  419. var host = getApp().globalData.d5c
  420. if (host === 'tm.d5ct.com') {
  421. wx.navigateTo({
  422. url: '/pages/parse/parse?id=2'
  423. })
  424. } else if (host === 'm.d5ct.com') {
  425. wx.navigateTo({
  426. url: '/pages/parse/parse?id=1'
  427. })
  428. }
  429. },
  430. toMerchant () {
  431. wx.navigateTo({
  432. url: '/packageMerchant/pages/merchant/orders/orders?id=' + this.data.checkData.merchant_id + '&is_super_admin=' + this.data.checkData.is_super_admin
  433. })
  434. },
  435. toMerchant1 () {
  436. wx.navigateTo({
  437. url: '/packageMerchant/pages/merchant/accounts/accounts?id=' + this.data.checkData.merchant_id
  438. })
  439. },
  440. onShareAppMessage: function (val) {
  441. return _request.share({
  442. sc: 'xcx_user'
  443. })
  444. }
  445. })