index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. const request = require('../../utils/request.js');
  4. Page({
  5. data: {
  6. // 轮播
  7. backgrounds: [{
  8. "pic": "/images/banner1.png"
  9. },
  10. {
  11. "pic": "/images/banner2.png"
  12. },
  13. {
  14. "pic": "/images/banner3.png"
  15. },
  16. ],
  17. indicatorDots: true,
  18. vertical: false,
  19. autoplay: true,
  20. interval: 5000,
  21. duration: 500,
  22. number: {},
  23. msgList: []
  24. },
  25. goCollect() {
  26. wx.navigateTo({
  27. url: '/pages/userBook/userBook',
  28. })
  29. },
  30. goChildren() {
  31. if (!wx.getStorageSync('openId')) {
  32. wx.login({
  33. success: res => {
  34. console.log("用户的code:" + res.code);
  35. wx.request({
  36. url: app.globalData.publicUrl + '/wx/getAppletOpenId',
  37. method: "GET",
  38. data: {
  39. cid: 'applet',
  40. code: res.code
  41. },
  42. success: res => {
  43. wx.setStorageSync('openId', res.data.data.openid)
  44. this.isBInd();
  45. }
  46. });
  47. }
  48. });
  49. } else {
  50. this.isBInd();
  51. }
  52. },
  53. // 判断子女是否绑定老人
  54. isBInd() {
  55. let id = wx.getStorageSync('openId');
  56. request.request('/wxinfo/visitIsExist', {
  57. openId: id
  58. }, 'GET').then((res) => {
  59. console.log(res)
  60. if (res.data.code == 1) {
  61. wx.navigateTo({
  62. url: '/pages/visitFind/visitFind',
  63. })
  64. } else if (res.data.code == 0) {
  65. wx.navigateTo({
  66. url: '/pages/bindOld/bindOld',
  67. })
  68. } else {
  69. wx.showModal({
  70. showCancel: false,
  71. content: res.data.message,
  72. })
  73. }
  74. })
  75. },
  76. goTongzhi() {
  77. tools.rzStatus().then((res) => {
  78. if (res.data.code == 0) {
  79. if (res.data.data) {
  80. wx.navigateTo({
  81. url: '/pages/notice/notice',
  82. })
  83. }
  84. } else {
  85. wx.clearStorageSync();
  86. wx.showModal({
  87. showCancel: false,
  88. content: '当前您未登录,请登录',
  89. success(res) {
  90. if (res.confirm) {
  91. wx.redirectTo({
  92. url: '/pages/login/login',
  93. })
  94. }
  95. }
  96. })
  97. }
  98. })
  99. },
  100. goPaiming() {
  101. tools.rzStatus().then((res) => {
  102. if (res.data.code == 0) {
  103. if (res.data.data) {
  104. tools.finishInfo().then((res) => {
  105. console.log(res.data.data.perfect, '我完善信息了吗 1代表完后 0代表未完成')
  106. console.log(res.data.data.comparison, '我人脸识别过了吗 1代表完后 0代表未完成')
  107. if (res.data.data.perfect == '0') {
  108. wx.redirectTo({
  109. url: '/pages/finishInfo/finishInfo',
  110. })
  111. return;
  112. }
  113. if (res.data.data.perfect == '1' && res.data.data.comparison == '0') {
  114. wx.redirectTo({
  115. url: '/pages/faceRecognition/faceRecognition',
  116. })
  117. return;
  118. }
  119. wx.navigateTo({
  120. url: '/pages/paiming/paiming',
  121. })
  122. })
  123. }
  124. } else {
  125. wx.clearStorageSync();
  126. wx.showModal({
  127. showCancel: false,
  128. content: '当前您未登录,请登录',
  129. success(res) {
  130. if (res.confirm) {
  131. wx.redirectTo({
  132. url: '/pages/login/login',
  133. })
  134. }
  135. }
  136. })
  137. }
  138. })
  139. },
  140. goSaoMa() {
  141. tools.rzStatus().then((res) => {
  142. if (res.data.code == 0) {
  143. if (res.data.data) {
  144. tools.finishInfo().then((res) => {
  145. console.log(res.data.data.perfect, '我完善信息了吗 1代表完后 0代表未完成')
  146. console.log(res.data.data.comparison, '我人脸识别过了吗 1代表完后 0代表未完成')
  147. if (res.data.data.perfect == '0') {
  148. wx.redirectTo({
  149. url: '/pages/finishInfo/finishInfo',
  150. })
  151. return;
  152. }
  153. if (res.data.data.perfect == '1' && res.data.data.comparison == '0') {
  154. wx.redirectTo({
  155. url: '/pages/faceRecognition/faceRecognition',
  156. })
  157. return;
  158. }
  159. wx.scanCode({
  160. onlyFromCamera: true,
  161. success: (res) => {
  162. let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
  163. wx.navigateTo({
  164. url: '/pages/love/love?id=' + length,
  165. })
  166. },
  167. fail: () => {
  168. wx.showToast({
  169. title: '扫码失败',
  170. icon: 'none',
  171. duration: 2000,
  172. })
  173. }
  174. })
  175. })
  176. }
  177. } else {
  178. wx.clearStorageSync();
  179. wx.showModal({
  180. showCancel: false,
  181. content: '当前您未登录,请登录',
  182. success(res) {
  183. if (res.confirm) {
  184. wx.redirectTo({
  185. url: '/pages/login/login',
  186. })
  187. }
  188. }
  189. })
  190. }
  191. })
  192. },
  193. depts() {
  194. request.request('/applet/homeStatistics', {
  195. appletsId: wx.getStorageSync('openId')
  196. }, 'GET').then((res) => {
  197. console.log(res)
  198. if (res.data.code == 0) {
  199. this.setData({
  200. number: res.data.data
  201. })
  202. }
  203. })
  204. },
  205. welcomeMessage() {
  206. this.setData({
  207. msgList: []
  208. })
  209. tools.rzStatus().then((res) => {
  210. console.log(res)
  211. if (res.data.code == 0) {
  212. if (res.data.data) {
  213. request.request('/appletNotice/listForAppletsFirst', {
  214. appletsId: wx.getStorageSync('openId')
  215. }, 'GET').then((res) => {
  216. console.log(res)
  217. if (res.data.code == 0) {
  218. if (res.data.data.length == 0) {
  219. this.data.msgList.push({
  220. title: '暂无通知'
  221. });
  222. this.setData({
  223. msgList: this.data.msgList
  224. })
  225. } else {
  226. let result = res.data.data.title;
  227. this.data.msgList.push({
  228. title: result
  229. });
  230. this.setData({
  231. msgList: this.data.msgList
  232. })
  233. }
  234. }
  235. })
  236. }
  237. } else {
  238. request.request('/welcomeMessage/list', {}, 'GET').then((res) => {
  239. if (res.data.code == 0) {
  240. if (res.data.data.length != 0) {
  241. let result = res.data.data[0].title
  242. this.data.msgList.push({
  243. title: result
  244. });
  245. this.data.msgList.push({
  246. title: result
  247. });
  248. this.setData({
  249. msgList: this.data.msgList
  250. })
  251. }
  252. }
  253. })
  254. }
  255. })
  256. },
  257. onShow() {
  258. this.depts();
  259. this.welcomeMessage();
  260. },
  261. onLoad: function () {
  262. const apps = getApp()
  263. apps.getAuthKey().then(() => {
  264. this.depts();
  265. })
  266. }
  267. })