index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. if (wx.getStorageSync('user') == '') {
  48. wx.redirectTo({
  49. url: '/pages/login/login',
  50. })
  51. } else {
  52. wx.navigateTo({
  53. url: '/pages/notice/notice',
  54. })
  55. }
  56. },
  57. goPaiming() {
  58. wx.navigateTo({
  59. url: '/pages/paiming/paiming',
  60. })
  61. },
  62. goSaoMa() {
  63. console.log("扫阿");
  64. // 允许从相机和相册扫码
  65. wx.scanCode({
  66. onlyFromCamera: true,
  67. success: (res) => {
  68. console.log(res, "打印锕");
  69. let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
  70. wx.navigateTo({
  71. url: '/pages/love/love?id=' + length,
  72. })
  73. },
  74. fail: (res) => {
  75. console.log(res, "假的");
  76. wx.showToast({
  77. title: '扫码失败',
  78. icon: 'none',
  79. duration: 2000,
  80. })
  81. }
  82. })
  83. },
  84. depts() {
  85. console.log(wx.getStorageSync('openId'), "openid的问题");
  86. wx.request({
  87. url: app.globalData.publicUrl + '/applet/homeStatistics',
  88. method: "GET",
  89. data: {
  90. appletsId: wx.getStorageSync('openId')
  91. },
  92. success: (res) => {
  93. if (res.data.code == 0) {
  94. this.setData({
  95. number: res.data.data
  96. })
  97. }
  98. }
  99. })
  100. },
  101. welcomeMessage() {
  102. this.setData({
  103. msgList: []
  104. })
  105. if (wx.getStorageSync('user') == '') {
  106. wx.request({
  107. url: app.globalData.publicUrl + '/welcomeMessage/list',
  108. method: "GET",
  109. success: (res) => {
  110. if (res.data.code == 0) {
  111. console.log(res);
  112. let result = res.data.data[0].title
  113. this.data.msgList.push({
  114. // url: '',
  115. title: result
  116. });
  117. this.data.msgList.push({
  118. // url: '',
  119. title: result
  120. });
  121. this.setData({
  122. msgList: this.data.msgList
  123. })
  124. }
  125. }
  126. })
  127. } else {
  128. wx.request({
  129. url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
  130. method: "GET",
  131. header: {
  132. appletsId: wx.getStorageSync('openId')
  133. },
  134. success: (res) => {
  135. if (res.data.code == 0) {
  136. console.log(res);
  137. if (res.data.data.length == 0) {
  138. this.data.msgList.push({
  139. // url: '',
  140. title: '暂无数据!!!'
  141. });
  142. this.data.msgList.push({
  143. // url: '',
  144. title: '暂无数据!!!'
  145. });
  146. this.setData({
  147. msgList: this.data.msgList
  148. })
  149. } else {
  150. let result = res.data.data.title;
  151. this.data.msgList.push({
  152. // url: '',
  153. title: result
  154. });
  155. this.data.msgList.push({
  156. // url: '',
  157. title: result
  158. });
  159. this.setData({
  160. msgList: this.data.msgList
  161. })
  162. }
  163. }
  164. }
  165. })
  166. }
  167. },
  168. onLoad() {
  169. this.depts();
  170. },
  171. onShow() {
  172. this.depts();
  173. this.welcomeMessage();
  174. }
  175. })