l***@163.com
l***@163.com
  • 发布:2022-05-05 15:01
  • 更新:2022-08-15 10:39
  • 阅读:578

uniapp 开发该如何接入支付宝生活号?

分类:uni-app
uniapp 开发该如何接入支付宝生活号?  

1.我在自定义组件中使用 lifestyle , 但在开发者工具中不会展示该元素。  

<template>  
  <view class="AlipayLifeServe">  
    <lifestyle v-if="canUse" :publicId="appIdComputed" />  
    <view v-else>请升级支付宝支持关注生活号组件</view>  

    <!-- <button open-type="lifestyle" :publicId="appIdComputed">关注</button> -->  
  </view>  

</template>  

<script>  
export default {  
  name: 'AlipayLifeServe',  
  props: {  
    config: {  
      type: Object,  
      default() {  
        return {};  
      },  
    },  
  },  
  data() {  
    return {  
      canUse: my.canIUse('lifestyle'),  
    };  
  },  
  mounted() {  
    console.log('this. canUse', this.canUse); // true  
    console.log('my.SDKVersion', my.SDKVersion); // 2.7.9  
  },  
  computed: {  
    appIdComputed() {  
      console.log('this.config.data.content', this.config.data.content); // 202xxx3127xxxxxx  
      return this.config.data.content;  
    },  
  },  
};  
</script>  

<style></style>
2022-05-05 15:01 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

添加 支付宝小程序 条件编译看下

  • l***@163.com (作者)

    您好, 我尝试将代码修改成:


    <template>  
    <!-- #ifdef MP-ALIPAY -->
    <view class="AlipayLifeServe">
    <button open-type="lifestyle" v-if="canUse" :publicId="appIdComputed" @click="handleClick">关注</button>

    <lifestyle :public-id="appIdComputed" />
    <!-- <view v-else>请升级支付宝支持关注生活号组件</view> -->

    <life-follow :scene-id="testId" onCheckFollow="checkFollowCb" onClose="closeCb" />
    </view>

    <!-- #endif -->
    </template>

    结果是:


    lifestyle元素即不能在支付宝开发者工具中渲染也不能在真机上显示;而我下方的测试代码life-follow元素可以在真机中显示但不能在支付宝开发者工具中渲染。


    请问您还有其他思路可以提供吗?

    2022-05-05 18:12

1***@qq.com

1***@qq.com

同问,请问楼主解决了吗?

要回复问题请先登录注册