index.js 4.2 KB

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