index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company;
  3. const getTabs = require("../../../utils/getTabs")
  4. const login = require("../../../utils/login");
  5. const dateF = require("../../../utils/date")
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. active: 0,
  12. showModel: false,
  13. isSignIn:false
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: async function (options) {
  19. let currentIndex = options.detail;
  20. // login.loginNow()
  21. this.setData({
  22. active: options?.active || 0
  23. })
  24. let list = await getTabs.getDiyTabs()
  25. this.setData({
  26. tabbarList: list
  27. })
  28. let {
  29. q,
  30. invite,
  31. groupId,
  32. path
  33. } = options
  34. let str = decodeURIComponent(q);
  35. let obj = this.getParaName(str)
  36. console.log(obj);
  37. if(path){
  38. wx.navigateTo({
  39. url: path,
  40. });
  41. }
  42. },
  43. async onChange(event) {
  44. let currentIndex = event.detail;
  45. let userInfo = wx.getStorageSync("userLogin");
  46. if ( userInfo == ''||!userInfo) {
  47. console.log(userInfo);
  48. login.loginNow()
  49. return
  50. }
  51. this.setData({
  52. active: currentIndex
  53. })
  54. let componentPage = this.selectComponent(`#comp${currentIndex}`)
  55. switch (currentIndex) {
  56. case 0:
  57. break;
  58. case 2:
  59. break;
  60. case 3:
  61. // componentPage.getUser()
  62. break;
  63. }
  64. },
  65. toCart() {
  66. this.setData({
  67. active: 2
  68. })
  69. },
  70. //解析二维码
  71. getParaName(url) {
  72. if (!url || url.indexOf('?') == -1) {
  73. return
  74. }
  75. let paraname = url.split('?')[1]
  76. return this.setObject(paraname) //封装成对象
  77. },
  78. setObject(paraArr) {
  79. let obj = {}
  80. let arr1 = paraArr.split('&')
  81. arr1.forEach(item => {
  82. let str = item.split('=')
  83. let key = str[0]
  84. let val = str[1]
  85. obj[key] = val
  86. })
  87. return obj
  88. },
  89. /**
  90. * 生命周期函数--监听页面初次渲染完成
  91. */
  92. onReady: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面显示
  96. */
  97. onShow: function () {
  98. this.getRenew()
  99. let {
  100. active
  101. } = this.data
  102. console.log(active)
  103. let componentPage = this.selectComponent(`#comp${active}`)
  104. if (!componentPage) {
  105. return
  106. }
  107. switch (active) {
  108. case 0:
  109. componentPage.refersh()
  110. break;
  111. case 1:
  112. break;
  113. case 4:
  114. componentPage.getMeChick()
  115. componentPage.getcircle()
  116. break;
  117. case 3:
  118. break;
  119. }
  120. },
  121. //朋友圈
  122. updateCom(){
  123. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  124. if (!componentPage) {
  125. return
  126. }
  127. componentPage.getcircle2()
  128. },
  129. //首页
  130. updateCom2(){
  131. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  132. if (!componentPage) {
  133. return
  134. }
  135. componentPage.order()
  136. componentPage.gettarget()
  137. },
  138. //我的页面
  139. updateCom3(){
  140. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  141. if (!componentPage) {
  142. return
  143. }
  144. componentPage.getcircle()
  145. componentPage.getname()
  146. },
  147. /* 服务器是否需要续费 */
  148. async getRenew(){
  149. let query = new Parse.Query("Company")
  150. query.select('website','expireMap')
  151. query.equalTo('objectId',company)
  152. let c = await query.first()
  153. if(c?.id && c?.get('expireMap')){
  154. let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath
  155. //website配置且renew(续费)存在
  156. if(c.get('expireMap')?.renew && c.get('website')){
  157. wx.showModal({
  158. title: '警告',
  159. content: '当前平台服务器承载已超出阈值,请与技术人员联系。',
  160. showCancel: false,
  161. cancelText: '取消',
  162. cancelColor: '#000000',
  163. confirmText: '确定',
  164. confirmColor: '#3CC51F',
  165. success: (result) => {
  166. if(result.confirm){
  167. wx.reLaunch({
  168. url: `/common-page/pages/loading/index?url=${url}`,
  169. });
  170. }
  171. },
  172. fail: ()=>{},
  173. complete: ()=>{}
  174. });
  175. }
  176. }
  177. },
  178. /**
  179. * 生命周期函数--监听页面隐藏
  180. */
  181. onHide: function () {
  182. },
  183. /**
  184. * 生命周期函数--监听页面卸载
  185. */
  186. onUnload: function () {
  187. },
  188. /**
  189. * 页面相关事件处理函数--监听用户下拉动作
  190. */
  191. onPullDownRefresh: function () {
  192. wx.reLaunch({
  193. url: '/index',
  194. });
  195. },
  196. /**
  197. * 页面上拉触底事件的处理函数
  198. */
  199. onReachBottom: function () {
  200. },
  201. /**
  202. * 用户点击右上角分享
  203. */
  204. onShareAppMessage: function () {
  205. let uid = Parse.User.current().id
  206. return {
  207. title: '分享',
  208. // path: `index?invite=${uid}`,
  209. path: `index`,
  210. imageUrl: '',
  211. }
  212. }
  213. })