Skip to content

Commit

Permalink
优化taro
Browse files Browse the repository at this point in the history
  • Loading branch information
kala888 committed Feb 29, 2024
1 parent 0ba6604 commit 539cfa6
Show file tree
Hide file tree
Showing 189 changed files with 2,682 additions and 1,097 deletions.
3 changes: 2 additions & 1 deletion tixwork-taro/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports ={
"jsx-quotes": "off",
"react/sort-comp": [0],
"no-shadow": "off",
"react/jsx-curly-brace-presence": "off"
"react/jsx-curly-brace-presence": "off",
"@typescript-eslint/no-useless-constructor": "off",
}
}
6 changes: 3 additions & 3 deletions tixwork-taro/project.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"miniprogramRoot": "dist/",
"projectname": "tixwork-taro",
"description": "tixwork-taro a wx development framework base on Taro and React",
"appid": "wxd7ff628dc0e8870d",
"appid": "wx49672d8fab486c4b",
"setting": {
"urlCheck": true,
"es6": false,
"enhance": false,
"es6": true,
"enhance": true,
"compileHotReLoad": false,
"postcss": false,
"minified": false,
Expand Down
8 changes: 5 additions & 3 deletions tixwork-taro/project.private.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "tixwork-taro",
"projectname": "marketing",
"setting": {
"compileHotReLoad": true
}
"compileHotReLoad": true,
"urlCheck": false
},
"libVersion": "3.3.1"
}
45 changes: 34 additions & 11 deletions tixwork-taro/src/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export default {
pages: [
// 'pages/test-page',
'pages/home/home-page',
'pages/test-page',
'pages/me/me-page',
'pages/login/login-page',
'pages/search/search-page',
'pages/policy/policy-detail-page',
'pages/me/user-profile-update',
'pages/me/about-us',

'pages/login/bind-mobile-page',
'pages/me/me-page',

// 'pages/biz/listof-test-page', // 有问题

// base
Expand Down Expand Up @@ -37,16 +39,37 @@ export default {
},
],

// permission: {
// 'scope.userLocation': {
// desc: '你的位置信息将用于小程序位置接口的效果展示',
// },
// },
permission: {
'scope.userLocation': {
desc: '获取微信信息以便定位到最近的店铺',
},
},
requiredPrivateInfos: ['getLocation', 'chooseAddress'],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#28aaff',
navigationBarTitleText: 'Tixwork',
navigationBarBackgroundColor: '#cc9172',
navigationBarTitleText: '钛安甄选',
navigationBarTextStyle: 'white',
enablePullDownRefresh: true,
},
tabBar: {
color: '#666',
selectedColor: '#cc9172',
backgroundColor: '#fafafa',
borderStyle: 'black',
list: [
{
pagePath: 'pages/home/home-page',
iconPath: './assets/icon/home.png',
selectedIconPath: './assets/icon/home_s.png',
text: '首页',
},
{
pagePath: 'pages/me/me-page',
iconPath: './assets/icon/me.png',
selectedIconPath: './assets/icon/me_s.png',
text: '我的',
},
],
},
};
10 changes: 4 additions & 6 deletions tixwork-taro/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ModelProvider } from '@/model/model-provider';
import './app.less';
import TestData from './pages/mock-data/test-data';
import { models } from '@/model/models';
import NavigationService from '@/nice-router/navigation-service';

TestData.initial();

Expand Down Expand Up @@ -32,7 +33,7 @@ const updateWeapp = () => {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function(res) {
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate();
}
Expand Down Expand Up @@ -62,12 +63,9 @@ function App({ children }: PropsWithChildren<any>) {
if (isWeapp()) {
updateWeapp();
}
NavigationService.dispatch('cart/load');
});
return (
<ModelProvider models={models}>
{children}
</ModelProvider>
);
return <ModelProvider models={models}>{children}</ModelProvider>;
}

export default App;
Binary file added tixwork-taro/src/assets/icon/cart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/cart_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/home_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file removed tixwork-taro/src/assets/icon/[email protected]
Binary file not shown.
Binary file added tixwork-taro/src/assets/icon/me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/me_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/icon/menu_s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/images/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tixwork-taro/src/assets/logo.png
Binary file not shown.
Binary file added tixwork-taro/src/assets/user-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/user-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tixwork-taro/src/assets/vip-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions tixwork-taro/src/components/action-icon/action-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import ServerImage, { ServerImageProps } from '@/server-image/server-image';
import { Text, View } from '@tarojs/components';
import classNames from 'classnames';
import { IconLike, ImageLike } from '@/nice-router/nice-router-types';
import { isEmpty, isNotEmpty } from '@/utils/object-utils';

