baseUtils.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. var netUtil = require('network.js')
  2. var baseUrl = require('wxconstant.js').BaseUrl()
  3. //判断是否进行注册
  4. function judgeisReg(openid){
  5. var url = baseUrl + 'loan/enterprise/getEnterpriseDO'
  6. var data = {
  7. openid: openid
  8. }
  9. netUtil.requestLoading(url, data, '正在请求...', 'POST', function (res) {
  10. if (res.data.data) {
  11. var isFinancing = res.data.data.isFinancing
  12. var isRegistered = res.data.data.isRegistered
  13. if (isRegistered == false){
  14. wx.showModal({
  15. title: '提示',
  16. content: '您当前尚未进行注册认证,是否立即前去认证',
  17. success:function(res){
  18. console.log(res)
  19. if (res.confirm == true && res.cancel == false){
  20. wx.navigateTo({
  21. url: '../registered/registered',
  22. })
  23. }
  24. }
  25. })
  26. }
  27. try {
  28. wx.setStorageSync('isFinancing', isFinancing)
  29. wx.setStorageSync('isRegistered', isRegistered)
  30. } catch (e) {
  31. }
  32. }
  33. }, function (res) {
  34. wx.showToast({
  35. title: '数据获取失败',
  36. icon: 'none',
  37. duration: 2000
  38. })
  39. })
  40. }
  41. //公用获取openid方法
  42. function getComOpenid(){
  43. var openid
  44. wx.login({
  45. success: function (res) {
  46. var url = baseUrl + 'usr/getOpenid'
  47. if (res.code) {
  48. var data = {
  49. code: res.code
  50. }
  51. netUtil.requestLoading(url, data, '正在请求...', 'GET', function (res) {
  52. if (res.data) {
  53. if (res.data.data.openid) {
  54. wx.setStorageSync('openid', res.data.data.openid)
  55. openid = res.data.data.openid
  56. }
  57. }
  58. }, function (res) {
  59. wx.showToast({
  60. title: '数据获取失败',
  61. icon: 'none',
  62. duration: 2000
  63. })
  64. })
  65. }
  66. }
  67. })
  68. return openid
  69. }
  70. module.exports = {
  71. judgeisReg: judgeisReg,
  72. getComOpenid: getComOpenid
  73. }