Skip to content

Commit

Permalink
Update news
Browse files Browse the repository at this point in the history
Signed-off-by: Kang HuaiShuai <khs1994@khs1994.com>
  • Loading branch information
khs1994 committed Apr 6, 2020
1 parent dc2f71b commit 0ba383a
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 6 deletions.
6 changes: 6 additions & 0 deletions client/pages/docker/summary/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,10 @@ Page({
'https://gitee.com/docker_practice/docker_practice/raw/master/_images/cover.jpg',
};
},
onTabItemTap(item) {
// tab 点击时执行
console.log(item.index);
console.log(item.pagePath);
console.log(item.text);
},
});
90 changes: 87 additions & 3 deletions client/pages/mdContent/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// pages/mdContent/index.js

import isqq from '../../src/utils/isqq';
import Cache from '../../src/Framework/src/Support/Cache';

let key: any = null;
let title: any;
let toDoActivityId: any;
let expirationTime: any;
let cache = new Cache();

Page({
/**
Expand All @@ -15,17 +18,55 @@ Page({
? ['f2ba7917096dc03c7d798df304a90c49', 'a4f45b9d8d5704ab70bebfd0780854a8']
: ['adunit-3ea71b7cfce6c721', 'adunit-1246f0a5e441ea4c'],
markdown: '',
openGId: null,
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: async function (options) {
console.log(JSON.stringify(options));

key = options.key;
title = options.title;
// 1585976131
const { activityId, expirationTime } = options;
toDoActivityId = null;

console.log(JSON.stringify(options));
let { shareTicket } = wx.getLaunchOptionsSync();

console.log('shareTicket: ' + shareTicket);
console.log('activityId: ' + activityId);

if (activityId && shareTicket) {
wx.showModal({
title: '欢迎从群聊中进入',
content: '您的每次进入,都会增加所在群的排名',
showCancel: false,
});

wx.getShareInfo({
shareTicket,
success: async (res) => {
let { cloudID } = res;

let result = await wx.cloud.callFunction({
name: 'getGroup',
data: {
// @ts-ignore
group: wx.cloud.CloudID(cloudID), // 这个 CloudID 值到云函数端会被替换
},
});

console.log(result);

this.setData({
// @ts-ignore
openGId: result.result,
});
},
});
}

wx.request({
url:
Expand All @@ -39,10 +80,49 @@ Page({
},
});

// 插屏广告
if ((await cache.get('is-news-show-ad')) !== 'true') {
let interstitialAd = wx.createInterstitialAd({
adUnitId: isqq
? 'b9b0567ae11780a9f7886b61683c1ae2'
: 'adunit-6ef44789d84b9392',
});

setTimeout(() => {
interstitialAd.show().then(
() => {
console.log('S 插屏广告 success');
cache.set('is-news-show-ad', 'true', 120);
},
(e) => {
console.log('E 插屏广告 error: ' + JSON.stringify(e));
},
);
}, 15000);

interstitialAd.onError((e) => {
console.log('E 插屏广告 onerror: ' + JSON.stringify(e));
});

interstitialAd.onLoad(() => {
console.log('L 插屏广告 onload');
});

interstitialAd.onClose(() => {
console.log('X 插屏广告 onclose');
});
} else {
console.log('120s 之内不再展示广告');
} // if end

if (!activityId) {
return;
}

if (activityId === 'null') {
return;
}

// @ts-ignore
if (Date.parse(new Date()) / 1000 > expirationTime) {
wx.showModal({
Expand Down Expand Up @@ -83,6 +163,10 @@ Page({
console.log(result);
},

onUnLoad() {
toDoActivityId = null;
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
Expand Down Expand Up @@ -158,8 +242,8 @@ Page({

onShareAppMessage(): any {
return {
title: '今日分享',
path: `pages/mdContent/index?key=${key}&activityId=${toDoActivityId}&expirationTime=${expirationTime}`,
title: '今日分享 -- ' + title,
path: `pages/mdContent/index?key=${key}&title=${title}&activityId=${toDoActivityId}&expirationTime=${expirationTime}`,
imageUrl:
'https://gitee.com/docker_practice/docker_practice/raw/master/_images/cover.jpg',
};
Expand Down
5 changes: 5 additions & 0 deletions client/pages/mdContent/index.wxml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<markdown markdown="{{markdown}}" ad="{{ad}}"></markdown>
<i-button shape="circle" bind:click="share" size="large" type="primary">群内学习</i-button>
<i-button shape="circle" size="large" type="success"
wx:if="{{openGId}}"
>
<open-data class="" type="groupName" open-gid="{{openGId}}"></open-data>
</i-button>
4 changes: 2 additions & 2 deletions client/pages/news/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ Page({
click(res: any) {
a = 1;
console.log(res);
const key = res.currentTarget.dataset.key;
const { key, title } = res.currentTarget.dataset;
wx.navigateTo({
url: '../mdContent/index?key=' + key,
url: `../mdContent/index?key=${key}&title=${title}`,
});
},
});
2 changes: 1 addition & 1 deletion client/pages/news/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<view class="kind-list">
<block wx:for="{{news}}">
<view class="kind-list__item">
<view id="{{item.id}}" class="weui-flex kind-list__item-hd {{item.open ? 'kind-list__item-hd_show' : ''}}" bindtap="click" data-key="{{item.key}}">
<view id="{{item.id}}" class="weui-flex kind-list__item-hd {{item.open ? 'kind-list__item-hd_show' : ''}}" bindtap="click" data-key="{{item.key}}" data-title="{{item.title}}">
<view wx:if="{{item.color}}" class="weui-flex__item" style="color: {{item.color}}">{{item.title}}</view>
<view wx:else class="weui-flex__item title">{{item.title}}</view>
<view class="weui-flex__item date">{{item.date}}</view>
Expand Down
5 changes: 5 additions & 0 deletions functions/getGroup/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"permissions": {
"openapi": []
}
}
13 changes: 13 additions & 0 deletions functions/getGroup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 云函数入口文件
const cloud = require('wx-server-sdk');

cloud.init();

// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext();

console.log(event.group);

return event.group.data.openGId;
};
14 changes: 14 additions & 0 deletions functions/getGroup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "getGroup",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~1.8.3"
}
}
11 changes: 11 additions & 0 deletions news/2020/azk8s.cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# azk8s.cn 镜像服务已转为仅限 Azure 云内部使用,请立即更换

编辑 `/etc/docker/daemon.json`,新增网易云加速器。

```json
{
"registry-mirrors": ["https://hub-mirror.c.163.com"]
}
```

详情请查看 [镜像加速器](../docker/content/index?key=install/mirror.md)
1 change: 1 addition & 0 deletions news/news.cloud.db
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
{"_id":9,"title":"[修订记录] 使用 docker context 操作多个 Docker 后端","date":"2019/12/01","key":"news/2019/docker-context.md"}
{"_id":10,"title":"[修订记录] 使用 kubeadm 部署 Kubernetes","date":"2019/12/01","key":"news/2019/kubeadm.md"}
{"_id":11,"title":"[修订记录] 在 Docker 桌面版启动 Kubernetes","date":"2019/12/01","key":"news/2019/docker-desktop-k8s.md"}
{"_id":12,"title":"azk8s.cn 镜像服务已转为仅限 Azure 云内部使用,请立即更换","date":"2020/04/05","key":"news/2020/azk8s.cn.md"}

0 comments on commit 0ba383a

Please sign in to comment.