all.js 9.2 KB

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