Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b9e93296
authored
Jun 27, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
oss
1 parent
53e6417f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
211 additions
and
126 deletions
App.vue
components/HomeFrame/index.vue
hybrid/html/index.html
hybrid/html/js/OSSUpLoader.js
main.js
mixin/click.js
mixin/storge.js
pages/equity/index.vue
utils/ossUploadFile/uploadFile.js
App.vue
View file @
b9e9329
...
@@ -7,12 +7,14 @@
...
@@ -7,12 +7,14 @@
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
-->
<
script
>
<
script
>
var
wv
;
import
checkUpdate
from
"@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js"
;
import
checkUpdate
from
"@/uni_modules/uni-upgrade-center-app/utils/check-update-nvue.js"
;
import
{
mapState
}
from
"vuex"
;
import
{
mapState
}
from
"vuex"
;
export
default
{
export
default
{
computed
:
{
computed
:
{
...
mapState
(
"audio"
,
[
"isEnd"
,
"isStart"
]),
...
mapState
(
"audio"
,
[
"isEnd"
,
"isStart"
]),
},
},
onLoad
()
{},
onLaunch
:
async
function
()
{
onLaunch
:
async
function
()
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
plus
.
screen
.
unlockOrientation
();
//解除锁定屏幕方向
plus
.
screen
.
unlockOrientation
();
//解除锁定屏幕方向
...
@@ -41,6 +43,9 @@ export default {
...
@@ -41,6 +43,9 @@ export default {
</
script
>
</
script
>
<
style
lang=
"scss"
>
<
style
lang=
"scss"
>
body
{
overflow
:
hidden
;
}
page
{
page
{
font-size
:
28
rpx
;
font-size
:
28
rpx
;
height
:
100%
;
height
:
100%
;
...
@@ -102,4 +107,11 @@ button::after {
...
@@ -102,4 +107,11 @@ button::after {
.button-hover
{
.button-hover
{
transform
:
translate
(
1
rpx
,
1
rpx
);
transform
:
translate
(
1
rpx
,
1
rpx
);
}
}
.webview-container
{
position
:
absolute
;
width
:
100
rpx
;
height
:
100
rpx
;
top
:
0
rpx
;
left
:
0
rpx
;
}
</
style
>
</
style
>
components/HomeFrame/index.vue
View file @
b9e9329
<
template
>
<
template
>
<view
<view
class=
"container"
@
click=
"handleTouchStart"
>
class=
"container"
@
click=
"handleTouchStart"
>
<view
:class=
"['home',
{ show: !id }]">
<view
:class=
"['home',
{ show: !id }]">
<view
class=
"bg"
>
<view
class=
"bg"
>
<view
class=
"top"
>
<view
class=
"top"
>
<view
<view
class=
"top-one"
:style=
"randomize"
></view>
class=
"top-one"
:style=
"randomize"
></view>
</view>
</view>
<view
class=
"bottom"
>
<view
class=
"bottom"
>
<view
<view
class=
"bottom-one"
:style=
"randomize"
></view>
class=
"bottom-one"
<view
class=
"bottom-two"
:style=
"randomize"
></view>
:style=
"randomize"
<view
class=
"bottom-three"
:style=
"randomize"
></view>
></view>
<view
class=
"bottom-two"
:style=
"randomize"
></view>
<view
class=
"bottom-three"
:style=
"randomize"
></view>
</view>
</view>
</view>
</view>
<view
class=
"left-side"
>
<view
class=
"left-side"
>
...
@@ -39,26 +24,22 @@
...
@@ -39,26 +24,22 @@
@click="changeIndex(index)"
@click="changeIndex(index)"
>
>
<view
class=
"icon-box"
>
<view
class=
"icon-box"
>
<view
:class=
"[
<view
:class=
"[
'sprite-icon',
'sprite-icon',
`icon-$
{i.icon}${tabIndex == index ? '-active' : ''}`,
`icon-$
{i.icon}${tabIndex == index ? '-active' : ''}`,
]">
</view>
]"
>
</view>
</view>
</view>
{{
i
.
label
}}
{{
i
.
label
}}
</view>
</view>
</
template
>
</
template
>
</view>
</view>
<view
class=
"left-footer"
>
<view
class=
"left-footer"
>
<view
<view
class=
"btn"
@
click=
"$refs.kfRef.open()"
>
class=
"btn"
@
click=
"$refs.kfRef.open()"
>
<view
class=
"sprite-icon icon-feedback"
></view>
<view
class=
"sprite-icon icon-feedback"
></view>
</view>
</view>
<view
<view
class=
"btn"
@
click=
"$refs.settingRef.open()"
>
class=
"btn"
@
click=
"$refs.settingRef.open()"
>
<view
class=
"sprite-icon icon-setting"
></view>
<view
class=
"sprite-icon icon-setting"
></view>
</view>
</view>
</view>
</view>
...
@@ -66,10 +47,7 @@
...
@@ -66,10 +47,7 @@
<view
class=
"right-side"
>
<view
class=
"right-side"
>
<
template
v-if=
"tabIndex == 0"
>
<
template
v-if=
"tabIndex == 0"
>
<view
class=
"right-content"
>
<view
class=
"right-content"
>
<view
<view
class=
"start"
@
click=
"$emit('start')"
>
class=
"start"
@
click=
"$emit('start')"
>
<image
<image
class=
"start-btn"
class=
"start-btn"
src=
"../../assets/images/home/start.gif"
src=
"../../assets/images/home/start.gif"
...
@@ -121,21 +99,13 @@
...
@@ -121,21 +99,13 @@
:isFooter=
"false"
:isFooter=
"false"
>
>
<view
class=
"footer"
>
<view
class=
"footer"
>
<view
<view
class=
"footer-btn confirm flex"
@
click=
"$emit('openStep')"
>
class=
"footer-btn confirm flex"
@
click=
"$emit('openStep')"
>
<
template
v-if=
"finishDoneText"
>
<
template
v-if=
"finishDoneText"
>
{{
finishDoneText
}}
{{
finishDoneText
}}
</
template
>
<
template
v-else
>
完成接待
<text>
(推荐)
</text>
</
template
>
</
template
>
<
template
v-else
>
完成接待
<text>
(推荐)
</text>
</
template
>
</view>
</view>
<view
<view
class=
"footer-btn cancel flex"
@
click=
"$emit('backHome')"
>
class=
"footer-btn cancel flex"
@
click=
"$emit('backHome')"
>
仍要退出
<text>
(不推荐)
</text>
仍要退出
<text>
(不推荐)
</text>
</view>
</view>
</view>
</view>
...
@@ -145,10 +115,7 @@
...
@@ -145,10 +115,7 @@
<!-- 客服弹框 -->
<!-- 客服弹框 -->
<kf-box
ref=
"kfRef"
/>
<kf-box
ref=
"kfRef"
/>
<!-- 设置弹框 -->
<!-- 设置弹框 -->
<setting-box
<setting-box
ref=
"settingRef"
@
stopAudio=
"stopAudio"
/>
ref=
"settingRef"
@
stopAudio=
"stopAudio"
/>
<slot
name=
"content"
/>
<slot
name=
"content"
/>
</view>
</view>
</template>
</template>
...
@@ -165,10 +132,10 @@ export default {
...
@@ -165,10 +132,10 @@ export default {
finishDoneText
:
String
,
finishDoneText
:
String
,
finishContene
:
{
finishContene
:
{
type
:
String
,
type
:
String
,
default
:
'当前操作视为强制退出接待,若需正常流程完成接待请点击“完成接待”'
default
:
"当前操作视为强制退出接待,若需正常流程完成接待请点击“完成接待”"
,
}
}
,
},
},
data
()
{
data
()
{
return
{
return
{
userInfo
:
{},
userInfo
:
{},
tabs
:
[
tabs
:
[
...
@@ -182,18 +149,18 @@ export default {
...
@@ -182,18 +149,18 @@ export default {
},
},
],
],
tabIndex
:
0
,
tabIndex
:
0
,
dateKey
:
null
dateKey
:
null
,
};
};
},
},
mounted
()
{
mounted
()
{
const
userInfo
=
uni
.
$storage
.
get
(
"userInfo"
)
||
{};
const
userInfo
=
uni
.
$storage
.
get
(
"userInfo"
)
||
{};
this
.
userInfo
=
userInfo
this
.
userInfo
=
userInfo
;
setInterval
(()
=>
{
setInterval
(()
=>
{
this
.
dateKey
=
Date
.
now
();
this
.
dateKey
=
Date
.
now
();
},
5
e3
);
},
5
e3
);
},
},
computed
:
{
computed
:
{
randomize
()
{
randomize
()
{
let
{
dateKey
}
=
this
;
let
{
dateKey
}
=
this
;
const
maxX
=
uni
.
getSystemInfoSync
().
windowWidth
-
300
,
const
maxX
=
uni
.
getSystemInfoSync
().
windowWidth
-
300
,
maxY
=
uni
.
getSystemInfoSync
().
windowHeight
-
100
,
maxY
=
uni
.
getSystemInfoSync
().
windowHeight
-
100
,
...
@@ -201,18 +168,18 @@ export default {
...
@@ -201,18 +168,18 @@ export default {
y
=
Math
.
floor
(
Math
.
random
()
*
maxY
);
y
=
Math
.
floor
(
Math
.
random
()
*
maxY
);
return
`transform:translate(
${
x
}
px,
${
y
}
px);
${
dateKey
}
;`
;
return
`transform:translate(
${
x
}
px,
${
y
}
px);
${
dateKey
}
;`
;
},
},
previewRef
()
{
previewRef
()
{
return
this
.
$refs
.
previewRef
return
this
.
$refs
.
previewRef
;
},
finishRef
()
{
return
this
.
$refs
.
finish
;
},
},
finishRef
()
{
return
this
.
$refs
.
finish
}
},
},
methods
:
{
methods
:
{
changeIndex
(
index
)
{
changeIndex
(
index
)
{
if
(
this
.
tabIndex
==
index
)
return
if
(
this
.
tabIndex
==
index
)
return
;
this
.
tabIndex
=
index
;
this
.
tabIndex
=
index
;
this
.
$emit
(
"changeTab"
,
index
)
this
.
$emit
(
"changeTab"
,
index
)
;
},
},
},
},
};
};
...
...
hybrid/html/index.html
View file @
b9e9329
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
file upload oss
</title>
</head>
<body>
<script
src=
"js/uni.webview.1.5.5.js"
></script>
<script
src=
"js/aliyun-oss-sdk-6.18.1.min.js"
></script>
<script
src=
"js/OSSUpLoader.js"
></script>
<script>
// document.addEventListener('UniAppJSBridgeReady', function(){
window
.
msgFromUniapp
=
function
(
accessKeyId
,
accessKeySecret
,
stsToken
,
fileName
,
options
=
{})
{
if
(
!
accessKeyId
||
!
accessKeySecret
||
!
stsToken
||
!
fileName
)
{
throw
new
Error
(
'accessKeyId,accessKeySecret,stsToken,fileName is required'
)
}
const
opt
=
Object
.
assign
({
accessKeyId
,
accessKeySecret
,
stsToken
},
options
)
let
uploader
=
new
OSSUpLoader
(
opt
)
uploader
.
upload
(
fileName
,
function
(
result
)
{
uni
.
postMessage
({
data
:
{
...
result
,
fileName
}
});
uploader
.
destroy
()
uploader
=
null
})
}
// }, false);
</script>
</body>
</html>
\ No newline at end of file
\ No newline at end of file
<head>
<meta
charset=
"utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
file upload oss
</title>
</head>
<body>
<script
src=
"js/uni.webview.1.5.5.js"
></script>
<script
src=
"js/aliyun-oss-sdk-6.18.1.min.js"
></script>
<script
src=
"js/OSSUpLoader.js"
></script>
<script>
// document.addEventListener('UniAppJSBridgeReady', function(){
window
.
msgFromUniapp
=
function
(
accessKeyId
,
accessKeySecret
,
stsToken
,
fileName
,
filePath
,
options
=
{}
)
{
console
.
log
(
options
);
if
(
!
accessKeyId
||
!
accessKeySecret
||
!
stsToken
||
!
fileName
)
{
throw
new
Error
(
"accessKeyId,accessKeySecret,stsToken,fileName is required"
);
}
console
.
log
(
fileName
);
const
opt
=
Object
.
assign
(
{
accessKeyId
,
accessKeySecret
,
stsToken
,
filePath
},
options
);
let
uploader
=
new
OSSUpLoader
(
opt
);
uploader
.
upload
(
fileName
,
function
(
result
)
{
uni
.
postMessage
({
data
:
{
...
result
,
fileName
,
},
});
uploader
.
destroy
();
uploader
=
null
;
});
};
// }, false);
</script>
</body>
</html>
hybrid/html/js/OSSUpLoader.js
View file @
b9e9329
This diff is collapsed.
Click to expand it.
main.js
View file @
b9e9329
...
@@ -44,7 +44,7 @@ import { index } from "./env";
...
@@ -44,7 +44,7 @@ import { index } from "./env";
// }
// }
Vue
.
prototype
.
$permision
=
permision
;
Vue
.
prototype
.
$permision
=
permision
;
import
sentryInit
from
"@/utils/sentryConfig/sentryInit"
;
import
sentryInit
from
"@/utils/sentryConfig/sentryInit"
;
if
(
index
==
3
)
{
if
(
index
==
5
)
{
const
sentry
=
sentryInit
();
const
sentry
=
sentryInit
();
Vue
.
prototype
.
$sendSentry
=
function
(
e
)
{
Vue
.
prototype
.
$sendSentry
=
function
(
e
)
{
sentry
.
captureException
(
e
);
sentry
.
captureException
(
e
);
...
...
mixin/click.js
View file @
b9e9329
...
@@ -33,7 +33,6 @@ export default {
...
@@ -33,7 +33,6 @@ export default {
const
url
=
[
"pages/equity/index"
,
"pages/boutique/index"
];
const
url
=
[
"pages/equity/index"
,
"pages/boutique/index"
];
if
(
url
.
includes
(
route
))
return
;
if
(
url
.
includes
(
route
))
return
;
this
.
initTime
();
this
.
initTime
();
// this.checkVoice();
},
},
computed
:
{
computed
:
{
...
mapState
(
"audio"
,
[
"receptionStatus"
,
"booksList"
,
"audioInfo"
]),
...
mapState
(
"audio"
,
[
"receptionStatus"
,
"booksList"
,
"audioInfo"
]),
...
@@ -58,7 +57,7 @@ export default {
...
@@ -58,7 +57,7 @@ export default {
"setBooks"
,
"setBooks"
,
"setAudioInfo"
,
"setAudioInfo"
,
]),
]),
//关闭提示
//
//
关闭提示
tipCancel
()
{
tipCancel
()
{
this
.
stopAudio
();
this
.
stopAudio
();
this
.
setReceptionStatus
(
0
);
this
.
setReceptionStatus
(
0
);
...
@@ -76,6 +75,14 @@ export default {
...
@@ -76,6 +75,14 @@ export default {
this
.
times
=
0
;
this
.
times
=
0
;
this
.
$refs
.
tipBox
?.
close
();
this
.
$refs
.
tipBox
?.
close
();
},
},
closeAudio
()
{
this
.
times
=
0
;
clearInterval
(
this
.
timer
);
this
.
timer
=
null
;
this
.
stopAudio
(
"abnormal"
);
this
.
setReceptionStatus
(
0
);
this
.
setAudioInfo
({
endReasonType
:
1
});
},
getParams
()
{
getParams
()
{
const
{
shopMerchantId
,
phone
,
sceneType
}
=
uni
.
$storage
.
get
(
"userInfo"
),
const
{
shopMerchantId
,
phone
,
sceneType
}
=
uni
.
$storage
.
get
(
"userInfo"
),
{
customerName
,
phoneNumber
,
salesUuid
,
carModel
,
staffName
}
=
{
customerName
,
phoneNumber
,
salesUuid
,
carModel
,
staffName
}
=
...
@@ -144,20 +151,22 @@ export default {
...
@@ -144,20 +151,22 @@ export default {
console
.
log
(
res
);
console
.
log
(
res
);
},
},
});
});
this
.
handleSave
(
saveResult
);
this
.
handleSave
(
saveResult
[
1
].
savedFilePath
);
});
});
},
},
handleSave
(
file
)
{
handleSave
(
file
)
{
if
(
this
.
audioInfo
.
audioStatus
==
"end"
)
{
const
audioList
=
[...
this
.
audioInfo
.
audioList
,
file
];
this
.
saveRecord
();
if
(
file
)
{
this
.
setBooks
([]);
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
this
.
setReceptionStatus
(
1
);
this
.
setAudioInfo
({
endReasonType
:
0
,
audioStatus
:
"finish"
});
}
else
{
const
audioList
=
[...
this
.
audioInfo
.
audioList
,
file
];
this
.
setAudioInfo
({
audioList
});
this
.
setAudioInfo
({
audioList
});
}
}
if
(
this
.
audioInfo
.
audioStatus
!=
"end"
)
{
return
;
}
this
.
saveRecord
();
this
.
setBooks
([]);
this
.
$store
.
dispatch
(
"clearCustomerInfo"
);
this
.
setReceptionStatus
(
1
);
this
.
setAudioInfo
({
endReasonType
:
0
,
audioStatus
:
"finish"
});
},
},
/**保存记录*/
/**保存记录*/
saveRecord
()
{
saveRecord
()
{
...
@@ -175,6 +184,7 @@ export default {
...
@@ -175,6 +184,7 @@ export default {
},
},
...
recordList
,
...
recordList
,
];
];
console
.
log
(
recordList
,
"recordList"
);
uni
.
$storage
.
set
(
"recordList"
,
JSON
.
stringify
(
recordList
));
uni
.
$storage
.
set
(
"recordList"
,
JSON
.
stringify
(
recordList
));
},
},
//结束接待
//结束接待
...
@@ -189,6 +199,15 @@ export default {
...
@@ -189,6 +199,15 @@ export default {
// });
// });
// return;
// return;
// }
// }
if
(
status
==
"abnormal"
)
{
this
.
setAudioInfo
({
audioStatus
:
"abnormal"
});
recorderManager
.
stop
();
return
;
}
if
(
this
.
audioInfo
.
audioStatus
==
"abnormal"
)
{
this
.
handleSave
();
return
;
}
if
(
this
.
audioInfo
.
audioStatus
!=
"start"
)
{
if
(
this
.
audioInfo
.
audioStatus
!=
"start"
)
{
return
;
return
;
}
}
...
@@ -226,8 +245,8 @@ export default {
...
@@ -226,8 +245,8 @@ export default {
this
.
$refs
.
tipBox
?.
open
();
this
.
$refs
.
tipBox
?.
open
();
}
}
if
(
this
.
times
>=
this
.
timeout
)
{
if
(
this
.
times
>=
this
.
timeout
)
{
//
结束接待
//
关闭录音
this
.
tipCancel
();
this
.
closeAudio
();
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
}
}
},
1000
*
10
);
},
1000
*
10
);
...
...
mixin/storge.js
View file @
b9e9329
...
@@ -3,18 +3,44 @@ const UPLOAD_STATUS = {
...
@@ -3,18 +3,44 @@ const UPLOAD_STATUS = {
success
:
1
,
success
:
1
,
fail
:
2
,
fail
:
2
,
};
};
import
upload
from
"@/utils/ossUploadFile/uploadFile.js"
;
let
wv
,
getResult
;
import
utils
from
"@/utils/utils.js"
;
import
{
uploadFile
,
getOssToken
}
from
"@/utils/ossUploadFile/uploadFile.js"
;
import
config
from
"@/config.js"
;
export
default
{
export
default
{
onLoad
()
{
// #ifdef APP-PLUS
// wv = plus.webview.create("", "custom-webview", {
// plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
// "uni-app": "none", //不加载uni-app渲染层框架,避免样式冲突
// top: uni.getSystemInfoSync().statusBarHeight + 44, //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
// });
// wv.loadURL("/hybrid/html/index.html");
// var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
// currentWebview.append(wv); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
// setTimeout(function () {
// wv.setStyle({ top: "100%", height: 300 });
// }, 1000); //如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
// // #endif
},
mounted
()
{
mounted
()
{
// this.checkRecord();
var
currentWebview
=
this
.
$scope
.
$getAppWebview
();
//此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
// setInterval(() => {
setTimeout
(
function
()
{
wv
=
currentWebview
.
children
()[
0
];
wv
.
setStyle
({
top
:
"100%"
,
height
:
300
});
},
1000
);
//如果是页面初始化调用时,需要延时一下
// console.log(88);
// // this.checkRecord();
// setTimeout(() => {
// this.checkRecord();
// this.checkRecord();
// }, 1000 * 6
0 * 10
);
// }, 1000 * 6);
},
},
methods
:
{
methods
:
{
handlerMessage
(
result
)
{
console
.
log
(
result
);
getResult
=
result
;
},
checkRecord
()
{
checkRecord
()
{
u
tils
.
isNetWork
().
then
(
async
(
res
)
=>
{
u
ni
.
$
isNetWork
().
then
(
async
(
res
)
=>
{
let
recordList
=
JSON
.
parse
(
uni
.
$storage
.
get
(
"recordList"
)
||
"[]"
);
let
recordList
=
JSON
.
parse
(
uni
.
$storage
.
get
(
"recordList"
)
||
"[]"
);
console
.
log
(
recordList
,
"recordList"
);
console
.
log
(
recordList
,
"recordList"
);
for
(
let
i
=
0
;
i
<
recordList
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
recordList
.
length
;
i
++
)
{
...
@@ -22,6 +48,20 @@ export default {
...
@@ -22,6 +48,20 @@ export default {
}
}
});
});
},
},
getFilePath
()
{
return
new
Promise
((
resolve
)
=>
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PRIVATE_DOC
,
function
(
fs
)
{
resolve
(
fs
.
root
.
fullPath
);
});
});
},
setTimeoutResult
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
resolve
(
getResult
);
},
1000
);
});
},
/**上传记录*/
/**上传记录*/
async
handleRerord
(
val
)
{
async
handleRerord
(
val
)
{
let
recordList
=
JSON
.
parse
(
uni
.
$storage
.
get
(
"recordList"
)
||
"[]"
);
let
recordList
=
JSON
.
parse
(
uni
.
$storage
.
get
(
"recordList"
)
||
"[]"
);
...
@@ -31,14 +71,38 @@ export default {
...
@@ -31,14 +71,38 @@ export default {
let
recordUrlList
=
val
.
recordUrlList
;
let
recordUrlList
=
val
.
recordUrlList
;
// 上传失败的记录
// 上传失败的记录
for
(
let
i
of
recordUrlList
)
{
for
(
let
i
of
recordUrlList
)
{
console
.
log
(
i
.
status
==
UPLOAD_STATUS
.
fail
);
if
(
i
.
status
==
UPLOAD_STATUS
.
fail
)
{
if
(
i
.
status
==
UPLOAD_STATUS
.
fail
)
{
const
filePath
=
i
.
file
;
const
filePath
=
i
.
file
.
split
(
"/"
).
pop
();
console
.
log
(
filePath
,
"filePath"
);
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
const
result
=
await
this
.
checkFileUpload
(
filePath
);
await
getOssToken
();
if
(
!
(
result
instanceof
Error
))
{
console
.
log
(
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
);
i
.
status
=
UPLOAD_STATUS
.
success
;
const
rootPath
=
await
this
.
getFilePath
();
i
.
file
=
result
;
wv
.
evalJS
(
`msgFromUniapp('
${
lsaccessKeyId
}
','
${
lsaccessKeySecret
}
','
${
securityToken
}
','
${
filePath
}
','file://
${
rootPath
}
uniapp_save/')`
);
for
(
let
k
=
0
;
k
<
100
;
k
++
)
{
const
result
=
await
this
.
setTimeoutResult
();
if
(
result
)
{
if
(
result
.
detail
.
data
[
0
].
code
==
0
)
{
uni
.
removeSavedFile
({
filePath
:
i
.
file
,
complete
:
function
(
res
)
{
console
.
log
(
res
);
},
});
i
.
status
=
UPLOAD_STATUS
.
success
;
i
.
file
=
config
.
OSS_DOMAIN
+
"/"
+
config
.
FOLDER
+
filePath
;
}
getResult
=
""
;
break
;
}
}
}
// const result = await this.checkFileUpload(filePath);
// if (!(result instanceof Error)) {
// i.status = UPLOAD_STATUS.success;
// i.file = result;
// }
}
}
}
}
// 判断是否全部上传成功
// 判断是否全部上传成功
...
@@ -60,7 +124,7 @@ export default {
...
@@ -60,7 +124,7 @@ export default {
let
errorMsg
=
""
;
let
errorMsg
=
""
;
while
(
attempt
<
2
)
{
while
(
attempt
<
2
)
{
try
{
try
{
const
result
=
await
upload
(
tempFilePath
);
const
result
=
await
upload
File
(
tempFilePath
);
// 上传成功
// 上传成功
return
result
;
return
result
;
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
pages/equity/index.vue
View file @
b9e9329
This diff is collapsed.
Click to expand it.
utils/ossUploadFile/uploadFile.js
View file @
b9e9329
...
@@ -100,7 +100,16 @@ const getPolicyBase64 = function () {
...
@@ -100,7 +100,16 @@ const getPolicyBase64 = function () {
const
policyBase64
=
base64
.
encode
(
JSON
.
stringify
(
policyText
));
const
policyBase64
=
base64
.
encode
(
JSON
.
stringify
(
policyText
));
return
policyBase64
;
return
policyBase64
;
};
};
const
getOssToken
=
async
function
()
{
console
.
log
(
"getOssToken"
);
const
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
}
=
await
uni
.
$api
.
commonApi
.
getToken
({});
return
{
lsaccessKeySecret
,
securityToken
,
lsaccessKeyId
,
};
};
// 生成签名
// 生成签名
const
getSignature
=
function
(
policyBase64
)
{
const
getSignature
=
function
(
policyBase64
)
{
return
new
Promise
(
async
(
reslove
)
=>
{
return
new
Promise
(
async
(
reslove
)
=>
{
...
@@ -144,4 +153,4 @@ const getSignature = function (policyBase64) {
...
@@ -144,4 +153,4 @@ const getSignature = function (policyBase64) {
});
});
};
};
module
.
exports
=
uploadFile
;
module
.
exports
=
{
uploadFile
,
getOssToken
}
;
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment