// 1 рік тому
батько
коміт
af0c0242f4
4 змінених файлів з 48 додано та 70 видалено
  1. 6 0
      api/activity.js
  2. 2 2
      app.json
  3. 31 21
      pages/activityDet/index.js
  4. 9 47
      pages/greeting/index.js

+ 6 - 0
api/activity.js

@@ -6,4 +6,10 @@ module.exports = {
     getActivityList: data => request('/card/activity', 'get', data),
     // 获取贺卡详情
     getActivityInfo: data => request(`/card/activity/template/${data}`, 'get'),
+    // 获取贺卡作品
+    getMyActivity: data => request('/card/activity/my', 'get', data),
+    // 点赞
+    thumbsUp: data => request(`/card/activity/like/${data}`, 'get'),
+    // 删除作品
+    deleteActivity: data => request(`card/activity/delete/${data}`, 'get'),
 }

+ 2 - 2
app.json

@@ -1,8 +1,8 @@
 {
     "pages": [
-        "pages/activityDet/index",
-        "pages/activityList/index",
         "pages/greeting/index",
+        "pages/activityList/index",
+        "pages/activityDet/index",
         "pages/index/index",
         "pages/login/login",
         "pages/my/index",

+ 31 - 21
pages/activityDet/index.js

@@ -20,26 +20,36 @@ Page({
         })
     },
     play() {
-        this.setData({
-            state: true
-        })
-        let countDown = 20
-        // 一分钟倒计时
-        let dsq = setInterval(item => {
-            if (countDown == 1) {
-                clearInterval(dsq)
-            }
-            if (countDown % 10 == 0) {
-                this.setData({
-                    tens: --this.data.tens,
-                    bits: 9
-                })
-            } else {
-                this.setData({
-                    bits: --this.data.bits
-                })
-            }
-            --countDown
-        }, 1000)
+        let dsq
+        if (!this.data.state) {
+            this.setData({
+                state: true
+            })
+            let countDown = 20
+            // 一分钟倒计时
+            dsq = setInterval(item => {
+                if (countDown == 1) {
+                    clearInterval(dsq)
+                }
+                if (countDown % 10 == 0) {
+                    this.setData({
+                        tens: --this.data.tens,
+                        bits: 9
+                    })
+                } else {
+                    this.setData({
+                        bits: --this.data.bits
+                    })
+                }
+                --countDown
+            }, 1000)
+        } else {
+            clearInterval(dsq)
+            this.setData({
+                state: false,
+                tens: 2,
+                bits: 0
+            })
+        }
     }
 })

+ 9 - 47
pages/greeting/index.js

@@ -1,4 +1,8 @@
-// pages/greeting/index.js
+import {
+    getMyActivity,
+    thumbsUp,
+    deleteActivity
+} from '~/api/activity'
 Page({
 
     /**
@@ -12,54 +16,12 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-
+        this.getMyActivity()
     },
-
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {
-
+    async getMyActivity() {
+        let res = await getMyActivity()
+        console.log(res);
     },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
-    },
-
-    /**
-     * 用户点击右上角分享
-     */
     onShareAppMessage() {
 
     }