158 行
3.6 KiB
Vue
158 行
3.6 KiB
Vue
<template>
|
|
<view class="grid-wap u-m-b-10 u-flex u-flex-wrap u-col-center" v-if="list.length">
|
|
<view class="grid-item u-flex-col u-row-center u-col-center" v-for="(menu, index) in gridList" :key="index"
|
|
@tap="jump(menu)">
|
|
<view v-if="menu.name != '在线客服'">
|
|
<image class="tool-img" :src="menu.image" mode="aspectFill"></image>
|
|
<view class="item-title">{{ menu.name }}</view>
|
|
</view>
|
|
<view v-else>
|
|
<!-- <button open-type="contact" class="wx-btn" style="border: none;background-color: #fff;line-height: 0;box-shadow: none;">
|
|
<image class="tool-img" :src="menu.image" mode="aspectFill"></image>
|
|
<view class="item-title">{{ menu.name }}</view>
|
|
</button> -->
|
|
<button @tap="openService" class="wx-btn"
|
|
style="border: none;background-color: #fff;line-height: 0;box-shadow: none;">
|
|
<image class="tool-img" :src="menu.image" mode="aspectFill"></image>
|
|
<view class="item-title">{{ menu.name }}</view>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
/**
|
|
* shGrid-宫格列表
|
|
* @property {Array} list - 宫格列表
|
|
*/
|
|
import {
|
|
mapGetters
|
|
} from 'vuex';
|
|
export default {
|
|
components: {},
|
|
data() {
|
|
return {
|
|
|
|
};
|
|
},
|
|
computed: {},
|
|
props: {
|
|
isLive: {
|
|
type: [String, Number],
|
|
default: 0
|
|
},
|
|
list: {
|
|
type: Array,
|
|
default: () => {
|
|
return [];
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters(['userInfo']),
|
|
gridList() {
|
|
if (this.userInfo.is_live == 1) {
|
|
return this.list
|
|
} else {
|
|
return this.list.filter(item => {
|
|
return item.name != '开启直播'
|
|
})
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
console.log(this.gridList)
|
|
},
|
|
methods: {
|
|
jump(data) {
|
|
if (data.name == '我的预约' && data.path === '') {
|
|
data.path = '/pages/user/rob-order';
|
|
}
|
|
if (data.name == '开启直播' && data.path === '') {
|
|
data.path = '/pages/user/live';
|
|
}
|
|
if (data.name === '在线客服') {
|
|
return false;
|
|
}
|
|
this.$tools.routerTo(data.path);
|
|
},
|
|
openService() {
|
|
// #ifdef MP-WEIXIN
|
|
wx.openCustomerServiceChat({
|
|
extInfo: {
|
|
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a' // 客服地址链接
|
|
},
|
|
corpId: 'wwc5f08e271cf73fb2', // 必须和你小程序上的一致
|
|
success(res) {
|
|
console.log(res, 1)
|
|
},
|
|
fail(res) {
|
|
console.log(res, 2)
|
|
},
|
|
})
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
let wechat = null
|
|
plus.share.getServices(res => {
|
|
wechat = res.find(v => v.id === 'weixin')
|
|
if (wechat) {
|
|
wechat.openCustomerServiceChat({
|
|
corpid: 'wwc5f08e271cf73fb2', // 企业ID
|
|
url: 'https://work.weixin.qq.com/kfid/kfc5aec53d2111b588a', // 客服地址
|
|
}, res => {
|
|
console.log("success:", JSON.stringify(res))
|
|
}, err => {
|
|
console.log("error:", JSON.stringify(err))
|
|
})
|
|
} else {
|
|
uni.showToast({
|
|
title: '当前环境不支持微信操作',
|
|
icon: "error"
|
|
});
|
|
}
|
|
}, function() {
|
|
uni.showToast({
|
|
title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
|
|
icon: 'none'
|
|
})
|
|
});
|
|
// #endif
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.wx-btn::after {
|
|
border: none;
|
|
}
|
|
|
|
// 宫格
|
|
.grid-wap {
|
|
background: #fff;
|
|
width: 100%;
|
|
padding: 30rpx 0 0;
|
|
border-radius: 20rpx;
|
|
|
|
.grid-item {
|
|
width: 25%;
|
|
margin-bottom: 40rpx;
|
|
text-align: center;
|
|
|
|
.tool-img {
|
|
width: 44rpx;
|
|
height: 44rpx;
|
|
}
|
|
|
|
.item-title {
|
|
font-size: 26rpx;
|
|
font-weight: 500;
|
|
color: rgba(153, 153, 153, 1);
|
|
line-height: 24rpx;
|
|
padding-top: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
</style> |