// 2 лет назад
Родитель
Сommit
8e94431d6f
6 измененных файлов с 73 добавлено и 19 удалено
  1. 2 0
      api/activity.js
  2. 1 1
      app.json
  3. 24 16
      pages/activityDet/index.js
  4. 22 1
      pages/greeting/index.js
  5. 1 1
      pages/greeting/index.wxml
  6. 23 0
      project.private.config.json

+ 2 - 0
api/activity.js

@@ -8,6 +8,8 @@ module.exports = {
   getActivityInfo: data => request(`/card/activity/template/${data}`, 'get'),
   // 获取贺卡作品
   getMyActivity: data => request('/card/activity/my', 'get', data),
+  // 获取单条贺卡作品
+  getOneActivity: data => request(`/card/activity/cardRead/${data}`, 'get'),
   // 保存贺卡
   saveActivity: data => request('/card/activity', 'post', data),
   // 触发播放音频埋点

+ 1 - 1
app.json

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

+ 24 - 16
pages/activityDet/index.js

@@ -1,5 +1,6 @@
 import {
   getActivityInfo,
+  getShareText,
   saveActivity
 } from '~/api/activity'
 /*微信录音*/
@@ -28,7 +29,20 @@ Page({
     greeting: [],
     // 是否更改过头像
     changeAvatarFlag: false,
-    greetingCard: null,
+    greetingCard: {
+      audioPath: "https://reader-wx.ai160.com/reader/resource/20230111/1673407488488535.mp3",
+      cardUrl: "https://reader-wx.ai160.com/reader/resource/20230111/1673407490510737.png",
+      duration: 6,
+      gmtCreated: null,
+      gmtModified: null,
+      id: 1673407492033889,
+      likeAmount: null,
+      playAmount: null,
+      status: null,
+      templateId: 50,
+      templateName: "",
+      uid: "9db2bedb2b9b47c5b0358bb9bec39145"
+    },
     userAudioState: false,
     // 当前音频播放时长
     playTime: '00:00',
@@ -224,13 +238,15 @@ Page({
   },
   // 生成活动图片
   createActivityImg(createType = 'share') {
-    return new Promise((resolve, reject) => {
-      let cardUrl = !this.data.greetingCard ? '' : this.data.greetingCard.cardUrl
-      if (cardUrl) {
+    return new Promise(async (resolve, reject) => {
+      if (createType == 'share') {
+        let title = await getShareText({
+          cardReadId: this.data.greetingCard.id
+        })
         resolve({
-          title: '请欣赏我的课文朗读作品,点赞+评论。',
-          path: `/pages/index/index`,
-          imageUrl: cardUrl
+          title,
+          path: `/pages/greeting/index?uid=${wx.getStorageSync('uid')}&cardId=${this.data.greetingCard.id}`,
+          imageUrl: this.data.greetingCard.cardUrl
         })
       }
       let context = wx.createSelectorQuery();
@@ -263,15 +279,7 @@ Page({
                 wx.canvasToTempFilePath({
                   canvas: canvas,
                   success(res) {
-                    if (createType == 'share') {
-                      resolve({
-                        title: '请欣赏我的课文朗读作品,点赞+评论。',
-                        path: `/pages/index/index`,
-                        imageUrl: res.tempFilePath
-                      })
-                    } else {
-                      resolve(res.tempFilePath)
-                    }
+                    resolve(res.tempFilePath)
                   },
                   fail(res) {
                     reject()

+ 22 - 1
pages/greeting/index.js

@@ -1,5 +1,6 @@
 import {
   getMyActivity,
+  getOneActivity,
   thumbsUp,
   deleteActivity,
   getShareText,
@@ -14,7 +15,10 @@ Page({
     pageNo: 1,
     totalSize: 0,
     list: [],
+    // 当前用户id
     uid: '',
+    // 贺卡作者id
+    userId: '',
     playAudioId: null,
     // 当前音频播放时长
     playTime: '00:00',
@@ -26,7 +30,15 @@ Page({
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad(options) {
+  async onLoad(options) {
+    console.log(options);
+    if (options.cardId) {
+      let oneCard = await getOneActivity(options.cardId)
+      this.setData({
+        list: oneCard ? [oneCard] : [],
+        userId: options.uid
+      })
+    }
     this.getMyActivity()
     this.setData({
       uid: wx.getStorageSync('uid')
@@ -47,15 +59,24 @@ Page({
       list,
       totalSize
     } = await getMyActivity({
+      userUid: this.data.userId ? this.data.userId : this.data.uid,
       pageNo: this.data.pageNo,
       pageSize: 6
     })
+    if (this.data.userId) {
+      let firstCard = this.data.list.length>0?this.data.list[0]:''
+      console.log(firstCard);
+      list = list.filter(item => {
+        return item.id != firstCard.id
+      })
+    }
     list = [...this.data.list, ...list]
     let isMy = false
     if (list.length > 0) {
       isMy = list[0].uid == wx.getStorageSync('uid')
     }
     this.setData({
+      isMy,
       list,
       totalSize
     })

+ 1 - 1
pages/greeting/index.wxml

@@ -35,7 +35,7 @@
         <button class="resetBtn" open-type="share" data-item='{{item}}' wx:if="{{isMy}}">
           <image src="http://reader-wx.ai160.com/images/reader/card/send_blessings.png" class="btn" />
         </button>
-        <button class="resetBtn" open-type="share" data-img='{{item.cardUrl}}' wx:if="{{!isMy}}">
+        <button class="resetBtn" open-type="share" data-item='{{item}}' wx:if="{{!isMy}}">
           <image src="http://reader-wx.ai160.com/images/reader/card/show_off.png" class="btn" />
         </button>
         <image src="http://reader-wx.ai160.com/images/reader/card/wyyw.png" class="btn" wx:if="{{!isMy}}"

+ 23 - 0
project.private.config.json

@@ -0,0 +1,23 @@
+{
+    "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+    "condition": {
+        "miniprogram": {
+            "list": [
+                {
+                    "name": "",
+                    "pathName": "pages/activityDet/index",
+                    "query": "id=50",
+                    "launchMode": "default",
+                    "scene": null
+                },
+                {
+                    "name": "",
+                    "pathName": "pages/greeting/index",
+                    "query": "uid=9db2bedb2b9b47c5b0358bb9bec39145&cardId=1673425305206207",
+                    "launchMode": "default",
+                    "scene": null
+                }
+            ]
+        }
+    }
+}