doctorArticleDetails.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. <view class="video" v-if="item.videoUrl!=null">
  10. <video class="myVideo" id="myVideo" :src="item.videoUrl"
  11. @error="videoErrorCallback" controls></video>
  12. </view>
  13. <!-- 正文 -->
  14. <view class="full-text" >
  15. <view v-html="item.content"></view>
  16. </view>
  17. </view>
  18. <!-- 咨询按钮 -->
  19. <view class="inquiry" >
  20. <view class="content" @click="navTo('/pages/doctor/doctorDetails?doctorId='+item.doctorId)">
  21. <image mode="aspectFill" :src="item.avatar" ></image>
  22. <text class="text">{{item.doctorName}}</text>
  23. </view>
  24. </view>
  25. <view class="ad">
  26. <u-swiper
  27. :list="advImgs"
  28. indicator
  29. indicatorMode="line"
  30. circular
  31. @click="handleAdvClick"
  32. ></u-swiper>
  33. </view>
  34. <!-- 分享弹窗 -->
  35. <u-popup :show="showShare" @close="showShare = false" >
  36. <share-box :shareItem="shareItem" @closeShare='showShare = false' ></share-box>
  37. </u-popup>
  38. </view>
  39. </template>
  40. <script>
  41. import {getAdvList} from '@/api/adv.js'
  42. import {getDoctorArticleById} from '@/api/doctorArticle.js'
  43. export default {
  44. data() {
  45. return {
  46. advs:[],
  47. advImgs:[],
  48. src: '',
  49. articleId:null,
  50. item:{},
  51. showShare:false,
  52. shareItem:{ imageUrl:"",title:"",path:"",isMini:true },
  53. };
  54. },
  55. onLoad(option) {
  56. this.articleId=option.articleId;
  57. },
  58. onShow() {
  59. if(!this.$isLogin()) {
  60. uni.navigateTo({
  61. url: '/pages/auth/loginIndex'
  62. })
  63. return
  64. }
  65. this.getAdvList()
  66. this.getDoctorArticleById();
  67. },
  68. //发送给朋友
  69. onShareAppMessage(res) {
  70. return {
  71. title: this.item.title,
  72. path: '/pages_doctor/doctorArticleDetails?articleId='+this.articleId,
  73. }
  74. },
  75. //分享到朋友圈
  76. onShareTimeline(res) {
  77. return {
  78. title: this.item.title,
  79. path: '/pages_doctor/doctorArticleDetails?articleId='+this.articleId,
  80. }
  81. },
  82. onNavigationBarButtonTap(e) {
  83. //#ifdef APP-PLUS
  84. this.shareItem.healthId= this.articleId;
  85. this.shareItem.title= this.item.title;
  86. this.shareItem.imageUrl="../../static/logo.png";
  87. this.shareItem.isMini=true;
  88. this.shareItem.path='/pages_doctor/doctorArticleDetails?articleId='+this.articleId;
  89. let cdn=uni.getStorageSync('h5Path');
  90. this.shareItem.url=cdn+'/pages/doctor/doctorArticleDetails?articleId='+this.articleId;
  91. this.showShare=true;
  92. //#endif
  93. },
  94. methods:{
  95. handleAdvClick(index){
  96. var ad=this.advs[index];
  97. if(ad.showType==1){
  98. uni.setStorageSync('url',ad.appAdvUrl);
  99. uni.navigateTo({
  100. url:"h5"
  101. })
  102. }
  103. else if(ad.showType==2){
  104. uni.navigateTo({
  105. url:ad.appAdvUrl
  106. })
  107. }
  108. else if(ad.showType==3){
  109. uni.setStorageSync('content',ad.content);
  110. uni.navigateTo({
  111. url:"content"
  112. })
  113. }
  114. },
  115. getAdvList() {
  116. //联网加载数据
  117. var that = this;
  118. var data = {
  119. advType:10
  120. };
  121. getAdvList(data).then(res => {
  122. if(res.code==200){
  123. that.advImgs=[];
  124. that.advs=[];
  125. res.data.forEach(function(element) {
  126. if(element.imageUrl!=null&&element.imageUrl!=""){
  127. that.advs.push(element);
  128. that.advImgs.push(element.imageUrl);
  129. }
  130. });
  131. }else{
  132. uni.showToast({
  133. icon:'none',
  134. title: "请求失败",
  135. });
  136. }
  137. });
  138. },
  139. videoErrorCallback: function(e) {
  140. uni.showModal({
  141. content: e.target.errMsg,
  142. showCancel: false
  143. })
  144. },
  145. navTo(url){
  146. uni.navigateTo({
  147. url: url
  148. })
  149. },
  150. getDoctorArticleById(){
  151. let data = {articleId:this.articleId};
  152. getDoctorArticleById(data).then(
  153. res => {
  154. if(res.code==200){
  155. this.item=res.data;
  156. }else{
  157. uni.showToast({
  158. icon:'none',
  159. title: "请求失败",
  160. });
  161. }
  162. },
  163. rej => {}
  164. );
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. page{
  171. height: 100%;
  172. }
  173. .content{
  174. height: 100%;
  175. }
  176. .detail-cont{
  177. width: 100%;
  178. flex: 1;
  179. padding: 40upx;
  180. overflow-y: auto;
  181. .title{
  182. font-size: 40upx;
  183. font-family: PingFang SC;
  184. // font-weight: bold;
  185. color: #222222;
  186. line-height: 70upx;
  187. }
  188. .info{
  189. display: flex;
  190. align-items: center;
  191. font-size: 24upx;
  192. font-family: PingFang SC;
  193. font-weight: 500;
  194. color: #999999;
  195. line-height: 48upx;
  196. margin: 23upx 0;
  197. .reads{
  198. margin-right: 30upx;
  199. }
  200. }
  201. .full-text{
  202. width: 100%;
  203. font-size: 36upx;
  204. font-family: PingFang SC;
  205. // font-weight: 500;
  206. color: #222222;
  207. line-height: 60upx;
  208. }
  209. .video{
  210. width: 100%;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. video{
  215. width: 100%;
  216. }
  217. }
  218. }
  219. .ad{
  220. // margin-bottom: 50rpx;
  221. width: 100%;
  222. padding: 15rpx;
  223. }
  224. .inquiry{
  225. position: fixed;
  226. right: 22upx;
  227. bottom: 193upx;
  228. z-index: 99;
  229. .content{
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. flex-direction: column;
  234. image{
  235. box-sizing: border-box;
  236. width: 100upx;
  237. height: 100upx;
  238. border-radius: 50%;
  239. z-index: 9;
  240. border: 2rpx solid #C39A58;
  241. }
  242. .text{
  243. margin-top: 15upx;
  244. font-size: 30upx;
  245. font-family: PingFang SC;
  246. font-weight: bold;
  247. color: #C39A58;
  248. }
  249. }
  250. }
  251. </style>