medicatedFoodDetails.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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.foodName}}</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="content" v-html="item.descs">
  17. </view>
  18. </view>
  19. <view class="ad">
  20. <u-swiper
  21. :list="advImgs"
  22. indicator
  23. indicatorMode="line"
  24. circular
  25. @click="handleAdvClick"
  26. ></u-swiper>
  27. </view>
  28. <!-- 分享弹窗 -->
  29. <u-popup :show="showShare" @close="showShare = false" >
  30. <share-box :shareItem="shareItem" @closeShare='showShare = false' ></share-box>
  31. </u-popup>
  32. <h5-down-app-tip :pageUrl="pageUrl"/>
  33. </view>
  34. </template>
  35. <script>
  36. import {getAdvList} from '@/api/adv.js'
  37. import {getMedicatedFoodById} from '@/api/index'
  38. export default {
  39. data() {
  40. return {
  41. advs:[],
  42. advImgs:[],
  43. item:{},
  44. isH5:false,
  45. showShare:false,
  46. shareItem:{ imageUrl:"",title:"",path:"",isMini:true, yyb:true },
  47. pageUrl: ''
  48. };
  49. },
  50. onLoad(option) {
  51. this.id=option.id;
  52. //#ifdef H5
  53. this.isH5=true;
  54. //#endif
  55. },
  56. onShow() {
  57. if(!this.$isLogin()) {
  58. uni.navigateTo({
  59. url: '/pages/auth/loginIndex'
  60. })
  61. return
  62. }
  63. this.pageUrl = '/pages/article/medicatedFoodDetails?id='+this.id;
  64. this.getAdvList();
  65. this.getMedicatedFoodById();
  66. },
  67. onShareAppMessage(res) {
  68. if(this.$isLogin()){
  69. return {
  70. title: this.item.foodName,
  71. path: '/pages_index/medicatedFoodDetails?id='+this.id,
  72. imageUrl: 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/minilogo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  73. }
  74. }
  75. },
  76. //分享到朋友圈
  77. onShareTimeline(res) {
  78. if(this.$isLogin()){
  79. return {
  80. title: this.item.foodName,
  81. path: '/pages_index/medicatedFoodDetails?id='+this.id,
  82. imageUrl: 'https://zkzh-2025.oss-cn-beijing.aliyuncs.com/appimgs/minilogo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  83. }
  84. }
  85. },
  86. onNavigationBarButtonTap(e) {
  87. this.doShare();
  88. },
  89. methods:{
  90. handleAdvClick(index){
  91. var ad=this.advs[index];
  92. if(ad.showType==1){
  93. uni.setStorageSync('url',ad.appAdvUrl);
  94. uni.navigateTo({
  95. url:"h5"
  96. })
  97. }
  98. else if(ad.showType==2){
  99. uni.navigateTo({
  100. url:ad.appAdvUrl
  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:4
  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. getMedicatedFoodById(){
  135. let data = {id:this.id};
  136. getMedicatedFoodById(data).then(
  137. res => {
  138. if(res.code==200){
  139. this.item=res.data;
  140. }else{
  141. uni.showToast({
  142. icon:'none',
  143. title: "请求失败",
  144. });
  145. }
  146. },
  147. rej => {}
  148. );
  149. },
  150. doShare(){
  151. if(this.isH5){
  152. return;
  153. }
  154. this.shareItem.healthId= this.id;
  155. this.shareItem.title= this.item.foodName;
  156. this.shareItem.imageUrl=this.item.imgUrl;
  157. this.shareItem.compressImage = 1;
  158. this.shareItem.isMini=true;
  159. this.shareItem.path='/pages/article/medicatedFoodDetails?id='+this.id;
  160. this.showShare=true;
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. page{
  167. height: 100%;
  168. }
  169. .content{
  170. height: 100%;
  171. image{
  172. height:450rpx;
  173. width:100%;
  174. }
  175. .detail-cont{
  176. flex: 1;
  177. padding: 20upx;
  178. overflow-y: auto;
  179. .title-box{
  180. width: 100%;
  181. display: flex;
  182. justify-content: flex-start;
  183. align-items: center;
  184. .line{
  185. border-radius: 5rpx;
  186. width: 8rpx;
  187. height:30rpx;
  188. background-color: #FF233C;
  189. }
  190. .title{
  191. margin-left: 15rpx;
  192. font-size: 40upx;
  193. font-family: PingFang SC;
  194. font-weight: bold;
  195. color: #333;
  196. }
  197. .title-py{
  198. margin-left: 15rpx;
  199. font-size: 32upx;
  200. font-family: PingFang SC;
  201. color: #333;
  202. }
  203. }
  204. .desc{
  205. margin-top: 20rpx;
  206. font-size: 32upx;
  207. font-family: PingFang SC;
  208. color: #333;
  209. }
  210. .line-h{
  211. margin: 15rpx 0rpx;
  212. border-bottom: 1rpx dashed #d4d4d4;
  213. }
  214. .tabs{
  215. width: 100%;
  216. margin: 20rpx 0rpx;
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. // border: 1rpx solid #FF233C;
  221. border-radius: 30rpx;
  222. line-height: 60rpx;
  223. .tab1{
  224. border-radius: 30rpx 0rpx 0rpx 30rpx;
  225. width: 25%;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. background-color: #fff;
  230. color: #4F575A;
  231. font-size: 28upx;
  232. font-weight: bold;
  233. font-family: PingFang SC;
  234. }
  235. .tab2{
  236. width: 25%;
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. background-color: #fff;
  241. color: #4F575A;
  242. font-size: 28upx;
  243. font-weight: bold;
  244. font-family: PingFang SC;
  245. }
  246. .tab3{
  247. width: 25%;
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. background-color: #fff;
  252. color: #4F575A;
  253. font-size: 28upx;
  254. font-weight: bold;
  255. font-family: PingFang SC;
  256. }
  257. .tab4{
  258. border-radius: 0rpx 30rpx 30rpx 0rpx;
  259. width: 25%;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. background-color: #fff;
  264. color: #4F575A;
  265. font-size: 28upx;
  266. font-weight: bold;
  267. font-family: PingFang SC;
  268. }
  269. .active{
  270. background-color: #FF233C;
  271. color: #fff;
  272. }
  273. }
  274. }
  275. .ad{
  276. margin-bottom: 50rpx;
  277. width: 100%;
  278. padding: 15rpx;
  279. }
  280. }
  281. </style>