all.js 8.4 KB

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