all.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. if (this.data.bindTel) {
  46. this.getBalanceInfo()
  47. if (that.data.checkData.merchant_id > 0) {
  48. that.getmerchant()
  49. }
  50. } else {
  51. this.check()
  52. // this.info()
  53. }
  54. //2020登陆检测
  55. wx.login({
  56. success: res => {
  57. getApp().globalData.try_login = true;
  58. var url = 'xcx/login'
  59. var params = {
  60. code: res.code
  61. }
  62. var success = function (res) {
  63. console.log('pageLogin',res);
  64. if(res.data.wx_user){
  65. var userInfo = res.data.wx_user
  66. that.setData({
  67. userInfo: userInfo
  68. })
  69. }else{
  70. that.setData({
  71. userInfo: 'nologin'
  72. })
  73. }
  74. }
  75. _request.$get(url, params, success)
  76. }
  77. })
  78. //原登陆检测
  79. // wx.getSetting({
  80. // success: res => {
  81. // var auth = res.authSetting
  82. // if (auth['scope.userInfo']) {
  83. // wx.getUserInfo({
  84. // success: function (res) {
  85. // var userInfo = res.userInfo
  86. // that.setData({
  87. // userInfo: userInfo
  88. // })
  89. // }
  90. // })
  91. // }else{
  92. // that.setData({
  93. // userInfo: 'nologin'
  94. // })
  95. // }
  96. // }
  97. // })
  98. },
  99. getPoster: function (val) {
  100. poster = val.split('$')
  101. if (poster.length > 0) {
  102. invite = poster[2]
  103. }
  104. },
  105. getPosterProject: function (val) {
  106. project = val.split('$')
  107. if (project.length > 0) {
  108. invite = project[2]
  109. }
  110. },
  111. urlHandle: function (val) {
  112. if (val.url) {
  113. url = val.url + '?'
  114. for (var i in val) {
  115. if (i !== 'url') {
  116. url += i + '=' + val[i] + '&'
  117. }
  118. }
  119. }
  120. },
  121. getScene: function () {
  122. var that = this
  123. var url = 'v1/xcx/channel/info/' + scene
  124. var params = {}
  125. var success = function (res) {
  126. channel = res.data
  127. }
  128. _request.$get(url, params, success)
  129. },
  130. getUserInfo: function (val) {
  131. var channel_id = 0;
  132. invite = wx.getStorageSync('invite');
  133. if (channel && Number(channel.parent_id) > 0) {
  134. channel_id = Number(channel.parent_id)
  135. }
  136. var that = this
  137. if (val.detail.errMsg === 'getUserInfo:ok') {
  138. wx.showLoading({
  139. title: '加载中'
  140. })
  141. _request.sendInfo(val, channel_id, invite, that)
  142. that.onShow();
  143. // wx.showToast({
  144. // title: '请绑定手机号~',
  145. // icon: 'none',
  146. // duration: 2000
  147. // })
  148. // wx.navigateTo({
  149. // url: '/packageUser/pages/user/bind/bind'
  150. // })
  151. }
  152. },
  153. getVersion: function (val) {
  154. this.check()
  155. },
  156. info(){
  157. var that = this
  158. var url = 'v1/user/info'
  159. var params = {}
  160. var success = function (res) {
  161. console.log(res)
  162. that.setData({
  163. info: res.data,
  164. show: res.data.wx_user.show_invite_mode
  165. })
  166. }
  167. _request.$get(url, params, success)
  168. },
  169. check () {
  170. var that = this
  171. var url = 'v1/user/check'
  172. var params = {
  173. cache: false
  174. }
  175. var success = function (res) {
  176. if (res.data.wx_user_id <= 0) {
  177. wx.login({
  178. success: res => {
  179. _request.login(res)
  180. }
  181. })
  182. } else {
  183. that.setData({
  184. checkData: res.data
  185. })
  186. if (that.data.checkData.merchant_id > 0) {
  187. that.getmerchant()
  188. }
  189. if (res.data.user_id > 0 && !that.data.bindTel) {
  190. that.setData({
  191. bindTel: true
  192. })
  193. that.getBalanceInfo()
  194. that.info()
  195. }
  196. }
  197. }
  198. _request.$get(url, params, success)
  199. },
  200. getmerchant () {
  201. var that = this
  202. var url = 'v1/merchant/orders/count'
  203. var params = {
  204. merchant_id: that.data.checkData.merchant_id
  205. }
  206. var success = function (res) {
  207. var result = res.data
  208. that.setData({
  209. merchant: result
  210. })
  211. console.log(that.data.merchant)
  212. }
  213. _request.$get(url, params, success)
  214. },
  215. getBalanceInfo () {
  216. var that = this
  217. var url = 'v1/user/balance/info'
  218. var params = {
  219. }
  220. var success = function (res) {
  221. var result = res.data.total
  222. that.setData({
  223. balance: result
  224. })
  225. }
  226. _request.$get(url, params, success)
  227. },
  228. toInviteList () {
  229. wx.navigateTo({
  230. url: '/packageUser/pages/user/invite/invite'
  231. })
  232. },
  233. toCashList () {
  234. wx.navigateTo({
  235. url: '/packageUser/pages/user/fund/fund'
  236. })
  237. },
  238. toIdentity () {
  239. wx.navigateTo({
  240. url: '/packageUser/pages/user/identity/identity'
  241. })
  242. },
  243. toBankInfo () {
  244. wx.navigateTo({
  245. url: '/packageUser/pages/user/bankinfo/bankinfo'
  246. })
  247. },
  248. toAddressList () {
  249. wx.navigateTo({
  250. url: '/packageUser/pages/user/address/address'
  251. })
  252. },
  253. toRadish () {
  254. wx.navigateTo({
  255. url: '/packageUser/pages/user/radish/radish'
  256. })
  257. },
  258. toSafe () {
  259. wx.navigateTo({
  260. url: '/packageUser/pages/user/safe/safe'
  261. })
  262. },
  263. toCustom () {
  264. wx.reLaunch({
  265. url: '/pages/customservice/customservice'
  266. })
  267. },
  268. toBindTel () {
  269. wx.navigateTo({
  270. url: '/packageUser/pages/user/bind/bind'
  271. })
  272. },
  273. toAbout () {
  274. var host = getApp().globalData.d5c
  275. if (host === 'tm.d5ct.com') {
  276. wx.navigateTo({
  277. url: '/pages/parse/parse?id=2'
  278. })
  279. } else if (host === 'm.d5ct.com') {
  280. wx.navigateTo({
  281. url: '/pages/parse/parse?id=1'
  282. })
  283. }
  284. },
  285. toMerchant () {
  286. wx.navigateTo({
  287. url: '/packageMerchant/pages/merchant/orders/orders?id=' + this.data.checkData.merchant_id + '&is_super_admin=' + this.data.checkData.is_super_admin
  288. })
  289. },
  290. toMerchant1 () {
  291. wx.navigateTo({
  292. url: '/packageMerchant/pages/merchant/accounts/accounts?id=' + this.data.checkData.merchant_id
  293. })
  294. },
  295. onShareAppMessage: function (val) {
  296. return _request.share({
  297. sc: 'xcx_user'
  298. })
  299. }
  300. })