Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【代码优化】SYSTEM:支付宝小程序兼容性:修复无法启动、tabbar与宫格组件无法点击、首页的自定义顶部导航栏与轮播图样式 #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mini.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"format": 2,
"compileOptions": {
"component2": true,
"enableNodeModuleBabelTransform": true,
"transpile": {},
"globalObjectMode": "enable"
}
}

1 change: 0 additions & 1 deletion pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</s-layout>
</view>
</template>

<script setup>
import {
computed
Expand Down
11 changes: 10 additions & 1 deletion sheep/components/s-layout/s-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
>
<view class="page-main" :style="[bgMain]">
<!-- 顶部导航栏-情况1:默认通用顶部导航栏 -->
<!--<view>{{navbar}}{{navbarMode}}</view>-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里,好像没用?

<su-navbar
v-if="navbar === 'normal'"
:title="title"
Expand All @@ -17,19 +18,25 @@
/>

<!-- 顶部导航栏-情况2:装修组件导航栏-标准 -->
<!--#ifndef MP-ALIPAY-->
<s-custom-navbar
v-else-if="navbar === 'custom' && navbarMode === 'normal'"
:data="navbarStyle"
:showLeftButton="showLeftButton"
/>
<!--#endif-->

<!--#ifdef MP-ALIPAY-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里,看着是注释掉了 是不是也可以删除?

<!-- -->
<!--#endif-->

<view class="page-body" :style="[bgBody]">
<!-- 顶部导航栏-情况3:沉浸式头部 -->
<su-inner-navbar v-if="navbar === 'inner'" :title="title" />
<view
v-if="navbar === 'inner'"
:style="[{ paddingTop: sheep.$platform.navbar + 'px' }]"
></view>

<!-- 顶部导航栏-情况4:装修组件导航栏-沉浸式 -->
<s-custom-navbar v-if="navbar === 'custom' && navbarMode === 'inner'" :data="navbarStyle" :showLeftButton="showLeftButton" />

Expand Down Expand Up @@ -201,6 +208,8 @@
if (!isEmpty(shareInfo.value)) {
sheep.$platform.share.updateShareInfo(shareInfo.value);
}

console.log("导航栏模式",navbarMode.value,props.navbar.value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个打印,是不是去掉哈?

});
</script>

Expand Down
46 changes: 23 additions & 23 deletions sheep/components/s-menu-grid/s-menu-grid.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<!-- 装修基础组件:宫格导航 -->
<template>
<uni-grid :showBorder="Boolean(data.border)" :column="data.column">
<uni-grid-item
v-for="(item, index) in data.list"
:key="index"
@tap="sheep.$router.go(item.url)"
>
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="img-box">
<view
class="tag-box"
v-if="item.badge.show"
:style="[{ background: item.badge.bgColor, color: item.badge.textColor }]"
>
{{ item.badge.text }}
<view v-for="(item, index) in data.list"
:key="index"
@tap="sheep.$router.go(item.url)">
<uni-grid-item>
<view class="grid-item-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="img-box">
<view
class="tag-box"
v-if="item.badge.show"
:style="[{ background: item.badge.bgColor, color: item.badge.textColor }]"
>
{{ item.badge.text }}
</view>
<image class="menu-image" :src="sheep.$url.cdn(item.iconUrl)"></image>
</view>
<image class="menu-image" :src="sheep.$url.cdn(item.iconUrl)"></image>
</view>

<view class="title-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="grid-text" :style="[{ color: item.titleColor }]">
{{ item.title }}
</view>
<view class="grid-tip" :style="[{ color: item.subtitleColor }]">
{{ item.subtitle }}
<view class="title-box ss-flex ss-flex-col ss-row-center ss-col-center">
<view class="grid-text" :style="[{ color: item.titleColor }]">
{{ item.title }}
</view>
<view class="grid-tip" :style="[{ color: item.subtitleColor }]">
{{ item.subtitle }}
</view>
</view>
</view>
</view>
</uni-grid-item>
</uni-grid-item>
</view>
</uni-grid>
</template>

Expand Down
31 changes: 15 additions & 16 deletions sheep/components/s-tabbar/s-tabbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
:midTabBar="tabbar.mode === 2"
:customStyle="tabbarStyle"
>
<su-tabbar-item
v-for="(item, index) in tabbar.items"
:key="item.text"
:text="item.text"
:name="item.url"
:isCenter="getTabbarCenter(index)"
:centerImage="sheep.$url.cdn(item.iconUrl)"
@tap="sheep.$router.go(item.url)"
>
<template v-slot:active-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIconUrl)"></image>
</template>
<template v-slot:inactive-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.iconUrl)"></image>
</template>
</su-tabbar-item>
<view v-for="(item, index) in tabbar.items" :key="item.text" @tap="sheep.$router.go(item.url)">
<su-tabbar-item
:text="item.text"
:name="item.url"
:isCenter="getTabbarCenter(index)"
:centerImage="sheep.$url.cdn(item.iconUrl)"
>
<template v-slot:active-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.activeIconUrl)"></image>
</template>
<template v-slot:inactive-icon>
<image class="u-page__item__slot-icon" :src="sheep.$url.cdn(item.iconUrl)"></image>
</template>
</su-tabbar-item>
</view>
</su-tabbar>
</view>
</template>
Expand Down
13 changes: 13 additions & 0 deletions sheep/platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isWxBrowser } from '@/sheep/helper/utils';
// #endif
import wechat from './provider/wechat/index.js';
import apple from './provider/apple';
import alipay from './provider/alipay/index';
import share from './share';
import Pay from './pay';

Expand Down Expand Up @@ -53,6 +54,12 @@ platform = 'miniProgram';
provider = 'wechat';
// #endif

// #ifdef MP-ALIPAY
name = 'AlipayMiniProgram';
platform = 'miniProgram';
provider = 'alipay';
// #endif

if (isEmpty(name)) {
uni.showToast({
title: '暂不支持该平台',
Expand All @@ -64,14 +71,20 @@ if (isEmpty(name)) {
const load = () => {
if (provider === 'wechat') {
wechat.load();
}else if (provider === 'alipay') {
alipay.load();
} else {
console.log('未知平台', provider);
}
};

// 使用厂商独占sdk name = 'wechat' | 'alipay' | 'apple'
const useProvider = (_provider = '') => {
console.error('useProvider', _provider, provider)
if (_provider === '') _provider = provider;
if (_provider === 'wechat') return wechat;
if (_provider === 'apple') return apple;
if (_provider === 'alipay') return alipay;
};

// 支付服务转发
Expand Down
7 changes: 7 additions & 0 deletions sheep/platform/provider/alipay/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

// 这里 特指支付宝小程序,后面如果需要拓展什么阿里云小程序、淘宝小程序之类的,就自己新建
import service from './miniProgram';

const alipay = service;

export default alipay;
Loading