doctorArticleDetails.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. </view>
  35. </template>
  36. <script>
  37. import {getAdvList} from '@/api/adv.js'
  38. import {getDoctorArticleById} from '@/api/doctorArticle.js'
  39. export default {
  40. data() {
  41. return {
  42. advs:[],
  43. advImgs:[],
  44. src: '',
  45. articleId:null,
  46. item:{},
  47. };
  48. },
  49. onLoad(option) {
  50. this.articleId=option.articleId;
  51. },
  52. onShow() {
  53. this.getAdvList()
  54. this.getDoctorArticleById();
  55. },
  56. //发送给朋友
  57. onShareAppMessage(res) {
  58. return {
  59. title: this.item.title,
  60. path: '/pages_doctor/doctorArticleDetails?articleId='+this.articleId,
  61. }
  62. },
  63. //分享到朋友圈
  64. onShareTimeline(res) {
  65. return {
  66. title: this.item.title,
  67. query:'articleId='+this.articleId,//页面参数
  68. }
  69. },
  70. methods:{
  71. handleAdvClick(index){
  72. var ad=this.advs[index];
  73. console.log(ad.advUrl);
  74. if(ad.showType==1){
  75. uni.setStorageSync('url',ad.advUrl);
  76. uni.navigateTo({
  77. url:"h5"
  78. })
  79. }
  80. else if(ad.showType==2){
  81. uni.navigateTo({
  82. url:ad.advUrl
  83. })
  84. }
  85. else if(ad.showType==3){
  86. uni.setStorageSync('content',ad.content);
  87. uni.navigateTo({
  88. url:"content"
  89. })
  90. }
  91. },
  92. getAdvList() {
  93. //联网加载数据
  94. var that = this;
  95. var data = {
  96. advType:10
  97. };
  98. getAdvList(data).then(res => {
  99. if(res.code==200){
  100. that.advImgs=[];
  101. that.advs=[];
  102. res.data.forEach(function(element) {
  103. if(element.imageUrl!=null&&element.imageUrl!=""){
  104. that.advs.push(element);
  105. that.advImgs.push(element.imageUrl);
  106. }
  107. });
  108. }else{
  109. uni.showToast({
  110. icon:'none',
  111. title: "请求失败",
  112. });
  113. }
  114. });
  115. },
  116. videoErrorCallback: function(e) {
  117. uni.showModal({
  118. content: e.target.errMsg,
  119. showCancel: false
  120. })
  121. },
  122. navTo(url){
  123. uni.navigateTo({
  124. url: url
  125. })
  126. },
  127. getDoctorArticleById(){
  128. let data = {articleId:this.articleId};
  129. getDoctorArticleById(data).then(
  130. res => {
  131. if(res.code==200){
  132. this.item=res.data;
  133. }else{
  134. uni.showToast({
  135. icon:'none',
  136. title: "请求失败",
  137. });
  138. }
  139. },
  140. rej => {}
  141. );
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. page{
  148. height: 100%;
  149. }
  150. .content{
  151. height: 100%;
  152. display: flex;
  153. flex-direction: column;
  154. }
  155. .detail-cont{
  156. width: 100%;
  157. flex: 1;
  158. padding: 40upx;
  159. overflow-y: auto;
  160. .title{
  161. font-size: 40upx;
  162. font-family: PingFang SC;
  163. // font-weight: bold;
  164. color: #222222;
  165. line-height: 70upx;
  166. }
  167. .info{
  168. display: flex;
  169. align-items: center;
  170. font-size: 24upx;
  171. font-family: PingFang SC;
  172. font-weight: 500;
  173. color: #999999;
  174. line-height: 48upx;
  175. margin: 23upx 0;
  176. .reads{
  177. margin-right: 30upx;
  178. }
  179. }
  180. .full-text{
  181. width: 100%;
  182. font-size: 36upx;
  183. font-family: PingFang SC;
  184. // font-weight: 500;
  185. color: #222222;
  186. line-height: 60upx;
  187. }
  188. .video{
  189. width: 100%;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. video{
  194. width: 100%;
  195. }
  196. }
  197. }
  198. .ad{
  199. margin-bottom: 50rpx;
  200. width: 100%;
  201. padding: 15rpx;
  202. }
  203. .inquiry{
  204. position: fixed;
  205. right: 22upx;
  206. bottom: 193upx;
  207. z-index: 99;
  208. .content{
  209. display: flex;
  210. align-items: center;
  211. justify-content: center;
  212. flex-direction: column;
  213. image{
  214. box-sizing: border-box;
  215. width: 100upx;
  216. height: 100upx;
  217. border-radius: 50%;
  218. z-index: 9;
  219. border: 2rpx solid #C39A58;
  220. }
  221. .text{
  222. margin-top: 15upx;
  223. font-size: 30upx;
  224. font-family: PingFang SC;
  225. font-weight: bold;
  226. color: #C39A58;
  227. }
  228. }
  229. }
  230. </style>