This article is only for personal development of small programs, local development and testing, no need to buy services, domain names.
Precautions:
1, nginx environment variables and nginx.conf file configuration
2. Remove the verification of illegal domain names in the applet
Here is the text:
1. Apply for WeChat applet permission. . .
2. Download nginx, I downloaded the windows-1.12.2 version, the official website: http://nginx.org/en/download.html
3. Configure nginx reverse proxy to access tomcat: https://blog.csdn.net/wild46cat/article/details/52840125
In the nginx directory, where there is nginx.exe, use Shift and right-click, and choose to open the command line here
Enter start nginx to start nginx, enter localhost:8989 in the web page, add your own interface link, you can see the data
4. Please refer to https://blog.csdn.net/leedaning/article/details/71125559 for configuration of https
Enter nginx -s stop on the command line to close nginx, and then restart start nginx
Just find a project to start, use the https link to access the interface, and you can use it.
(After testing, it was found that restarting nginx was invalid, so this method of closing and reopening was used)
I integrated the two configurations, and the following is the complete nginx.conf file configuration:
events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; fastcgi_buffers 8 128k; server { listen 8989; server_name localhost:8080; location / { root html; index index.html index.htm; proxy_pass http://127.0.0.1:8080/; } } # HTTPS server # server { listen 443 ssl; #这里的域名要和hosts中配置的相同 server_name wx.kikyou.cn; ssl_certificate D:/weixin/nginx/ssl/service.crt; ssl_certificate_key D:/weixin/nginx/ssl/service.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; server_name_in_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:8989/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }
The content of the local hosts file: add it directly at the end of the file, where wx.kikyou.cn needs to correspond to the server_name wx.kikyou.cn in the second server;
10.73.120.2 axineczihslb1 10.73.120.3 axineczappmocalb1 10.73.120.4 axinweb 127.0.0.1 wx.kikyou.cn
5. Open the applet development tool, create a test applet, and log in to the applet
Add a trigger event to kikyou to access the interface
[Note] Before accessing the interface, you need to remove the https verification, otherwise you cannot access, because such https is not legal.
Click Details, check Do not verify the security domain name, if you can't find the details, please click Interface - Toolbar, you can see it.
userManage.js
var url = "https://wx.kikyou.cn/system/user/info"; Page({ data: { hidden: true, list: [], scrollTop: 0, scrollHeight: 0 }, onLoad: function () { console.log("成功跳转页面"); // 这里要非常注意,微信的scroll-view必须要设置高度才能监听滚动事件,所以,需要在页面的onLoad事件中给scroll-view的高度赋值 var that = this; wx.getSystemInfo({ success: function (res) { that.setData({ scrollHeight: res.windowHeight }); wx.request({ url: url, data: { id: 1 }, success: function (res) { console.info(res); var list = res.data.data; console.info(list); that.setData({ list: list }); // page++; that.setData({ hidden: true }); console.log(that.data) } }); } }); } })
<view class="container"> <scroll-view scroll-top="{{scrollTop}}" scroll-y="true" style="height:{{scrollHeight}}px;" class="list" bindscrolltolower="bindDownLoad" bindscroll="scroll" bindscrolltoupper="refresh"> <view class="item" wx:for="{{list}}"> <view class="text"> <text class="title">{{item}}</text> <!-- <text class="title">{{item.userName}}</text> <text class="description">{{item.email}}</text> --> </view> </view> </scroll-view> <view class="body-view"> <loading hidden="{{hidden}}" bindchange="loadingChange"> 加载中... </loading> </view> </view>返回结果:
完成了✿✿ヽ(°▽°)ノ✿
第一次接触小程序和前端,希望自己以后能有更多更优质的分享(#^.^#)