index.js 5.0 KB

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