评论

第三方平台常坑之:设置用户隐私保护指引

第三方平台开发小技巧之一。

第三方平台的设置用户隐私保护指引,经常有人过不去,以下代码仅供参考。

const privacy_desc_list = [
  { privacy_key: "UserInfo", privacy_desc: "订单中显示用户信息" },
  { privacy_key: "Location", privacy_desc: "订单配送中显示位置信息" },
  { privacy_key: "Address", privacy_desc: "收件人微信地址" },
  { privacy_key: "Invoice", privacy_desc: "打印订单发票" },
  { privacy_key: "RunData", privacy_desc: "显示微信运动数据" },
  { privacy_key: "Record", privacy_desc: "用户语音留言" },
  { privacy_key: "Album", privacy_desc: "店家上传产品图片" },
  { privacy_key: "Camera", privacy_desc: "店家拍摄产品图片" },
  { privacy_key: "PhoneNumber", privacy_desc: "收件人通过手机号确认订单" },
  { privacy_key: "Contact", privacy_desc: "将收件人地址写入微信地址簿" },
  { privacy_key: "DeviceInfo", privacy_desc: "显示设备信息" },
  { privacy_key: "EXIDNumber", privacy_desc: "收件人身份证号码" },
  { privacy_key: "EXOrderInfo", privacy_desc: "显示订单信息" },
  { privacy_key: "EXUserPublishContent", privacy_desc: "用户留言发布内容" },
  { privacy_key: "EXUserFollowAcct", privacy_desc: "显示用户所关注账号" },
  { privacy_key: "EXUserOpLog", privacy_desc: "显示店家操作日志" },
  { privacy_key: "AlbumWriteOnly", privacy_desc: "用户保存订单信息" },
  { privacy_key: "LicensePlate", privacy_desc: "骑手自用车的车牌号" },
  { privacy_key: "BlueTooth", privacy_desc: "连接蓝牙扫码设备" },
  { privacy_key: "CalendarWriteOnly", privacy_desc: "订单过期提醒" },
  { privacy_key: "Email", privacy_desc: "收件人地址中的邮箱信息" },
  { privacy_key: "MessageFile", privacy_desc: "店家上传产品说明书" },
  { privacy_key: "ChooseLocation", privacy_desc: "用户选择地址位置" },
  { privacy_key: "Accelerometer", privacy_desc: "显示加速传感器信息" },
  { privacy_key: "Compass", privacy_desc: "显示磁场传感器信息" },
  { privacy_key: "DeviceMotion", privacy_desc: "显示方向传感器信息" },
  { privacy_key: "Gyroscope", privacy_desc: "显示陀螺仪传感器信息" },
  { privacy_key: "Clipboard", privacy_desc: "读取剪切板中的订单链接" }
]

  //隐私保护配置
  onSetPrivacy: async function () {
    let appid = this.data.doc._id
    let res = await wx.gd.cloud.callFunction({
      name: 'appApi',
      data: {
        uri: 'cgi-bin/component/getprivacysetting?access_token={token}',//获取小程序用户隐私保护指引
        appid,
        body: {
        }
      }
    })
    let privacy = {
      owner_setting: {
        contact_email: "xx@hotix.cn",
        notice_method: "弹窗",
        store_region: 1017
      },
      privacy_ver: 2,
      setting_list: []
    }
    let privacy_list = res?.result?.privacy_list || []
    privacy_list.forEach(v => {
      let desc = privacy_desc_list.find(u => u.privacy_key == v)
      if (desc) {
        privacy.setting_list.push({
          privacy_key: v,
          privacy_text: desc.privacy_desc
        })
      }
    })
    this.setData({
      privacy
    })
    res = await wx.gd.cloud.callFunction({
      name: 'appApi',
      data: {
        uri: 'cgi-bin/component/setprivacysetting?access_token={token}',//设置小程序用户隐私保护指引
        appid,
        body: privacy
      }
    })
    this.toast(res)//统一弹出错误信息
  },


以上代码仅供参考。

最后一次编辑于  2023-04-06  
点赞 0
收藏
评论

1 个评论

  • ⁰¹.₀₁fgs℘࿐
    ⁰¹.₀₁fgs℘࿐
    2023-12-19

    请问下我通过接口设置了安全隐私协了,在平台上怎么没有显示


    2023-12-19
    赞同
    回复
登录 后发表内容