智慧申请系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
4.5 KiB

  1. /*
  2. * @Description:
  3. * @Author:
  4. * @Date: 2021-10-17 11:49:57
  5. * @LastEditors:
  6. * @LastEditTime: 2022-03-20 17:58:20
  7. */
  8. const app = getApp(),
  9. gData = app.globalData;
  10. Page({
  11. data: {
  12. motto: 'Hello World',
  13. userInfo: {},
  14. hasUserInfo: false,
  15. canIUse: wx.canIUse('button.open-type.getUserInfo'),
  16. menus: [
  17. [
  18. {img:'/images/icon14.png',name:'智慧验证',type:'familys',loginType:'104'},
  19. ]
  20. ],
  21. canIUseGetUserProfile: false
  22. },
  23. //事件处理函数
  24. bindViewTap: function() {
  25. wx.navigateTo({
  26. url: '../logs/logs'
  27. })
  28. },
  29. onLoad: function () {
  30. if (wx.getUserProfile) {
  31. this.setData({
  32. canIUseGetUserProfile: true
  33. })
  34. }
  35. wx.login({
  36. success: (res)=> {
  37. this.setData({
  38. wxCode: res.code
  39. })
  40. }
  41. })
  42. if (app.globalData.userInfo) {
  43. this.setData({
  44. userInfo: app.globalData.userInfo,
  45. hasUserInfo: true
  46. })
  47. } else if (this.data.canIUse){
  48. // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
  49. // 所以此处加入 callback 以防止这种情况
  50. app.userInfoReadyCallback = res => {
  51. this.setData({
  52. userInfo: res.userInfo,
  53. hasUserInfo: true
  54. })
  55. }
  56. } else {
  57. // 在没有 open-type=getUserInfo 版本的兼容处理
  58. wx.getUserInfo({
  59. success: res => {
  60. app.globalData.userInfo = res.userInfo
  61. this.setData({
  62. userInfo: res.userInfo,
  63. hasUserInfo: true
  64. })
  65. }
  66. })
  67. }
  68. },
  69. getUserInfo: function(e) {
  70. console.log(e)
  71. app.globalData.userInfo = e.detail.userInfo
  72. this.setData({
  73. userInfo: e.detail.userInfo,
  74. hasUserInfo: true
  75. })
  76. },
  77. getUserProfile: (e)=>{
  78. wx.getUserProfile({
  79. desc: '用于完善会员资料',
  80. success: (res) => {
  81. const nickname = res.userInfo.nickName;
  82. var apiType = e.currentTarget.dataset.item;
  83. if(apiType === 'family' || apiType === 'elder' || apiType === 'help' || apiType === 'familys') {
  84. wx.login({
  85. success: (res)=> {
  86. app.ajax(`jjSubsidyApply/client/user/login/${res.code}`, 'post', {name: nickname}, null, (res)=> {
  87. gData.token = res.token;
  88. let urls = {
  89. 'family': '/pages/family/index/index',
  90. 'familys': '/pages/familys/community/community',
  91. };
  92. apiType.indexOf('family') > -1 ? app.justpage(urls[apiType]) : app.justpage(`/pages/${apiType}/advanced/advanced`);
  93. }, (err)=> {
  94. app.tips(err)
  95. })
  96. },
  97. fail: (err)=> {
  98. console.log(err)
  99. app.tips(err)
  100. }
  101. })
  102. return;
  103. }
  104. if(apiType === 'familys') {
  105. app.justpage("/pages/familys/community/community")
  106. }
  107. if(apiType === 'signture') {
  108. app.justpage("/pages/signature/signature");
  109. return;
  110. }
  111. if (apiType) {
  112. app.globalData.apiType = apiType;
  113. app.globalData.loginType = e.currentTarget.dataset.logintype;
  114. app.justpage("../login/login");
  115. } else {
  116. app.tips("该功能暂未开放");
  117. }
  118. }
  119. })
  120. },
  121. goto:function(e){
  122. var apiType = e.currentTarget.dataset.item;
  123. if(apiType === 'family' || apiType === 'elder' || apiType === 'help' || apiType === 'familys') {
  124. wx.login({
  125. success: (res)=> {
  126. app.ajax(`jjSubsidyApply/client/user/login/${res.code}`, 'get', {}, null, (res)=> {
  127. gData.token = res.token;
  128. let urls = {
  129. 'family': '/pages/family/index/index',
  130. 'familys': '/pages/familys/community/community',
  131. };
  132. apiType.indexOf('family') > -1 ? app.justpage(urls[apiType]) : app.justpage(`/pages/${apiType}/advanced/advanced`);
  133. }, (err)=> {
  134. app.tips(err)
  135. })
  136. },
  137. fail: (err)=> {
  138. console.log(err)
  139. app.tips(err)
  140. }
  141. })
  142. return;
  143. }
  144. if(apiType === 'familys') {
  145. app.justpage("/pages/familys/community/community")
  146. }
  147. if(apiType === 'signture') {
  148. app.justpage("/pages/signature/signature");
  149. return;
  150. }
  151. if (apiType) {
  152. app.globalData.apiType = apiType;
  153. app.globalData.loginType = e.currentTarget.dataset.logintype;
  154. app.justpage("../login/login");
  155. } else {
  156. app.tips("该功能暂未开放");
  157. }
  158. },
  159. /**
  160. * 用户点击右上角分享
  161. */
  162. onShareAppMessage: function () {
  163. },
  164. })