1.0.1 • Published 4 years ago
kwlib-re v1.0.1
Rate 全渠道评价
进入APP/小程序,调中台接口,接口返回当前用户在周期内是否有触发问题。用于推荐、搜索、商品、商详、支付成功等场景。
RateInit 初始化评价
参数
参数 | 说明 | 类型 | 必填 | 回调参数 | |
---|---|---|---|---|---|
config | 配置 | object | 否 | ||
>designWidth | 设计图尺寸 | number | 否 | ||
>deviceRatio | 缩放比例 | number | 否 | ||
params | 查询随机问题入参 | object | |||
>uid | uid | string | 否 | ||
>skey | skey | string | 否 | ||
>sceneId | 场景id | number | 是 | ||
>skuId | 规格id | number | 场景id为1101时,必须 | ||
>channelId | 渠道id | number | 场景id为1101时,必须 | ||
>entityId | 店id | number | 场景id为1101时,必须 | ||
>categoryId | 商品四级类目id | number | 场景id为1101时,必须 | ||
confirm | 发表评价回调 | function | - | 随机问题数据和评价成功或失败出参 | |
cancel | 取消评价回调 | function | - | - | 随机问题数据 |
close | 关闭评价弹窗回调 | function | - | - | 随机问题数据 |
queryQuestionSuccess | 查询随机问题成功回调 | function | - | 随机问题列表 |
h5 示例代码
import { rateInit } from 'kwlib-re/dist/main'
rateInit({
config: {
designWidth: 750,
deviceRatio: 1
},
params: {
uid,
skey,
sceneId,
skuId,
channelId,
entityId,
categoryId
},
confirm: (res) => {
console.log('确认评价', res)
},
cancel: (res) => {
console.log('取消评价', res)
},
close: () => {
console.log('关闭评价弹框')
},
queryQuestionSuccess: (res) => {
console.log('随机问题查询成功', res)
}
})
小程序示例代码
<view>
<rate id="J_rate" />
</view>
usingComponents: {
'rate': '../../components/Rate/index', // 路径 src/components/Rate/index
}
onLoad() {
// 原生
this.rate = this.selectComponent('#J_rate')
// wepy
this.rate = this.$wxpage.selectComponent('#J_rate')
}
onShow() {
this.rate.rateInit({
params: {
sceneId: 1101,
skuId: 20,
channelId: 1,
entityId: 8000,
categoryId: 1111
},
confirm: (res) => {
console.log('确认评价', res)
},
close: (res) => {
console.log('关闭评价弹框', res)
},
queryQuestionSuccess: (res) => {
console.log('随机问题查询成功', res)
}
})
}