receiveList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. </view>
  25. <view class="gbox-item-bottom adfacjb">
  26. <view class="gbox-item-bottom-rightbox adfac">
  27. <view class="gbox-item-bottom-right" @click="reviewReport(item)">查看报告</view>
  28. </view>
  29. </view>
  30. </view>
  31. </u-list-item>
  32. </u-list>
  33. </view>
  34. </template>
  35. <script>
  36. import { getPlatformInfo } from '@/utils/platform.js';
  37. export default {
  38. props:{
  39. list:{
  40. typeof:Array,
  41. default:[]
  42. }
  43. },
  44. data(){
  45. return {
  46. typeCfg:{
  47. 1:'个人版',
  48. 2:'团队版',
  49. 0:'团队PRO版'
  50. },
  51. }
  52. },
  53. methods:{
  54. scrolltolower(){
  55. this.$emit('scrolltolower')
  56. },
  57. reviewReport(item){
  58. // uni.navigateTo({
  59. // url:`/pagesHome/reportDetail?pdfUrl=${item.fileUrl}&reportId=${item.reportId}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  60. // })
  61. // wx.downloadFile({
  62. // url:item.fileUrl,
  63. // success: function (res) {
  64. // const filePath = res.tempFilePath
  65. // wx.openDocument({
  66. // filePath: filePath
  67. // })
  68. // }
  69. // })
  70. const { isPC, isMobile, platform } = getPlatformInfo();
  71. if (isPC) {
  72. this.$showModal('请在手机端该微信小程序中查看报告')
  73. } else if (isMobile||platform==='devtools') {
  74. if(!item.fileUrl) return this.$showToast('报告pdf为空,请稍后再试。')
  75. this.openPdf(item.fileUrl)
  76. // uni.navigateTo({
  77. // url:'/pages/webView?src='+item.fileUrl
  78. // })
  79. }
  80. },
  81. async openPdf(pdfUrl) {
  82. try {
  83. // 1. 显示加载提示
  84. uni.showLoading({ title: '加载中...' });
  85. // 2. 先下载PDF文件到本地(解决安卓直接预览网络文件慢的问题)
  86. const downloadRes = await uni.downloadFile({
  87. url: pdfUrl,
  88. // 可选:设置超时时间,避免长时间等待
  89. timeout: 30000
  90. });
  91. const dres = downloadRes[1]||null;
  92. if (dres.statusCode !== 200) {
  93. uni.hideLoading();
  94. uni.showToast({ title: '文件下载失败', icon: 'none' });
  95. return;
  96. }
  97. // 3. 用微信原生API打开本地PDF
  98. const openRes = await uni.openDocument({
  99. filePath: dres.tempFilePath,
  100. fileType: 'pdf',
  101. showMenu: true // 允许用户转发/保存等
  102. });
  103. uni.hideLoading();
  104. } catch (error) {
  105. uni.hideLoading();
  106. uni.showToast({ title: '加载失败,请重试', icon: 'none' });
  107. }
  108. },
  109. askReport(item){
  110. uni.navigateTo({
  111. url:`/pages/reportAsk?pdfUrl=${item.fileUrl}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. .gbox{
  119. height: 100%;
  120. &-item{
  121. margin-top: 20rpx;
  122. background: #FFFFFF;
  123. border-radius: 24rpx;
  124. padding: 40rpx 20rpx 20rpx;
  125. &-top{
  126. &-type{
  127. width: 98rpx;
  128. height: 36rpx;
  129. padding: 2rpx 13rpx;
  130. box-sizing: border-box;
  131. background: #FFF7DC;
  132. border-radius: 6rpx;
  133. font-family: PingFangSC, PingFang SC;
  134. font-weight: 400;
  135. font-size: 24rpx;
  136. color: #BA9B31;
  137. line-height: 33rpx;
  138. }
  139. &-title{
  140. width: calc(100% - 98rpx);
  141. font-family: PingFang-SC, PingFang-SC;
  142. font-weight: bold;
  143. font-size: 32rpx;
  144. color: #002846;
  145. line-height: 32rpx;
  146. text-indent: 17rpx;
  147. }
  148. }
  149. &-ps{
  150. margin-top: 20rpx;
  151. background: #F5F8FA;
  152. border-radius: 5px;
  153. padding: 20rpx 20rpx 30rpx;
  154. position: relative;
  155. }
  156. &-p{
  157. margin-top: 32rpx;
  158. &:first-child{
  159. margin-top: 0;
  160. }
  161. &>view{
  162. font-family: PingFangSC, PingFang SC;
  163. font-weight: 400;
  164. font-size: 24rpx;
  165. color: #667E90;
  166. line-height: 24rpx;
  167. }
  168. &-left{
  169. width: 134rpx;
  170. }
  171. &-right{
  172. width: calc(100% - 134rpx);
  173. }
  174. &-progress{
  175. width: calc(100% - 134rpx);
  176. &-l{
  177. width: 410rpx;
  178. height: 12rpx;
  179. background: #F0F2F8;
  180. border-radius: 6rpx;
  181. position: relative;
  182. &-current{
  183. height: 12rpx;
  184. background: #FFDF73;
  185. border-radius: 6rpx;
  186. position: absolute;
  187. left: 0;
  188. top: 0;
  189. }
  190. }
  191. &-r{
  192. width: calc(100% - 410rpx);
  193. font-family: PingFangSC, PingFang SC;
  194. font-weight: 400;
  195. font-size: 24rpx;
  196. color: #002846;
  197. line-height: 24rpx;
  198. text-align: right;
  199. }
  200. }
  201. }
  202. &-ask{
  203. width: 64rpx;
  204. height: 64rpx;
  205. position: absolute;
  206. right: 20rpx;
  207. bottom: 42rpx;
  208. }
  209. &-bottom{
  210. margin-top: 20rpx;
  211. overflow: hidden;
  212. &-rightbox{
  213. flex: 1;
  214. margin-left: -35rpx;
  215. justify-content: flex-end;
  216. }
  217. &-left{
  218. &>view{
  219. font-family: PingFangSC, PingFang SC;
  220. font-weight: 400;
  221. font-size: 24rpx;
  222. color: #667E90;
  223. line-height: 24rpx;
  224. }
  225. }
  226. &-right{
  227. width: calc(25% - 35rpx);
  228. padding: 15rpx;
  229. text-align: center;
  230. box-sizing: border-box;
  231. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  232. border-radius: 20rpx;
  233. font-family: PingFang-SC, PingFang-SC;
  234. font-size: 24rpx;
  235. color: #FFFFFF;
  236. margin-left: 35rpx;
  237. }
  238. }
  239. }
  240. }
  241. </style>