index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. // if (wx.getStorageSync('user') == '') {
  38. // wx.showModal({
  39. // showCancel: false,
  40. // content: '当前您未登录,请登录',
  41. // success(res) {
  42. // if (res.confirm) {
  43. // wx.redirectTo({
  44. // url: '/pages/login/login',
  45. // })
  46. // } else if (res.cancel) {
  47. // console.log('用户点击取消')
  48. // }
  49. // }
  50. // })
  51. // } else {
  52. // wx.switchTab({
  53. // url: '/pages/collectInfo/collectInfo',
  54. // })
  55. // }
  56. if (wx.getStorageSync('user') == '') {
  57. wx.redirectTo({
  58. url: '/pages/login/login',
  59. })
  60. } else {
  61. wx.switchTab({
  62. url: '/pages/collectInfo/collectInfo',
  63. })
  64. }
  65. },
  66. goXunfang() {
  67. // if (wx.getStorageSync('user') == '') {
  68. // wx.showModal({
  69. // showCancel: false,
  70. // content: '当前您未登录,请登录',
  71. // success(res) {
  72. // if (res.confirm) {
  73. // wx.redirectTo({
  74. // url: '/pages/login/login',
  75. // })
  76. // } else if (res.cancel) {
  77. // console.log('用户点击取消')
  78. // }
  79. // }
  80. // })
  81. // } else {
  82. // wx.switchTab({
  83. // url: '/pages/visitandinfo/visitandinfo',
  84. // })
  85. // }
  86. // if (wx.getStorageSync('user') == '') {
  87. // wx.redirectTo({
  88. // url: '/pages/login/login',
  89. // })
  90. // } else {
  91. // wx.switchTab({
  92. // url: '/pages/visitandinfo/visitandinfo',
  93. // })
  94. // }
  95. },
  96. goTongzhi() {
  97. if (wx.getStorageSync('user') == '') {
  98. wx.redirectTo({
  99. url: '/pages/login/login',
  100. })
  101. } else {
  102. wx.navigateTo({
  103. url: '/pages/notice/notice',
  104. })
  105. }
  106. },
  107. goPaiming() {
  108. if (wx.getStorageSync('user') == '') {
  109. wx.redirectTo({
  110. url: '/pages/login/login',
  111. })
  112. } else {
  113. wx.navigateTo({
  114. url: '/pages/paiming/paiming',
  115. })
  116. }
  117. },
  118. goSaoMa() {
  119. console.log("扫阿");
  120. if (wx.getStorageSync('user') == '') {
  121. wx.redirectTo({
  122. url: '/pages/login/login',
  123. })
  124. } else {
  125. wx.scanCode({
  126. onlyFromCamera: true,
  127. success: (res) => {
  128. console.log(res, "打印锕");
  129. let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
  130. wx.navigateTo({
  131. url: '/pages/love/love?id=' + length,
  132. })
  133. },
  134. fail: (res) => {
  135. console.log(res, "假的");
  136. wx.showToast({
  137. title: '扫码失败',
  138. icon: 'none',
  139. duration: 2000,
  140. })
  141. }
  142. })
  143. }
  144. },
  145. depts() {
  146. console.log("1111111111111111111111111111");
  147. wx.request({
  148. url: app.globalData.publicUrl + '/applet/homeStatistics',
  149. method: "GET",
  150. data: {
  151. appletsId: wx.getStorageSync('openId')
  152. },
  153. success: (res) => {
  154. console.log("resrrrrrrrrrrrrrrrrrrrrrrr",res);
  155. if (res.data.code == 0) {
  156. this.setData({
  157. number: res.data.data
  158. })
  159. }
  160. }
  161. })
  162. },
  163. welcomeMessage() {
  164. this.setData({
  165. msgList: []
  166. })
  167. if (wx.getStorageSync('user') == '') {
  168. wx.request({
  169. url: app.globalData.publicUrl + '/welcomeMessage/list',
  170. method: "GET",
  171. success: (res) => {
  172. if (res.data.code == 0) {
  173. if (res.data.data.length != 0) {
  174. let result = res.data.data[0].title
  175. this.data.msgList.push({
  176. title: result
  177. });
  178. this.data.msgList.push({
  179. title: result
  180. });
  181. this.setData({
  182. msgList: this.data.msgList
  183. })
  184. }
  185. }
  186. }
  187. })
  188. } else {
  189. wx.request({
  190. url: app.globalData.publicUrl + '/appletNotice/listForAppletsFirst',
  191. method: "GET",
  192. header: {
  193. appletsId: wx.getStorageSync('openId')
  194. },
  195. success: (res) => {
  196. if (res.data.code == 0) {
  197. if (res.data.data.length == 0) {
  198. this.data.msgList.push({
  199. title: '暂无通知'
  200. });
  201. this.setData({
  202. msgList: this.data.msgList
  203. })
  204. } else {
  205. let result = res.data.data.title;
  206. this.data.msgList.push({
  207. title: result
  208. });
  209. this.setData({
  210. msgList: this.data.msgList
  211. })
  212. }
  213. }
  214. }
  215. })
  216. }
  217. },
  218. // onLoad() {
  219. // console.log("onloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonloadonload");
  220. // this.depts();
  221. // },
  222. onShow() {
  223. this.depts();
  224. this.welcomeMessage();
  225. },
  226. onLoad: function () {
  227. console.log("主页load11111");
  228. var that = this;
  229. const apps = getApp()
  230. apps.getAuthKey().then(function (res) {
  231. that.depts();
  232. })
  233. console.log("主页load2222222222222222");
  234. }
  235. })