odc.xiaohui
2023-05-12 4b48bacef8646cee8b66f5e10b0ed7124534e93e
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// index.ts
// 获取应用实例
const userCause = getApp()
 
Page({
    data: {
        autoplay:true,
        cardFig:true,
        swcurrent: 0,
        causeList: [],
        isShow: false
    },
    register(e){
        console.log(e);
        
    },
    detalnew(e){
        console.log(e)
        wx.navigateTo({
            url: '/pages/user/pubulicty/detail/index?id='+e.currentTarget.dataset.id,
        })
    },
    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 => {
                        let imgarr=[]
                        if (i.photoStr != null) {
                            i.photoStr = i.photoStr.split(",").map(i => userCause.globalData.imageUrl + "/img/" + i),
                                this.data.images = i.photoStr
                                i.photoStr.map(j=>{
                                    let type=j.substring(j.lastIndexOf(".")+1)
 
                                   
                                    let obj={
                                        url: j,
                                        type:'png'
                                     }
                                     if (type=='mp4') {
                                        obj.type = 'mp4'
                                    }else{
                                        obj.type = 'png'
                                    }
                                    imgarr.push(obj)
                                })
                                i.imagarr=imgarr
                        }
                        i.releaseTime = i.releaseTime.replace(/-/g,"/")
                    })
                    this.setData({
                        causeList: res.data.data
                    })
                }
            })
    },
    videoplay(e){
        console.log(e);
        
        this.setData({
            autoplay:false
        })
    },
})