index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. // 轮播
  6. backgrounds: [{
  7. "pic": "/images/banner1.png",
  8. // link:'../aboutme/index',
  9. },
  10. {
  11. "pic": "/images/banner2.png",
  12. // link:'../aboutme/index',
  13. },
  14. {
  15. "pic": "/images/banner3.png",
  16. // link:'../aboutme/index',
  17. },
  18. ],
  19. indicatorDots: true,
  20. vertical: false,
  21. autoplay: true,
  22. interval: 5000,
  23. duration: 500,
  24. number: {},
  25. msgList: [
  26. // {
  27. // url: "url",
  28. // title: "欢迎来到吉顺致养小程序"
  29. // },
  30. // {
  31. // url: "url",
  32. // title: "欢迎来到吉顺致养小程序"
  33. // },
  34. ]
  35. },
  36. goCollect() {
  37. wx.switchTab({
  38. url: '/pages/collectInfo/collectInfo',
  39. })
  40. },
  41. goXunfang() {
  42. wx.switchTab({
  43. url: '/pages/visitandinfo/visitandinfo',
  44. })
  45. },
  46. goTongzhi() {
  47. wx.navigateTo({
  48. url: '/pages/notice/notice',
  49. })
  50. },
  51. goPaiming() {
  52. wx.navigateTo({
  53. url: '/pages/paiming/paiming',
  54. })
  55. },
  56. goSaoMa() {
  57. console.log("扫阿");
  58. // 允许从相机和相册扫码
  59. wx.scanCode({
  60. onlyFromCamera: true,
  61. success: (res) => {
  62. console.log(res, "打印锕");
  63. let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
  64. wx.navigateTo({
  65. url: '/pages/love/love?id=' + length,
  66. })
  67. },
  68. fail: (res) => {
  69. console.log(res, "假的");
  70. wx.showToast({
  71. title: '扫码失败',
  72. icon: 'none',
  73. duration: 2000,
  74. })
  75. }
  76. })
  77. },
  78. depts() {
  79. console.log(wx.getStorageSync('openId'), "openid的问题");
  80. wx.request({
  81. url: app.globalData.publicUrl + '/applet/homeStatistics',
  82. method: "GET",
  83. data: {
  84. appletsId: wx.getStorageSync('openId')
  85. },
  86. success: (res) => {
  87. if (res.data.code == 0) {
  88. this.setData({
  89. number: res.data.data
  90. })
  91. }
  92. }
  93. })
  94. },
  95. welcomeMessage() {
  96. this.setData({
  97. msgList: []
  98. })
  99. if (wx.getStorageSync('user') == '') {
  100. wx.request({
  101. url: app.globalData.publicUrl + '/welcomeMessage/list',
  102. method: "GET",
  103. success: (res) => {
  104. if (res.data.code == 0) {
  105. console.log(res);
  106. let result = res.data.data[0].title
  107. this.data.msgList.push({
  108. // url: '',
  109. title: result
  110. });
  111. this.data.msgList.push({
  112. // url: '',
  113. title: result
  114. });
  115. this.setData({
  116. msgList: this.data.msgList
  117. })
  118. }
  119. }
  120. })
  121. } else {
  122. wx.request({
  123. url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
  124. method: "GET",
  125. header: {
  126. appletsId: wx.getStorageSync('openId')
  127. },
  128. success: (res) => {
  129. if (res.data.code == 0) {
  130. console.log(res);
  131. if (res.data.data.length == 0) {
  132. this.data.msgList.push({
  133. // url: '',
  134. title: '暂无数据!!!'
  135. });
  136. this.data.msgList.push({
  137. // url: '',
  138. title: '暂无数据!!!'
  139. });
  140. this.setData({
  141. msgList: this.data.msgList
  142. })
  143. } else {
  144. let result = res.data.data.title;
  145. this.data.msgList.push({
  146. // url: '',
  147. title: result
  148. });
  149. this.data.msgList.push({
  150. // url: '',
  151. title: result
  152. });
  153. this.setData({
  154. msgList: this.data.msgList
  155. })
  156. }
  157. }
  158. }
  159. })
  160. }
  161. },
  162. onLoad() {
  163. this.depts();
  164. },
  165. onShow() {
  166. this.depts();
  167. this.welcomeMessage();
  168. }
  169. })