微信原生小程序转uniapp过程及错误总结

https://ask.dcloud.net.cn/article/35786 此文章尤为重要,可以使用辅助工具

1、this.setData

复制代码
源代码:
this.setData({
      dateTime: obj.dateTime,
});

需更换为
this.dateTime =  obj.dateTime

2、cookie问题

在此文章有解释

https://blog.csdn.net/ni15534789894/article/details/141607435?spm=1011.2415.3001.5331

3、区分小程序及uniapp

复制代码
if(uni.getSystemInfoSync().platform == 'devtools')
uni.getSystemInfoSync().platform为devtools是小程序

4、接口请求不成功

一定要查看url以及filePath都不为空才可以
复制代码
if(uni.getSystemInfoSync().platform == 'devtools'){
		console.log(999)
		const uploadFilePross = wx.uploadFile({
		    // url: 'http://10.64.11.212:8088/receive/uploadAudio',
		    url: 'https://qrcode.sprixin.com:51080/receive/uploadAudio',
		    methid: 'POST',
		    // 可用可不用
		    formData: {
		        username: username
		    },
		    filePath: upVideoArr,
		    name: 'file',
		    // 服务器定义key字段名称
		    header: app.globalData.header,
		    success: function (res) {
				console.log(res,'888')
		        var data = JSON.parse(res.data);
				console.log(data,'999')
		        if (data.success) {
		            // if (index == upVideoArr.length - 1) {
		                uni.showModal({
		                    title: '提示',
		                    content: '上传成功',
		                    showCancel: false,
		                    complete: (res) => {
		                        if (res.confirm) {
		                            t.disabled = false
		                            t.upVideoArr = []
		                            t.upFilesProgress = false
		                        }
		                    }
		                });
		            // }
					 // else {
		    //             index++;
		    //             data.index = index;
		    //             // uploadFiles(username, t, data, progress, success);
		    //         }
		        } else {
		        }
		    }
		});
		uploadFilePross.onProgressUpdate((res) => {
		    res['index'] = index;
		    if (typeof progress == 'function') {
		        progress(res);
		    }
		});
	}
相关推荐
MoonMoonLee2 天前
小程序配置
小程序
码兄科技2 天前
24小时自助健身房系统软件开发实战指南:功能设计与部署方案
java·spring boot·uni-app
微信开发api2 天前
微信iPad协议怎么用?基于协议的二次开发实践
微信·机器人·ipad
wechatbot8882 天前
极客互动企业微信 SCRM 自动运营平台效果实测
java·微信·企业微信·rpa
懂软件的胡子个哥2 天前
微信机器人为什么需要“回复候选”而不是所有 AI 内容直接发送
运维·微信·自动化·wechatapi·个人微信号二次开发
2501_916007472 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
JQweryuiop2 天前
中小型游戏陪练工作室数字化管理实践:基于七彩屋电竞护航小程序订单、履约与绩效系统的落地复盘
大数据·游戏·小程序·架构
Ai-_Man2 天前
您您这可以把Mistral AI的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。
人工智能·ai·小程序·电脑
微信开发api2 天前
微信机器人接口:REST API vs WebSocket 选型建议
微信·机器人·ipad
2501_916008892 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview