questionsDetails.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="content">
  3. <view class="detail-cont">
  4. <view class="title">{{item.title}}</view>
  5. <view class="info">
  6. <view class="reads">阅读数:{{item.views}}</view>
  7. <view class="time">{{item.createTime}}</view>
  8. </view>
  9. <!-- 正文 -->
  10. <view class="full-text">
  11. <view v-html="item.answers"></view>
  12. </view>
  13. </view>
  14. <view class="ad" v-show="advImgs&&advImgs.length>0">
  15. <u-swiper
  16. :list="advImgs"
  17. indicator
  18. indicatorMode="line"
  19. circular
  20. @click="handleAdvClick"
  21. ></u-swiper>
  22. </view>
  23. <!-- 分享弹窗 -->
  24. <u-popup :show="showShare" @close="showShare = false" >
  25. <share-box :shareItem="shareItem" @closeShare='showShare = false' ></share-box>
  26. </u-popup>
  27. <h5-down-app-tip :pageUrl="pageUrl"/>
  28. </view>
  29. </template>
  30. <script>
  31. import {getAdvList} from '@/api/adv.js'
  32. import {getQuestionsById} from '@/api/index'
  33. export default {
  34. data() {
  35. return {
  36. advs:[],
  37. advImgs:[],
  38. id:null,
  39. item:{},
  40. showShare:false,
  41. shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
  42. pageUrl: ''
  43. };
  44. },
  45. onLoad(option) {
  46. this.id=option.id;
  47. },
  48. onShow() {
  49. if(!this.$isLogin()) {
  50. uni.navigateTo({
  51. url: '/pages/auth/loginIndex'
  52. })
  53. return
  54. }
  55. this.pageUrl = '/pages/article/questionsDetails?id='+this.id;
  56. this.getAdvList();
  57. this.getQuestionsById();
  58. },
  59. onShareAppMessage(res) {
  60. if(this.$isLogin()){
  61. return {
  62. title: this.item.vesselName,
  63. path: '/pages_index/questionsDetails?id='+this.id,
  64. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  65. }
  66. }
  67. },
  68. //分享到朋友圈
  69. onShareTimeline(res) {
  70. if(this.$isLogin()){
  71. return {
  72. title: this.item.vesselName,
  73. path: '/pages_index/questionsDetails?id='+this.id,
  74. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  75. }
  76. }
  77. },
  78. onNavigationBarButtonTap(e) {
  79. //#ifdef APP-PLUS
  80. this.shareItem.healthId= this.id;
  81. this.shareItem.title= this.item.title;
  82. this.shareItem.imageUrl="../../static/logo.png";
  83. this.shareItem.isMini=true;
  84. this.shareItem.path='/pages_index/questionsDetails?id='+this.id;
  85. let cdn=uni.getStorageSync('h5Path');
  86. this.shareItem.url=cdn+'/pages/article/questionsDetails?id='+this.id;
  87. this.showShare=true;
  88. //#endif
  89. },
  90. methods:{
  91. handleAdvClick(index){
  92. var ad=this.advs[index];
  93. if(ad.showType==1){
  94. uni.setStorageSync('url',ad.appAdvUrl);
  95. uni.navigateTo({
  96. url:"h5"
  97. })
  98. }
  99. else if(ad.showType==2){
  100. uni.navigateTo({
  101. url:ad.appAdvUrl
  102. })
  103. }
  104. else if(ad.showType==3){
  105. uni.setStorageSync('content',ad.content);
  106. uni.navigateTo({
  107. url:"content"
  108. })
  109. }
  110. },
  111. getAdvList() {
  112. //联网加载数据
  113. var that = this;
  114. var data = {
  115. advType:6
  116. };
  117. getAdvList(data).then(res => {
  118. if(res.code==200){
  119. that.advImgs=[];
  120. that.advs=[];
  121. res.data.forEach(function(element) {
  122. if(element.imageUrl!=null&&element.imageUrl!=""){
  123. that.advs.push(element);
  124. that.advImgs.push(element.imageUrl);
  125. }
  126. });
  127. }else{
  128. uni.showToast({
  129. icon:'none',
  130. title: "请求失败",
  131. });
  132. }
  133. });
  134. },
  135. getQuestionsById(){
  136. let data = {id:this.id};
  137. getQuestionsById(data).then(
  138. res => {
  139. if(res.code==200){
  140. this.item=res.data;
  141. }else{
  142. uni.showToast({
  143. icon:'none',
  144. title: "请求失败",
  145. });
  146. }
  147. },
  148. rej => {}
  149. );
  150. },
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. page{
  156. height: 100%;
  157. }
  158. .content{
  159. height: 100%;
  160. }
  161. .detail-cont{
  162. flex: 1;
  163. padding: 40upx;
  164. overflow-y: auto;
  165. .title{
  166. font-size: 40upx;
  167. font-family: PingFang SC;
  168. // font-weight: bold;
  169. color: #222222;
  170. line-height: 70upx;
  171. }
  172. .info{
  173. display: flex;
  174. align-items: center;
  175. font-size: 24upx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #999999;
  179. line-height: 48upx;
  180. margin: 23upx 0;
  181. .reads{
  182. margin-right: 30upx;
  183. }
  184. }
  185. .full-text{
  186. font-size: 36upx;
  187. font-family: PingFang SC;
  188. // font-weight: 500;
  189. color: #222222;
  190. line-height: 60upx;
  191. }
  192. }
  193. .ad{
  194. margin-bottom: 50rpx;
  195. width: 100%;
  196. padding: 15rpx;
  197. }
  198. .recent-reads{
  199. flex-shrink: 0;
  200. box-sizing: border-box;
  201. height: 121upx;
  202. background: #FFFFFF;
  203. border-top: 1px solid #F0F0F0;
  204. padding: 0 40upx 0 37upx;
  205. display: flex;
  206. align-items: center;
  207. justify-content: space-between;
  208. .left{
  209. display: flex;
  210. align-items: center;
  211. .label{
  212. font-size: 28upx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #666666;
  216. line-height: 1;
  217. margin-right: 20upx;
  218. }
  219. .peop-box{
  220. display: flex;
  221. align-items: center;
  222. .head-box{
  223. margin-right: 28upx;
  224. display: flex;
  225. align-items: center;
  226. .head{
  227. width: 48upx;
  228. height: 48upx;
  229. border-radius: 50%;
  230. overflow: hidden;
  231. box-shadow: 0 0 0 1px #fff;
  232. margin-right: -10upx;
  233. image{
  234. width: 100%;
  235. height: 100%;
  236. }
  237. }
  238. }
  239. .arrow{
  240. width: 13upx;
  241. height: 23upx;
  242. }
  243. }
  244. }
  245. .share-btn{
  246. position: relative;
  247. width: 240upx;
  248. height: 80upx;
  249. line-height: 80upx;
  250. font-size: 30upx;
  251. font-family: PingFang SC;
  252. font-weight: 500;
  253. color: #FFFFFF;
  254. background: #C39A58;
  255. border-radius: 40upx;
  256. display: flex;
  257. align-items: center;
  258. justify-content: center;
  259. image{
  260. width: 32upx;
  261. height: 32upx;
  262. margin-right: 15upx;
  263. }
  264. .share{
  265. position: absolute;
  266. width: 100%;
  267. height: 100%;
  268. opacity: 0;
  269. }
  270. }
  271. }
  272. .inquiry{
  273. width: 131upx;
  274. height: 131upx;
  275. position: fixed;
  276. right: 22upx;
  277. bottom: 193upx;
  278. z-index: 99;
  279. .content{
  280. position: relative;
  281. image{
  282. width: 100%;
  283. height: 100%;
  284. position: absolute;
  285. top: 0;
  286. left: 0;
  287. z-index: 9;
  288. }
  289. .text{
  290. position: absolute;
  291. top: 70upx;
  292. left: 50%;
  293. transform: translateX(-50%);
  294. z-index: 10;
  295. font-size: 22upx;
  296. font-family: PingFang SC;
  297. font-weight: bold;
  298. color: #C39A58;
  299. line-height: 1;
  300. }
  301. }
  302. }
  303. .contact-btn{
  304. display: inline-block;
  305. position: absolute;
  306. top: 0;
  307. left: 0;
  308. width: 100%;
  309. height: 100%;
  310. opacity: 0;
  311. z-index: 9999;
  312. }
  313. </style>