all.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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. }else{
  105. that.setData({
  106. userInfo: 'nologin'
  107. })
  108. }
  109. }
  110. })
  111. }
  112. //checkwxhead---end
  113. }else{
  114. that.setData({
  115. userInfo: 'nologin'
  116. })
  117. }
  118. }
  119. _request.$get(url, params, success)
  120. }
  121. })
  122. },
  123. getPoster: function (val) {
  124. poster = val.split('$')
  125. if (poster.length > 0) {
  126. invite = poster[2]
  127. }
  128. },
  129. getPosterProject: function (val) {
  130. project = val.split('$')
  131. if (project.length > 0) {
  132. invite = project[2]
  133. }
  134. },
  135. urlHandle: function (val) {
  136. if (val.url) {
  137. url = val.url + '?'
  138. for (var i in val) {
  139. if (i !== 'url') {
  140. url += i + '=' + val[i] + '&'
  141. }
  142. }
  143. }
  144. },
  145. getScene: function () {
  146. var that = this
  147. var url = 'v1/xcx/channel/info/' + scene
  148. var params = {}
  149. var success = function (res) {
  150. channel = res.data
  151. }
  152. _request.$get(url, params, success)
  153. },
  154. getUserInfo: function (val) {
  155. var channel_id = 0;
  156. invite = wx.getStorageSync('invite');
  157. if (channel && Number(channel.parent_id) > 0) {
  158. channel_id = Number(channel.parent_id)
  159. }
  160. var that = this
  161. if (val.detail.errMsg === 'getUserInfo:ok') {
  162. wx.showLoading({
  163. title: '加载中'
  164. })
  165. _request.sendInfo(val, channel_id, invite, that)
  166. that.onShow();
  167. // wx.showToast({
  168. // title: '请绑定手机号~',
  169. // icon: 'none',
  170. // duration: 2000
  171. // })
  172. // wx.navigateTo({
  173. // url: '/packageUser/pages/user/bind/bind'
  174. // })
  175. }
  176. },
  177. getVersion: function (val) {
  178. this.check()
  179. },
  180. info(){
  181. var that = this
  182. var url = 'v1/user/info'
  183. var params = {}
  184. var success = function (res) {
  185. console.log(res)
  186. that.setData({
  187. info: res.data,
  188. show: res.data.wx_user.show_invite_mode
  189. })
  190. }
  191. _request.$get(url, params, success)
  192. },
  193. check () {
  194. var that = this
  195. var url = 'v1/user/check'
  196. var params = {
  197. cache: false
  198. }
  199. var success = function (res) {
  200. if (res.data.wx_user_id <= 0) {
  201. wx.login({
  202. success: res => {
  203. _request.login(res)
  204. }
  205. })
  206. } else {
  207. that.setData({
  208. checkData: res.data
  209. })
  210. if (that.data.checkData.merchant_id > 0) {
  211. that.getmerchant()
  212. }
  213. if (res.data.user_id > 0 && !that.data.bindTel) {
  214. that.setData({
  215. bindTel: true
  216. })
  217. that.getBalanceInfo()
  218. that.getIntegralInfo()
  219. that.info()
  220. }
  221. }
  222. }
  223. _request.$get(url, params, success)
  224. },
  225. buyVoucher(){
  226. if(this.data.info.user.tel == ''){//未绑定手机号
  227. wx.navigateTo({
  228. url: '/packageUser/pages/user/bind/bind'
  229. })
  230. wx.showToast({
  231. title: '请先绑定手机号~',
  232. icon: 'none',
  233. duration: 2000
  234. })
  235. //2020
  236. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/buy/buy'); //存入手机绑定后跳转页面
  237. }else{
  238. wx.navigateTo({
  239. url: '/packageUser/pages/user/buy/buy'
  240. })
  241. }
  242. },
  243. getmerchant () {
  244. var that = this
  245. var url = 'v1/merchant/orders/count'
  246. var params = {
  247. merchant_id: that.data.checkData.merchant_id
  248. }
  249. var success = function (res) {
  250. var result = res.data
  251. that.setData({
  252. merchant: result
  253. })
  254. console.log(that.data.merchant)
  255. }
  256. _request.$get(url, params, success)
  257. },
  258. getBalanceInfo () {
  259. var that = this
  260. var url = 'v1/user/balance/info'
  261. var params = {
  262. }
  263. var success = function (res) {
  264. var result = res.data.total
  265. that.setData({
  266. balance: result
  267. })
  268. }
  269. _request.$get(url, params, success)
  270. },
  271. getIntegralInfo () {
  272. var that = this
  273. var url = 'v1/user/cent/info'
  274. var params = {
  275. }
  276. var success = function (res) {
  277. var result = res.data.total
  278. that.setData({
  279. integral: result
  280. })
  281. }
  282. _request.$get(url, params, success)
  283. },
  284. toInviteList () {
  285. wx.navigateTo({
  286. url: '/packageUser/pages/user/invite/invite'
  287. })
  288. },
  289. toCashList () {
  290. if(this.data.info.user.tel == ''){//未绑定手机号
  291. wx.navigateTo({
  292. url: '/packageUser/pages/user/bind/bind'
  293. })
  294. wx.showToast({
  295. title: '请先绑定手机号~',
  296. icon: 'none',
  297. duration: 2000
  298. })
  299. //2020
  300. wx.setStorageSync('bindbackurl', '/packageUser/pages/user/fund/fund'); //存入手机绑定后跳转页面
  301. }else{
  302. wx.navigateTo({
  303. url: '/packageUser/pages/user/fund/fund'
  304. })
  305. }
  306. },
  307. toBindOldSys () {
  308. let that = this;
  309. wx.navigateTo({
  310. url: '/packageUser/pages/user/bindoldsys/bindoldsys?id='+that.data.userInfo.id
  311. })
  312. },
  313. toIdentity () {
  314. wx.navigateTo({
  315. url: '/packageUser/pages/user/identity/identity'
  316. })
  317. },
  318. toBankInfo () {
  319. wx.navigateTo({
  320. url: '/packageUser/pages/user/bankinfo/bankinfo'
  321. })
  322. },
  323. toAddressList () {
  324. wx.navigateTo({
  325. url: '/packageUser/pages/user/address/address'
  326. })
  327. },
  328. toRadish () {
  329. wx.navigateTo({
  330. url: '/packageUser/pages/user/radish/radish'
  331. })
  332. },
  333. toIntegral () {
  334. wx.navigateTo({
  335. url: '/packageUser/pages/user/integral/integral'
  336. })
  337. },
  338. toSafe () {
  339. wx.navigateTo({
  340. url: '/packageUser/pages/user/safe/safe'
  341. })
  342. },
  343. toCustom () {
  344. wx.reLaunch({
  345. url: '/pages/customservice/customservice'
  346. })
  347. },
  348. toApplyLeader () {
  349. wx.navigateTo({
  350. url: '/packageUser/pages/user/applyLeader/applyLeader'
  351. })
  352. },
  353. toAreaCart () {
  354. wx.navigateTo({
  355. url: '/pages/areacart/areacart'
  356. })
  357. },
  358. toBindTel () {
  359. wx.navigateTo({
  360. url: '/packageUser/pages/user/bind/bind'
  361. })
  362. },
  363. toAbout () {
  364. var host = getApp().globalData.d5c
  365. if (host === 'tm.d5ct.com') {
  366. wx.navigateTo({
  367. url: '/pages/parse/parse?id=2'
  368. })
  369. } else if (host === 'm.d5ct.com') {
  370. wx.navigateTo({
  371. url: '/pages/parse/parse?id=1'
  372. })
  373. }
  374. },
  375. toMerchant () {
  376. wx.navigateTo({
  377. url: '/packageMerchant/pages/merchant/orders/orders?id=' + this.data.checkData.merchant_id + '&is_super_admin=' + this.data.checkData.is_super_admin
  378. })
  379. },
  380. toMerchant1 () {
  381. wx.navigateTo({
  382. url: '/packageMerchant/pages/merchant/accounts/accounts?id=' + this.data.checkData.merchant_id
  383. })
  384. },
  385. onShareAppMessage: function (val) {
  386. return _request.share({
  387. sc: 'xcx_user'
  388. })
  389. }
  390. })