chineseMedicineDetails.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. </view>
  49. </template>
  50. <script>
  51. import {getAdvList} from '@/api/adv.js'
  52. import {getChineseMedicineById} from '@/api/index'
  53. export default {
  54. data() {
  55. return {
  56. advs:[],
  57. advImgs:[],
  58. tabIndex:1,
  59. articleId:null,
  60. item:{},
  61. };
  62. },
  63. onLoad(option) {
  64. this.id=option.id;
  65. },
  66. onShow() {
  67. this.getChineseMedicineById();
  68. this.getAdvList();
  69. },
  70. onShareAppMessage(res) {
  71. if(this.$isLogin()){
  72. return {
  73. title: this.item.medicineName,
  74. path: '/pages_index/chineseMedicineDetails?id='+this.id,
  75. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  76. }
  77. }
  78. },
  79. //分享到朋友圈
  80. onShareTimeline(res) {
  81. if(this.utils.isLogin()){
  82. return {
  83. title: this.item.title,
  84. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  85. }
  86. }
  87. },
  88. methods:{
  89. handleAdvClick(index){
  90. var ad=this.advs[index];
  91. console.log(ad.advUrl);
  92. if(ad.showType==1){
  93. uni.setStorageSync('url',ad.advUrl);
  94. uni.navigateTo({
  95. url:"h5"
  96. })
  97. }
  98. else if(ad.showType==2){
  99. uni.navigateTo({
  100. url:ad.advUrl
  101. })
  102. }
  103. else if(ad.showType==3){
  104. uni.setStorageSync('content',ad.content);
  105. uni.navigateTo({
  106. url:"content"
  107. })
  108. }
  109. },
  110. getAdvList() {
  111. //联网加载数据
  112. var that = this;
  113. var data = {
  114. advType:8
  115. };
  116. getAdvList(data).then(res => {
  117. if(res.code==200){
  118. that.advImgs=[];
  119. that.advs=[];
  120. res.data.forEach(function(element) {
  121. if(element.imageUrl!=null&&element.imageUrl!=""){
  122. that.advs.push(element);
  123. that.advImgs.push(element.imageUrl);
  124. }
  125. });
  126. }else{
  127. uni.showToast({
  128. icon:'none',
  129. title: "请求失败",
  130. });
  131. }
  132. });
  133. },
  134. tabClick(index){
  135. this.tabIndex=index;
  136. },
  137. getChineseMedicineById(){
  138. let data = {id:this.id};
  139. getChineseMedicineById(data).then(
  140. res => {
  141. if(res.code==200){
  142. this.item=res.data;
  143. }else{
  144. uni.showToast({
  145. icon:'none',
  146. title: "请求失败",
  147. });
  148. }
  149. },
  150. rej => {}
  151. );
  152. },
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. page{
  158. height: 100%;
  159. }
  160. .content{
  161. height: 100%;
  162. image{
  163. height:450rpx;
  164. width:100%;
  165. }
  166. .detail-cont{
  167. flex: 1;
  168. padding: 20upx;
  169. overflow-y: auto;
  170. .title-box{
  171. width: 100%;
  172. display: flex;
  173. justify-content: flex-start;
  174. align-items: center;
  175. .line{
  176. border-radius: 5rpx;
  177. width: 8rpx;
  178. height:30rpx;
  179. background-color: #C39A58;
  180. }
  181. .title{
  182. margin-left: 15rpx;
  183. font-size: 40upx;
  184. font-family: PingFang SC;
  185. font-weight: bold;
  186. color: #333;
  187. }
  188. .title-py{
  189. margin-left: 15rpx;
  190. font-size: 32upx;
  191. font-family: PingFang SC;
  192. color: #333;
  193. }
  194. }
  195. .desc{
  196. margin-top: 20rpx;
  197. font-size: 32upx;
  198. font-family: PingFang SC;
  199. color: #333;
  200. }
  201. .line-h{
  202. margin: 15rpx 0rpx;
  203. border-bottom: 1rpx dashed #d4d4d4;
  204. }
  205. .tabs{
  206. width: 100%;
  207. margin: 20rpx 0rpx;
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. // border: 1rpx solid #C39A58;
  212. border-radius: 30rpx;
  213. line-height: 60rpx;
  214. .tab1{
  215. border-radius: 30rpx 0rpx 0rpx 30rpx;
  216. width: 25%;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. background-color: #fff;
  221. color: #4F575A;
  222. font-size: 28upx;
  223. font-weight: bold;
  224. font-family: PingFang SC;
  225. }
  226. .tab2{
  227. width: 25%;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. background-color: #fff;
  232. color: #4F575A;
  233. font-size: 28upx;
  234. font-weight: bold;
  235. font-family: PingFang SC;
  236. }
  237. .tab3{
  238. width: 25%;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. background-color: #fff;
  243. color: #4F575A;
  244. font-size: 28upx;
  245. font-weight: bold;
  246. font-family: PingFang SC;
  247. }
  248. .tab4{
  249. border-radius: 0rpx 30rpx 30rpx 0rpx;
  250. width: 25%;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. background-color: #fff;
  255. color: #4F575A;
  256. font-size: 28upx;
  257. font-weight: bold;
  258. font-family: PingFang SC;
  259. }
  260. .active{
  261. background-color: #C39A58;
  262. color: #fff;
  263. }
  264. }
  265. }
  266. .ad{
  267. margin-bottom: 50rpx;
  268. width: 100%;
  269. padding: 15rpx;
  270. }
  271. }
  272. </style>