index.js 5.4 KB

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