当前位置:网站首页>Uni app wechat applet ordering system [another order] page Jump
Uni app wechat applet ordering system [another order] page Jump
2022-07-19 02:35:00 【Tamarind_】
1 Like hungry Click on 【 Another one 】 The effect of
2 When you click on another order , Get the order of this order id, Jump to the page , By order id Get the goods in the order id, Query products id, The goods must be on the shelves / Inventory cannot be 0 etc. .
3 After the item is successfully added , Click again on the 【 Another one 】, Did not continue to add items to the shopping cart , But it will jump .
4 Adding other products can Add to the shopping cart
--------------------------------------------------------------------------------------------------
Problems encountered :
Click on 【 Another one 】 When I jump to the page , The goods have been successfully added to the shopping cart . Every time you enter the shopping cart from another page , Add the same items to the shopping cart .
Code :
template in :
<button type="primary" plain hover-class="none" @tap="onceMore(order.orderId)"> Another one </button>
methods in :
onceMore(orderId) {
if(orderId != '') {
uni.setStorageSync('orderId', orderId);
uni.switchTab({
// Another one
url:"/pages/index/index"
})
}
}/pages/index/index.vue:
script in :
onShow() {
this.orderId = '';
this.type = '';
this.orderId = uni.getStorageSync('orderId');
console.log("this.orderId="+this.orderId);
if(this.orderId != '' && this.orderId != undefined && this.type != '' && this.type != undefined) {
if(!this.cartFlag) {
this.getAddCartGoods(this.orderId, this.type);
}
}
},
analysis :
① Think it's onShow problem .
So will onShow and onLoad Changed many times , So I have the following understanding .
-----onShow and onLoad The difference between -----
onShow: Every time you switch pages and then switch back, you will reload
onLoad: Load the page only once , Switching pages will not load
It's not about it .
② Guess if there is a cache problem .
So I checked switchTab The value of the setStorageSync And receive parameters getStorageSync.
stay uni-app Official website Found the relevant introduction (https://uniapp.dcloud.io/api/storage/storage?id=setstoragesync)
setStorageSync Is stored in the local cache ,getStorageSync Is to get values from the local cache . Then when I switch pages, the value transfer always exists , So every page switch , When switching back to the page of adding to the shopping cart, products will be added to the shopping cart . Even if you don't click another order, it will accumulate .
I happened to see it on the official website removeStorage.
So in index.vue Added code :
script in :
onShow() {
this.orderId = '';
this.type = '';
this.orderId = uni.getStorageSync('orderId');
console.log("this.orderId="+this.orderId);
// Clear the cache of orderId, But the page has been obtained orderId, Use global variables directly
uni.removeStorage({
key: 'orderId',
success: function (res) {
console.log('success');
}
});
if(this.orderId != '' && this.orderId != undefined) {
if(!this.cartFlag) {
this.getAddCartGoods(this.orderId);
}
}
},
This solves the problem .
边栏推荐
- Logical vulnerability - authentication vulnerability
- VLAN and trunk port configuration
- [antv G2] how to solve the memory leak caused by G2
- UE4 notes
- php伪协议实现命令执行
- 【Unity开发小技巧】Unity混音器Mixer控制全局音量
- [tools] unity screen drawing line, unity screen drawing Hsj drawing tool
- 【Unity编辑器扩展】查找场景和资源内挂载某脚本的所有对象
- 【工具篇】Unity2D人物控制器,控制2D玩家移动跳跃,四方向和水平方向
- 30分钟搞懂 HTTP 缓存
猜你喜欢

网络一般知识(详)

Jmeter beanshell实现把请求生成的参数化数据写入文件

Detailed explanation of caduceus project of metauniverse public chain (I): project concept and technical framework of caduceus metaverse protocol

子网划分(详)

STL -- stack container

去中心化边缘渲染元宇宙协议Caduceus受邀出席CBAIA 2022峰会,以技术赋能更多Web3应用场景

30分钟搞懂 HTTP 缓存

【Unity编辑器扩展】Unity资产预处理和后处理图片自动转Sprite2D

Logic vulnerability - login verification code security

网络层传输协议(详解)
随机推荐
元宇宙开发者的乐园 解析元宇宙协议Caduceus生态价值
Server knowledge (details)
In depth performance test data analysis
Tree array and St table
转载:SQL注入常见绕过
Chapter 2 - system control principle - > classical control theory
Detailed explanation of caduceus project of metauniverse public chain (I): project concept and technical framework of caduceus metaverse protocol
Stl--queue container
Jmeter响应时间测试组件&多接口并发
Decentralized edge rendering meta universe protocol cadeus was invited to attend the cbaia 2022 summit to enable more Web3 application scenarios with technology
Performance test implementation specification Guide
接口(Collection/Map)- 各接口的实现与对比
How to configure multiple SSH keys for novices (easy to understand hand-in-hand teaching)
STL -- List container (linked list)
Simple use case writing specification
Method of JMeter connecting to database
项目性能优化实战:解决首页白屏问题,自定义 loading 动画优化首屏效果
sqlmap的使用
[tools] unity2d character controller, which controls 2D players to move and jump in four directions and horizontal directions
Unity导入fbx模型后,运行时物体的旋转和位置自动改变的问题解决方法