GithubHelp home page GithubHelp logo

leiyun1993 / wanandroid-mini Goto Github PK

View Code? Open in Web Editor NEW
42.0 2.0 3.0 451 KB

基于玩安卓开放api的微信小程序

Home Page: http://www.wanandroid.com/blog/show/2

License: Apache License 2.0

JavaScript 100.00%
wanandroid wanandoidclient javascript weixin mini

wanandroid-mini's Introduction

玩Android-小程序版

关注wanandroid有些时日了,一直以来也是鸿洋大神的粉丝,一直都有用他开放的api此前是使用kotlin完成了一个版本【wanandroid】,这次我们使用微信小程序完成一个版本。

没有申请公众号并且小程序只支持https所以不能发体验,仅作为交流之用,希望大家看的开心、玩的愉快~

简介

开发工具:小程序开发工具1.02.1811290---下载地址

调试基础版本:2.4.1

项目截图

image image image image image image image image image image image image image

部分功能解析

1、网络请求

加入ES6 Promise 封装网络请求,同时处理登录时候的cookie保存,并持久化

let request = (url, data, type) => new Promise((resolve, reject) => {
  wx.request({
    url: 'http://www.wanandroid.com' + url,
    data: data,
    method: type, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    header: {
      'content-type': 'application/x-www-form-urlencoded', // 默认值
      "cookie": wx.getStorageSync("cookie")
    },
    success: function(res) {
      // success
      if (res.data.errorCode === 0) {
        if (url == interfaces.INTERFACE_USER_LOGIN){
          wx.setStorageSync("cookie", res.header['Set-Cookie'])
        }
        resolve(res.data);
      } else {
        reject(res.data)
      }
    },
    fail: function(err) {
      // fail
      reject(err)
    },
    complete: function() {
      // complete
    }
  })
})

这样处理回调的时候就可以很简单的如下处理:

import api from "../../api/api.js";
api.IPostCollect(id)
  .then(res => {
    //success
  })
  .catch(e => {
    //fail
  })

版本信息

v1.0.0

  • 首页文章与Banner
  • 微信文章
  • 项目
  • 登录
  • 注册
  • 我的收藏
  • 知识体系
  • TODO工具
  • 搜索功能
  • 优化项目页瀑布流显示

TKS

  • 感谢鸿洋大神创建了这么好的学习网站WanAndroid

License

Copyright 2018 YunLei

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

wanandroid-mini's People

Contributors

leiyun1993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wanandroid-mini's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.