Use DeviceOne to implement the WeChat applet function

Source: Internet
Author: User
The small program is coming soon, and it will not work until it is launched. Based on this huge platform, the small program will surely have great success. However, it cannot completely replace the App, and the App must be developed. If we want to implement a small program function based on our own APP, how can we implement it? Let's take a look at the technical features of small programs. The small program is coming soon, and it will not work until it is launched. Based on this huge platform, the small program will surely have great success. However, it cannot completely replace the App, and the App must be developed. If we want to implement a small program function based on our own APP, how can we implement it? Let's take a look at the technical features of small programs.

# Features of applets
1. cross-platform, just like JRE, is implemented on different operating systems, so small programs are like java programs running on JRE, so as to implement cross-platform. It also solves the problem of multi-platform and multi-model adaptation.

2. good experience. loading html from webview is the easiest cross-platform method, but the experience on mobile phones is too poor. There is no relationship between applets and web development, as well as h5. its ui and running mechanism are completely native, so the experience is much better than the public account.

3. no installation is required. you only need to scan the QR code. In fact, there will still be downloads, but the downloaded data is very small and the user cannot detect it. For example, if you develop a small program with 10 pages, the user only downloads several files on the home page during scanning, which may be less than 1 kB, and is cached locally and in memory after the download.

In fact, there is another biggest advantage: the application with the highest viscosity of a huge number of users, which is easy to promote based on the above small programs. we will not talk about it here.

Let's take a look at the disadvantages:
1. it can only be based on the portal. this is obvious. Currently, the received message cannot have a applet portal on the desktop. I don't know if it will be supported in the future.

2. you can only use the features of the app. you cannot use other third-party functions such as map, payment, and statistics. These functions are both available and well-developed, but diversified technologies make better use of long-term technological development.

3. the capabilities of small programs are limited. limited UIs and limited functions cannot meet complex interaction and business requirements. In addition, developers cannot expand their basic functions.

DeviceOne has both the above advantages and can also avoid the above shortcomings, and you will certainly question this. First, let's briefly introduce the corresponding descriptions of DeviceOne for the above points, and then take a look at an example.

# Features of DeviceOne
1. cross-platform, with js or lua as the development language, one-time writing, released to android, ios, and windows platforms. It also automatically adapts to various models.

2. good experience. from ui to functions, deviceone is completely native and has nothing to do with html. Therefore, it is a native experience.

3. no installation is required. we can analyze the installation carefully from the example below.

4. it is not based on a fixed framework App. that is to say, you can create your own program. for now, we call it the main program. you can have your own icons and portals, then load your own small program. Both the main program and the main program can be hot upgraded, just as convenient as updating the mini program.

5. deviceone completely componentized app development across platforms. developers are divided into two parts: business developers who develop apps and native developers who develop native components.

5.1 app developers do not need to understand android and ios, and do not need to have android and ios development environments. they only need js to develop apps.

5.2 developers do not need to understand and understand the business needs of specific apps, but only need to develop reusable cross-platform ui and functional components. Therefore, you can integrate any third-party components. for example, you can integrate Baidu Map, AMAP, alipay, and payment.

6. the deviceone component has the extended function. Currently, more than 100 components are officially provided, and more than 30 components are provided by other developers. based on the deviceone platform, other native developers can continuously expand the component store.


# Example of a applet
Run first
3. click a row to open the new page, load the applet, exit the page, and close the applet.

The basic code is as follows:

Var http = mm ("do_Http"); // display the waiting window var waittingLayer = require ("source: // modules/waittingLayer/call"); waittingLayer. invoke ({hint: "please wait"}); var src = "data: //" + data. id + ". zip "; http. url = data. url; http. on ("result", function (d) {sm ("do_Storage "). unzip (src, "data: // temp/" + data. id, function (_ d, e) {var updatesrc = "data: // temp/" + data. id + "/source/view"; sm ("do_App "). update ([updatesrc], "source: // view", function () {sm ("do_Page "). fire ("installed", data. id); // hide the waiting window var waittingLayer = require ("source: // modules/waittingLayer/call"); waittingLayer. invoke ({close: true}) ;})}) http. download (src );

# Summary
I think it is very simple, but it is of great significance. in addition to the easy update of small programs, the main program is also easy to update and the principle is completely consistent. This can be used for two basic purposes.
1. implement the hot update of the program. all the logic and pages of the deviceone service are text files, including js code and ui files (json description), which are easy to update.

2. for larger applications or enterprises, different development teams and departments can complete the business independently, and then managed by a framework App to standardize application development and management. In addition, deviceone has powerful cloud packaging capabilities, and compilation and packaging can also be managed in a standard manner.

The last thing I want to talk about is that deviceone is not just an idea and practice. it has been a product that has been in operation for more than a year and has provided many services to many individuals and companies on the Internet, many personal and enterprise-oriented applications have been launched.

For more articles about how to use DeviceOne to implement the applet function, please follow the PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.