index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. import Toast from '@vant/weapp/toast/toast';
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. active: 0,
  13. showModel: false,
  14. isSignIn:false
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: async function (options) {
  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 (currentIndex != 0 && 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. let componentPage = this.selectComponent(`#comp${active}`)
  103. if (!componentPage) {
  104. return
  105. }
  106. switch (active) {
  107. case 0:
  108. // componentPage.refresh()
  109. break;
  110. case 1:
  111. // componentPage.setData({
  112. // scate: []
  113. // })
  114. // componentPage.getcircle()
  115. break;
  116. case 2:
  117. componentPage.setData({
  118. allCheck: false,
  119. cartList: [],
  120. totalPrice: 0.00,
  121. })
  122. componentPage.getShopcart()
  123. break;
  124. case 3:
  125. componentPage.refresh()
  126. break;
  127. }
  128. },
  129. updateCom(){
  130. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  131. if (!componentPage) {
  132. return
  133. }
  134. componentPage.getcircle2()
  135. },
  136. /* 服务器是否需要续费 */
  137. async getRenew(){
  138. let query = new Parse.Query("Company")
  139. query.select('website','expireMap')
  140. query.equalTo('objectId',company)
  141. let c = await query.first()
  142. if(c?.id && c?.get('expireMap')){
  143. let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath
  144. //website配置且renew(续费)存在
  145. if(c.get('expireMap')?.renew && c.get('website')){
  146. wx.showModal({
  147. title: '警告',
  148. content: '当前平台服务器承载已超出阈值,请与技术人员联系。',
  149. showCancel: false,
  150. cancelText: '取消',
  151. cancelColor: '#000000',
  152. confirmText: '确定',
  153. confirmColor: '#3CC51F',
  154. success: (result) => {
  155. if(result.confirm){
  156. wx.reLaunch({
  157. url: `/common-page/pages/loading/index?url=${url}`,
  158. });
  159. }
  160. },
  161. fail: ()=>{},
  162. complete: ()=>{}
  163. });
  164. }
  165. }
  166. },
  167. /**
  168. * 生命周期函数--监听页面隐藏
  169. */
  170. onHide: function () {
  171. },
  172. /**
  173. * 生命周期函数--监听页面卸载
  174. */
  175. onUnload: function () {
  176. },
  177. /**
  178. * 页面相关事件处理函数--监听用户下拉动作
  179. */
  180. onPullDownRefresh: function () {
  181. wx.reLaunch({
  182. url: '/index',
  183. });
  184. },
  185. /**
  186. * 页面上拉触底事件的处理函数
  187. */
  188. onReachBottom: function () {
  189. },
  190. /**
  191. * 用户点击右上角分享
  192. */
  193. onShareAppMessage: function () {
  194. let uid = Parse.User.current().id
  195. return {
  196. title: '分享',
  197. // path: `index?invite=${uid}`,
  198. path: `index`,
  199. imageUrl: '',
  200. }
  201. }
  202. })