|
@@ -0,0 +1,206 @@
|
|
|
+<template>
|
|
|
+ <div class="service-item-perch">
|
|
|
+ <template v-if="wxReady && item.linkUrlType == 2">
|
|
|
+ <div class="service-item">
|
|
|
+ <wx-open-launch-weapp :username="item.weappGhId" :path="item.weappPath">
|
|
|
+ <script type="text/wxtag-template">
|
|
|
+ <style>.media{ text-align:center; }.img { display:inline-block; width: 50px; height: 50px; object-fit: cover;}.title { font-size: 14px; height: 20px; line-height: 20px; margin-top: 3px; color:#2c3e50; text-align:center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }</style>
|
|
|
+ <div class="media"><img class="img" src="{{item.status === 1 ? item.serviceIcon : item.grayWechatIcon}}" alt=""></div>
|
|
|
+ <div class="title">{{item.serviceName}}</div>
|
|
|
+ </script>
|
|
|
+ </wx-open-launch-weapp>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="service-item" @click="onClick">
|
|
|
+ <img class="service-item-img" :src="item.status === 1 ? item.serviceIcon : item.grayWechatIcon" alt="" />
|
|
|
+ <div class="service-item-title">{{ item.serviceName }}</div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { setLocalforage, interceptorUrl } from '@/utils'
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ service: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({}),
|
|
|
+ },
|
|
|
+ wxReady: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['userInfo', 'org']),
|
|
|
+ item() {
|
|
|
+ const userInfo = this.userInfo
|
|
|
+ const v = { ...this.service }
|
|
|
+ // 微信跳转小程序标签
|
|
|
+ if (Number(v.linkUrlType) === 2) {
|
|
|
+ v.weappGhId = v.jumpAddress.split(';')[0]
|
|
|
+ v.weappAppId = v.jumpAddress.split(';')[1]
|
|
|
+ v.weappPath = v.jumpAddress.split(';')[2]
|
|
|
+ if (userInfo.userToken && v.weappPath) {
|
|
|
+ v.weappPath = interceptorUrl(v.weappPath, { userToken: userInfo.userToken })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 文本省略(兼容微信跳转小程序标签文本css省略不起作用)
|
|
|
+ v.serviceName = v.serviceName.length > 6 ? `${v.serviceName.slice(0, 5)}...` : v.serviceName
|
|
|
+
|
|
|
+ return v
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // TODO: 服务跳转业务
|
|
|
+ onClick() {
|
|
|
+ this.$emit('click', this.item)
|
|
|
+ this.externalLink(this.item)
|
|
|
+ },
|
|
|
+ /*
|
|
|
+ * 服务跳转业务
|
|
|
+ * @description
|
|
|
+ * userInfo.userType(用户类型) 0(普通用户(有企业信息的就称作白名单)), -1(游客), 2被禁用的白名单
|
|
|
+ * lowPower 是否低权限 0(游客不可操作), 1(游客可操作), 2(不需要登录)
|
|
|
+ * serviceLevel 服务级别 1-平台级;2-运营中心级;3-项目级
|
|
|
+ * isLinked 是否需要拼接参数 0-不需要;1-需要
|
|
|
+ * status 服务状态 0-下线;1-上线;2-灰度
|
|
|
+ * centrePower(中心权限) 1-是 0-否
|
|
|
+ * linkUrlType 跳转类型 0-内链,1-外链,2-小程序
|
|
|
+ * permissionControlType 权限控制类型 1-使用服务权限,2-使用身份权限
|
|
|
+ * enabled 权限控制类型 是否可用 1-可用 0-不可用
|
|
|
+ */
|
|
|
+ externalLink({
|
|
|
+ id,
|
|
|
+ jumpAddress: url,
|
|
|
+ serviceName: name,
|
|
|
+ linkUrlType,
|
|
|
+ lowPower,
|
|
|
+ status,
|
|
|
+ graySkipUrl,
|
|
|
+ serviceLevel,
|
|
|
+ permissionControlType,
|
|
|
+ enabled,
|
|
|
+ }) {
|
|
|
+ // console.log(url, lowPower, serviceLevel, 'url', 'lowPower', 'serviceLevel')
|
|
|
+
|
|
|
+ const userToken = this.userInfo.userToken
|
|
|
+ // 灰度链接
|
|
|
+ if (status === 2 && graySkipUrl) {
|
|
|
+ window.location.href = `${graySkipUrl}`
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 是否登录
|
|
|
+ if (!this.userInfo.isLogin && (lowPower === 1 || lowPower === 0)) {
|
|
|
+ setLocalforage('url', url)
|
|
|
+ setLocalforage('lowPower', lowPower)
|
|
|
+ return this.$router.push('/login')
|
|
|
+ } else {
|
|
|
+ setLocalforage('url', null)
|
|
|
+ setLocalforage('lowPower', null)
|
|
|
+ }
|
|
|
+
|
|
|
+ setLocalforage('accType', serviceLevel)
|
|
|
+ // 用户已经登录,跳转子服务,小程序逻辑
|
|
|
+ if (linkUrlType === 2) {
|
|
|
+ this.$dialog.alert({ title: '提示', message: '抱歉,暂时不能跳转小程序' })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 用户已经登录,跳转子服务,网页逻辑
|
|
|
+ const jumpH5Logic = () => {
|
|
|
+ const openLink = () => {
|
|
|
+ if (this.userInfo.isLogin) {
|
|
|
+ window.location.href = interceptorUrl(url, { userToken })
|
|
|
+ } else {
|
|
|
+ window.location.href = interceptorUrl(url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 权限控制为用户身份类型
|
|
|
+ if (permissionControlType === 2) {
|
|
|
+ if (!enabled) {
|
|
|
+ this.$dialog.alert({ title: '提示', message: '抱歉,您没有权限使用本服务' })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 针对运营中心级别项目,用户拥有运营中心权限
|
|
|
+ if (this.userInfo.centrePower && serviceLevel === 2 && url) {
|
|
|
+ openLink()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 针对运营中心级别项目,用户没有运营中心权限
|
|
|
+ if (!this.userInfo.centrePower && serviceLevel === 2) {
|
|
|
+ return this.$dialog.alert({
|
|
|
+ title: '提示',
|
|
|
+ message: '你没有运营中心操作权限',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 操作权限,用户必须登录且是白名单用户才允许访问
|
|
|
+ if (lowPower === 0 && this.userInfo.userType !== 0) {
|
|
|
+ this.$dialog.alert({ title: '提示', message: '你没有操作权限' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.userInfo.userType === 0 || (this.userInfo.userType === -1 && lowPower === 1) || lowPower === 2) {
|
|
|
+ if (name === '我的房屋') {
|
|
|
+ return this.$router.push('/service/myHouse/index')
|
|
|
+ }
|
|
|
+ if (name === '住户认证') {
|
|
|
+ return this.$router.push('/service/houseHold/index')
|
|
|
+ }
|
|
|
+ if (url) {
|
|
|
+ openLink()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$dialog.alert({
|
|
|
+ title: '提示',
|
|
|
+ message: '你没有操作权限',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 权限控制为用户身份类型
|
|
|
+ if (permissionControlType === 2) {
|
|
|
+ if (enabled) {
|
|
|
+ jumpH5Logic()
|
|
|
+ } else {
|
|
|
+ this.$dialog.alert({ title: '提示', message: '抱歉,您没有权限使用本服务', onHide() {} })
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 权限控制为服务权限(默认)
|
|
|
+ jumpH5Logic()
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.service-item {
|
|
|
+ width: 100%;
|
|
|
+ background: #fff;
|
|
|
+ text-align: center;
|
|
|
+ &-perch {
|
|
|
+ background: #eee;
|
|
|
+ height: 88px;
|
|
|
+ }
|
|
|
+ &-img {
|
|
|
+ width: 50px;
|
|
|
+ height: 50px;
|
|
|
+ object-fit: cover;
|
|
|
+ }
|
|
|
+ &-title {
|
|
|
+ font-size: 14px;
|
|
|
+ height: 20px;
|
|
|
+ line-height: 20px;
|
|
|
+ padding-bottom: 16px;
|
|
|
+ color: #333;
|
|
|
+ text-align: center;
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|