receiveList.vue 5.7 KB

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