小程序的代码如下:
<view class="grid">
<view>服务</view>
<view class="btn-wrap">
<button class="btn-contact" open-type="contact" @bindcontact="handleContact" session-from="sessionFrom" :show-message-card="true">
<text class="iconfont icon-kefu icon-size" style="color: #9999ff"></text>
<view class="txt">联系客服</view>
</button>
<button class="btn-contact" open-type="share">
<text class="iconfont icon-yaoqinghaoyou1 icon-size" style="color: #79d279"></text>
<view class="txt">分享好友</view>
</button>
</view>
</view>
<!-- #endif -->
</view>
export default {
data() {
return {
userInfo: {},
hasLogin: false
};
},
onLoad() {
console.log("onLoad11111")
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
//#endif
},
onShow() {
if (uni.getStorageSync('hasLogin')) {
this.getUserInfo();
this.hasLogin = true;
}
},
onShareAppMessage(res) {
if (res.from === 'button') {
// 来自页面内分享按钮
console.log(res.target);
}
let imgURL = '/static/images/KXF-Logo.png';
return {
title: this.$c.miniappName,
path: '/pages/index/index',
imageUrl: imgURL
};
},
methods: {
toLogin() {
uni.navigateTo({
url: '/pages/login/login'
});
},
getUserInfo() {
this.$H.get('/wechat/getWeInfo').then(res => {
this.userInfo = res.data;
});
},
toNav(url) {
// uni.navigateTo({
// url: url
// })
},
handleContact(e) {
console.log("111111111111")
this.$log.info('打一些日志测试一下111111111111')
console.log(e)
console.log(e.detail.path)
console.log(e.detail.query)
const url = 'e.detail.path' + e.detail.query;
wx.navigateTo({ url });
}
},
};
测试过程中相应页面以及真机模式下显示的日志:
1,点击“联系客服”按钮
2,进入对话页面,触发产生了小程序链接。并点击小程序消息“小程序默认页”
消息包
调试页面内的JSON结果:
{
"ans_node_id": 43743334,
"ans_node_name": "给出小程序链接",
"answer": "{"miniprogrampage":{"title":"小程序默认页","appid":"wx46df5bfe8ca55cb9","pagepath":"pages/index/index","thumb_url":"https://chatbotassets-75050.gzc.vod.tencent-cloud.com/openaiassets_756cdca387ed915f54d3f4fcb51432b7.png"}}",
"answer_open": 1,
"answer_type": "text",
"article": "",
"bid_stat": null,
"confidence": 1,
"create_time": "1698806537",
"dialog_status": "END",
"dialog_session_status": "END",
"event": "",
"from_user_name": "o9U-85u7nwsZ6-eLvrm8Xk-kzUHU",
"intent_confirm_status": "",
"is_default_answer": false,
"list_options": false,
"options": null,
"msg": [
{
"ans_node_id": 43743334,
"ans_node_name": "给出小程序链接",
"article": "",
"confidence": 1,
"content": "{"miniprogrampage":{"title":"小程序默认页","appid":"wx46df5bfe8ca55cb9","pagepath":"pages/index/index","thumb_url":"https://chatbotassets-75050.gzc.vod.tencent-cloud.com/openaiassets_756cdca387ed915f54d3f4fcb51432b7.png"}}",
"debug_info": "",
"event": "",
"list_options": false,
"msg_type": "text",
"opening": "",
"options": null,
"request_id": 1698806537,
"scene_status": "",
"session_id": "0_773472|o9U-85u7nwsZ6-eLvrm8Xk-kzUHU",
"status": "GENERAL_FAQ",
"take_options_only": false,
"resp_title": "给出小程序链接"
}
],
"msg_id": "83f7a2f6",
"opening": "",
"request_id": 1698806537,
"ret": 0,
"scene_status": "",
"session_id": "0_773472|o9U-85u7nwsZ6-eLvrm8Xk-kzUHU",
"skill_id": "1288490190846398",
"skill_name": "给出小程序链接",
"slot_info": null,
"slots_info": null,
"status": "GENERAL_FAQ",
"take_options_only": false,
"title": "给出小程序链接",
"to_user_name": "773472",
"msgtype": "miniprogrampage",
"from_xwbrain": true,
"question": ""
}
问:在使用开发工具时发现模拟器上显示设备在线状态,而用手机扫描二维码预览时显示设备为离线状态?使用真机调试又是在线
问题已解决,在uniapp中要用@contact="handleContact"
您好,请问您是想小程序卡片跳转吗?
我看链接里有以下介绍,但是不成功。