You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.
Page ( {
clickBtn ( ) {
let that = this ;
wx . chooseMessageFile ( {
count : 1 ,
type : 'file' ,
success : res => {
wx . showLoading ( {
title : '正在上传' ,
} ) ;
let filePath = res . tempFiles [ 0 ] . path ;
console . log ( "选择execl成功" , filePath ) ;
that . clearDatabase ( filePath ) ;
}
} ) ;
} ,
clearDatabase ( filePath ) {
const db = wx . cloud . database ( {
env : 'fzu-rollcall-system-7c9tbd0e8c2b'
} ) ;
const stu = db . collection ( 'users' ) ; // 替换为你的集合名称
stu . where ( {
_id : db . command . exists ( true )
} ) . remove ( ) . then ( res => {
console . log ( '删除成功' ) ;
this . setData ( {
number : ''
} ) ;
this . cloudFile ( filePath ) ;
} ) . catch ( err => {
console . log ( '删除失败' , err ) ; // 失败提示错误信息
} ) ;
} ,
cloudFile ( path ) {
let that = this
wx . cloud . uploadFile ( {
cloudPath : "xueshemingdan.xlsx" ,
filePath : path ,
success : res => {
wx . hideLoading ( )
console . log ( "上传成功" , res . fileID )
that . jiexi ( res . fileID )
} ,
fail : err => {
console . log ( "上传失败" , err )
}
} )
} ,
jiexi ( fileId ) {
wx . cloud . callFunction ( {
name : "excel" ,
data : {
fileID : fileId
} ,
success ( res ) {
console . log ( "success" , res )
} ,
fail ( res )
{
console . log ( "failed" , res )
}
} )
}
} ) ;