淘宝小程序
淘宝小程序跳转外部链接
小程序端
my.call("navigateToOutside", {
url: 'https://detail.tmall.com/item.htm?id=' + globalData.itemId,
})
千牛端
my.qn.navigateToWebPage({
url: "https://fuwu.taobao.com/ser/detail.htm?service_code=FW_GOODS-1001096584&code=FW_GOODS-1001096584",
success: res => {
},
fail: res => {
}
});
请求方法封装
app.js中
//公共HTTP请求
async HttpAPI(path, method = 'GET', params = '', body = {},exts={}) {
try {
let res = await cloud.application.httpRequest({
'path': path,
'method': method,
'headers': {
"mc-dd": "test",
"content-type": "application/json",
},
'params': params,
'body': body,
'exts':exts
})
console.log(`${path}请求成功`, res)
return res
} catch (error) {
my.showToast({
content: '' + error,
});
console.log(`${path}请求失败------HttpAPI==error-------`, error)
}
},
组件中使用
const app = getApp();
const { HttpAPI } = app;
let result = await HttpAPI('crm-service-taobao/api/v2.1/interactionInstance/search', 'POST', app.globalData.paramsObj, obj)
链接转二维码
安装依赖 ym-ui-library
引用:
json文件中
{
"component": true,
"usingComponents": {
"qrcode": "ym-ui-library/es/mf-qrcode/mf-qrcode"
}
}
使用
qrData: {str, w, h } str:生成二维码字符串, w:二维码宽, h: 二维码高,
千牛端需要将源码mf-qrcode.js中的比例 num改为1
<view a:if="{{qrData1.str==''?false:true}}" style="width:{{w}}px;height:{{h}}px">
<qrcode qrData="{{qrData1}}" />
</view>
手机端使用rpx
<view a:if="{{qrData1.str==''?false:true}}" style="width:{{w}}rpx;height:{{h}}rpx">
<qrcode qrData="{{qrData1}}" />
</view>