123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- const Parse = getApp().Parse;
- const company = getApp().globalData.company;
- const getTabs = require("../../../utils/getTabs")
- const login = require("../../../utils/login");
- const dateF = require("../../../utils/date")
- import Toast from '@vant/weapp/toast/toast';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- active: 0,
- showModel: false,
- isSignIn:false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: async function (options) {
- login.loginNow()
- this.setData({
- active: options?.active || 0
- })
- let list = await getTabs.getDiyTabs()
- this.setData({
- tabbarList: list
- })
- let {
- q,
- invite,
- groupId,
- path
- } = options
- let str = decodeURIComponent(q);
- let obj = this.getParaName(str)
- console.log(obj);
- // if ((obj && obj.invite) || invite) {
- // wx.setStorageSync("invite", obj && obj.invite || invite);
- // let user = Parse.User.current()
- // if (user && user.id) {
- // invite = wx.getStorageSync("invite")
- // console.log('invite=====>', invite);
- // let query = new Parse.Query("_User")
- // query.include("invite")
- // let res = await query.get(user.id)
- // let userJSON = res.toJSON()
- // //查询邀请人user
- // let queryUserInvite = new Parse.Query("_User")
- // queryUserInvite.equalTo('objectId',invite)
- // let result = await queryUserInvite.first()
- // if (result && result.id && result.get('invite')?.id == res.id) {
- // console.log('邀请人不能是自己的下级')
- // }
- // // 用户没有邀请人, 并且邀请人不是自己
- // else if (!userJSON.invite && userJSON.objectId != invite && !userJSON.agentLevel) {
- // console.log('上下级绑定成功');
- // user.set('invite', {
- // __type: "Pointer",
- // className: "_User",
- // objectId: invite
- // })
- // user.set('agent', {
- // __type: "Pointer",
- // className: "_User",
- // objectId: invite
- // })
- // }
- // await res.save()
- // }
- // }
- if(path){
- wx.navigateTo({
- url: path,
- });
- }
- },
- async onChange(event) {
- let currentIndex = event.detail;
- let userInfo = wx.getStorageSync("userLogin");
- if (currentIndex != 0 && userInfo == '') {
- console.log(userInfo);
- login.loginNow()
- return
- }
- this.setData({
- active: currentIndex
- })
- let componentPage = this.selectComponent(`#comp${currentIndex}`)
- switch (currentIndex) {
- case 0:
- break;
- case 2:
- break;
- case 3:
- // componentPage.getUser()
- break;
- }
- },
- toCart() {
- this.setData({
- active: 2
- })
- },
- //解析二维码
- getParaName(url) {
- if (!url || url.indexOf('?') == -1) {
- return
- }
- let paraname = url.split('?')[1]
- return this.setObject(paraname) //封装成对象
- },
- setObject(paraArr) {
- let obj = {}
- let arr1 = paraArr.split('&')
- arr1.forEach(item => {
- let str = item.split('=')
- let key = str[0]
- let val = str[1]
- obj[key] = val
- })
- return obj
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getRenew()
- let {
- active
- } = this.data
- let componentPage = this.selectComponent(`#comp${active}`)
- if (!componentPage) {
- return
- }
- switch (active) {
- case 0:
- // componentPage.refresh()
- break;
- case 1:
- componentPage.setData({
- scate: []
- })
- componentPage.refresh()
- break;
- case 2:
- componentPage.setData({
- allCheck: false,
- cartList: [],
- totalPrice: 0.00,
- })
- componentPage.getShopcart()
- break;
- case 3:
- componentPage.refresh()
- break;
- }
- },
- /* 服务器是否需要续费 */
- async getRenew(){
- let query = new Parse.Query("Company")
- query.select('website','expireMap')
- query.equalTo('objectId',company)
- let c = await query.first()
- if(c?.id && c?.get('expireMap')){
- let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath
- //website配置且renew(续费)存在
- if(c.get('expireMap')?.renew && c.get('website')){
- wx.showModal({
- title: '警告',
- content: '当前平台服务器承载已超出阈值,请与技术人员联系。',
- showCancel: false,
- cancelText: '取消',
- cancelColor: '#000000',
- confirmText: '确定',
- confirmColor: '#3CC51F',
- success: (result) => {
- if(result.confirm){
- wx.reLaunch({
- url: `/common-page/pages/loading/index?url=${url}`,
- });
- }
- },
- fail: ()=>{},
- complete: ()=>{}
- });
- }
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- wx.reLaunch({
- url: '/index',
- });
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- let uid = Parse.User.current().id
- return {
- title: '分享',
- // path: `index?invite=${uid}`,
- path: `index`,
- imageUrl: '',
- }
- }
- })
|