import './styles.less';
import ObjectUtils from '@/utils/object-utils';

type ActionIconProps = IconLike & ImageLike & ServerImageProps;

/**
* 有icon,优先展示ICON
*/
export default function ActionIcon(props: ActionIconProps) {
const { icon = '', imageUrl, className, mode } = props;
if (isEmpty(icon) && isEmpty(imageUrl)) {
const { icon = '', imageUrl, className, mode, ...rest } = props;
if (ObjectUtils.isEmpty(icon) && ObjectUtils.isEmpty(imageUrl)) {
return null;
}

if (isNotEmpty(icon)) {
if (ObjectUtils.isNotEmpty(icon)) {
const isBizFont = icon.startsWith('bizfont-');
const rootClass = classNames(
'iconfont',
Expand All @@ -30,7 +30,7 @@ export default function ActionIcon(props: ActionIconProps) {
mode
);
return (
<View className='action-icon'>
<View className='action-icon' {...rest}>
<Text className={rootClass} />
</View>
);
Expand All @@ -39,7 +39,7 @@ export default function ActionIcon(props: ActionIconProps) {
const rootClass = classNames('action-icon', 'action-image', className);

return (
<View className={rootClass}>
<View className={rootClass} {...rest}>
<ServerImage customStyle={{ width: '100%', height: '100%' }} mode={mode} src={imageUrl} />
</View>
);
Expand Down
19 changes: 0 additions & 19 deletions tixwork-taro/src/components/base-page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions tixwork-taro/src/components/biz/action-floor-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import ServerImage from '@/server-image/server-image';
import { Text, View } from '@tarojs/components';
import EleButton, { EleButtonProps } from '@/components/elements/ele-button';
import { getExtMode } from '@/nice-router/nice-router-utils';
import { isEmpty } from '@/utils/object-utils';

import './styles.less';
import ObjectUtils from '@/utils/object-utils';

type ActionFloorItemProps = {
color?: 'blue';
} & Omit<EleButtonProps, 'mode'>;

function ActionFloorItem(props: ActionFloorItemProps) {
const { title, brief, imageUrl, color, ...others } = props || {};
if (isEmpty(title) && isEmpty(brief) && isEmpty(imageUrl)) {
if (ObjectUtils.isEmpty(title) && ObjectUtils.isEmpty(brief) && ObjectUtils.isEmpty(imageUrl)) {
return null;
}

Expand Down
90 changes: 90 additions & 0 deletions tixwork-taro/src/components/biz/order-actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Text, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import Q from '@/http/q';
import NavigationService from '@/nice-router/navigation-service';
import ApiConfig from '@/utils/api-config';
import { Order } from '@/types';
import WechatPayUtils from '@/utils/wechat-pay-utils';

// const mockActions = [
// { code: 'CANCEL', title: '取消订单', uiType: 'primary' },
// { code: 'PAY', title: '微信支付' },
// { code: 'CONFIRM_RECEIVE', title: '确认收货' },
// { code: 'REORDER', title: '再来一单' },
// { code: 'VIEW', title: '查看详情' },
// ];
export default function OrderActions(props: { order: Order; onRefresh: () => void }) {
const { order, onRefresh } = props;
const goToDetail = () => NavigationService.goPage('/pages/order/order-detail-page', { id: order?.id });

const { actions = [] } = order;
const handleClick = async (e, it) => {
e.preventDefault();
e.stopPropagation();

if (it.code === 'CANCEL') {
Taro.showModal({
title: '取消订单',
content: '是否确认取消订单?',
success: async (res) => {
if (res.confirm) {
const resp = await Q.remove(ApiConfig.cancelOrder, { id: order?.id });
if (resp.data === true) {
Taro.showToast({ title: '取消成功', icon: 'none' });
onRefresh?.();
}
}
},
});
return;
}

if (it.code === 'PAY') {
await WechatPayUtils.pay(order?.id);
onRefresh?.();
return;
}
if (it.code === 'CONFIRM_RECEIVE') {
// TODO
Taro.showToast({ title: '确认订单', icon: 'none' });
return;
}
if (it.code === 'REORDER') {
Taro.showModal({
title: '再来一单',
content: '重新添加到购物车?',
success: async (res) => {
if (res.confirm) {
const resp = await Q.get(ApiConfig.reorder, { id: order?.id });
if (resp.data === true) {
Taro.showToast({ title: '添加成功', icon: 'none' });
await NavigationService.goPage('/pages/cart/cart-page');
}
}
},
});
return;
}
if (it.code === 'VIEW') {
goToDetail();
return;
}
Taro.showToast({ title: '暂未开放', icon: 'none' });
};

return (
<View className='order-item-footer'>
{actions.map((it) => {
return (
<View
key={it.code}
className={'order-action ' + (it.uiType == 'primary' ? 'primary' : '')}
onClick={(e) => handleClick(e, it)}
>
<Text className='order-action-txt'>{it.title}</Text>
</View>
);
})}
</View>
);
}
4 changes: 2 additions & 2 deletions tixwork-taro/src/components/divider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { View } from '@tarojs/components';
import './styles.less';
import { isEmpty } from '@/utils/object-utils';
import ObjectUtils from '@/utils/object-utils';

type DividerType = {
title?: string;
Expand All @@ -11,7 +11,7 @@ type DividerType = {
export default function Divider(props: DividerType) {
const { title, fontColor = '#ddd', lineColor = '#ccc' } = props;

if (isEmpty(title)) {
if (ObjectUtils.isEmpty(title)) {
return (
<View className='divider'>
<View className='divider--line' style={{ backgroundColor: lineColor }} />
Expand Down
2 changes: 1 addition & 1 deletion tixwork-taro/src/components/ele-table/card-info-table.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import '/src/styles/theme';

.card-info-table {
color: @text-color-lighter;
color: @text-color-light;

&-label {
width: 5rem;
Expand Down
8 changes: 4 additions & 4 deletions tixwork-taro/src/components/ele-table/card-info-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import EleTable from '@/components/ele-table/ele-table';
import EleTableRow from '@/components/ele-table/ele-table-row';
import EleTableCell from '@/components/ele-table/ele-table-cell';
import { TitleValue } from '@/nice-router/nice-router-types';
import { isEmpty, isNotEmpty } from '@/utils/object-utils';
import './card-info-table.less';
import ObjectUtils from '@/utils/object-utils';

const getMaxLabelLength = (list, idx = 0) => {
const result = _.max(
Expand Down Expand Up @@ -45,16 +45,16 @@ export default function CardInfoTable(props: CardInfoTableProps) {
{rowList.map((row: [TitleValue, TitleValue], idx) => {
const leftItem = row[0] || {};
const rightItem = row[1] || {};
const showRight = isNotEmpty(rightItem);
const showRight = ObjectUtils.isNotEmpty(rightItem);

let colspan = 1;
if (!showRight) {
colspan = isEmpty(leftItem.title) ? 4 : 3;
colspan = ObjectUtils.isEmpty(leftItem.title) ? 4 : 3;
}

return (
<EleTableRow key={idx}>
{isNotEmpty(leftItem.title) && (
{ObjectUtils.isNotEmpty(leftItem.title) && (
<EleTableCell title={leftItem.title} className={leftItemLabelClass} mode='left' />
)}

Expand Down
5 changes: 3 additions & 2 deletions tixwork-taro/src/components/ele-table/ele-table-cell.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Text, View } from '@tarojs/components';
import React from 'react';
import { getExtMode } from '@/nice-router/nice-router-utils';
import { isNotEmpty } from '@/utils/object-utils';
import './ele-table.less';
import ObjectUtils from '@/utils/object-utils';

export type EleTableCellProps = {
title?: string;
colspan?: number;
children?: React.ReactNode;
mode?: 'left' | 'right';
className?: string;
style?: React.CSSProperties;
};

const EleTableCell: React.FC<EleTableCellProps> = (props) => {
Expand All @@ -19,7 +20,7 @@ const EleTableCell: React.FC<EleTableCellProps> = (props) => {

return (
<View className={rootClass} style={{ flex: colspan }}>
{isNotEmpty(title) && <Text className='ele-table-cell-text'>{title}</Text>}
{ObjectUtils.isNotEmpty(title) && <Text className='ele-table-cell-text'>{title}</Text>}
{props.children}
</View>
);
Expand Down
Loading

0 comments on commit 539cfa6

Please sign in to comment.