安瑾然
2023-03-23 f68f67f34857085d627cc2acdcfe714eb8bbdcb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// index.ts
// 获取应用实例
const userCause = getApp()
 
Page({
    data: {
        cardFig:true,
        swcurrent: 0,
        causeList: [],
        isShow: false
    },
    register(e){
        console.log(e);
        
    },
    getMobile(){
     // 获取手机号
     wx.request(  
        {
          url:userCause.globalData.url+  "/wx/user/myself",
          method:"GET",
          data:{
              id:wx.getStorageSync('id')
          },
          header:{'token':wx.getStorageSync('token')},
          success:(res)=>{
              console.log(res)
            if (res.data.data.userMobile) {
                this.getUserRegister(res.data.data.userMobile)
            }
          }
              })
  
    },
    // 通过手机号查询是否是已注册用户
    getUserRegister(phone){
        wx.request(  
            {
              url:userCause.globalData.url+  "/wx/isExist",
              method:"GET",
              data:{
                phone:phone
              },
              header:{'token':wx.getStorageSync('token')},
              success:(res)=>{
                  console.log(res)
               
                     }
                  })
    },
    // 事件处理函数
    onLoad() {
        if (wx.getStorageSync('token')) {
            this.setData({
                cardFig:false
            })
        }
        // this.getMobile()
        // let  info=wx.getStorageSync('card')
        // console.log(info);
        
        //                     if (info) {
        //                       this.setData({
        //                           cardFig :false
        //                       })
        //                     }else{
        //                         this.setData({
        //                             cardFig :true
        //                         })
        //                     }
        wx.request(
            {
                url: userCause.globalData.url + "/wx/publicity",
                method: "GET",
                // header: { 'token': wx.getStorageSync('token') },
                success: (res) => {
                    res.data.data.map(i => {
                        if (i.photoStr != null) {
                            i.photoStr = i.photoStr.split(",").map(i => userCause.globalData.imageUrl + "/img/" + i),
                                this.data.images = i.photoStr
                        }
                    })
                    this.setData({
                        causeList: res.data.data
                    })
                }
            })
    }
})