demo
|
@ -0,0 +1,12 @@
|
|||
import { injectApp, waitLogin, gatewayHttpClient } from '@jdmini/api'
|
||||
App(injectApp()({
|
||||
globalData: {
|
||||
|
||||
},
|
||||
async onLaunch() {
|
||||
// 等待登陆完成以后请求自动携带token
|
||||
await waitLogin()
|
||||
// 三方登录本地缓存
|
||||
console.log(wx.getStorageSync('jdwx-userinfo'))
|
||||
},
|
||||
}))
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarBackgroundColor": "#ffffff"
|
||||
},
|
||||
"style": "v2",
|
||||
"componentFramework": "glass-easel",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
|
@ -0,0 +1,295 @@
|
|||
// Generated by dts-bundle v0.7.3
|
||||
|
||||
declare module '@jdmini/api' {
|
||||
import { onLoginReady, waitLogin } from '@jdmini/api/app';
|
||||
import HttpClient, { gatewayHttpClient, baseHttpClient, apiHttpClient } from '@jdmini/api/httpClient';
|
||||
import { injectApp, injectPage, injectComponent, hijackApp, hijackAllPage } from '@jdmini/api/injector';
|
||||
import adManager from '@jdmini/api/adManager';
|
||||
export { onLoginReady, waitLogin, injectApp, injectPage, injectComponent, hijackApp, hijackAllPage, gatewayHttpClient, baseHttpClient, apiHttpClient, HttpClient, adManager, };
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/app' {
|
||||
export interface AppOptions {
|
||||
gatewayUrl?: string;
|
||||
baseUrl?: string;
|
||||
apiUrl?: string;
|
||||
}
|
||||
export interface PageOptions {
|
||||
showInterstitialAd?: boolean;
|
||||
}
|
||||
export function initApp(options?: AppOptions): Promise<void>;
|
||||
export function showPage(options: PageOptions | undefined, pageId: string): Promise<void>;
|
||||
export const checkTokenValid: () => boolean;
|
||||
/**
|
||||
* 确保登录完成
|
||||
* @param {Function} callback - 回调函数
|
||||
* @returns {void}
|
||||
*/
|
||||
export function onLoginReady(callback: (...args: any[]) => void): void;
|
||||
/**
|
||||
* 等待登录完成
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export function waitLogin(): Promise<void>;
|
||||
export function login(): Promise<void>;
|
||||
export function fetchEchoData(): Promise<void>;
|
||||
export function trackVisit(): Promise<void>;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/httpClient' {
|
||||
import { HttpClientOptions, RequestOptions, ApiResponse } from '@jdmini/api/types';
|
||||
class HttpClient {
|
||||
constructor({ baseURL, timeout }: HttpClientOptions);
|
||||
setBaseURL(baseURL: string): void;
|
||||
/**
|
||||
* 请求
|
||||
* @param {string} path 路径
|
||||
* @param {string} method 方法, 默认GET
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {Object} options 传入wx.request的其他配置, 默认{}
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
request<T = any>(path: string, method?: WechatMiniprogram.RequestOption['method'], data?: Record<string, any>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 上传文件
|
||||
* @param {string} filePath 文件路径
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
uploadFile<T = any>(filePath: string, data?: Record<string, any>, type?: 'avatar' | 'file'): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 上传文件
|
||||
* @param {string} filePath 文件路径
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
upload<T = any>(path: string, filePath: string, data?: Record<string, any>): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 删除文件
|
||||
* @param {number} fileId 文件id
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
deleteFile(fileId: number): Promise<ApiResponse<null>>;
|
||||
/**
|
||||
* 上传头像
|
||||
* @param {string} filePath 文件路径
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
uploadAvatar<T = any>(filePath: string): Promise<ApiResponse<T>>;
|
||||
}
|
||||
export const gatewayHttpClient: HttpClient;
|
||||
export const baseHttpClient: HttpClient;
|
||||
export const apiHttpClient: HttpClient;
|
||||
export default HttpClient;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/injector' {
|
||||
interface AppConfig {
|
||||
onLaunch?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface PageConfig {
|
||||
onShow?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface ComponentConfig {
|
||||
methods?: {
|
||||
onLoad?: (...args: any[]) => void | Promise<void>;
|
||||
onShow?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
};
|
||||
[key: string]: any;
|
||||
}
|
||||
interface InjectAppOptions {
|
||||
gatewayUrl?: string;
|
||||
baseUrl?: string;
|
||||
apiUrl?: string;
|
||||
}
|
||||
interface InjectPageOptions {
|
||||
showInterstitialAd?: boolean;
|
||||
}
|
||||
/**
|
||||
* 注入应用配置
|
||||
* @param {Object} options - 配置选项
|
||||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||||
* @returns {Function} 返回一个接收应用配置的函数
|
||||
*/
|
||||
export function injectApp(options?: InjectAppOptions): (appConfig: AppConfig) => AppConfig;
|
||||
/**
|
||||
* 注入页面配置
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {Function} 返回一个接收页面配置的函数
|
||||
*/
|
||||
export function injectPage(options?: InjectPageOptions): (pageConfig?: PageConfig) => PageConfig;
|
||||
/**
|
||||
* 注入组件配置
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {Function} 返回一个接收组件配置的函数
|
||||
*/
|
||||
export function injectComponent(options?: InjectPageOptions): (pageConfig?: PageConfig) => ComponentConfig;
|
||||
/**
|
||||
* 劫持App
|
||||
* @param {InjectAppOptions} options - 配置选项
|
||||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||||
* @returns {void}
|
||||
*/
|
||||
export const hijackApp: (options?: InjectAppOptions) => void;
|
||||
/**
|
||||
* 劫持所有Page
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {void}
|
||||
*/
|
||||
export const hijackAllPage: (options?: InjectPageOptions) => void;
|
||||
export {};
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/adManager' {
|
||||
import { AdData, LinkData, TopData } from '@jdmini/api/types';
|
||||
type Ads = Partial<Record<AdData['appPage'], AdData['ads'][0]['adUnitId']>>;
|
||||
class AdManager {
|
||||
/**
|
||||
* 广告数据
|
||||
*/
|
||||
ads: Ads;
|
||||
/**
|
||||
* 友情链接数据
|
||||
*/
|
||||
link: LinkData[];
|
||||
/**
|
||||
* 友情链接顶部广告数据
|
||||
*/
|
||||
top: TopData | null;
|
||||
constructor();
|
||||
/**
|
||||
* 确保广告数据就绪
|
||||
* @param {Function} callback - 回调函数
|
||||
* @returns {void}
|
||||
*/
|
||||
onDataReady: (callback: (...args: any[]) => void) => void;
|
||||
/**
|
||||
* 等待广告数据加载完成
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
waitAdData: () => Promise<void>;
|
||||
/**
|
||||
* 初始化广告数据
|
||||
* @returns {void}
|
||||
*/
|
||||
init: () => void;
|
||||
/**
|
||||
* 创建并展示插屏广告
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createAndShowInterstitialAd: () => Promise<void>;
|
||||
/**
|
||||
* 创建并展示激励视频广告
|
||||
* @param {any} context - 页面上下文
|
||||
* @param {string} [pageId] - 页面ID
|
||||
* @returns {Promise<boolean>} 是否完成播放
|
||||
*/
|
||||
createAndShowRewardedVideoAd: (context: any, pageId?: string) => Promise<boolean>;
|
||||
}
|
||||
const _default: AdManager;
|
||||
export default _default;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/types' {
|
||||
export interface Config {
|
||||
API: {
|
||||
GATEWAY_URL: string;
|
||||
BASE_URL: string;
|
||||
API_URL: string;
|
||||
};
|
||||
APP: {
|
||||
APP_ID: number;
|
||||
LOGIN_MAX_RETRY: number;
|
||||
};
|
||||
HTTP: {
|
||||
TIMEOUT: number;
|
||||
};
|
||||
DATA: {
|
||||
PAGE_ID: string;
|
||||
};
|
||||
STORAGE_KEYS: {
|
||||
TOKEN: string;
|
||||
USER_INFO: string;
|
||||
SPA_DATA: string;
|
||||
LINK_DATA: string;
|
||||
TOP_DATA: string;
|
||||
};
|
||||
EVENT_KEYS: {
|
||||
LOGIN_SUCCESS: string;
|
||||
AD_DATA_READY: string;
|
||||
REWARDED_VIDEO_AD_CLOSE: string;
|
||||
};
|
||||
}
|
||||
export interface HttpClientOptions {
|
||||
baseURL: string;
|
||||
timeout?: number;
|
||||
}
|
||||
export interface RequestOptions {
|
||||
headers?: Record<string, string>;
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface LoginData {
|
||||
appId: number;
|
||||
code: string;
|
||||
brand: string;
|
||||
model: string;
|
||||
platform: string;
|
||||
}
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number;
|
||||
message?: string;
|
||||
data?: T;
|
||||
}
|
||||
export interface UserInfo {
|
||||
token: string;
|
||||
user: {
|
||||
id: number;
|
||||
name: string;
|
||||
avatar: string;
|
||||
openId: string;
|
||||
};
|
||||
}
|
||||
export interface EchoData {
|
||||
isPublished: boolean;
|
||||
spads: AdData[];
|
||||
links: LinkData[];
|
||||
top: TopData;
|
||||
version: number;
|
||||
}
|
||||
export interface AdData {
|
||||
id: number;
|
||||
status: number;
|
||||
appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
|
||||
ads: {
|
||||
id: number;
|
||||
type: number;
|
||||
adId: number;
|
||||
adUnitId: string;
|
||||
}[];
|
||||
}
|
||||
export interface LinkData {
|
||||
appId: string;
|
||||
appLogo: string;
|
||||
linkName: string;
|
||||
linkPage: string;
|
||||
}
|
||||
export interface TopData {
|
||||
appId: string;
|
||||
appLogo: string;
|
||||
linkName: string;
|
||||
appDsc: string;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,22 @@
|
|||
import { adManager } from '@jdmini/api'
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
type: {
|
||||
type: String,
|
||||
value: 'custom' // 可选banner, video, custom
|
||||
}
|
||||
},
|
||||
data: {
|
||||
ads: {}
|
||||
},
|
||||
lifetimes: {
|
||||
attached: function () {
|
||||
adManager.onDataReady(() => {
|
||||
this.setData({ ads: adManager.ads })
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"component": true
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<view class="jdwx-ad-component">
|
||||
<ad wx:if="{{type === 'banner' && ads.banner}}" class="jdwx-ad-item" unit-id="{{ads.banner}}"></ad>
|
||||
<ad wx:if="{{type === 'video' && ads.video}}" class="jdwx-ad-item" ad-type="video" unit-id="{{ads.video}}"></ad>
|
||||
<ad-custom wx:if="{{type === 'custom' && ads.custom}}" class="jdwx-ad-item" unit-id="{{ads.custom}}"></ad-custom>
|
||||
</view>
|
|
@ -0,0 +1,7 @@
|
|||
.jdwx-ad-component {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.jdwx-ad-item {
|
||||
bottom: 10rpx;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
import { adManager } from '@jdmini/api'
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
},
|
||||
data: {
|
||||
link: [],
|
||||
top: {},
|
||||
},
|
||||
pageLifetimes: {
|
||||
show: function () {
|
||||
adManager.onDataReady(() => {
|
||||
this.setData({
|
||||
link: adManager.link,
|
||||
top: adManager.top
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
gotopLink: function () {
|
||||
wx.vibrateShort()
|
||||
wx.openEmbeddedMiniProgram({
|
||||
appId: this.data.top.appId,
|
||||
path: this.data.top.linkPage
|
||||
});
|
||||
},
|
||||
goLink: function (e) {
|
||||
let index = e.currentTarget.id
|
||||
wx.vibrateShort()
|
||||
wx.openEmbeddedMiniProgram({
|
||||
appId: this.data.link[index].appId,
|
||||
path: this.data.link[index].linkPage
|
||||
});
|
||||
},
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"component": true
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<view class="jdwx-link-component">
|
||||
<view wx:if="{{top.appId}}" class="jdwx-applink-top" bindtap="gotopLink">
|
||||
<view><image src="{{top.appLogo}}" class="jdwx-applink-icon" /> </view>
|
||||
<view ><text class="jdwx-applink-top-linkname">{{top.linkName}}</text>
|
||||
<text class="jdwx-applink-top-text">{{top.appDsc}}</text> </view>
|
||||
</view>
|
||||
<view id="{{bindex}}" bindtap="goLink" wx:for="{{link}}" wx:for-index="bindex" wx:key="index" class="jdwx-applink-list">
|
||||
<image src="{{item.appLogo}}" class="jdwx-applink-icon" />
|
||||
<text class="jdwx-applink-text">{{item.linkName}}</text>
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1,63 @@
|
|||
/* 页面容器 */
|
||||
.jdwx-link-component {
|
||||
/* background-image: linear-gradient(to right, #4F9863, #4F9863); */
|
||||
background-attachment: fixed;
|
||||
background-size: cover; /* 确保背景图像覆盖整个元素 */
|
||||
/* height: 100vh; */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: auto; /* 允许内容滚动 */
|
||||
}
|
||||
|
||||
/* 列表项样式 */
|
||||
.jdwx-applink-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
/* 假设我们想要每个view的高度约为屏幕高度的1/8 */
|
||||
/* 使用小程序的wx.getSystemInfo API动态计算并设置这个值会更准确 */
|
||||
height: calc((100vh - 40rpx) / 10); /* 减去容器padding的影响 */
|
||||
padding: 20rpx;
|
||||
background-color: rgba(248, 250, 252, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
.jdwx-applink-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
/* 假设我们想要每个view的高度约为屏幕高度的1/8 */
|
||||
/* 使用小程序的wx.getSystemInfo API动态计算并设置这个值会更准确 */
|
||||
height: calc((100vh - 40rpx) / 6); /* 减去容器padding的影响 */
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 30rpx;
|
||||
background-color: rgba(248, 250, 252, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.jdwx-applink-top-linkname{
|
||||
display: flex;
|
||||
font-size: 36rpx;
|
||||
color: rgb(39, 37, 37);
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
/* 图标样式 */
|
||||
.jdwx-applink-icon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 50rpx;
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
|
||||
/* 文本样式 */
|
||||
.jdwx-applink-text {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
color: rgb(39, 37, 37);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "template",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@jdmini/api": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmmirror.com/@jdmini/api/-/api-1.0.10.tgz",
|
||||
"integrity": "sha512-bVFU0awuY033mUT4QqArrYbrnPkBaBFKHoqCMHTVnRCk4b6gTs+cCGDH8uyf2t8ybCgWITKxaaH4Vjzyq8VF8g=="
|
||||
},
|
||||
"node_modules/@jdmini/components": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/@jdmini/components/-/components-1.0.6.tgz",
|
||||
"integrity": "sha512-ndva1nlZ1QJqDVgHfB0GPxMGmXsZ7SbWjUkRm/WoQIkow75fFbaQCW/xhtQQ+bPbJLjXmCg2p2356klsLLib8A==",
|
||||
"peerDependencies": {
|
||||
"@jdmini/api": ">=1.0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
## 安装/更新
|
||||
|
||||
1、终端使用命令安装 npm 包
|
||||
|
||||
```bash
|
||||
npm install --save @jdmini/api@latest
|
||||
```
|
||||
|
||||
> ```bash
|
||||
> npm install --save @jdmini/components@latest
|
||||
> ```
|
||||
|
||||
2、在小程序开发者工具中:菜单选择工具 -> 构建 npm
|
||||
|
||||
## 使用
|
||||
|
||||
```js
|
||||
import {
|
||||
onLoginReady,
|
||||
waitLogin,
|
||||
|
||||
injectApp,
|
||||
injectPage,
|
||||
injectComponent,
|
||||
hijackApp,
|
||||
hijackAllPage,
|
||||
|
||||
gatewayHttpClient,
|
||||
baseHttpClient,
|
||||
apiHttpClient,
|
||||
HttpClient,
|
||||
|
||||
adManager,
|
||||
} from '@jdmini/api'
|
||||
```
|
||||
|
||||
### `waitLogin`/`onLoginReady` - 确保登录完成
|
||||
|
||||
- 同步的写法
|
||||
|
||||
```js
|
||||
async function onLoad() {
|
||||
await waitLogin()
|
||||
// 此处代码将在已登录或登陆完成后执行。请求将自动携带Token
|
||||
await gatewayHttpClient.request('/xxx', 'GET', {})
|
||||
}
|
||||
```
|
||||
|
||||
- 异步的写法
|
||||
|
||||
```js
|
||||
function onLoad() {
|
||||
onLoginReady(() => {
|
||||
// 此处代码将在已登录或登陆完成后执行。请求将自动携带Token
|
||||
gatewayHttpClient.request('/xxx', 'GET', {})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### `injectApp` - 向App注入基础代码
|
||||
|
||||
- 注入之后实现自动登录、广告初始化等功能
|
||||
|
||||
```js
|
||||
// app.js
|
||||
App(injectApp()({
|
||||
// 业务代码
|
||||
onLaunch() {
|
||||
|
||||
}
|
||||
}))
|
||||
```
|
||||
|
||||
### `injectPage` - 向Page注入基础代码
|
||||
|
||||
- 注入之后实现页面自动统计、自动展示插屏广告以及激励视频广告的调用支持
|
||||
- 参数:
|
||||
- showInterstitialAd: 是否自动展示插屏广告
|
||||
|
||||
```js
|
||||
// pages/xxx/xxx.js
|
||||
Page(injectPage({
|
||||
showInterstitialAd: true
|
||||
})({
|
||||
// 业务代码
|
||||
onLoad() {
|
||||
|
||||
}
|
||||
}))
|
||||
```
|
||||
|
||||
### `injectComponent` - 向Component注入基础代码
|
||||
|
||||
- 适用于使用Component构造页面的场景
|
||||
- 注入之后实现页面自动统计、自动展示插屏广告以及激励视频广告的调用支持
|
||||
- 参数:
|
||||
- showInterstitialAd: 是否自动展示插屏广告
|
||||
|
||||
```js
|
||||
// pages/xxx/xxx.js
|
||||
Component(injectComponent({
|
||||
showInterstitialAd: true
|
||||
})({
|
||||
// 业务代码
|
||||
methods: {
|
||||
onLoad() {
|
||||
|
||||
}
|
||||
}
|
||||
}))
|
||||
```
|
||||
|
||||
### `hijackApp` - 劫持全局App方法,注入基础代码
|
||||
|
||||
- 在不方便使用injectApp时使用(如解包后代码复杂,难以修改App调用)
|
||||
- 此方法会修改全局App方法,存在未知风险,使用时请进行完整测试
|
||||
- 不可与injectApp同时使用
|
||||
|
||||
```js
|
||||
// app.js
|
||||
hijackApp()
|
||||
```
|
||||
|
||||
### `hijackAllPage` - 劫持全局Page方法,注入基础代码
|
||||
|
||||
- 在不方便使用injectPage/injectComponent时使用(如解包后代码复杂,难以修改Page/Component调用)
|
||||
- 此方法会修改全局Page方法,并影响所有的页面,存在未知风险,使用时请进行完整测试
|
||||
- 参数同injectPage/injectComponent方法,不可与这些方法同时使用
|
||||
|
||||
```js
|
||||
// app.js
|
||||
hijackAllPage({
|
||||
showInterstitialAd: true
|
||||
})
|
||||
```
|
||||
|
||||
### `gatewayHttpClient` - 网关API调用封装
|
||||
|
||||
- 同步的写法
|
||||
|
||||
```js
|
||||
async function onLoad() {
|
||||
try {
|
||||
// 网关请求。参数:路径、方法、数据、其他选项(如headers、responseType)
|
||||
const data = await gatewayHttpClient.request(path, method, data,options)
|
||||
|
||||
// 头像上传。参数:文件路径
|
||||
const data = await gatewayHttpClient.uploadAvatar(filePath)
|
||||
|
||||
// 文件上传。参数:文件路径、数据
|
||||
const data = await gatewayHttpClient.uploadFile(filePath, data)
|
||||
|
||||
// 文件删除。参数:文件ID
|
||||
const data = await gatewayHttpClient.deleteFile(fileId)
|
||||
} catch(err) {
|
||||
// 响应HTTP状态码非200时自动showToast并抛出异常
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- 所有方法均支持异步的写法
|
||||
|
||||
```js
|
||||
function onLoad() {
|
||||
gatewayHttpClient.request('/xxx')
|
||||
.then(data => {
|
||||
console.log(data)
|
||||
})
|
||||
.catch(err => {})
|
||||
}
|
||||
```
|
||||
|
||||
### `baseHttpClient`/`apiHttpClient` - 为老版本兼容保留,不推荐使用
|
||||
|
||||
### `HttpClient` - API底层类,用于封装自定义请求
|
||||
|
||||
- 示例:封装一个百度的请求客户端,并调用百度搜索
|
||||
|
||||
```js
|
||||
const baiduHttpClient = new HttpClient({
|
||||
baseURL: 'https://www.baidu.com',
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
baiduHttpClient.request('/s', 'GET', { wd: '测试' }, { responseType: 'text' })
|
||||
.then(data => console.log(data))
|
||||
```
|
||||
|
||||
### `adManager` - 广告管理器
|
||||
|
||||
- 确保广告数据加载完成,支持同步/异步的写法
|
||||
|
||||
```js
|
||||
// 同步的写法
|
||||
async function onLoad() {
|
||||
await adManager.waitAdData()
|
||||
// 此处代码将在广告数据加载完成后执行
|
||||
await adManager.createAndShowInterstitialAd()
|
||||
}
|
||||
|
||||
// 异步的写法
|
||||
function onLoad () {
|
||||
adManager.onDataReady(() => {
|
||||
// 此处代码将在广告数据加载完成后执行
|
||||
adManager.createAndShowInterstitialAd()
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
- 广告数据
|
||||
|
||||
```js
|
||||
// 格式化之后的广告数据对象,如{banner: "adunit-f7709f349de05edc", custom: "adunit-34c76b0c3e4a6ed0", ...}
|
||||
const ads = adManager.ads
|
||||
|
||||
// 友情链接顶部广告数据
|
||||
const top = adManager.top
|
||||
|
||||
// 友情链接数据
|
||||
const link = adManager.link
|
||||
```
|
||||
|
||||
- 创建并展示插屏广告
|
||||
|
||||
```js
|
||||
function onLoad() {
|
||||
adManager.createAndShowInterstitialAd()
|
||||
}
|
||||
```
|
||||
|
||||
- 创建并展示激励视频广告
|
||||
- 传入当前页面的上下文this,返回用户是否已看完广告
|
||||
- 由于微信的底层限制,需要先在调用的页面上进行injectPage注入,且该方法必须放在用户的点击事件里调用
|
||||
- 使用示例可参考[jdwx-demo](https://code.miniappapi.com/wx/jdwx-demo)
|
||||
|
||||
```js
|
||||
// 同步的写法
|
||||
page({
|
||||
async handleClick() {
|
||||
const isEnded = await adManager.createAndShowRewardedVideoAd(this)
|
||||
}
|
||||
})
|
||||
|
||||
// 异步的写法
|
||||
page({
|
||||
handleClick() {
|
||||
adManager.createAndShowRewardedVideoAd(this).then((isEnded) => {
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
|
@ -0,0 +1,295 @@
|
|||
// Generated by dts-bundle v0.7.3
|
||||
|
||||
declare module '@jdmini/api' {
|
||||
import { onLoginReady, waitLogin } from '@jdmini/api/app';
|
||||
import HttpClient, { gatewayHttpClient, baseHttpClient, apiHttpClient } from '@jdmini/api/httpClient';
|
||||
import { injectApp, injectPage, injectComponent, hijackApp, hijackAllPage } from '@jdmini/api/injector';
|
||||
import adManager from '@jdmini/api/adManager';
|
||||
export { onLoginReady, waitLogin, injectApp, injectPage, injectComponent, hijackApp, hijackAllPage, gatewayHttpClient, baseHttpClient, apiHttpClient, HttpClient, adManager, };
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/app' {
|
||||
export interface AppOptions {
|
||||
gatewayUrl?: string;
|
||||
baseUrl?: string;
|
||||
apiUrl?: string;
|
||||
}
|
||||
export interface PageOptions {
|
||||
showInterstitialAd?: boolean;
|
||||
}
|
||||
export function initApp(options?: AppOptions): Promise<void>;
|
||||
export function showPage(options: PageOptions | undefined, pageId: string): Promise<void>;
|
||||
export const checkTokenValid: () => boolean;
|
||||
/**
|
||||
* 确保登录完成
|
||||
* @param {Function} callback - 回调函数
|
||||
* @returns {void}
|
||||
*/
|
||||
export function onLoginReady(callback: (...args: any[]) => void): void;
|
||||
/**
|
||||
* 等待登录完成
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export function waitLogin(): Promise<void>;
|
||||
export function login(): Promise<void>;
|
||||
export function fetchEchoData(): Promise<void>;
|
||||
export function trackVisit(): Promise<void>;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/httpClient' {
|
||||
import { HttpClientOptions, RequestOptions, ApiResponse } from '@jdmini/api/types';
|
||||
class HttpClient {
|
||||
constructor({ baseURL, timeout }: HttpClientOptions);
|
||||
setBaseURL(baseURL: string): void;
|
||||
/**
|
||||
* 请求
|
||||
* @param {string} path 路径
|
||||
* @param {string} method 方法, 默认GET
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {Object} options 传入wx.request的其他配置, 默认{}
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
request<T = any>(path: string, method?: WechatMiniprogram.RequestOption['method'], data?: Record<string, any>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 上传文件
|
||||
* @param {string} filePath 文件路径
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
uploadFile<T = any>(filePath: string, data?: Record<string, any>, type?: 'avatar' | 'file'): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 上传文件
|
||||
* @param {string} filePath 文件路径
|
||||
* @param {Object} data 数据, 默认{}
|
||||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
upload<T = any>(path: string, filePath: string, data?: Record<string, any>): Promise<ApiResponse<T>>;
|
||||
/**
|
||||
* 删除文件
|
||||
* @param {number} fileId 文件id
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
deleteFile(fileId: number): Promise<ApiResponse<null>>;
|
||||
/**
|
||||
* 上传头像
|
||||
* @param {string} filePath 文件路径
|
||||
* @returns {Promise<Object>} 返回一个Promise对象
|
||||
*/
|
||||
uploadAvatar<T = any>(filePath: string): Promise<ApiResponse<T>>;
|
||||
}
|
||||
export const gatewayHttpClient: HttpClient;
|
||||
export const baseHttpClient: HttpClient;
|
||||
export const apiHttpClient: HttpClient;
|
||||
export default HttpClient;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/injector' {
|
||||
interface AppConfig {
|
||||
onLaunch?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface PageConfig {
|
||||
onShow?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface ComponentConfig {
|
||||
methods?: {
|
||||
onLoad?: (...args: any[]) => void | Promise<void>;
|
||||
onShow?: (...args: any[]) => void | Promise<void>;
|
||||
[key: string]: any;
|
||||
};
|
||||
[key: string]: any;
|
||||
}
|
||||
interface InjectAppOptions {
|
||||
gatewayUrl?: string;
|
||||
baseUrl?: string;
|
||||
apiUrl?: string;
|
||||
}
|
||||
interface InjectPageOptions {
|
||||
showInterstitialAd?: boolean;
|
||||
}
|
||||
/**
|
||||
* 注入应用配置
|
||||
* @param {Object} options - 配置选项
|
||||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||||
* @returns {Function} 返回一个接收应用配置的函数
|
||||
*/
|
||||
export function injectApp(options?: InjectAppOptions): (appConfig: AppConfig) => AppConfig;
|
||||
/**
|
||||
* 注入页面配置
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {Function} 返回一个接收页面配置的函数
|
||||
*/
|
||||
export function injectPage(options?: InjectPageOptions): (pageConfig?: PageConfig) => PageConfig;
|
||||
/**
|
||||
* 注入组件配置
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {Function} 返回一个接收组件配置的函数
|
||||
*/
|
||||
export function injectComponent(options?: InjectPageOptions): (pageConfig?: PageConfig) => ComponentConfig;
|
||||
/**
|
||||
* 劫持App
|
||||
* @param {InjectAppOptions} options - 配置选项
|
||||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||||
* @returns {void}
|
||||
*/
|
||||
export const hijackApp: (options?: InjectAppOptions) => void;
|
||||
/**
|
||||
* 劫持所有Page
|
||||
* @param {InjectPageOptions} options - 配置选项
|
||||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||||
* @returns {void}
|
||||
*/
|
||||
export const hijackAllPage: (options?: InjectPageOptions) => void;
|
||||
export {};
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/adManager' {
|
||||
import { AdData, LinkData, TopData } from '@jdmini/api/types';
|
||||
type Ads = Partial<Record<AdData['appPage'], AdData['ads'][0]['adUnitId']>>;
|
||||
class AdManager {
|
||||
/**
|
||||
* 广告数据
|
||||
*/
|
||||
ads: Ads;
|
||||
/**
|
||||
* 友情链接数据
|
||||
*/
|
||||
link: LinkData[];
|
||||
/**
|
||||
* 友情链接顶部广告数据
|
||||
*/
|
||||
top: TopData | null;
|
||||
constructor();
|
||||
/**
|
||||
* 确保广告数据就绪
|
||||
* @param {Function} callback - 回调函数
|
||||
* @returns {void}
|
||||
*/
|
||||
onDataReady: (callback: (...args: any[]) => void) => void;
|
||||
/**
|
||||
* 等待广告数据加载完成
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
waitAdData: () => Promise<void>;
|
||||
/**
|
||||
* 初始化广告数据
|
||||
* @returns {void}
|
||||
*/
|
||||
init: () => void;
|
||||
/**
|
||||
* 创建并展示插屏广告
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
createAndShowInterstitialAd: () => Promise<void>;
|
||||
/**
|
||||
* 创建并展示激励视频广告
|
||||
* @param {any} context - 页面上下文
|
||||
* @param {string} [pageId] - 页面ID
|
||||
* @returns {Promise<boolean>} 是否完成播放
|
||||
*/
|
||||
createAndShowRewardedVideoAd: (context: any, pageId?: string) => Promise<boolean>;
|
||||
}
|
||||
const _default: AdManager;
|
||||
export default _default;
|
||||
}
|
||||
|
||||
declare module '@jdmini/api/types' {
|
||||
export interface Config {
|
||||
API: {
|
||||
GATEWAY_URL: string;
|
||||
BASE_URL: string;
|
||||
API_URL: string;
|
||||
};
|
||||
APP: {
|
||||
APP_ID: number;
|
||||
LOGIN_MAX_RETRY: number;
|
||||
};
|
||||
HTTP: {
|
||||
TIMEOUT: number;
|
||||
};
|
||||
DATA: {
|
||||
PAGE_ID: string;
|
||||
};
|
||||
STORAGE_KEYS: {
|
||||
TOKEN: string;
|
||||
USER_INFO: string;
|
||||
SPA_DATA: string;
|
||||
LINK_DATA: string;
|
||||
TOP_DATA: string;
|
||||
};
|
||||
EVENT_KEYS: {
|
||||
LOGIN_SUCCESS: string;
|
||||
AD_DATA_READY: string;
|
||||
REWARDED_VIDEO_AD_CLOSE: string;
|
||||
};
|
||||
}
|
||||
export interface HttpClientOptions {
|
||||
baseURL: string;
|
||||
timeout?: number;
|
||||
}
|
||||
export interface RequestOptions {
|
||||
headers?: Record<string, string>;
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface LoginData {
|
||||
appId: number;
|
||||
code: string;
|
||||
brand: string;
|
||||
model: string;
|
||||
platform: string;
|
||||
}
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number;
|
||||
message?: string;
|
||||
data?: T;
|
||||
}
|
||||
export interface UserInfo {
|
||||
token: string;
|
||||
user: {
|
||||
id: number;
|
||||
name: string;
|
||||
avatar: string;
|
||||
openId: string;
|
||||
};
|
||||
}
|
||||
export interface EchoData {
|
||||
isPublished: boolean;
|
||||
spads: AdData[];
|
||||
links: LinkData[];
|
||||
top: TopData;
|
||||
version: number;
|
||||
}
|
||||
export interface AdData {
|
||||
id: number;
|
||||
status: number;
|
||||
appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
|
||||
ads: {
|
||||
id: number;
|
||||
type: number;
|
||||
adId: number;
|
||||
adUnitId: string;
|
||||
}[];
|
||||
}
|
||||
export interface LinkData {
|
||||
appId: string;
|
||||
appLogo: string;
|
||||
linkName: string;
|
||||
linkPage: string;
|
||||
}
|
||||
export interface TopData {
|
||||
appId: string;
|
||||
appLogo: string;
|
||||
linkName: string;
|
||||
appDsc: string;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@jdmini/api",
|
||||
"version": "1.0.10",
|
||||
"main": "miniprogram_dist/index.js",
|
||||
"files": [
|
||||
"miniprogram_dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"pub": "npm run build && npm publish --access public",
|
||||
"build:js": "tsc --project tsconfig_tsc.json"
|
||||
},
|
||||
"miniprogram": "miniprogram_dist",
|
||||
"author": "",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@types/wechat-miniprogram": "^3.4.8",
|
||||
"dts-bundle": "^0.7.3",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.6.3",
|
||||
"webpack": "^5.96.1",
|
||||
"webpack-cli": "^5.1.4"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
## 安装/更新
|
||||
|
||||
1、终端使用命令安装 npm 包
|
||||
|
||||
```bash
|
||||
npm install --save @jdmini/components@latest
|
||||
```
|
||||
|
||||
2、在小程序开发者工具中:菜单选择工具 -> 构建 npm
|
||||
|
||||
`注意:依赖@jdmini/api,请确保小程序项目已安装@jdmini/api`
|
||||
|
||||
## 使用
|
||||
|
||||
1、在页面的 json 文件中引入组件:
|
||||
|
||||
```json
|
||||
{
|
||||
"usingComponents": {
|
||||
"jdwx-ad": "@jdmini/components/jdwx-ad",
|
||||
"jdwx-link": "@jdmini/components/jdwx-link"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2、在页面的 wxml 文件中使用组件:
|
||||
|
||||
```html
|
||||
<jdwx-ad type="custom" />
|
||||
<jdwx-link />
|
||||
```
|
BIN
node_modules/@jdmini/components/miniprogram_dist/icons/home-active.png
generated
vendored
Normal file
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.0 KiB |
BIN
node_modules/@jdmini/components/miniprogram_dist/icons/link-active.png
generated
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.8 KiB |
|
@ -0,0 +1,22 @@
|
|||
import { adManager } from '@jdmini/api'
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
type: {
|
||||
type: String,
|
||||
value: 'custom' // 可选banner, video, custom
|
||||
}
|
||||
},
|
||||
data: {
|
||||
ads: {}
|
||||
},
|
||||
lifetimes: {
|
||||
attached: function () {
|
||||
adManager.onDataReady(() => {
|
||||
this.setData({ ads: adManager.ads })
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
})
|
3
node_modules/@jdmini/components/miniprogram_dist/jdwx-ad/index.json
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"component": true
|
||||
}
|
5
node_modules/@jdmini/components/miniprogram_dist/jdwx-ad/index.wxml
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<view class="jdwx-ad-component">
|
||||
<ad wx:if="{{type === 'banner' && ads.banner}}" class="jdwx-ad-item" unit-id="{{ads.banner}}"></ad>
|
||||
<ad wx:if="{{type === 'video' && ads.video}}" class="jdwx-ad-item" ad-type="video" unit-id="{{ads.video}}"></ad>
|
||||
<ad-custom wx:if="{{type === 'custom' && ads.custom}}" class="jdwx-ad-item" unit-id="{{ads.custom}}"></ad-custom>
|
||||
</view>
|
7
node_modules/@jdmini/components/miniprogram_dist/jdwx-ad/index.wxss
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
.jdwx-ad-component {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.jdwx-ad-item {
|
||||
bottom: 10rpx;
|
||||
}
|
37
node_modules/@jdmini/components/miniprogram_dist/jdwx-link/index.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { adManager } from '@jdmini/api'
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
},
|
||||
data: {
|
||||
link: [],
|
||||
top: {},
|
||||
},
|
||||
pageLifetimes: {
|
||||
show: function () {
|
||||
adManager.onDataReady(() => {
|
||||
this.setData({
|
||||
link: adManager.link,
|
||||
top: adManager.top
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
gotopLink: function () {
|
||||
wx.vibrateShort()
|
||||
wx.openEmbeddedMiniProgram({
|
||||
appId: this.data.top.appId,
|
||||
path: this.data.top.linkPage
|
||||
});
|
||||
},
|
||||
goLink: function (e) {
|
||||
let index = e.currentTarget.id
|
||||
wx.vibrateShort()
|
||||
wx.openEmbeddedMiniProgram({
|
||||
appId: this.data.link[index].appId,
|
||||
path: this.data.link[index].linkPage
|
||||
});
|
||||
},
|
||||
}
|
||||
})
|
3
node_modules/@jdmini/components/miniprogram_dist/jdwx-link/index.json
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"component": true
|
||||
}
|
11
node_modules/@jdmini/components/miniprogram_dist/jdwx-link/index.wxml
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<view class="jdwx-link-component">
|
||||
<view wx:if="{{top.appId}}" class="jdwx-applink-top" bindtap="gotopLink">
|
||||
<view><image src="{{top.appLogo}}" class="jdwx-applink-icon" /> </view>
|
||||
<view ><text class="jdwx-applink-top-linkname">{{top.linkName}}</text>
|
||||
<text class="jdwx-applink-top-text">{{top.appDsc}}</text> </view>
|
||||
</view>
|
||||
<view id="{{bindex}}" bindtap="goLink" wx:for="{{link}}" wx:for-index="bindex" wx:key="index" class="jdwx-applink-list">
|
||||
<image src="{{item.appLogo}}" class="jdwx-applink-icon" />
|
||||
<text class="jdwx-applink-text">{{item.linkName}}</text>
|
||||
</view>
|
||||
</view>
|
63
node_modules/@jdmini/components/miniprogram_dist/jdwx-link/index.wxss
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* 页面容器 */
|
||||
.jdwx-link-component {
|
||||
/* background-image: linear-gradient(to right, #4F9863, #4F9863); */
|
||||
background-attachment: fixed;
|
||||
background-size: cover; /* 确保背景图像覆盖整个元素 */
|
||||
/* height: 100vh; */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 20rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: auto; /* 允许内容滚动 */
|
||||
}
|
||||
|
||||
/* 列表项样式 */
|
||||
.jdwx-applink-list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
/* 假设我们想要每个view的高度约为屏幕高度的1/8 */
|
||||
/* 使用小程序的wx.getSystemInfo API动态计算并设置这个值会更准确 */
|
||||
height: calc((100vh - 40rpx) / 10); /* 减去容器padding的影响 */
|
||||
padding: 20rpx;
|
||||
background-color: rgba(248, 250, 252, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
.jdwx-applink-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
/* 假设我们想要每个view的高度约为屏幕高度的1/8 */
|
||||
/* 使用小程序的wx.getSystemInfo API动态计算并设置这个值会更准确 */
|
||||
height: calc((100vh - 40rpx) / 6); /* 减去容器padding的影响 */
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 30rpx;
|
||||
background-color: rgba(248, 250, 252, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.jdwx-applink-top-linkname{
|
||||
display: flex;
|
||||
font-size: 36rpx;
|
||||
color: rgb(39, 37, 37);
|
||||
padding-bottom: 10rpx;
|
||||
}
|
||||
/* 图标样式 */
|
||||
.jdwx-applink-icon {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 50rpx;
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
|
||||
/* 文本样式 */
|
||||
.jdwx-applink-text {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
color: rgb(39, 37, 37);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "@jdmini/components",
|
||||
"version": "1.0.6",
|
||||
"description": "",
|
||||
"files": [
|
||||
"miniprogram_dist",
|
||||
"resources"
|
||||
],
|
||||
"scripts": {
|
||||
"pub": "npm publish --access public"
|
||||
},
|
||||
"miniprogram": "miniprogram_dist",
|
||||
"author": "",
|
||||
"peerDependencies": {
|
||||
"@jdmini/api": ">=1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/wechat-miniprogram": "^3.4.8"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "template",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@jdmini/api": "^1.0.10",
|
||||
"@jdmini/components": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@jdmini/api": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmmirror.com/@jdmini/api/-/api-1.0.10.tgz",
|
||||
"integrity": "sha512-bVFU0awuY033mUT4QqArrYbrnPkBaBFKHoqCMHTVnRCk4b6gTs+cCGDH8uyf2t8ybCgWITKxaaH4Vjzyq8VF8g=="
|
||||
},
|
||||
"node_modules/@jdmini/components": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmmirror.com/@jdmini/components/-/components-1.0.6.tgz",
|
||||
"integrity": "sha512-ndva1nlZ1QJqDVgHfB0GPxMGmXsZ7SbWjUkRm/WoQIkow75fFbaQCW/xhtQQ+bPbJLjXmCg2p2356klsLLib8A==",
|
||||
"peerDependencies": {
|
||||
"@jdmini/api": ">=1.0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@jdmini/api": "^1.0.10",
|
||||
"@jdmini/components": "^1.0.6"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { injectPage, adManager } from '@jdmini/api'
|
||||
|
||||
Page(injectPage({
|
||||
//showInterstitialAd:true// 插屏广告
|
||||
})({
|
||||
data: {
|
||||
|
||||
},
|
||||
//视频激励广告
|
||||
async showRewardedVideoAd() {
|
||||
const isEnded = await adManager.createAndShowRewardedVideoAd(this)
|
||||
console.log(isEnded)
|
||||
}
|
||||
}))
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<view>null</view>
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "trial",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"setting": {
|
||||
"coverView": true,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"enhance": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"packNpmRelationList": [],
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"compileWorklet": false,
|
||||
"uglifyFileName": false,
|
||||
"uploadWithSourceMap": true,
|
||||
"packNpmManually": false,
|
||||
"minifyWXSS": true,
|
||||
"minifyWXML": true,
|
||||
"localPlugins": false,
|
||||
"condition": false,
|
||||
"swc": false,
|
||||
"disableSWC": true,
|
||||
"disableUseStrict": false,
|
||||
"useCompilerPlugins": false
|
||||
},
|
||||
"condition": {},
|
||||
"editorSetting": {
|
||||
"tabIndent": "auto",
|
||||
"tabSize": 2
|
||||
},
|
||||
"appid": "wxe4ef1cc6e75de032",
|
||||
"simulatorPluginLibVersion": {}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "template",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false,
|
||||
"coverView": true,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"skylineRenderEnable": false,
|
||||
"preloadBackgroundData": false,
|
||||
"autoAudits": false,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"useStaticServer": false,
|
||||
"useLanDebug": false,
|
||||
"showES6CompileOption": false,
|
||||
"bigPackageSizeSupport": false,
|
||||
"checkInvalidKey": true,
|
||||
"ignoreDevUnusedFiles": true
|
||||
},
|
||||
"libVersion": "3.10.1"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|