78 lines
2.0 KiB
Vue
Executable File
78 lines
2.0 KiB
Vue
Executable File
<template>
|
|
<button v-if="isShow" class="btn-normal" :open-type="setting.provider == 'mpwxkf' ? 'contact' : ''" @click="handleContact()">
|
|
<slot></slot>
|
|
</button>
|
|
</template>
|
|
|
|
<script>
|
|
import SettingKeyEnum from '@/common/enum/setting/Key'
|
|
import SettingModel from '@/common/model/Setting'
|
|
|
|
export default {
|
|
props: {
|
|
|
|
},
|
|
data() {
|
|
return {
|
|
isShow: false,
|
|
setting: {}
|
|
}
|
|
},
|
|
async created() {
|
|
// 是否显示在线客服按钮
|
|
this.isShow = await SettingModel.isShowCustomerBtn()
|
|
// 商城客服设置
|
|
this.setting = await SettingModel.item(SettingKeyEnum.CUSTOMER.value, true)
|
|
},
|
|
methods: {
|
|
|
|
// 在线客服
|
|
handleContact() {
|
|
const app = this
|
|
const { setting } = app
|
|
// 企业微信客服
|
|
if (setting.provider == 'wxqykf') {
|
|
if (!setting.config.wxqykf.url || !setting.config.wxqykf.corpId) {
|
|
this.$toast('客服链接和企业ID不能为空')
|
|
return
|
|
}
|
|
// #ifdef H5
|
|
window.open(setting.config.wxqykf.url)
|
|
// #endif
|
|
// #ifdef MP-WEIXIN
|
|
wx.openCustomerServiceChat({
|
|
extInfo: { url: setting.config.wxqykf.url },
|
|
corpId: setting.config.wxqykf.corpId,
|
|
success(res) {}
|
|
})
|
|
// #endif
|
|
// #ifdef APP-PLUS
|
|
uni.share({
|
|
provider: 'weixin',
|
|
scene: 'WXSceneSession',
|
|
type: 0,
|
|
openCustomerServiceChat: true,
|
|
corpid: setting.config.wxqykf.corpId,
|
|
customerUrl: setting.config.wxqykf.url,
|
|
success(res) {
|
|
console.log("success:" + JSON.stringify(res));
|
|
},
|
|
fail(e) {
|
|
console.log('errCode', e.errCode, e)
|
|
if (e.errCode === -8) {
|
|
app.$toast('很抱歉,您的手机没有安装微信~')
|
|
}
|
|
}
|
|
})
|
|
// #endif
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
</style>
|