receiveList.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.openPdf(item.fileUrl)
  85. // uni.navigateTo({
  86. // url:'/pages/webView?src='+item.fileUrl
  87. // })
  88. }
  89. },
  90. async openPdf(pdfUrl) {
  91. try {
  92. // 1. 显示加载提示
  93. uni.showLoading({ title: '加载中...' });
  94. // 2. 先下载PDF文件到本地(解决安卓直接预览网络文件慢的问题)
  95. const downloadRes = await uni.downloadFile({
  96. url: pdfUrl,
  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: 'pdf',
  110. showMenu: true // 允许用户转发/保存等
  111. });
  112. uni.hideLoading();
  113. } catch (error) {
  114. uni.hideLoading();
  115. uni.showToast({ title: '加载失败,请重试', icon: 'none' });
  116. }
  117. },
  118. askReport(item){
  119. uni.navigateTo({
  120. url:`/pages/reportAsk?pdfUrl=${item.fileUrl}&fileName=${this.typeCfg[item.type]||'个人版'}-${item.reportName}`
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .gbox{
  128. height: 100%;
  129. &-item{
  130. margin-top: 20rpx;
  131. background: #FFFFFF;
  132. border-radius: 24rpx;
  133. padding: 40rpx 20rpx 20rpx;
  134. &-top{
  135. &-type{
  136. width: 98rpx;
  137. height: 36rpx;
  138. padding: 2rpx 13rpx;
  139. box-sizing: border-box;
  140. background: #FFF7DC;
  141. border-radius: 6rpx;
  142. font-family: PingFangSC, PingFang SC;
  143. font-weight: 400;
  144. font-size: 24rpx;
  145. color: #BA9B31;
  146. line-height: 33rpx;
  147. }
  148. &-title{
  149. width: calc(100% - 98rpx);
  150. font-family: PingFang-SC, PingFang-SC;
  151. font-weight: bold;
  152. font-size: 32rpx;
  153. color: #002846;
  154. line-height: 32rpx;
  155. text-indent: 17rpx;
  156. }
  157. }
  158. &-ps{
  159. margin-top: 20rpx;
  160. background: #F5F8FA;
  161. border-radius: 5px;
  162. padding: 20rpx 20rpx 30rpx;
  163. position: relative;
  164. }
  165. &-p{
  166. margin-top: 32rpx;
  167. &:first-child{
  168. margin-top: 0;
  169. }
  170. &>view{
  171. font-family: PingFangSC, PingFang SC;
  172. font-weight: 400;
  173. font-size: 24rpx;
  174. color: #667E90;
  175. line-height: 24rpx;
  176. }
  177. &-left{
  178. width: 134rpx;
  179. }
  180. &-right{
  181. width: calc(100% - 134rpx);
  182. }
  183. &-progress{
  184. width: calc(100% - 134rpx);
  185. &-l{
  186. width: 410rpx;
  187. height: 12rpx;
  188. background: #F0F2F8;
  189. border-radius: 6rpx;
  190. position: relative;
  191. &-current{
  192. height: 12rpx;
  193. background: #FFDF73;
  194. border-radius: 6rpx;
  195. position: absolute;
  196. left: 0;
  197. top: 0;
  198. }
  199. }
  200. &-r{
  201. width: calc(100% - 410rpx);
  202. font-family: PingFangSC, PingFang SC;
  203. font-weight: 400;
  204. font-size: 24rpx;
  205. color: #002846;
  206. line-height: 24rpx;
  207. text-align: right;
  208. }
  209. }
  210. }
  211. &-ask{
  212. width: 64rpx;
  213. height: 64rpx;
  214. position: absolute;
  215. right: 20rpx;
  216. bottom: 42rpx;
  217. }
  218. &-bottom{
  219. margin-top: 20rpx;
  220. overflow: hidden;
  221. &-rightbox{
  222. flex: 1;
  223. margin-left: -35rpx;
  224. justify-content: flex-end;
  225. }
  226. &-left{
  227. &>view{
  228. font-family: PingFangSC, PingFang SC;
  229. font-weight: 400;
  230. font-size: 24rpx;
  231. color: #667E90;
  232. line-height: 24rpx;
  233. }
  234. }
  235. &-right{
  236. width: calc(25% - 35rpx);
  237. padding: 15rpx;
  238. text-align: center;
  239. box-sizing: border-box;
  240. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  241. border-radius: 20rpx;
  242. font-family: PingFang-SC, PingFang-SC;
  243. font-size: 24rpx;
  244. color: #FFFFFF;
  245. margin-left: 35rpx;
  246. }
  247. }
  248. }
  249. .kind-reminder{
  250. position: fixed;
  251. left: 0;
  252. right: 0;
  253. top: 0;
  254. bottom: 0;
  255. z-index: 1000;
  256. background: rgba(0, 0, 0, .6);
  257. .kr-box{
  258. width: calc(100% - 100rpx);
  259. padding: 54rpx 60rpx 48rpx;
  260. box-sizing: border-box;
  261. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/remind_bg.png') no-repeat;
  262. background-size: 100% 100%;
  263. position: relative;
  264. image{
  265. width: 48rpx;
  266. height: 48rpx;
  267. position: absolute;
  268. top: 40rpx;
  269. right: 30rpx;
  270. }
  271. .kr-title{
  272. font-family: PingFang-SC, PingFang-SC;
  273. font-weight: bold;
  274. font-size: 36rpx;
  275. color: #002846;
  276. line-height: 56rpx;
  277. text-align: center;
  278. }
  279. .kr-p{
  280. font-family: PingFangSC, PingFang SC;
  281. font-weight: 400;
  282. font-size: 30rpx;
  283. color: #002846;
  284. line-height: 48rpx;
  285. text-align: center;
  286. span{
  287. font-weight: bold;
  288. margin: 0 10rpx;
  289. }
  290. }
  291. .kr-btn{
  292. width: calc(100% - 80rpx);
  293. height: 88rpx;
  294. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  295. border-radius: 44rpx;
  296. font-family: PingFang-SC, PingFang-SC;
  297. font-weight: bold;
  298. font-size: 32rpx;
  299. color: #FFFFFF;
  300. line-height: 88rpx;
  301. text-align: center;
  302. letter-spacing: 2rpx;
  303. margin-top: 66rpx;
  304. }
  305. }
  306. }
  307. }
  308. </style>