receiveList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="gbox">
  3. <u-list @scrolltolower="scrolltolower" height="100%">
  4. <u-list-item v-for="(item, index) in list" :key="item.id">
  5. <view class="gbox-item">
  6. <view class="gbox-item-top adfac">
  7. <view class="gbox-item-top-type">{{typeCfg[item.type]||'个人版'}}</view>
  8. <view class="gbox-item-top-title">{{item.reportName||''}}</view>
  9. </view>
  10. <view class="gbox-item-ps">
  11. <view class="gbox-item-p adf">
  12. <view class="gbox-item-p-left">团队名称:</view>
  13. <view class="gbox-item-p-right">{{item.teamName||''}}</view>
  14. </view>
  15. <view class="gbox-item-p adf">
  16. <view class="gbox-item-p-left">发送教练:</view>
  17. <view class="gbox-item-p-right">{{item.coachName||''}}</view>
  18. </view>
  19. <view class="gbox-item-p adf">
  20. <view class="gbox-item-p-left">报告时间:</view>
  21. <view class="gbox-item-p-right">{{item.createDate||''}}</view>
  22. </view>
  23. <!-- <image class="gbox-item-ask" :src="imgBase+'report_ask.png'" @click="askReport(item)"></image> -->
  24. <image class="gbox-item-ask" :src="imgBase+'report_ask.png'" @click="testShow=true" v-if="item.fileUrl"></image>
  25. </view>
  26. <view class="gbox-item-bottom adfacjb">
  27. <view class="gbox-item-bottom-rightbox adfac">
  28. <view class="gbox-item-bottom-right" @click="reviewReport(item)">查看报告</view>
  29. </view>
  30. </view>
  31. </view>
  32. </u-list-item>
  33. </u-list>
  34. <view class="kind-reminder adffcacjc" v-if="testShow">
  35. <view class="kr-box adffcac">
  36. <view class="kr-title">温馨提示</view>
  37. <view class="kr-p" style="margin-top: 54rpx;">功能测试中,即将上线,敬请期待!</view>
  38. <view class="kr-btn" @click="testShow=false">确定</view>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import { getPlatformInfo } from '@/utils/platform.js';
  45. export default {
  46. props:{
  47. list:{
  48. typeof:Array,
  49. default:[]
  50. }
  51. },
  52. data(){
  53. return {
  54. typeCfg:{
  55. 1:'个人版',
  56. 2:'团队版',
  57. 0:'团队PRO版'
  58. },
  59. testShow:false
  60. }
  61. },
  62. methods:{
  63. scrolltolower(){
  64. this.$emit('scrolltolower')
  65. },
  66. reviewReport(item){
  67. // uni.navigateTo({
  68. // url:`/pagesHome/reportDetail?pdfUrl=${item.fileUrl}&reportId=${item.reportId}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  69. // })
  70. // wx.downloadFile({
  71. // url:item.fileUrl,
  72. // success: function (res) {
  73. // const filePath = res.tempFilePath
  74. // wx.openDocument({
  75. // filePath: filePath
  76. // })
  77. // }
  78. // })
  79. const { isPC, isMobile, platform } = getPlatformInfo();
  80. if (isPC) {
  81. this.$showModal('请在手机端该微信小程序中查看报告')
  82. } else if (isMobile||platform==='devtools') {
  83. if(!item.fileUrl) return this.$showToast('报告pdf为空,请稍后再试。')
  84. this.openDocument(item.fileUrl)
  85. // uni.navigateTo({
  86. // url:'/pages/webView?src='+item.fileUrl
  87. // })
  88. }
  89. },
  90. async openDocument(fileUrl) {
  91. try {
  92. // 1. 显示加载提示
  93. uni.showLoading({ title: '加载中...' });
  94. // 2. 先下载PDF文件到本地(解决安卓直接预览网络文件慢的问题)
  95. const downloadRes = await uni.downloadFile({
  96. url: fileUrl,
  97. // 可选:设置超时时间,避免长时间等待
  98. timeout: 30000
  99. });
  100. const dres = downloadRes[1]||null;
  101. if (dres.statusCode !== 200) {
  102. uni.hideLoading();
  103. uni.showToast({ title: '文件下载失败', icon: 'none' });
  104. return;
  105. }
  106. // 3. 用微信原生API打开本地PDF
  107. const openRes = await uni.openDocument({
  108. filePath: dres.tempFilePath,
  109. fileType: this.documentType(fileUrl),
  110. showMenu: false
  111. });
  112. uni.hideLoading();
  113. } catch (error) {
  114. uni.hideLoading();
  115. uni.showToast({ title: '加载失败,请重试', icon: 'none' });
  116. }
  117. },
  118. documentType(fileUrl) {
  119. const path = (fileUrl || '').split('?')[0].toLowerCase()
  120. return path.endsWith('.docx') ? 'docx' : 'pdf'
  121. },
  122. askReport(item){
  123. uni.navigateTo({
  124. url:`/pages/reportAsk?pdfUrl=${item.fileUrl}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. @import '../../../static/_asset-config';
  132. .gbox{
  133. height: 100%;
  134. &-item{
  135. margin-top: 20rpx;
  136. background: #FFFFFF;
  137. border-radius: 24rpx;
  138. padding: 40rpx 20rpx 20rpx;
  139. &-top{
  140. &-type{
  141. width: 98rpx;
  142. height: 36rpx;
  143. padding: 2rpx 13rpx;
  144. box-sizing: border-box;
  145. background: #FFF7DC;
  146. border-radius: 6rpx;
  147. font-family: PingFangSC, PingFang SC;
  148. font-weight: 400;
  149. font-size: 24rpx;
  150. color: #BA9B31;
  151. line-height: 33rpx;
  152. }
  153. &-title{
  154. width: calc(100% - 98rpx);
  155. font-family: PingFang-SC, PingFang-SC;
  156. font-weight: bold;
  157. font-size: 32rpx;
  158. color: #002846;
  159. line-height: 32rpx;
  160. text-indent: 17rpx;
  161. }
  162. }
  163. &-ps{
  164. margin-top: 20rpx;
  165. background: #F5F8FA;
  166. border-radius: 5px;
  167. padding: 20rpx 20rpx 30rpx;
  168. position: relative;
  169. }
  170. &-p{
  171. margin-top: 32rpx;
  172. &:first-child{
  173. margin-top: 0;
  174. }
  175. &>view{
  176. font-family: PingFangSC, PingFang SC;
  177. font-weight: 400;
  178. font-size: 24rpx;
  179. color: #667E90;
  180. line-height: 24rpx;
  181. }
  182. &-left{
  183. width: 134rpx;
  184. }
  185. &-right{
  186. width: calc(100% - 134rpx);
  187. }
  188. &-progress{
  189. width: calc(100% - 134rpx);
  190. &-l{
  191. width: 410rpx;
  192. height: 12rpx;
  193. background: #F0F2F8;
  194. border-radius: 6rpx;
  195. position: relative;
  196. &-current{
  197. height: 12rpx;
  198. background: #FFDF73;
  199. border-radius: 6rpx;
  200. position: absolute;
  201. left: 0;
  202. top: 0;
  203. }
  204. }
  205. &-r{
  206. width: calc(100% - 410rpx);
  207. font-family: PingFangSC, PingFang SC;
  208. font-weight: 400;
  209. font-size: 24rpx;
  210. color: #002846;
  211. line-height: 24rpx;
  212. text-align: right;
  213. }
  214. }
  215. }
  216. &-ask{
  217. width: 64rpx;
  218. height: 64rpx;
  219. position: absolute;
  220. right: 20rpx;
  221. bottom: 42rpx;
  222. }
  223. &-bottom{
  224. margin-top: 20rpx;
  225. overflow: hidden;
  226. &-rightbox{
  227. flex: 1;
  228. margin-left: -35rpx;
  229. justify-content: flex-end;
  230. }
  231. &-left{
  232. &>view{
  233. font-family: PingFangSC, PingFang SC;
  234. font-weight: 400;
  235. font-size: 24rpx;
  236. color: #667E90;
  237. line-height: 24rpx;
  238. }
  239. }
  240. &-right{
  241. width: calc(25% - 35rpx);
  242. padding: 15rpx;
  243. text-align: center;
  244. box-sizing: border-box;
  245. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  246. border-radius: 20rpx;
  247. font-family: PingFang-SC, PingFang-SC;
  248. font-size: 24rpx;
  249. color: #FFFFFF;
  250. margin-left: 35rpx;
  251. }
  252. }
  253. }
  254. .kind-reminder{
  255. position: fixed;
  256. left: 0;
  257. right: 0;
  258. top: 0;
  259. bottom: 0;
  260. z-index: 1000;
  261. background: rgba(0, 0, 0, .6);
  262. .kr-box{
  263. width: calc(100% - 100rpx);
  264. padding: 54rpx 60rpx 48rpx;
  265. box-sizing: border-box;
  266. background: asset-image('remind_bg.png') no-repeat;
  267. background-size: 100% 100%;
  268. position: relative;
  269. image{
  270. width: 48rpx;
  271. height: 48rpx;
  272. position: absolute;
  273. top: 40rpx;
  274. right: 30rpx;
  275. }
  276. .kr-title{
  277. font-family: PingFang-SC, PingFang-SC;
  278. font-weight: bold;
  279. font-size: 36rpx;
  280. color: #002846;
  281. line-height: 56rpx;
  282. text-align: center;
  283. }
  284. .kr-p{
  285. font-family: PingFangSC, PingFang SC;
  286. font-weight: 400;
  287. font-size: 30rpx;
  288. color: #002846;
  289. line-height: 48rpx;
  290. text-align: center;
  291. span{
  292. font-weight: bold;
  293. margin: 0 10rpx;
  294. }
  295. }
  296. .kr-btn{
  297. width: calc(100% - 80rpx);
  298. height: 88rpx;
  299. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  300. border-radius: 44rpx;
  301. font-family: PingFang-SC, PingFang-SC;
  302. font-weight: bold;
  303. font-size: 32rpx;
  304. color: #FFFFFF;
  305. line-height: 88rpx;
  306. text-align: center;
  307. letter-spacing: 2rpx;
  308. margin-top: 66rpx;
  309. }
  310. }
  311. }
  312. }
  313. </style>