What are the difficulties in mini program development?
This article lists several difficult knowledge for developing small programs, I hope it can help everyone.
(Learning video sharing: Programming video)
1. Mini program generates QR code
Mini program generates QR code Mini program generates 2 The QR code actually needs to be called by the backend, and then the frontend can call the backend interface.
In the following example, we pass additional parameters to the backend scene (the maximum length is 32 characters, only supports numbers, uppercase and lowercase English and some special characters: !#$&'()*, /:;=?@-._~, please encode other characters into legal characters by yourself), which are used in the opened applet.
let scene = 't=3&n='+ this.inputVal+'&sale='+this.saleId; request(qcode,{isHyaline:false,qrcodeType:2,scene:scene,width:255,color:{r:'255',g:'255',b:'255'}}) .then(res=>{}) })
The pitfall here is how the front-end obtains the parameters of users by scanning the QR code
onLoad(opts){ var scene = decodeURIComponent(opts.scene); // scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene }
2. Mini program jumps to mini program
The mini program calls toMiniProgram, here I am Made a simple package
function toMiniProgram(appid, path, extraData) { wx.navigateToMiniProgram({ appId: appid, // 要打开的小程序 appId path: path, // 打开的页面路径 envVersion: 'develop', //要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。 extraData: extraData, // 需要传递给目标小程序的数据 success: function (res) { console.log('打开成功') }, fail: function (res) {} }) }
Use
toMiniProgram('appid','pages/customer/goods-detail?id='+id+'&saleId='+this.saleId,{});
on the page to get the parameters in another small program
onLoad(opts){ this.goodsId=opts.id this.saleId=opts.saleId }
3. Implementation of the ceiling effect
The principle of the ceiling effect is to rearrange the tabs scrolled to a certain height into fixed
html
<view class="tab-ctn"> <view class="tabs flex flex-justify {{isTabFixed?'fixed':''}}" id="tabs"> <view class="item pr {{tabIndex===0?'on':''}}" @tap="toggleTab(0)">商品介绍</view> <view class="item pr {{tabIndex===1?'on':''}}" @tap="toggleTab(1)">规格参数</view> </view> </view>
css
.tabs{ padding:0 176rpx; font-size:30rpx; height:90rpx; border-bottom:0.5px solid #E4E4E4;} .item{ height:100%; position:relative; padding-top:20rpx; color:#999; &.on{ color:#FD343B; font-weight:bold; } } .fixed{ position:fixed; top:0; left:0; right:0; z-index:9; }
js
data={ detailTopH:300, } onLoad(){ this.getElHeight('') // tab上面元素的高度 } /**封装根据id获取元素高度 */ getElHeightById(id){ return new Promise(function(resolve,reject){ const query = wx.createSelectorQuery() query.select('#'+id).boundingClientRect() query.selectViewport().scrollOffset() query.exec(function (res) { resolve(res[0].height) }) }) } // 调用 getElHeight(id){ this.getElHeightById(id).then(res=>{ this.detailTopH = res }) } /**监听页面滚动事件 */ onPageScroll(e){ if(e.scrollTop>=this.detailTopH && !this.isTabFixed){ this.isTabFixed=true }else if(e.scrollTop<=this.detailTopH && this.isTabFixed){ this.isTabFixed=false } }
4 , encapsulation timestamp
function formatTime(timestamp, type = "date") { var date = new Date(timestamp); var year = date.getFullYear() var month = date.getMonth() + 1 var day = date.getDate() var hour = date.getHours() var minute = date.getMinutes() var second = date.getSeconds() if (type == "date") { return [year, month, day].map(formatNumber).join('-'); } else if (type == "all") { return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':') } else if (type == "time") { return [hour, minute, second].map(formatNumber).join(':') } else if (type == "time2") { return [hour, minute].map(formatNumber).join(':') } else if (type == 'month') { return [month, day].map(formatNumber).join('-'); } } /**niu 封装时间戳格式化辅助,将年月日先转为字符串,再判断是否加0*/ function formatNumber(n) { n = n.toString() return n[1] ? n : '0' + n } formatTime(1236547891,'all') // 2019-11-02 03:11:11 formatTime(1236547891,'time') // 03:11:22 formatTime(1236547891,'time2') // 03:11 formatTime(1236547891,'month') // 03-03 formatTime(1236547891,'date') // 2019-11-02
Related recommendations:小program development
The above is the detailed content of What are the difficulties in mini program development?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











With the popularity of mobile Internet technology and smartphones, WeChat has become an indispensable application in people's lives. WeChat mini programs allow people to directly use mini programs to solve some simple needs without downloading and installing applications. This article will introduce how to use Python to develop WeChat applet. 1. Preparation Before using Python to develop WeChat applet, you need to install the relevant Python library. It is recommended to use the two libraries wxpy and itchat here. wxpy is a WeChat machine

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

Mini programs can use react. How to use it: 1. Implement a renderer based on "react-reconciler" and generate a DSL; 2. Create a mini program component to parse and render DSL; 3. Install npm and execute the developer Build npm in the tool; 4. Introduce the package into your own page, and then use the API to complete the development.

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

This article brings you some related issues about WeChat mini programs. It mainly introduces how to use official account template messages in mini programs. Let’s take a look at them together. I hope it will be helpful to everyone.

Implementation idea: Establishing the server side of thread, so as to process the various functions of the chat room. The establishment of the x02 client is much simpler than the server. The function of the client is only to send and receive messages, and to enter specific characters according to specific rules. To achieve the use of different functions, therefore, on the client side, you only need to use two threads, one is dedicated to receiving messages, and the other is dedicated to sending messages. As for why not use one, that is because, only

Geolocation positioning and map display of PHP and mini programs Geolocation positioning and map display have become one of the necessary functions in modern technology. With the popularity of mobile devices, people's demand for positioning and map display is also increasing. During the development process, PHP and applets are two common technology choices. This article will introduce you to the implementation method of geographical location positioning and map display in PHP and mini programs, and attach corresponding code examples. 1. Geolocation in PHP In PHP, we can use third-party geolocation
