Commit 52af2663 authored by wildfirecode13's avatar wildfirecode13

1

parent 6d7894fc
{"view":{"children":[{"name":"share","properties":{"style":{"width":750,"height":1624,"position":"absolute"},"attrs":{},"className":""},"uuid":"56b8468a-451e-423d-bc93-843f74e35170","nodeType":"Div","children":[{"name":"bg","properties":{"style":{"width":750,"height":1624,"position":"absolute"},"attrs":{"source":"asset://64bd0c7b-cf6a-45da-847a-846866120f06"},"className":""},"uuid":"9c7a49b1-a443-4e35-a5e1-2939349f09e7","nodeType":"Image"},{"name":"share_btn","properties":{"style":{"width":446,"height":99,"left":152,"top":1136,"position":"absolute"},"attrs":{"source":"asset://53ff7051-7b71-49ad-ac7f-d35df1e135f0"},"className":""},"uuid":"566aad1b-c581-4e3c-87c6-c3a051656ec8","nodeType":"Image"}],"viewType":"Page"}]},"assets":[{"name":"bg","ext":".png","uuid":"64bd0c7b-cf6a-45da-847a-846866120f06","url":"https://yun.duiba.com.cn/spark/assets/f22ffa96142c33ea321a5d3bec383c2a6e09cee4.png"},{"name":"share_btn","ext":".png","uuid":"53ff7051-7b71-49ad-ac7f-d35df1e135f0","url":"https://yun.duiba.com.cn/spark/assets/eeea9e26e6010babeb918efe6595cf59ee774d18.png"}],"animations":[],"dependencies":{},"customModules":{},"type":"save dsljson"}
node_modules
dist
\ No newline at end of file
import MD from 'spark-utils/out/md/index.js';
let appId = CFG.appID;
const dcm = '202.' + CFG.projectId + '.0.0';
const domain = '//embedlog.duiba.com.cn';
let MDList = [
{
ele: `.test-md1`,
data: {
dpm: `${appId}.110.5.1`,
dcm,
domain,
appId
},
once: false
}
];
export default () =>
MD({
show: MDList, // 曝光
click: MDList // 点击
});
export const join = {
"success": true,
"data": {
message: "参与成功"
}
};
export * from './rule';
import { Random } from 'mockjs';
export const rule = {
"success": true,
"data": `活动规则: ${Random.cparagraph(20, 40)}`
};
import Mock from 'mockjs';
import proxy from './proxy';
Object.keys(proxy).map(method => {
Object.keys(proxy[method]).map(URI => {
let data = proxy[method][URI];
Mock.mock(new RegExp(URI), method, opt => {
console.log(`%c[mock] 链接:${opt.url} 类型:${method} 参数:${method === 'post' && JSON.stringify(opt.body) || ''}`, "color: rgb(63, 172, 203)", data);
return data
});
})
})
\ No newline at end of file
import * as common from './common';
import * as collect_0722 from './collect_0722';
let projectId = window.CFG.projectId || '';
export default {
get: {
[`/projectx/${projectId}/projectRule.query`]: common.rule
},
post: {
[`/projectx/${projectId}/join.do`]: collect_0722.join
}
};
\ No newline at end of file
This diff is collapsed.
{
"name": "sparkproject-1608343653108",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "spark dev --type h5",
"prod": "spark build --type h5 --env prod",
"tb": "spark build --type taobao"
},
"dependencies": {
"axios": "^0.19.2",
"css-loader": "^3.6.0",
"fyge-tbmini": "^1.3.1",
"postcss-loader": "^3.0.0",
"prettier": "^2.0.5",
"qs": "^6.9.4",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"style-loader": "^1.2.1",
"spark-utils": "^0.0.12",
"duiba-utils": "^1.0.2",
"@spark/api-base": "^1.0.11",
"@spark/projectx": "^1.0.3"
},
"devDependencies": {
"mockjs": "^1.1.0"
}
}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>React App</title>
<script src="getTokenKey" id="scriptkey"></script>
<script id="scriptjs" src="//yun.duiba.com.cn/js-libs/px-token/0.0.4/px-token.min.js"></script>
<script src="//yun.duiba.com.cn/js-libs/rem/1.1.0/rem.min.js"></script>
<script src="//yun.duiba.com.cn/h5/lib/zepto.min.js"></script>
<script>
function getApp() {
return {
cloud: {},
cloudName: "clientTemplate2C",
requestType: "mock"
}
}
var CFG = CFG || {};
CFG.projectId = location.pathname.split('/')[2] || '1';
function getUrlParam(name) {
const search = window.location.search;
const matched = search
.slice(1)
.match(new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'));
return search.length ? matched && matched[2] : null;
}
CFG.appID = '${APPID}';
if (!getUrlParam("appID")) {
alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。")
}
</script>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
module.exports = {
OUTPUT_DIR: "dist",
SOURCE_DIR: "src",
TEMP_DIR: "./.temp",
ENTRY: "src/app.jsx",
TEMPLATE: "./public/index.html",
MOCK_STATUS: true,
PX2REM: true
};
const apiCfg = {
getRule:`projectRule.query`,
doJoin: {
uri: `join.do`,
method: "post"
},
}
export default apiCfg;
import apiCfg from './apicfg';
import {getPxToken} from "@spark/projectx";
import {callApi} from '@spark/api-base'
import {isFromShare, newUser} from 'duiba-utils';
let mergeData = {
user_type: newUser ? '0' : '1',
is_from_share: isFromShare ? '0' : '1',
}
const apiList = {
...apiCfg
}
const API = generateAPI(apiList);
export default API;
function getRequestParams(value) {
if (typeof value === 'string') {
return {
uri: value,
method: 'get'
}
} else if (typeof value === 'object') {
const {uri, method = 'post', headers, withToken, secret, secretKey} = value;
return {
uri,
method,
headers,
withToken,
secret,
secretKey,
}
} else {
console.error('getRequestParams: 传参有误');
}
}
function generateAPI(apiList) {
const api = {};
for (let key in apiList) {
let value = apiList[key];
const {method, uri, headers: mHeaders, withToken, secret, secretKey} = getRequestParams(value);
api[key] = async (params = {}, headers) => {
let token;
if (withToken) {
const {type, payload} = await getPxToken();
switch (type) {
case 'success':
token = payload.token;
break;
case 'failed':
location.reload();
break;
}
}
let mergedHeaders = {...mHeaders, ...headers}
if (withToken && token) {
params.token = token;
}
params = {...params, ...mergeData};
const result = await callApi(uri, params, method, mergedHeaders, false, secret, secretKey);
if (result.type === 'success') {
return result.payload;
}
throw new Error(result.payload);
}
}
return api;
}
import Qs from "qs";
import axios from "axios";
// 分享召回工具类
import { isFromShare, newUser } from 'duiba-utils';
let mergeData = {
user_type: newUser ? '0' : '1',
is_from_share: isFromShare ? '0' : '1',
_t: Date.now()
}
const TIMEOUT = 10000;
const instance = axios.create({
timeout: TIMEOUT, // 请求超时时间
});
instance.interceptors.request.use(
(config) => {
if (config.method === "get") {
config.data = true;
}
config.method === "post"
? (config.data = Qs.stringify({ ...config.data, ...mergeData }))
: (config.params = { ...config.params, ...mergeData });
config.headers["Content-Type"] = "application/x-www-form-urlencoded";
return config;
},
(error) => {
//请求错误处理
Promise.reject(error);
}
);
// 响应拦截器
instance.interceptors.response.use(
// 请求成功
(res) => {
const { status } = res || -1000;
return (status >= 200 && status <= 400) ? res.data : res
}
);
export default instance;
import React, { Component } from "react";
import ReactDOM from "react-dom";
import "./app.less";
import { MOCK_STATUS } from '../sparkrc';
MOCK_STATUS && (require('../mock/index'));
import MD from '../MD';
MD();
//此处为spark-cli动态生成
import Share from "./pages/share/share.jsx";
class App extends Component {
render() {
return (
<Share>请在app.jsx中指定首页</Share>
);
}
}
ReactDOM.render(<App />, document.getElementById("root"));
* {
margin: 0;
padding: 0;
}
html,
body {
font-size: 24px;
width: 100%;
height: 100%;
}
'use strict';
import React, { Component } from 'react';
import resList from '../../resconfig/resList';
//import API from '../../api';
import './share.less';
class Share extends Component {
constructor(props) {
super(props);
this.state = { resList: resList };
}
render() {
return (
<div className="share " uuid="56b8468a-451e-423d-bc93-843f74e35170">
<img
className="bg "
uuid="9c7a49b1-a443-4e35-a5e1-2939349f09e7"
src={this.state.resList['64bd0c7b-cf6a-45da-847a-846866120f06'].url}
/>
<img
className="share_btn "
uuid="566aad1b-c581-4e3c-87c6-c3a051656ec8"
src={this.state.resList['53ff7051-7b71-49ad-ac7f-d35df1e135f0'].url}
/>
</div>
);
}
}
export default Share;
.share {
width: 750px;
height: 1624px;
position: absolute;
.bg {
width: 750px;
height: 1624px;
position: absolute;
}
.share_btn {
width: 446px;
height: 99px;
left: 152px;
top: 1136px;
position: absolute;
}
}
/**
* 目前没有用到
* @param {*} resList
* @param {*} uuid
*/
const getSrcByUuid = (resList, uuid) => {
resList = resList || [];
for (let i = 0; i < resList.length; i++) {
if (resList[i].uuid == uuid) {
return resList[i].url
}
}
}
module.exports = {
getSrcByUuid
}
\ No newline at end of file
const resList = {
'64bd0c7b-cf6a-45da-847a-846866120f06': {
name: 'bg',
ext: '.png',
uuid: '64bd0c7b-cf6a-45da-847a-846866120f06',
url: 'https://yun.duiba.com.cn/spark/assets/f22ffa96142c33ea321a5d3bec383c2a6e09cee4.png',
},
'53ff7051-7b71-49ad-ac7f-d35df1e135f0': {
name: 'share_btn',
ext: '.png',
uuid: '53ff7051-7b71-49ad-ac7f-d35df1e135f0',
url: 'https://yun.duiba.com.cn/spark/assets/eeea9e26e6010babeb918efe6595cf59ee774d18.png',
},
};
export default resList;
{"proName":"icbcrpgshare1","proDesc":"","proPath":"/Users/wanghongyuan/icbcrpgshare1","createTime":1608343633642}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment