receiveList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. .gbox{
  132. height: 100%;
  133. &-item{
  134. margin-top: 20rpx;
  135. background: #FFFFFF;
  136. border-radius: 24rpx;
  137. padding: 40rpx 20rpx 20rpx;
  138. &-top{
  139. &-type{
  140. width: 98rpx;
  141. height: 36rpx;
  142. padding: 2rpx 13rpx;
  143. box-sizing: border-box;
  144. background: #FFF7DC;
  145. border-radius: 6rpx;
  146. font-family: PingFangSC, PingFang SC;
  147. font-weight: 400;
  148. font-size: 24rpx;
  149. color: #BA9B31;
  150. line-height: 33rpx;
  151. }
  152. &-title{
  153. width: calc(100% - 98rpx);
  154. font-family: PingFang-SC, PingFang-SC;
  155. font-weight: bold;
  156. font-size: 32rpx;
  157. color: #002846;
  158. line-height: 32rpx;
  159. text-indent: 17rpx;
  160. }
  161. }
  162. &-ps{
  163. margin-top: 20rpx;
  164. background: #F5F8FA;
  165. border-radius: 5px;
  166. padding: 20rpx 20rpx 30rpx;
  167. position: relative;
  168. }
  169. &-p{
  170. margin-top: 32rpx;
  171. &:first-child{
  172. margin-top: 0;
  173. }
  174. &>view{
  175. font-family: PingFangSC, PingFang SC;
  176. font-weight: 400;
  177. font-size: 24rpx;
  178. color: #667E90;
  179. line-height: 24rpx;
  180. }
  181. &-left{
  182. width: 134rpx;
  183. }
  184. &-right{
  185. width: calc(100% - 134rpx);
  186. }
  187. &-progress{
  188. width: calc(100% - 134rpx);
  189. &-l{
  190. width: 410rpx;
  191. height: 12rpx;
  192. background: #F0F2F8;
  193. border-radius: 6rpx;
  194. position: relative;
  195. &-current{
  196. height: 12rpx;
  197. background: #FFDF73;
  198. border-radius: 6rpx;
  199. position: absolute;
  200. left: 0;
  201. top: 0;
  202. }
  203. }
  204. &-r{
  205. width: calc(100% - 410rpx);
  206. font-family: PingFangSC, PingFang SC;
  207. font-weight: 400;
  208. font-size: 24rpx;
  209. color: #002846;
  210. line-height: 24rpx;
  211. text-align: right;
  212. }
  213. }
  214. }
  215. &-ask{
  216. width: 64rpx;
  217. height: 64rpx;
  218. position: absolute;
  219. right: 20rpx;
  220. bottom: 42rpx;
  221. }
  222. &-bottom{
  223. margin-top: 20rpx;
  224. overflow: hidden;
  225. &-rightbox{
  226. flex: 1;
  227. margin-left: -35rpx;
  228. justify-content: flex-end;
  229. }
  230. &-left{
  231. &>view{
  232. font-family: PingFangSC, PingFang SC;
  233. font-weight: 400;
  234. font-size: 24rpx;
  235. color: #667E90;
  236. line-height: 24rpx;
  237. }
  238. }
  239. &-right{
  240. width: calc(25% - 35rpx);
  241. padding: 15rpx;
  242. text-align: center;
  243. box-sizing: border-box;
  244. background: linear-gradient( 90deg, #33A7A7 0%, #4DB2B2 100%);
  245. border-radius: 20rpx;
  246. font-family: PingFang-SC, PingFang-SC;
  247. font-size: 24rpx;
  248. color: #FFFFFF;
  249. margin-left: 35rpx;
  250. }
  251. }
  252. }
  253. .kind-reminder{
  254. position: fixed;
  255. left: 0;
  256. right: 0;
  257. top: 0;
  258. bottom: 0;
  259. z-index: 1000;
  260. background: rgba(0, 0, 0, .6);
  261. .kr-box{
  262. width: calc(100% - 100rpx);
  263. padding: 54rpx 60rpx 48rpx;
  264. box-sizing: border-box;
  265. background: url('https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/master/remind_bg.png') no-repeat;
  266. background-size: 100% 100%;
  267. position: relative;
  268. image{
  269. width: 48rpx;
  270. height: 48rpx;
  271. position: absolute;
  272. top: 40rpx;
  273. right: 30rpx;
  274. }
  275. .kr-title{
  276. font-family: PingFang-SC, PingFang-SC;
  277. font-weight: bold;
  278. font-size: 36rpx;
  279. color: #002846;
  280. line-height: 56rpx;
  281. text-align: center;
  282. }
  283. .kr-p{
  284. font-family: PingFangSC, PingFang SC;
  285. font-weight: 400;
  286. font-size: 30rpx;
  287. color: #002846;
  288. line-height: 48rpx;
  289. text-align: center;
  290. span{
  291. font-weight: bold;
  292. margin: 0 10rpx;
  293. }
  294. }
  295. .kr-btn{
  296. width: calc(100% - 80rpx);
  297. height: 88rpx;
  298. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  299. border-radius: 44rpx;
  300. font-family: PingFang-SC, PingFang-SC;
  301. font-weight: bold;
  302. font-size: 32rpx;
  303. color: #FFFFFF;
  304. line-height: 88rpx;
  305. text-align: center;
  306. letter-spacing: 2rpx;
  307. margin-top: 66rpx;
  308. }
  309. }
  310. }
  311. }
  312. </style>