| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 |
- <template>
- <view v-show="!isSortType && menus.length">
- <common-wrapper :config="configData" :style="[boxContentStyle]">
- <view>
- <view
- class="menu-header"
- v-if="
- headerConfig.enable && (leftTopText.enable || rightTopText.enable)
- "
- :style="[headerBoxStyle]"
- >
- <text
- class="left-text"
- v-if="leftTopText.enable"
- :style="[leftTextStyle]"
- >
- {{ leftTopText.text }}
- </text>
- <view
- class="right-text"
- v-if="rightTopText.enable"
- :style="[rightTextStyle]"
- @click="goMenuPage(rightTopText.link, item)"
- >
- {{ rightTopText.text }}
- <text
- class="iconfont icon-xiangyou"
- v-if="rightTopText.text && rightTopText.link"
- :style="[rightIconStyle]"
- ></text>
- </view>
- </view>
- <!-- 列表样式 -->
- <view class="list-menu" v-if="menuStyleConfig === 2">
- <view class="list-item" v-for="(item, index) in menus" :key="index">
- <view
- v-if="
- !item.routine_contact_type ||
- item.info[1].value !== '/pages/extension/customer_list/chat'
- "
- class="list-item-content"
- @click="goMenuPage(item.info[1].value)"
- >
- <view class="list-img-box" v-if="navDisplayStyle !== 2">
- <block v-if="listStyle == 0">
- <easy-loadimage
- v-if="item.img"
- :image-src="item.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- <view class="list-empty-box" v-else>
- <image
- src="/static/images/shan.png"
- mode="aspectFill"
- ></image>
- </view>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', item.icon]"
- :style="[iconContentStyle]"
- ></view>
- <text v-if="item.num" class="num">{{ item.num }}</text>
- </view>
- </block>
- </view>
- <view
- class="list-text"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >
- {{ item.info[0].value }}
- </view>
- </view>
- <template v-else>
- <!-- #ifdef MP -->
- <button
- class="list-item-content"
- open-type="contact"
- v-if="item.routine_contact_type"
- >
- <view class="list-img-box" v-if="navDisplayStyle !== 2">
- <block v-if="listStyle == 0">
- <easy-loadimage
- v-if="item.img"
- :image-src="item.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- <view class="list-empty-box" v-else>
- <image
- src="/static/images/shan.png"
- mode="aspectFill"
- ></image>
- </view>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', item.icon]"
- :style="[iconContentStyle]"
- ></view>
- <text v-if="item.num" class="num">{{ item.num }}</text>
- </view>
- </block>
- </view>
- <view
- class="list-text"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >
- {{ item.info[0].value }}
- </view>
- </button>
- <!-- #endif -->
- </template>
- <text class="iconfont icon-xiangyou list-arrow"></text>
- </view>
- </view>
- <!-- 宫格/排列样式 -->
- <view v-else>
- <view class="swiper" v-if="isShowConfig">
- <swiper
- :interval="3000"
- :duration="500"
- :style="'height:' + navHigh + 'px;'"
- @change="bannerfun"
- >
- <block>
- <swiper-item v-for="(item, indexw) in menuList" :key="indexw">
- <view
- class="menu"
- :id="'nav' + indexw"
- :class="{
- 'grid-three': menuStyleConfig === 1 && gridStyle === 0,
- 'grid-four': menuStyleConfig === 1 && gridStyle === 1,
- }"
- :style="[gridContainerStyle]"
- >
- <template v-for="(itemn, indexn) in item.list">
- <view
- v-if="
- !itemn.routine_contact_type ||
- itemn.info[1].value !==
- '/pages/extension/customer_list/chat'
- "
- class="flex-col flex-center"
- :class="{
- 'grid-item': menuStyleConfig === 1,
- }"
- :key="indexn"
- @click="goMenuPage(itemn.info[1].value)"
- :style="[gridItemContentStyle]"
- >
- <view
- class="pictrue skeleton-radius"
- v-if="navDisplayStyle !== 2"
- >
- <block v-if="listStyle == 0">
- <easy-loadimage
- :image-src="itemn.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', itemn.icon]"
- :style="[iconContentStyle]"
- ></view>
- <text v-if="itemn.num" class="num">{{
- itemn.num
- }}</text>
- </view>
- </block>
- </view>
- <view
- class="fs-24"
- :class="{ 'mt-10': listStyle === 0 }"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >{{ itemn.info[0].value }}</view
- >
- </view>
- <template v-else>
- <!-- #ifdef MP -->
- <button
- class="flex-col flex-center reset-btn"
- :class="{
- 'grid-item': menuStyleConfig === 1,
- }"
- :key="'btn_' + indexn"
- open-type="contact"
- v-if="itemn.routine_contact_type"
- :style="[gridItemContentStyle]"
- >
- <view
- class="pictrue skeleton-radius"
- v-if="navDisplayStyle !== 2"
- >
- <block v-if="listStyle == 0">
- <easy-loadimage
- :image-src="itemn.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', itemn.icon]"
- :style="[iconContentStyle]"
- ></view>
- <text v-if="itemn.num" class="num">{{
- itemn.num
- }}</text>
- </view>
- </block>
- </view>
- <view
- class="fs-24"
- :class="{ 'mt-10': listStyle === 0 }"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >{{ itemn.info[0].value }}</view
- >
- </button>
- <!-- #endif -->
- </template>
- </template>
- </view>
- </swiper-item>
- </block>
- </swiper>
- </view>
- <view v-else>
- <view
- class="menu"
- :class="{
- 'grid-three': menuStyleConfig === 1 && gridStyle === 0,
- 'grid-four': menuStyleConfig === 1 && gridStyle === 1,
- }"
- :style="[gridContainerStyle]"
- >
- <template v-for="(item, index) in menus">
- <view
- v-if="
- !item.routine_contact_type ||
- item.info[1].value !== '/pages/extension/customer_list/chat'
- "
- class="flex-col flex-center"
- :class="{
- 'grid-item': menuStyleConfig === 1,
- }"
- :key="index"
- @click="goMenuPage(item.info[1].value)"
- :style="[gridItemContentStyle]"
- >
- <view
- class="pictrue skeleton-radius"
- v-if="navDisplayStyle !== 2"
- >
- <block v-if="listStyle == 0">
- <easy-loadimage
- :image-src="item.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', item.icon]"
- :style="[iconContentStyle]"
- ></view>
- <!-- 角标数量 -->
- <text v-if="item.num" class="num">{{ item.num }}</text>
- </view>
- </block>
- </view>
- <view
- class="fs-24"
- :class="{ 'mt-10': listStyle === 0 }"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >{{ item.info[0].value }}</view
- >
- </view>
- <template v-else>
- <!-- #ifdef MP -->
- <button
- class="flex-col flex-center reset-btn"
- :class="{
- 'grid-item': menuStyleConfig === 1,
- }"
- :key="'btn_' + index"
- open-type="contact"
- v-if="item.routine_contact_type"
- :style="[gridItemContentStyle]"
- >
- <view
- class="pictrue skeleton-radius"
- v-if="navDisplayStyle !== 2"
- >
- <block v-if="listStyle == 0">
- <easy-loadimage
- :image-src="item.img"
- width="90rpx"
- height="90rpx"
- :borderRadius="imgStyle"
- ></easy-loadimage>
- </block>
- <block v-else>
- <view class="icon-box" :style="[iconBoxStyle]">
- <view
- :class="['iconfont', item.icon]"
- :style="[iconContentStyle]"
- ></view>
- <!-- 角标数量 -->
- <text v-if="item.num" class="num">{{
- item.num
- }}</text>
- </view>
- </block>
- </view>
- <view
- class="fs-24"
- :class="{ 'mt-10': listStyle === 0 }"
- :style="[textColor]"
- v-if="navDisplayStyle !== 1"
- >{{ item.info[0].value }}</view
- >
- </button>
- <!-- #endif -->
- </template>
- </template>
- </view>
- </view>
- <view
- class="dot acea-row row-center-wrapper"
- v-if="menuList.length > 1 && isShowConfig"
- >
- <view
- class="dot-item line_dot-item"
- :style="[getDotStyle(index)]"
- v-for="(item, index) in menuList"
- :key="index"
- ></view>
- </view>
- </view>
- </view>
- </common-wrapper>
- </view>
- </template>
- <script>
- import commonWrapper from "./commonWrapper.vue";
- import { getCustomer } from "@/utils/index.js";
- import { toLogin } from "@/libs/login.js";
- import { mapGetters } from "vuex";
- export default {
- components: { commonWrapper },
- name: "menus",
- props: {
- dataConfig: {
- type: Object,
- default: () => {},
- },
- isSortType: {
- type: String | Number,
- default: 0,
- },
- },
- data() {
- return {
- navHigh: 0,
- menuList: [],
- active: 0,
- };
- },
- computed: {
- ...mapGetters({
- isLogin: "isLogin",
- }),
- rowsNum() {
- return this.dataConfig.rowsNum.tabVal;
- },
- number() {
- return this.dataConfig.number.tabVal;
- },
- configData() {
- return {
- ...this.dataConfig,
- };
- },
- menus() {
- let list = this.dataConfig.menuConfig.list || [];
- let menuList = [];
- list.forEach((item) => {
- if (item.show) {
- menuList.push(item);
- }
- });
- return menuList;
- },
- isShowConfig() {
- return this.dataConfig.showConfig.tabVal;
- },
- textColor() {
- return {
- color: this.dataConfig.textColor
- ? this.dataConfig.textColor.color[0].item
- : "#333",
- };
- },
- boxContentStyle() {
- let borderRadius = `${this.dataConfig.fillet.val * 2}rpx`;
- if (this.dataConfig.fillet.type) {
- borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${
- this.dataConfig.fillet.valList[1].val * 2
- }rpx ${this.dataConfig.fillet.valList[3].val * 2}rpx ${
- this.dataConfig.fillet.valList[2].val * 2
- }rpx`;
- }
- return {
- background: `linear-gradient(90deg, ${this.dataConfig.bgColor.color[0].item} 0%, ${this.dataConfig.bgColor.color[1].item} 100%)`,
- };
- },
- imgStyle() {
- let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
- if (this.dataConfig.filletImg.type) {
- borderRadius = `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${
- this.dataConfig.filletImg.valList[1].val * 2
- }rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${
- this.dataConfig.filletImg.valList[2].val * 2
- }rpx`;
- }
- return borderRadius;
- },
- //分几行展示,一行展示多少个
- gridColumns() {
- if (this.dataConfig.number.tabVal == 0) {
- return {
- gridTemplateColumns: "repeat(3, 1fr)",
- };
- } else if (this.dataConfig.number.tabVal == 1) {
- return {
- gridTemplateColumns: "repeat(4, 1fr)",
- };
- } else {
- return {
- gridTemplateColumns: "repeat(5, 1fr)",
- };
- }
- },
- menuStyleConfig() {
- return this.dataConfig.menuStyleConfig.tabVal;
- },
- dotColor() {
- return this.dataConfig.pointerBgColor.color[0].item;
- },
- dotSelectColor() {
- return this.dataConfig.pointerColor.color[0].item;
- },
- headerConfig() {
- return this.dataConfig.headerConfig || {};
- },
- leftTopText() {
- return this.dataConfig.leftTopText || {};
- },
- rightTopText() {
- return this.dataConfig.rightTopText || {};
- },
- headerStyle() {
- return this.dataConfig.headerStyle || {};
- },
- navDisplayStyle() {
- return this.dataConfig.navDisplayStyle
- ? this.dataConfig.navDisplayStyle.tabVal
- : 0;
- },
- gridStyle() {
- return this.dataConfig.gridStyle ? this.dataConfig.gridStyle.tabVal : 0;
- },
- gridItemStyle() {
- return (
- this.dataConfig.gridItemStyle || {
- itemPadding: 8,
- itemBgColor: "#ffffff",
- itemRadius: 0,
- itemPaddingTop: 0,
- }
- );
- },
- listStyle() {
- return this.dataConfig.menuConfig.listStyle || 0;
- },
- iconStyleConfig() {
- let iconConfig = this.dataConfig.iconStyleConfig || {};
- return {
- color: iconConfig.color ? iconConfig.color.color[0].item : "#333",
- size: iconConfig.size ? iconConfig.size.val : 24,
- position: iconConfig.position ? iconConfig.position.tabVal : 1,
- padding: iconConfig.padding ? iconConfig.padding.val : 0,
- rotate: iconConfig.rotate ? iconConfig.rotate.val : 0,
- shadow: iconConfig.shadow ? iconConfig.shadow.tabVal : 0,
- };
- },
- iconBoxStyle() {
- const position = this.iconStyleConfig.position;
- return {
- justifyContent:
- position === 0
- ? "flex-start"
- : position === 1
- ? "center"
- : "flex-end",
- };
- },
- headerBoxStyle() {
- return {
- paddingTop: this.headerStyle.topPadding * 2 + "rpx",
- paddingBottom: this.headerStyle.bottomPadding * 2 + "rpx",
- paddingLeft: this.headerStyle.leftRightPadding * 2 + "rpx",
- paddingRight: this.headerStyle.leftRightPadding * 2 + "rpx",
- };
- },
- leftTextStyle() {
- return {
- color: this.headerStyle.leftColor,
- fontSize: this.headerStyle.fontSize * 2 + "rpx",
- fontWeight: this.headerStyle.leftWeight,
- };
- },
- rightTextStyle() {
- return {
- color: this.headerStyle.rightColor,
- fontSize: (this.headerStyle.rightFontSize || 12) * 2 + "rpx",
- fontWeight: this.headerStyle.rightWeight,
- };
- },
- rightIconStyle() {
- return {
- fontSize: (this.headerStyle.rightFontSize || 12) * 2 + "rpx",
- };
- },
- iconContentStyle() {
- const config = this.iconStyleConfig;
- return {
- color: config.color,
- fontSize: config.size * 2 + "rpx",
- padding: config.padding * 2 + "rpx",
- transform: "rotate(" + config.rotate + "deg)",
- textShadow: config.shadow ? "0px 2px 4px rgba(0,0,0,0.2)" : "none",
- };
- },
- gridContainerStyle() {
- if (this.menuStyleConfig === 1) {
- return {
- padding: this.gridItemStyle.itemPadding * 2 + "rpx",
- };
- } else {
- return this.gridColumns;
- }
- },
- gridItemContentStyle() {
- if (this.menuStyleConfig === 1) {
- return {
- backgroundColor: this.gridItemStyle.itemBgColor,
- borderRadius: this.gridItemStyle.itemRadius * 2 + "rpx",
- paddingTop: this.gridItemStyle.itemPaddingTop * 2 + "rpx",
- paddingBottom: this.gridItemStyle.itemPaddingTop * 2 + "rpx",
- };
- } else {
- return {};
- }
- },
- },
- mounted() {
- this.getSwiperCount();
- this.$nextTick(() => {
- if (this.menuList.length && this.isShowConfig) {
- let that = this;
- // #ifdef H5
- that.menuHeight();
- // #endif
- // #ifndef H5
- setTimeout(() => {
- that.menuHeight();
- }, 150);
- // #endif
- }
- });
- },
- methods: {
- getSwiperCount() {
- /* rowsNum 显示行数 0: 1行 1: 2行 2: 3行 3 4行 */
- /* number 单行显示 0: 3个 1: 4个 2: 5个 */
- this.pageNum((this.rowsNum + 1) * (this.number + 3));
- },
- bannerfun(e) {
- this.active = e.detail.current;
- },
- menuHeight() {
- let that = this;
- const query = uni.createSelectorQuery().in(this);
- query
- .select("#nav0")
- .boundingClientRect((data) => {
- that.navHigh = data.height;
- })
- .exec();
- },
- pageNum(num) {
- let count = Math.ceil(this.menus.length / num);
- let goodArray = new Array();
- for (let i = 0; i < count; i++) {
- let list = this.menus.slice(i * num, i * num + num);
- if (list.length)
- goodArray.push({
- list: list,
- });
- }
- this.$set(this, "menuList", goodArray);
- },
- getDotStyle(index) {
- return {
- "background-color":
- this.active === index ? this.dotSelectColor : this.dotColor,
- };
- },
- menusTap(url) {
- this.$util.JumpPath(url);
- },
- goMenuPage(url) {
- if (this.isLogin) {
- if (url.indexOf("http") === -1) {
- if (url== "/kefu/mobile_list") {
- return uni.navigateTo({
- url: `/pages/annex/web_view/index?url=${location.origin}${url}`,
- });
- } else if (url == "/pages/extension/customer_list/chat") {
- return getCustomer(url);
- }
- uni.navigateTo({
- url: url,
- fail(err) {
- uni.switchTab({
- url: url,
- });
- },
- });
- } else {
- uni.navigateTo({
- url: `/pages/annex/web_view/index?url=${url}`,
- });
- }
- } else {
- toLogin();
- }
- },
- },
- };
- </script>
- <style lang="scss">
- .menu-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .right-text {
- display: flex;
- align-items: center;
- }
- }
- .dot {
- width: 100%;
- padding-bottom: 20rpx;
- .instruct {
- width: 50rpx;
- height: 36rpx;
- line-height: 36rpx;
- background-color: rgba(0, 0, 0, 0.8);
- color: #fff;
- border-radius: 16rpx;
- font-size: 24rpx;
- text-align: center;
- }
- .dot-item {
- width: 10rpx;
- height: 10rpx;
- background: rgba(0, 0, 0, 0.4);
- border-radius: 50%;
- margin: 0 4px;
- &.line_dot-item {
- width: 20rpx;
- height: 6rpx;
- border-radius: 3rpx;
- }
- }
- }
- .nav {
- .item {
- margin-right: 42rpx;
- width: 90rpx;
- text-align: center;
- font-size: 24rpx;
- display: inline-block;
- }
- }
- .menu {
- display: grid;
- grid-template-rows: auto;
- grid-row-gap: 24rpx;
- width: 100%;
- padding: 0 0 20rpx 0;
- }
- .swiper {
- z-index: 20;
- position: relative;
- overflow: hidden;
- swiper,
- .swiper-item {
- width: 100%;
- display: block;
- }
- }
- .list-menu {
- .list-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin: 0 24rpx;
- padding: 24rpx 0;
- border-bottom: 1rpx solid #eee;
- &:first-child {
- margin-top: 0;
- }
- &:last-child {
- border-bottom: none;
- margin-bottom: 0;
- }
- .list-item-content {
- display: flex;
- align-items: center;
- .list-img-box {
- margin-right: 20rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .list-text {
- font-size: 28rpx;
- }
- }
- .list-arrow {
- color: #999;
- font-size: 24rpx;
- }
- }
- }
- .icon-box {
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- width: 90rpx;
- height: 90rpx;
- }
- .num {
- position: absolute;
- top: 10rpx;
- right: 8rpx;
- height: 28rpx;
- min-width: 20rpx;
- padding: 4rpx 8rpx;
- line-height: 20rpx;
- text-align: center;
- font-size: 20rpx;
- color: #fff;
- background-color: #ff4444;
- border-radius: 50%;
- }
- .grid-three {
- grid-template-columns: repeat(3, 1fr) !important;
- }
- .grid-four {
- grid-template-columns: repeat(4, 1fr) !important;
- }
- .grid-item {
- width: 100%;
- }
- </style>
|