Forráskód Böngészése

完成找活动列表接口和报名活动接口

adminthw 4 éve%!(EXTRA string=óta)
szülő
commit
6880e44420
3 módosított fájl, 318 hozzáadás és 37 törlés
  1. 115 1
      pages/activity/activity_deatil.vue
  2. 79 4
      pages/activity/index.vue
  3. 124 32
      pages/index/index.vue

+ 115 - 1
pages/activity/activity_deatil.vue

@@ -35,12 +35,15 @@
         <view class="shareCount">17</view>
         <image src="../../static/share_icon.png"></image>
       </view>
-      <view class="button"><button>活动进行中</button></view>
+      <view class="button"
+        ><button @click="signUpActivity">活动进行中</button></view
+      >
     </view>
   </view>
 </template>
 
 <script>
+import md5 from "@/common/md5.js";
 import activity_rich_card from "../policy/policy_rich_card";
 export default {
   components: {
@@ -48,6 +51,17 @@ export default {
   },
   data() {
     return {
+      id: "",
+      model: {
+        title: "",
+        read: 0,
+        url: "",
+        date: "",
+        type: "",
+        way: "",
+        share: 0,
+        activiteState: "",
+      },
       textModel: {
         title: "活动内容",
         text:
@@ -55,6 +69,106 @@ export default {
       },
     };
   },
+  onLoad(op) {
+    this.id = op.id;
+    // this.getActivityDeatil();
+  },
+  methods: {
+    getActivityDeatil() {
+      let md5Sign = md5(
+        "method=" +
+          "common" +
+          "&timestamp=" +
+          getApp().globalData.globalTimestamp +
+          "&secret=" +
+          getApp().globalData.secret
+      );
+      let url =
+        getApp().globalData.shareUrl +
+        "api/api.php" +
+        "?method=common&source=activity&action=info_by_id&timestamp=" +
+        getApp().globalData.globalTimestamp +
+        "&sign=" +
+        md5Sign;
+      let postData = {
+        id: this.id,
+      };
+      //获取文章
+      uni.request({
+        url: url,
+        method: "POST",
+        header: {
+          "content-type": "application/x-www-form-urlencoded",
+        },
+        data: postData,
+        success: (res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            this.getRich();
+          }
+        },
+        fail: () => {
+          console.log("连接失败");
+        },
+      });
+    },
+    getRich() {
+      uni.request({
+        url:
+          getApp().globalData.shareUrl +
+          `content/business/${Math.floor(this.id / 1000)}/${this.id}.html`,
+        method: "GET",
+        header: {
+          "content-type": "application/x-www-form-urlencoded",
+        },
+
+        success: (res) => {
+          console.log(res);
+          if (res.statusCode === 200) {
+            this.model.artical = res.data;
+          }
+        },
+        fail: () => {
+          console.log("连接失败");
+        },
+      });
+    },
+    signUpActivity() {
+      let md5Sign = md5(
+        "method=" +
+          "common" +
+          "&timestamp=" +
+          getApp().globalData.globalTimestamp +
+          "&secret=" +
+          getApp().globalData.secret
+      );
+      let url =
+        getApp().globalData.shareUrl +
+        "api/api.php" +
+        "?method=common&source=activity&action=active&timestamp=" +
+        getApp().globalData.globalTimestamp +
+        "&sign=" +
+        md5Sign;
+      let postData = {
+        openId: getApp().globalData.open_id,
+        id: this.id,
+      };
+      uni.request({
+        url: url,
+        method: "POST",
+        header: {
+          "content-type": "application/x-www-form-urlencoded",
+        },
+        data: postData,
+        success: (res) => {
+          console.log(res);
+        },
+        fail: () => {
+          console.log("连接失败");
+        },
+      });
+    },
+  },
 };
 </script>
 

+ 79 - 4
pages/activity/index.vue

@@ -66,6 +66,7 @@
 </template>
 
 <script>
+import md5 from "@/common/md5.js";
 export default {
   data() {
     return {
@@ -126,12 +127,14 @@ export default {
           date: "2021-08-07",
           read: 322,
           share: 1,
-          type: 0, //0线下
+          type: 2, //2线下
         },
       ],
     };
   },
-  onLoad() {},
+  onLoad() {
+    this.getActive();
+  },
   methods: {
     bindPickerChange(e, op) {
       console.log(e);
@@ -149,12 +152,82 @@ export default {
 
       this.index = e.detail.value;
     },
-    goDeatil(id = 1) {
-      console.log(123);
+    goDeatil(id) {
       uni.navigateTo({
         url: "/pages/activity/activity_deatil?id=" + id,
       });
     },
+    getActive() {
+      let md5Sign = md5(
+        "method=" +
+          "common" +
+          "&timestamp=" +
+          getApp().globalData.globalTimestamp +
+          "&secret=" +
+          getApp().globalData.secret
+      );
+      let url =
+        getApp().globalData.shareUrl +
+        "api/api.php" +
+        "?method=common&source=activity&action=list&timestamp=" +
+        getApp().globalData.globalTimestamp +
+        "&sign=" +
+        md5Sign;
+      let postData = {
+        page: 1,
+        page_size: 15,
+      };
+      uni.request({
+        url: url,
+        method: "POST",
+        header: {
+          "content-type": "application/x-www-form-urlencoded",
+        },
+        data: postData,
+        success: (res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            let list = res.data.data.list;
+            this.activeList = list.map((item) => {
+              /*
+                  url: "/static/activity/2.png",
+            title: "智能制造商标品牌培育系列培训活动",
+            way: "市场监督管理局",
+            date: "2021-08-07",
+            read: 322,
+            share: 1,
+            type: 0, //0线下
+             */
+              let ob = {
+                url: "",
+                title: "",
+                way: "",
+                date: "",
+                read: 0,
+                share: 0,
+                type: "",
+                id: "",
+              };
+              ob.url = getApp().globalData.shareUrl + item.pic_url;
+              ob.title = item.name;
+              ob.way = item.sponsor;
+              ob.date = this.$options.filters["globalTime"](item.start_time);
+              ob.read =
+                parseInt(item.base_read_count) + parseInt(item.real_read_count);
+              ob.share =
+                parseInt(item.real_repost_count) +
+                parseInt(item.base_repost_count);
+              ob.type = item.type;
+              ob.id = item.id;
+              return ob;
+            });
+          }
+        },
+        fail: () => {
+          console.log("连接失败");
+        },
+      });
+    },
   },
 };
 </script>
@@ -227,6 +300,7 @@ export default {
           img {
             width: 100%;
             height: 100%;
+            border-radius: 10%;
           }
         }
         .right {
@@ -234,6 +308,7 @@ export default {
           box-sizing: border-box;
           display: flex;
           flex-direction: column;
+          justify-content: space-between;
           .right-title {
             margin-bottom: 20rpx;
             font-size: 27rpx;

+ 124 - 32
pages/index/index.vue

@@ -1,6 +1,10 @@
 <template>
   <view class="content">
-	<top-title :titleValue="title" :pageScroll="scrollVal" style="width: 100%;"></top-title> 
+    <top-title
+      :titleValue="title"
+      :pageScroll="scrollVal"
+      style="width: 100%"
+    ></top-title>
     <view class="page-section-spacing" style="width: 100%; position: relative">
       <swiper
         class="swiper"
@@ -224,7 +228,9 @@
       <view class="notice-title-box">
         <view class="notice-font">区内活动</view>
         <view class="notice-more-font">
-          <view style="margin-right: 8rpx; font-size: 22rpx">更多</view>
+          <view style="margin-right: 8rpx; font-size: 22rpx" @click="goActive"
+            >更多</view
+          >
           <image
             src="/static/right-arrow-blue.png"
             mode="aspectFill"
@@ -238,11 +244,16 @@
         v-for="(item, index) in activityList"
         :key="index"
         style="justify-content: start; padding: 30rpx 0 30rpx 30rpx"
+        @click="goActiveDeatil(item.id)"
       >
         <image
           :src="item.url"
-          mode="aspectFit"
-          style="width: 128rpx; height: 128rpx; margin-right: 20rpx"
+          style="
+            width: 112rpx;
+            height: 112rpx;
+            margin-right: 20rpx;
+            border-radius: 10%;
+          "
         ></image>
         <view class="notice-content" style="width: 70%">
           <view class="notice-content-font" style="white-space: break-spaces">{{
@@ -279,17 +290,17 @@
 
 <script>
 import md5 from "@/common/md5.js";
-import topTitle from '@/components/top-title/top-title.vue';
-import footTabs from '@/components/foot-tabs/footTabs.vue';
+import topTitle from "@/components/top-title/top-title.vue";
+import footTabs from "@/components/foot-tabs/footTabs.vue";
 export default {
-	components: {
-		'foot-tabs': footTabs,
-		'top-title': topTitle
-	},
+  components: {
+    "foot-tabs": footTabs,
+    "top-title": topTitle,
+  },
   data() {
     return {
-	  title:"Air企通",
-	  scrollVal:Number,
+      title: "Air企通",
+      scrollVal: Number,
       swiperList: [
         {
           img: "/static/swiper/swiper1.jpg",
@@ -394,24 +405,24 @@ export default {
         },
       ],
       activityList: [
-        {
-          url: "/static/activity/2.png",
-          title: "400场讲座,200门课程,免费送上门!就等你申请",
-          isOnline: 1,
-          department: "区人力资源局",
-          time: "2021-09-05",
-          browe: "322",
-          share: "2",
-        },
-        {
-          url: "/static/activity/1.png",
-          title: "智能制造商标品牌培育系列培训活动",
-          isOnline: 0,
-          department: "市场监督管理局",
-          time: "2021-09-05",
-          browe: "322",
-          share: "2",
-        },
+        // {
+        //   url: "/static/activity/2.png",
+        //   title: "400场讲座,200门课程,免费送上门!就等你申请",
+        //   isOnline: 1,
+        //   department: "区人力资源局",
+        //   time: "2021-09-05",
+        //   browe: "322",
+        //   share: "2",
+        // },
+        // {
+        //   url: "/static/activity/1.png",
+        //   title: "智能制造商标品牌培育系列培训活动",
+        //   isOnline: 0,
+        //   department: "市场监督管理局",
+        //   time: "2021-09-05",
+        //   browe: "322",
+        //   share: "2",
+        // },
       ],
     };
   },
@@ -422,7 +433,7 @@ export default {
     this.getSwiperList();
     this.getPark();
     this.getNotice();
-	console.log(getApp().global)
+    this.getActive();
     //this.getAttract(); //招商接口
   },
   onShareAppMessage() {
@@ -630,6 +641,77 @@ export default {
         },
       });
     },
+    getActive() {
+      let md5Sign = md5(
+        "method=" +
+          "common" +
+          "&timestamp=" +
+          getApp().globalData.globalTimestamp +
+          "&secret=" +
+          getApp().globalData.secret
+      );
+      let url =
+        getApp().globalData.shareUrl +
+        "api/api.php" +
+        "?method=common&source=activity&action=list&timestamp=" +
+        getApp().globalData.globalTimestamp +
+        "&sign=" +
+        md5Sign;
+      let postData = {
+        page: 1,
+        page_size: 15,
+      };
+      uni.request({
+        url: url,
+        method: "POST",
+        header: {
+          "content-type": "application/x-www-form-urlencoded",
+        },
+        data: postData,
+        success: (res) => {
+          console.log(res);
+          if (res.data.code === 200) {
+            let list = res.data.data.list;
+            this.activityList = list.map((item) => {
+              /*
+                  url: "/static/activity/2.png",
+            title: "智能制造商标品牌培育系列培训活动",
+            way: "市场监督管理局",
+            date: "2021-08-07",
+            read: 322,
+            share: 1,
+            type: 0, //0线下
+             */
+              let ob = {
+                url: "",
+                title: "",
+                department: "",
+                time: "",
+                browe: 0,
+                share: 0,
+                type: "",
+                id: "",
+              };
+              ob.url = getApp().globalData.shareUrl + item.pic_url;
+              ob.title = item.name;
+              ob.department = item.sponsor;
+              ob.time = this.$options.filters["globalTime"](item.start_time);
+              ob.browe =
+                parseInt(item.base_read_count) + parseInt(item.real_read_count);
+              ob.share =
+                parseInt(item.real_repost_count) +
+                parseInt(item.base_repost_count);
+              ob.isOnline = item.type == 1 ? 1 : 0;
+              ob.id = item.id;
+              return ob;
+            });
+          }
+        },
+        fail: () => {
+          console.log("连接失败");
+        },
+      });
+    },
     goParkDetailFn(id) {
       uni.navigateTo({
         url: "/pages/park/park_deatil?id=" + id,
@@ -645,6 +727,11 @@ export default {
         url: "/pages/attract/attract_deatil?id=" + id,
       });
     },
+    goActiveDeatil(id) {
+      uni.navigateTo({
+        url: "/pages/activity/activity_deatil?id=" + id,
+      });
+    },
     goAttract() {
       uni.navigateTo({
         url: "/pages/attract/index",
@@ -655,9 +742,14 @@ export default {
         url: "/pages/notice/index",
       });
     },
+    goActive() {
+      uni.navigateTo({
+        url: "/pages/activity/index",
+      });
+    },
   },
   onPageScroll(e) {
-	this.scrollVal = e.scrollTop;
+    this.scrollVal = e.scrollTop;
   },
 };
 </script>