From 188cf156ca5b62754c8a1a576a300bb715735e81 Mon Sep 17 00:00:00 2001 From: nonespace Date: Tue, 17 Mar 2020 23:43:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=9C=A8=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/commont.js | 18 ++++++++++++++++++ src/article/Index.vue | 2 +- src/utils/request.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/api/commont.js create mode 100644 src/utils/request.js diff --git a/src/api/commont.js b/src/api/commont.js new file mode 100644 index 0000000..70b4b79 --- /dev/null +++ b/src/api/commont.js @@ -0,0 +1,18 @@ +import { get } from '../utils/request' + +export function getTotic(params) { + /** + * @description 获取主题 + * @param {string} tab 顶部tab,如果全部,可不传或all,其他使用 node name + * @param {number} p 第几页,不传代表第1页 + */ + return get('/topics', params) +} +export function getToticDetail(params) { + /** + * @description 获取主题详情 + * @param {number} tid 主题id + */ + return get('/topic/detail', params) +} + diff --git a/src/article/Index.vue b/src/article/Index.vue index ccb406d..bb67beb 100644 --- a/src/article/Index.vue +++ b/src/article/Index.vue @@ -21,7 +21,7 @@ export default Vue.extend({ name: 'Article', data() { return { - article:{ + article: { author: { avatar: 'http://img1.3lian.com/gif/more/11/2012/03/d037a77443c0a72a1432d815cd3b5724.jpg', nickname: '昵称' diff --git a/src/utils/request.js b/src/utils/request.js new file mode 100644 index 0000000..91619ed --- /dev/null +++ b/src/utils/request.js @@ -0,0 +1,34 @@ + +const baseUrl = 'https://studygolang.com/app' +function request({ url, data, method }) { + const header = { + token: wx.getStorageSync('token') || '', + } + return new Promise((resove, reject) => { + wx.request({ + url: baseUrl + url, + method, + data: { ...data, from: 4 }, + header, + success: (res) => { + resove(res.data) + }, + fail: (res) => { + reject(res) + } + }) + }) +} + +function get(url, data) { + return request({ url, method: 'get', data }) +} +function post(url, data) { + return request({ url, method: 'post', data }) +} + +export { + request, + get, + post +} From a24661588cbec353fc573e486d127359006014a7 Mon Sep 17 00:00:00 2001 From: nonespace Date: Wed, 18 Mar 2020 20:29:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=20#17:=E8=AF=B7=E6=B1=82=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/commont.js | 95 +++++++++++++++++++++++++++++++++++++++-- src/home/Tabs/Index.vue | 6 +++ 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/src/api/commont.js b/src/api/commont.js index 70b4b79..56278a0 100644 --- a/src/api/commont.js +++ b/src/api/commont.js @@ -1,4 +1,4 @@ -import { get } from '../utils/request' +import { get, post } from '../utils/request' export function getTotic(params) { /** @@ -8,11 +8,100 @@ export function getTotic(params) { */ return get('/topics', params) } -export function getToticDetail(params) { +export function getToticDetail(tid) { /** * @description 获取主题详情 * @param {number} tid 主题id */ - return get('/topic/detail', params) + return get('/topic/detail', { tid }) } +export function checkSession(code) { + /** + * @description 检查登录 + * @param {string} code 小程序登录code + */ + return get('/wechat/check_session', { code }) +} + +export function register(params) { + /** + * @description 注册系统账号并绑定 + * @param {string} params.unbind_token + * @param {string} params.username 用户名 + * @param {string} params.email 邮箱 + * @param {string} params.passwd 密码 + * @param {string} params.pass2 确认密码 + * @param {string} params.userInfo 小程序 wx.getUserInfo 返回的 userInfo,json 格式原样传过来 + */ + return post('/wechat/register', params) +} + +export function login(params) { + /** + * @description 登录 + * @param {string} params.token token + * @param {number} params.uid 中文网用户uid + * @param {string} params.nickname 微信昵称 + * @param {string} params.avatar 微信头像 + */ + return get('/wechat/login', params) +} + +export function getArticles(p) { + /** + * @description 文章列表 + * @param {number} p token + */ + return get('/articles', { p }) +} + +export function articleDetail(id) { + /** + * @description 文章详情 + * @param {number} id + */ + return get('/article/detail', { id }) +} + +export function getSources(p) { + /** + * @description 资源列表 + * @param {number} p + */ + return get('/resources', { p }) +} + +export function getSourceDetail(id) { + /** + * @description 资源详情 + * @param {number} id + */ + return get('/resource/detail', { id }) +} + +export function getProjects(p) { + /** + * @description 项目列表 + * @param {number} p + */ + return get('/projects', { p }) +} + +export function getProjectDetail(id) { + /** + * @description 项目详情 + * @param {number} id + */ + return get('/project/detail', { id }) +} + +export function comment(objid, data) { + /** + * @description 提交评论 + * @param {number} objid + * @param {number} data.objtype 0-主题;1-文章;2-资源;3-wiki;4-开源项目;5-图书; + * @param {string} data.content + */ + return post(`comment/${objid}`, data) +} diff --git a/src/home/Tabs/Index.vue b/src/home/Tabs/Index.vue index ca0172f..7c1fa5d 100644 --- a/src/home/Tabs/Index.vue +++ b/src/home/Tabs/Index.vue @@ -23,6 +23,7 @@ From f60fbd5b5455bec232b651855fd8fe4155cea05a Mon Sep 17 00:00:00 2001 From: Dean Zhang Date: Fri, 20 Mar 2020 15:28:24 +0800 Subject: [PATCH 3/3] update --- build/miniprogram.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/miniprogram.config.js b/build/miniprogram.config.js index 8ca1bdd..dbe65ee 100644 --- a/build/miniprogram.config.js +++ b/build/miniprogram.config.js @@ -3,8 +3,8 @@ */ module.exports = { - origin: 'https://mina.baobeihuijia.com', - entry: '/', + origin: 'https://studygolang.com/', + entry: '/app', router: { home: [ '/(home|index)?',