all.js 11 KB

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