chineseMedicineDetails.vue 7.1 KB

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