From 4b48bacef8646cee8b66f5e10b0ed7124534e93e Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期五, 12 五月 2023 17:10:47 +0800
Subject: [PATCH] 首页修改

---
 miniprogram/pages/user/index.ts |  156 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 125 insertions(+), 31 deletions(-)

diff --git a/miniprogram/pages/user/index.ts b/miniprogram/pages/user/index.ts
index 92ebeb6..4a59772 100644
--- a/miniprogram/pages/user/index.ts
+++ b/miniprogram/pages/user/index.ts
@@ -4,9 +4,14 @@
 
 Page({
     data: {
+        videoheight: '',
+        autoplay: true,
+        role: 0,
+        swcurrent: 0,
         isShow: false,
         userInfo: {},
-        causeList:[]
+        causeList: [],
+        images: []
     },
     // 浜嬩欢澶勭悊鍑芥暟
     bindViewTap() {
@@ -14,56 +19,145 @@
             url: '../logs/logs',
         })
     },
-
+    detalnew(e){
+        console.log(e)
+        wx.navigateTo({
+            url: '/pages/user/pubulicty/detail/index?id='+e.currentTarget.dataset.id,
+        })
+    },
+    resizeVideo(e) {
+        console.log(e);
+        this.setData({
+            videoheight: e.detail.height
+        })
+    },
 
     onLoad() {
-        wx.request(  
-            {
-              url:user.globalData.url+"/publicity?size="+"4",
-              method:"GET",
-              header:{'token':wx.getStorageSync('token')},
-              success:(res)=>{
-                  this.setData({
-                    causeList:res.data.data.records
-                  })
-                  console.log(this.data.causeList)
-              }
-                  })
+
+        wx.request({
+            url: user.globalData.url + "/wx/login",
+            data: {
+                "phone": wx.getStorageSync('phone'),
+            },
+            method: "GET",
+            success: (res) => {
+                wx.setStorageSync('token', res.data.data.token)
+                wx.setStorageSync('role', res.data.data.role)
+                wx.setStorageSync('id', res.data.data.id)
+                wx.setStorageSync('card', res.data.data.time)
+
+                wx.request(
+                    {
+                        url: user.globalData.url + "/wx/publicity?size=" + "4",
+                        method: "GET",
+                        header: { 'token': wx.getStorageSync('token') },
+                        success: (res) => {
+                            this.setData({
+                                role: wx.getStorageSync('role')
+                            })
+
+                            res.data.data.map(i => {
+                                let imgarr = []
+                                if (i.photoStr != null) {
+
+                                    i.photoStr = i.photoStr.split(",").map(i => user.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,
+                            })
+                            console.log(this.data.causeList);
+
+
+                        }
+                    })
+            }
+        })
+        if (wx.getStorageSync('info') == '') {
+            wx.redirectTo({
+                url: "pages/user/index"
+            })
+        }
+
+
+
+    },
+    videoplay(e) {
+        console.log(e);
+
+        this.setData({
+            autoplay: false
+        })
+    },
+    toDetailedInformation() {
+        console.log('鎶ユ璇︽儏');
+        wx.navigateTo({
+            url: '/pages/manager/report/index'
+        })
+    },
+    toManage() {
+        console.log('妗堜欢绠$悊');
+        wx.navigateTo({
+            url: '/pages/manager/cause/index'
+        })
     },
     getReport() {
-        console.log("xxx")
         wx.navigateTo({
             url: '../user/report/index'
         })
-    }
-    ,getPublicty(){
+    },
+    getamoter() {
+        wx.navigateTo({
+            url: '../user/announcement/index'
+        })
+    },
+    getPublicty() {
         console.log("publicty")
         wx.navigateTo({
-            url:'../user/pubulicty/index'
+            url: '../user/pubulicty/index'
         })
-        
-    }
-    ,getGroup(){
+    },
+    getGroup() {
         console.log("group")
         wx.navigateTo({
-            url:'../user/group/index'
-        })}
-    ,getCause(){
+            url: '../user/group/index'
+        })
+    },
+    getCause() {
         console.log("cause")
         wx.navigateTo({
-            url:'../manager/cause/index'
+            url: '../manager/cause/index'
         })
-    }
-    ,getAudi(){
+    },
+    getAudi() {
         console.log("myself")
         wx.navigateTo({
-            url:'../user/myself/index'
+            url: '../user/myself/index'
         })
-    }
-    ,more(){
+    },
+    more() {
         console.log("myself")
         wx.navigateTo({
-            url:'../user/pubulicty/index'
+            url: '../user/pubulicty/index'
         })
     }
 })

--
Gitblit v1.8.0