index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. //朋友圈
  130. updateCom(){
  131. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  132. if (!componentPage) {
  133. return
  134. }
  135. componentPage.getcircle2()
  136. },
  137. //首页
  138. updateCom2(){
  139. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  140. if (!componentPage) {
  141. return
  142. }
  143. componentPage.order()
  144. componentPage.gettarget()
  145. },
  146. //我的页面
  147. updateCom3(){
  148. let componentPage = this.selectComponent(`#comp${this.data.active}`)
  149. if (!componentPage) {
  150. return
  151. }
  152. componentPage.getcircle()
  153. componentPage.getname()
  154. },
  155. /* 服务器是否需要续费 */
  156. async getRenew(){
  157. let query = new Parse.Query("Company")
  158. query.select('website','expireMap')
  159. query.equalTo('objectId',company)
  160. let c = await query.first()
  161. if(c?.id && c?.get('expireMap')){
  162. let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath
  163. //website配置且renew(续费)存在
  164. if(c.get('expireMap')?.renew && c.get('website')){
  165. wx.showModal({
  166. title: '警告',
  167. content: '当前平台服务器承载已超出阈值,请与技术人员联系。',
  168. showCancel: false,
  169. cancelText: '取消',
  170. cancelColor: '#000000',
  171. confirmText: '确定',
  172. confirmColor: '#3CC51F',
  173. success: (result) => {
  174. if(result.confirm){
  175. wx.reLaunch({
  176. url: `/common-page/pages/loading/index?url=${url}`,
  177. });
  178. }
  179. },
  180. fail: ()=>{},
  181. complete: ()=>{}
  182. });
  183. }
  184. }
  185. },
  186. /**
  187. * 生命周期函数--监听页面隐藏
  188. */
  189. onHide: function () {
  190. },
  191. /**
  192. * 生命周期函数--监听页面卸载
  193. */
  194. onUnload: function () {
  195. },
  196. /**
  197. * 页面相关事件处理函数--监听用户下拉动作
  198. */
  199. onPullDownRefresh: function () {
  200. wx.reLaunch({
  201. url: '/index',
  202. });
  203. },
  204. /**
  205. * 页面上拉触底事件的处理函数
  206. */
  207. onReachBottom: function () {
  208. },
  209. /**
  210. * 用户点击右上角分享
  211. */
  212. onShareAppMessage: function () {
  213. let uid = Parse.User.current().id
  214. return {
  215. title: '分享',
  216. // path: `index?invite=${uid}`,
  217. path: `index`,
  218. imageUrl: '',
  219. }
  220. }
  221. })