├── src
├── pages
│ ├── index
│ │ ├── index.less
│ │ └── index.tsx
│ ├── home
│ │ ├── index.less
│ │ ├── mock.json
│ │ └── index.tsx
│ └── dynamic
│ │ ├── index.less
│ │ ├── mock_theme_dynamic_data.json
│ │ ├── mock_theme_data.json
│ │ └── index.tsx
├── model
│ ├── constants
│ │ ├── global.ts
│ │ └── counter.ts
│ ├── actions
│ │ ├── global.ts
│ │ └── counter.ts
│ ├── reducers
│ │ ├── index.ts
│ │ ├── global.ts
│ │ └── counter.ts
│ └── store
│ │ └── index.ts
├── assets
│ └── images
│ │ ├── bg.png
│ │ ├── close.png
│ │ ├── code.png
│ │ ├── dragon.png
│ │ ├── scale.png
│ │ ├── versa.png
│ │ ├── canvasBg.png
│ │ ├── feedback.png
│ │ ├── question.png
│ │ ├── icon.close.png
│ │ ├── icon_sound.png
│ │ ├── pic_loading.png
│ │ ├── icon_only_gif.png
│ │ ├── powerbyversa.png
│ │ ├── icon_back_dark.png
│ │ ├── icon_back_light.png
│ │ ├── icon_menu_dark.png
│ │ ├── icon_menu_light.png
│ │ ├── icon_music_gif.png
│ │ └── icon_sound_off.png
├── components
│ ├── SceneList
│ │ ├── index.less
│ │ ├── SceneItem
│ │ │ ├── index.less
│ │ │ └── index.tsx
│ │ └── index.tsx
│ ├── Title
│ │ ├── index.less
│ │ └── index.tsx
│ ├── Icon
│ │ ├── index.less
│ │ └── index.tsx
│ ├── AuthModal
│ │ ├── index.less
│ │ └── index.tsx
│ ├── CategoryItem
│ │ ├── index.less
│ │ └── index.tsx
│ ├── Sticker
│ │ ├── index.less
│ │ └── index.tsx
│ └── ResultModal
│ │ ├── index.tsx
│ │ └── index.less
├── services
│ ├── config.ts
│ ├── global_data.ts
│ ├── cache.ts
│ ├── api.config.ts
│ ├── session.ts
│ ├── service.ts
│ └── http.ts
├── app.less
├── index.html
├── app.tsx
└── utils
│ └── tool.ts
├── .gitignore
├── config
├── dev.js
├── prod.js
└── index.js
├── .npmrc
├── .editorconfig
├── .eslintrc
├── global.d.ts
├── project.config.json
├── tsconfig.json
├── LICENSE
├── package.json
└── README.md
/src/pages/index/index.less:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/model/constants/global.ts:
--------------------------------------------------------------------------------
1 | export const SYSTEM = 'SYSTEM'
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/
2 | .temp/
3 | .rn_temp/
4 | node_modules/
5 | .DS_Store
6 |
--------------------------------------------------------------------------------
/src/model/constants/counter.ts:
--------------------------------------------------------------------------------
1 | export const ADD = 'ADD'
2 | export const MINUS = 'MINUS'
3 |
--------------------------------------------------------------------------------
/src/assets/images/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/bg.png
--------------------------------------------------------------------------------
/src/assets/images/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/close.png
--------------------------------------------------------------------------------
/src/assets/images/code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/code.png
--------------------------------------------------------------------------------
/src/assets/images/dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/dragon.png
--------------------------------------------------------------------------------
/src/assets/images/scale.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/scale.png
--------------------------------------------------------------------------------
/src/assets/images/versa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/versa.png
--------------------------------------------------------------------------------
/src/assets/images/canvasBg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/canvasBg.png
--------------------------------------------------------------------------------
/src/assets/images/feedback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/feedback.png
--------------------------------------------------------------------------------
/src/assets/images/question.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/question.png
--------------------------------------------------------------------------------
/src/assets/images/icon.close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon.close.png
--------------------------------------------------------------------------------
/src/assets/images/icon_sound.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_sound.png
--------------------------------------------------------------------------------
/src/assets/images/pic_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/pic_loading.png
--------------------------------------------------------------------------------
/src/assets/images/icon_only_gif.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_only_gif.png
--------------------------------------------------------------------------------
/src/assets/images/powerbyversa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/powerbyversa.png
--------------------------------------------------------------------------------
/src/components/SceneList/index.less:
--------------------------------------------------------------------------------
1 | .scene-list {
2 | // margin-right:-68rpx;
3 | .scroll {
4 | white-space:nowrap;
5 | }
6 | }
--------------------------------------------------------------------------------
/src/assets/images/icon_back_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_back_dark.png
--------------------------------------------------------------------------------
/src/assets/images/icon_back_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_back_light.png
--------------------------------------------------------------------------------
/src/assets/images/icon_menu_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_menu_dark.png
--------------------------------------------------------------------------------
/src/assets/images/icon_menu_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_menu_light.png
--------------------------------------------------------------------------------
/src/assets/images/icon_music_gif.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_music_gif.png
--------------------------------------------------------------------------------
/src/assets/images/icon_sound_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarryChen0506/taro-makaron-demo/HEAD/src/assets/images/icon_sound_off.png
--------------------------------------------------------------------------------
/config/dev.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"development"'
4 | },
5 | defineConstants: {
6 | },
7 | weapp: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/config/prod.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | NODE_ENV: '"production"'
4 | },
5 | defineConstants: {
6 | },
7 | weapp: {},
8 | h5: {}
9 | }
10 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=https://r.cnpmjs.org
2 | disturl=https://r.cnpmjs.org/node
3 | sass_binary_site=https://r.cnpmjs.org/node-sass/
4 | fse_binary_host_mirror=https://r.cnpmjs.org/fsevents
5 |
--------------------------------------------------------------------------------
/src/model/actions/global.ts:
--------------------------------------------------------------------------------
1 | import {
2 | SYSTEM,
3 | } from '../constants/global'
4 |
5 | export const getSystemInfo = (data) => {
6 | return {
7 | type: SYSTEM,
8 | data
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/src/model/reducers/index.ts:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux'
2 | import counter from './counter'
3 | import global from './global'
4 |
5 | export default combineReducers({
6 | counter,
7 | global
8 | })
9 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["taro"],
3 | "rules": {
4 | "no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
5 | "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
6 | },
7 | "parser": "babel-eslint",
8 | "plugins": ["typescript"]
9 | }
10 |
--------------------------------------------------------------------------------
/global.d.ts:
--------------------------------------------------------------------------------
1 | declare module "*.png";
2 | declare module "*.gif";
3 | declare module "*.jpg";
4 | declare module "*.jpeg";
5 | declare module "*.svg";
6 | declare module "*.css";
7 | declare module "*.less";
8 | declare module "*.scss";
9 | declare module "*.sass";
10 | declare module "*.styl";
11 |
--------------------------------------------------------------------------------
/src/components/Title/index.less:
--------------------------------------------------------------------------------
1 | .title-wrap {
2 | position:absolute;
3 | width:100%;
4 | top:0;
5 | left: 0;
6 | z-index: 100;
7 | text-align:center;
8 | font-size:36px;
9 | color:#fff;
10 | .left {
11 | position:absolute;
12 | left: 20px;
13 | top: 2px;
14 | }
15 | }
--------------------------------------------------------------------------------
/src/components/Icon/index.less:
--------------------------------------------------------------------------------
1 | .icon {
2 | width:70rpx;
3 | height:50rpx;
4 | display:flex;
5 | align-items:center;
6 | justify-content:center;
7 | .icon-menu {
8 | width:40rpx;
9 | height:28rpx;
10 | }
11 | .icon-back {
12 | width:22rpx;
13 | height:38rpx;
14 | }
15 | }
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "miniprogramRoot": "./dist",
3 | "projectname": "taro-makaron-demo",
4 | "description": "马卡龙玩图",
5 | "appid": "wxcfe56965f4d986f0",
6 | "setting": {
7 | "urlCheck": true,
8 | "es6": false,
9 | "postcss": false,
10 | "minified": false
11 | },
12 | "compileType": "miniprogram"
13 | }
14 |
--------------------------------------------------------------------------------
/src/services/config.ts:
--------------------------------------------------------------------------------
1 | // 配置文件
2 | export const ENV:string = 'dev' // 'dev' 测试
3 | // export const ENV = 'prod' // 'prod' 生产
4 | export const appId:string = 'wxcfe56965f4d986f0'
5 | export const appConfig:object = {
6 | image_oss_postfix: '?x-oss-process=image/resize,h_748,w_560',
7 | }
8 | export default {
9 | ENV,
10 | appId: appId,
11 | appConfig: appConfig
12 | }
--------------------------------------------------------------------------------
/src/services/global_data.ts:
--------------------------------------------------------------------------------
1 | // 全局对象 单例
2 |
3 | interface GlobalProps {
4 | name: string
5 | }
6 |
7 | class GlobalObj implements GlobalProps {
8 | name: string;
9 | constructor (name) {
10 | this.name = name
11 | }
12 | }
13 |
14 | export const createGlobalObj = (name:string) => {
15 | return new GlobalObj(name)
16 | }
17 |
18 | const globalData = createGlobalObj('global object')
19 | export default globalData
--------------------------------------------------------------------------------
/src/components/AuthModal/index.less:
--------------------------------------------------------------------------------
1 | .auth-wrap {
2 | position: fixed;
3 | left: 0;
4 | top: 0;
5 | width: 100%;
6 | height: 100%;
7 | display: flex;
8 | justify-content: center;
9 | align-items: center;
10 | .modal {
11 | position: absolute;
12 | left: 0;
13 | top: 0;
14 | width: 100%;
15 | height: 100%;
16 | background: #000;
17 | opacity: 0.5;
18 | }
19 | button {
20 |
21 | }
22 | }
--------------------------------------------------------------------------------
/src/model/actions/counter.ts:
--------------------------------------------------------------------------------
1 | import {
2 | ADD,
3 | MINUS
4 | } from '../constants/counter'
5 |
6 | export const add = () => {
7 | return {
8 | type: ADD
9 | }
10 | }
11 | export const minus = () => {
12 | return {
13 | type: MINUS
14 | }
15 | }
16 |
17 | // 异步的action
18 | export function asyncAdd () {
19 | return dispatch => {
20 | setTimeout(() => {
21 | dispatch(add())
22 | }, 2000)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/model/reducers/global.ts:
--------------------------------------------------------------------------------
1 | import { SYSTEM } from '../constants/global'
2 |
3 | const INITIAL_STATE = {
4 | system: {
5 | statusBarHeight: 20
6 | }
7 | }
8 |
9 | export default function counter (state = INITIAL_STATE, action) {
10 | switch (action.type) {
11 | case SYSTEM:
12 | return {
13 | ...state,
14 | system: {...state.system, ...action.data}
15 | }
16 | default:
17 | return state
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/components/CategoryItem/index.less:
--------------------------------------------------------------------------------
1 | .category-box {
2 | position:relative;
3 | width:290rpx;
4 | height:296rpx;
5 | margin-top:20px;
6 | .category-box-button {
7 | width:100%;
8 | height:100%;
9 | padding:0;
10 | margin:0;
11 | background:transparent;
12 | transition:all 0.2s;
13 | .category-box-image {
14 | width:290rpx;
15 | height:296rpx;
16 | }
17 | &.btn-hover {
18 | transform: scale(0.85)
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/model/reducers/counter.ts:
--------------------------------------------------------------------------------
1 | import { ADD, MINUS } from '../constants/counter'
2 |
3 | const INITIAL_STATE = {
4 | num: 10
5 | }
6 |
7 | export default function counter (state = INITIAL_STATE, action) {
8 | switch (action.type) {
9 | case ADD:
10 | return {
11 | ...state,
12 | num: state.num + 1
13 | }
14 | case MINUS:
15 | return {
16 | ...state,
17 | num: state.num - 1
18 | }
19 | default:
20 | return state
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/app.less:
--------------------------------------------------------------------------------
1 | page {
2 | width:100%;
3 | height:100%;
4 | overflow-y:hidden;
5 | }
6 | button::after{
7 | border: none;
8 | }
9 |
10 | .custom-button {
11 | border-radius:80rpx;
12 | width:100%;
13 | height:80rpx;
14 | line-height:80rpx;
15 | color:white;
16 | font-size:36rpx;
17 | text-align:center;
18 | transition:all 0.2s;
19 | &.btn-hover {
20 | transform: scale(0.85)
21 | }
22 | &.pink {
23 | background:#FF3366;
24 | }
25 | &.dark {
26 | background:#333;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/services/cache.ts:
--------------------------------------------------------------------------------
1 | // 缓存服务
2 | function Cache (name) {
3 | this.name = name
4 | }
5 | Cache.prototype = {
6 | set: function (key, value) {
7 | this[key] = value
8 | return this[key]
9 | },
10 | get: function (key) {
11 | return this[key]
12 | },
13 | clear: function () {
14 | // 清空
15 | Object.keys(this).forEach(v => {
16 | this[v] = undefined
17 | })
18 | }
19 | }
20 |
21 | export const createCache = (name:string) => {
22 | return new Cache(name)
23 | }
24 |
25 | export const cacheCover = new Cache('cover')
26 | export default {
27 | createCache,
28 | cacheCover
29 | }
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2017",
4 | "module": "commonjs",
5 | "removeComments": false,
6 | "preserveConstEnums": true,
7 | "moduleResolution": "node",
8 | "experimentalDecorators": true,
9 | "noImplicitAny": false,
10 | "allowSyntheticDefaultImports": true,
11 | "outDir": "lib",
12 | "noUnusedLocals": true,
13 | "noUnusedParameters": true,
14 | "strictNullChecks": true,
15 | "sourceMap": true,
16 | "baseUrl": ".",
17 | "rootDir": ".",
18 | "jsx": "preserve",
19 | "jsxFactory": "Taro.createElement",
20 | "allowJs": true,
21 | "typeRoots": [
22 | "node_modules/@types"
23 | ]
24 | },
25 | "compileOnSave": false
26 | }
27 |
--------------------------------------------------------------------------------
/src/pages/home/index.less:
--------------------------------------------------------------------------------
1 | .page-home {
2 | width:100%;
3 | height:100%;
4 | box-sizing:border-box;
5 | position:relative;
6 | background: #fff;
7 | .main {
8 | width:100%;
9 | height:100%;
10 | position:relative;
11 | overflow:auto;
12 | .main-bg {
13 | width:100%;
14 | height:98%;
15 | position:absolute;
16 | top:0;
17 | left:0;
18 | z-index:0;
19 | }
20 | .main-container {
21 | position:relative;
22 | width:100%;
23 | box-sizing:border-box;
24 | padding:78% 60rpx 40rpx;
25 | .category-wrap {
26 | width:100%;
27 | margin-top:10rpx;
28 | display:flex;
29 | flex-direction:row;
30 | flex-wrap:wrap;
31 | justify-content:space-between;
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/src/components/Sticker/index.less:
--------------------------------------------------------------------------------
1 | .sticker-wrap {
2 | position:absolute;
3 | top:0;
4 | left:0;
5 | z-index:1;
6 | // transition:opacity 0.1s;
7 | &.hidden {
8 | opacity: 0;
9 | }
10 | &.event-through {
11 | pointer-events: none;//使用当前属性点击div将触发链接
12 | }
13 | .border {
14 | position:absolute;
15 | left:0;
16 | top:0;
17 | z-index:-1;
18 | width:100%;
19 | height:100%;
20 | border:1px solid transparent;
21 | &.active {
22 | border:1px solid #fff;
23 | }
24 | }
25 | .control {
26 | width:50rpx;
27 | height:50rpx;
28 | position:absolute;
29 | right:-25rpx;
30 | bottom:-25rpx;
31 | background:#fff;
32 | border-radius:25rpx;
33 | display:flex;
34 | align-items:center;
35 | justify-content:center;
36 | opacity:0;
37 | &.active {
38 | opacity:1;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/services/api.config.ts:
--------------------------------------------------------------------------------
1 | // host域名管理
2 | import {ENV} from './config'
3 | const host = {
4 | miniapi: {
5 | dev: 'https://abc.xxx.com',
6 | prod: 'https://abc.xxx.com'
7 | },
8 | upload: {
9 | dev: 'https://abc.xxx.com',
10 | prod: 'https://abc.xxx.com'
11 | },
12 | download: {
13 | dev: 'https://abc.xxx.com',
14 | prod: 'https://abc.xxx.com'
15 | }
16 | }
17 |
18 | // 获取域名
19 | function getHost (type = 'miniapi', ENV = 'dev') {
20 | return host[type][ENV]
21 | }
22 | export const api = {
23 | base: {
24 | uploadToken: `${getHost('miniapi', ENV)}/xxx`,
25 | upload: `${getHost('miniapi', ENV)}/xxx`,
26 | auth: `${getHost('miniapi', ENV)}/xxx`,
27 | },
28 | core: {
29 | segment: `${getHost('miniapi', ENV)}/xxx`,
30 | column: `${getHost('miniapi', ENV)}/xxx`
31 | }
32 | }
33 | export default {
34 | name: 'api-config',
35 | api,
36 | }
--------------------------------------------------------------------------------
/src/model/store/index.ts:
--------------------------------------------------------------------------------
1 | import { createStore, applyMiddleware, compose } from 'redux'
2 | import thunkMiddleware from 'redux-thunk'
3 | import rootReducer from '../reducers'
4 |
5 | const composeEnhancers =
6 | typeof window === 'object' &&
7 | window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
8 | window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
9 | // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
10 | }) : compose
11 |
12 | const middlewares = [
13 | thunkMiddleware
14 | ]
15 |
16 | if (process.env.NODE_ENV === 'development') {
17 | middlewares.push(require('redux-logger').createLogger())
18 | }
19 |
20 | const enhancer = composeEnhancers(
21 | applyMiddleware(...middlewares),
22 | // other store enhancers if any
23 | )
24 |
25 | export default function configStore () {
26 | const store = createStore(rootReducer, enhancer)
27 | return store
28 | }
29 |
--------------------------------------------------------------------------------
/src/components/AuthModal/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View, Button } from '@tarojs/components'
4 |
5 | import './index.less'
6 |
7 | type ComponentStateProps = {}
8 |
9 | type ComponentOwnProps = {
10 | onClick: () => void
11 | }
12 |
13 | type ComponentState = {}
14 |
15 | type IProps = ComponentStateProps & ComponentOwnProps
16 |
17 | interface AuthModal {
18 | props: IProps;
19 | }
20 |
21 | class AuthModal extends Component {
22 | handleClick = () => {
23 | this.props.onClick && this.props.onClick()
24 | }
25 | render() {
26 | return (
27 |
28 |
29 |
30 |
31 |
32 |
33 | )
34 | }
35 | }
36 |
37 | export default AuthModal as ComponentClass
--------------------------------------------------------------------------------
/src/services/session.ts:
--------------------------------------------------------------------------------
1 | // session管理
2 | import Taro from '@tarojs/taro'
3 | import service from './service'
4 | import config from './config'
5 |
6 | const Session = {
7 | storageKey: 'session',
8 | headerKey: 'sessionId',
9 | get () {
10 | return Taro.getStorageSync(this.storageKey)
11 | },
12 | async set () {
13 | const loginInfo = await Taro.login()
14 | const {appId} = config
15 | const {code} = loginInfo
16 | try {
17 | const data = await service.base.auth({
18 | code, appId
19 | })
20 | const {statusCode, result} = data
21 | if (statusCode === 200 && result.responseCode === '0000') {
22 | Taro.setStorageSync(this.storageKey, result.result)
23 | return result.result
24 | } else {
25 | console.log('auth fail!(get sessionId)', data)
26 | }
27 | } catch (err) {
28 | console.log('auth fail!(get sessionId)', err)
29 | }
30 | },
31 | remove () {
32 | Taro.removeStorageSync(this.storageKey)
33 | }
34 | }
35 |
36 | export default Session
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Taro
12 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/components/SceneList/SceneItem/index.less:
--------------------------------------------------------------------------------
1 | .scene-item {
2 | position: relative;
3 | display: inline-block;
4 | width: 120rpx;
5 | height: 150rpx;
6 | margin-right: 44rpx;
7 | box-shadow:1px 1px 5px rgba(0,0,0,0.3);
8 | .music-icon {
9 | position: absolute;
10 | right: 7rpx;
11 | top: 10rpx;
12 | width: 20rpx;
13 | height: 20rpx;
14 | }
15 | .bg {
16 | width: 120rpx;
17 | height: 120rpx;
18 | position: relative;
19 | }
20 | .tag {
21 | position: absolute;
22 | left: 0;
23 | bottom: 0;
24 | box-sizing: border-box;
25 | padding: 0 10rpx;
26 | height: 32rpx;
27 | width: 120rpx;
28 | line-height: 32rpx;
29 | font-size: 16rpx;
30 | color: #fff;
31 | background: #FFA9C2;
32 | display: flex;
33 | align-items:center;
34 | justify-content: center;
35 | .tag-title {
36 | font-size:16rpx;
37 | }
38 | .icon {
39 | margin-right: 10rpx;
40 | display: inline-block;
41 | width: 8rpx;
42 | height: 8rpx;
43 | background: #fff;
44 | border-radius: 8rpx;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/components/Title/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View, Text } from '@tarojs/components'
4 |
5 | import './index.less'
6 |
7 | type ComponentStateProps = {}
8 |
9 | type ComponentOwnProps = {
10 | top: number,
11 | renderLeft: any,
12 | children: any,
13 | color?: string
14 | }
15 |
16 | type ComponentState = {}
17 |
18 | type IProps = ComponentStateProps & ComponentOwnProps
19 |
20 | interface Title {
21 | props: IProps;
22 | }
23 |
24 | class Title extends Component {
25 | static defaultProps = {
26 | color: '#fff'
27 | }
28 | componentWillReceiveProps (nextProps) {
29 | // console.log(this.props, nextProps)
30 | }
31 | render() {
32 | const { top, color } = this.props
33 | return (
34 |
35 |
36 | {this.props.renderLeft}
37 |
38 | {this.props.children}
39 |
40 | )
41 | }
42 | }
43 |
44 | export default Title as ComponentClass
--------------------------------------------------------------------------------
/src/components/ResultModal/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View, Button, Image } from '@tarojs/components'
4 |
5 | import './index.less'
6 |
7 | type ComponentStateProps = {}
8 |
9 | type ComponentOwnProps = {
10 | onClick: () => void,
11 | url: string,
12 | }
13 |
14 | type ComponentState = {}
15 |
16 | type IProps = ComponentStateProps & ComponentOwnProps
17 |
18 | interface ResultModal {
19 | props: IProps;
20 | }
21 |
22 | class ResultModal extends Component {
23 | handleClick = () => {
24 | this.props.onClick && this.props.onClick()
25 | }
26 | render() {
27 | return (
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | )
40 | }
41 | }
42 |
43 | export default ResultModal as ComponentClass
--------------------------------------------------------------------------------
/src/components/ResultModal/index.less:
--------------------------------------------------------------------------------
1 | .result-wrap {
2 | width:100%;
3 | height:100%;
4 | position:absolute;
5 | top:0;
6 | left:0;
7 | z-index:1000;
8 | .modal-mask {
9 | width: 100%;
10 | height:100%;
11 | position:absolute;
12 | top:0;
13 | left:0;
14 | background-color:#fff;
15 | }
16 | .modal-content {
17 | padding-top:140rpx;
18 | position:relative;
19 | z-index:1;
20 | width:100%;
21 | height:100%;
22 | box-sizing:border-box;
23 | display:flex;
24 | flex-direction:column;
25 | align-items:center;
26 | justify-content:center;
27 | .pic-wrap {
28 | width:690rpx;
29 | height:920rpx;
30 | .pic {
31 | width:100%;
32 | height:100%;
33 | }
34 | }
35 | .btn-wrap {
36 | width:690rpx;
37 | height:920rpx;
38 | margin-top: 80rpx;
39 | }
40 | }
41 |
42 | .custom-button {
43 | border-radius:80rpx;
44 | width:100%;
45 | height:80rpx;
46 | line-height:80rpx;
47 | color:white;
48 | font-size:36rpx;
49 | text-align:center;
50 | transition:all 0.2s;
51 | &.btn-hover {
52 | transform: scale(0.85)
53 | }
54 | &.pink {
55 | background:#FF3366;
56 | }
57 | &.dark {
58 | background:#333;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/src/pages/dynamic/index.less:
--------------------------------------------------------------------------------
1 | .page-dynamic {
2 | position:relative;
3 | width:100%;
4 | height:100%;
5 | padding-top:130rpx;
6 | box-sizing:border-box;
7 | display:flex;
8 | flex-direction:column;
9 | align-items:center;
10 | justify-content:center;
11 | .pic-section {
12 | position:relative;
13 | width:690rpx;
14 | .raw {
15 | position: absolute;
16 | left: 0;
17 | top: 0;
18 | width:690rpx;
19 | height:920rpx;
20 | &.hidden {
21 | opacity: 0;
22 | }
23 | }
24 | .crop {
25 | position:relative;
26 | width:690rpx;
27 | height:920rpx;
28 | background: #ccc;
29 | overflow: hidden;
30 | &.hidden {
31 | opacity: 0;
32 | }
33 | .background-image {
34 | position: absolute;
35 | top: 0;
36 | left: 0;
37 | width: 100%;
38 | height: 100%;
39 | }
40 | .raw-image {
41 | position: absolute;
42 | top: 0;
43 | left: 0;
44 | width: 100%;
45 | height: 100%;
46 | }
47 | }
48 | }
49 | .button-section {
50 | margin-top: 20rpx
51 | }
52 | .canvas-wrap {
53 | position:fixed;
54 | left:0;
55 | bottom:-3050px;
56 | z-index:-2;
57 | opacity:0;
58 | visibility:none;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/components/Icon/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View } from '@tarojs/components'
4 |
5 | import menu_light from '../../assets/images/icon_menu_light.png'
6 | import menu_dark from '../../assets/images/icon_menu_dark.png'
7 | import back_light from '../../assets/images/icon_back_light.png'
8 | import back_dark from '../../assets/images/icon_back_dark.png'
9 | import './index.less'
10 | type ComponentStateProps = {}
11 |
12 | type ComponentOwnProps = {
13 | type: string, // icon类型
14 | theme?: string // 主题
15 | onClick?: () => void
16 | }
17 | type ComponentState = {}
18 |
19 | type IProps = ComponentStateProps & ComponentOwnProps
20 |
21 | interface Icon {
22 | props: IProps;
23 | }
24 |
25 | class Icon extends Component {
26 | static defaultProps = {
27 | theme: 'light',
28 | onClick: () => {}
29 | }
30 | handleClick = () => {
31 | const {onClick} = this.props
32 | typeof onClick === 'function' && onClick()
33 | }
34 | render() {
35 | const { type, theme } = this.props
36 | return (
37 |
38 | {type === 'menu' ? : null}
39 | {type === 'back' ? : null}
40 |
41 | )
42 | }
43 | }
44 |
45 | export default Icon as ComponentClass
--------------------------------------------------------------------------------
/src/components/CategoryItem/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View, Button, Image } from '@tarojs/components'
4 |
5 | import './index.less'
6 | import loading from '../../assets/images/pic_loading.png'
7 |
8 | type ComponentStateProps = {}
9 |
10 | type ComponentOwnProps = {
11 | onGetUserInfo: (data:any) => void,
12 | onClick?: () => void,
13 | url: string
14 | }
15 |
16 | type ComponentState = {}
17 |
18 | type IProps = ComponentStateProps & ComponentOwnProps
19 |
20 | interface CategotyItem {
21 | props: IProps;
22 | }
23 |
24 | class CategotyItem extends Component {
25 | static defaultProps = {
26 | url: loading
27 | }
28 | componentWillReceiveProps (nextProps) {
29 | // console.log(this.props, nextProps)
30 | }
31 | handleGgetUserInfo = (data) => {
32 | const { onGetUserInfo } = this.props
33 | onGetUserInfo(data)
34 | }
35 | render() {
36 | const { onClick, url } = this.props
37 | return (
38 |
39 |
50 |
51 | )
52 | }
53 | }
54 |
55 | export default CategotyItem as ComponentClass
--------------------------------------------------------------------------------
/src/app.tsx:
--------------------------------------------------------------------------------
1 | import '@tarojs/async-await'
2 | import Taro, { Component, Config } from '@tarojs/taro'
3 | import { Provider } from '@tarojs/redux'
4 | import Index from './pages/index'
5 |
6 | import configStore from './model/store'
7 |
8 | import './app.less'
9 |
10 | // 如果需要在 h5 环境中开启 React Devtools
11 | // 取消以下注释:
12 | // if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
13 | // require('nerv-devtools')
14 | // }
15 |
16 | const store = configStore()
17 | class App extends Component {
18 |
19 | /**
20 | * 指定config的类型声明为: Taro.Config
21 | *
22 | * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
23 | * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
24 | * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
25 | */
26 | config: Config = {
27 | pages: [
28 | 'pages/home/index',
29 | 'pages/dynamic/index',
30 | 'pages/index/index'
31 | ],
32 | window: {
33 | backgroundTextStyle: 'light',
34 | navigationBarBackgroundColor: '#fff',
35 | navigationBarTitleText: 'WeChat',
36 | navigationBarTextStyle: 'black',
37 | navigationStyle: 'custom'
38 | }
39 | }
40 |
41 | componentDidMount () {
42 | }
43 |
44 | componentDidShow () {}
45 |
46 | componentDidHide () {}
47 |
48 | componentCatchError () {}
49 |
50 | componentDidCatchError () {}
51 |
52 | // 在 App 类中的 render() 函数没有实际作用
53 | // 请勿修改此函数
54 | render () {
55 | return (
56 |
57 |
58 |
59 | )
60 | }
61 | }
62 |
63 | Taro.render(, document.getElementById('app'))
64 |
--------------------------------------------------------------------------------
/src/components/SceneList/index.tsx:
--------------------------------------------------------------------------------
1 | import { ComponentClass } from 'react'
2 | import Taro, { Component } from '@tarojs/taro'
3 | import { View, ScrollView, Image } from '@tarojs/components'
4 |
5 | import './index.less'
6 | import SceneItem from './SceneItem'
7 | type ComponentStateProps = {}
8 |
9 | type ComponentOwnProps = {
10 | onClick?: (item:object) => void,
11 | list: Array