all.js 8.9 KB

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