如何修改动态消息?
发布于 4 年前 作者 mshen 10563 次浏览 来自 官方Issues
我是这么用的:

            wx.cloud.callFunction({
                name: 'CreateActivity'
            }).then(succ => {
                console.log('CreateActivity', succ);
                let activityId = succ.result;
                Global.UNG.Temp.ActivityId = activityId;
                wx.updateShareMenu({
                    withShareTicket: true,
                    isUpdatableMessage: true,
                    // isPrivateMessage: true,
                    activityId: activityId, // 活动 ID
                    templateInfo: {
                        parameterList: [{
                            name: 'member_count',
                            value: '1'
                        }, {
                            name: 'room_limit',
                            value: '2'
                        }]
                    }
                });
                WeAppService.shareAppMessage({
                    title: '{}想和你进行决斗 (比赛:{})'.format(nickname, r),
                    imageUrl: 'wx-res/share_225_180.png',
                    query: `stageId=${stageId}&roomKey=${roomKey}&gameuidv2=${gameuidv2}&nn=${nickname}&lv=${lv}&avatar=${avatar}&avatarUrl=${avatarUrl}`,
                });
            });

我遇到的问题是动态消息没法修改
不知道哪里错了,返回ok:

// 云函数入口函数
exports.main = async (event, context) => {

  return new Promise((resolve, reject) => {
    let { userInfo, activityId } = event
    cloud.openapi.updatableMessage.setUpdatableMsg({
      activityId: activityId,
      targetState: 1,
      templateInfo: {
        parameterList: [{
          name: 'member_count',
          value: '2'
        }, {
          name: 'room_limit',
          value: '2'
        }]
      }
    }).then(_ => {
      resolve(_);
    }).catch(err => {
      reject(err);
    });
  });
}
1 回复

找到答案了:

如果需要targetState:1 (已完成)状态。那么parameterList里面需要参数path和version_type。(昨天没看清文档)

但我还是不太清楚微信设计这两个参数必填有何用意?

    cloud.openapi.updatableMessage.setUpdatableMsg({
      activityId: activityId,
      targetState: 1,
      templateInfo: {
        parameterList: [{
          name: 'path',
          value: 'closed=1'
        }, {
          name: 'version_type',
          value: 'develop'
        }]
      }
    }).then(_ => {
      resolve(_);
    }).catch(err => {
      reject(err);
    });
回到顶部