medicatedFoodDetails.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 },
  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://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.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://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.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_index/medicatedFoodDetails?id='+this.id;
  160. let cdn=uni.getStorageSync('h5Path');
  161. this.shareItem.url=cdn+'/pages/article/medicatedFoodDetails?id='+this.id;
  162. this.showShare=true;
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. page{
  169. height: 100%;
  170. }
  171. .content{
  172. height: 100%;
  173. image{
  174. height:450rpx;
  175. width:100%;
  176. }
  177. .detail-cont{
  178. flex: 1;
  179. padding: 20upx;
  180. overflow-y: auto;
  181. .title-box{
  182. width: 100%;
  183. display: flex;
  184. justify-content: flex-start;
  185. align-items: center;
  186. .line{
  187. border-radius: 5rpx;
  188. width: 8rpx;
  189. height:30rpx;
  190. background-color: #C39A58;
  191. }
  192. .title{
  193. margin-left: 15rpx;
  194. font-size: 40upx;
  195. font-family: PingFang SC;
  196. font-weight: bold;
  197. color: #333;
  198. }
  199. .title-py{
  200. margin-left: 15rpx;
  201. font-size: 32upx;
  202. font-family: PingFang SC;
  203. color: #333;
  204. }
  205. }
  206. .desc{
  207. margin-top: 20rpx;
  208. font-size: 32upx;
  209. font-family: PingFang SC;
  210. color: #333;
  211. }
  212. .line-h{
  213. margin: 15rpx 0rpx;
  214. border-bottom: 1rpx dashed #d4d4d4;
  215. }
  216. .tabs{
  217. width: 100%;
  218. margin: 20rpx 0rpx;
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. // border: 1rpx solid #C39A58;
  223. border-radius: 30rpx;
  224. line-height: 60rpx;
  225. .tab1{
  226. border-radius: 30rpx 0rpx 0rpx 30rpx;
  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. .tab2{
  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. .tab3{
  249. width: 25%;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. background-color: #fff;
  254. color: #4F575A;
  255. font-size: 28upx;
  256. font-weight: bold;
  257. font-family: PingFang SC;
  258. }
  259. .tab4{
  260. border-radius: 0rpx 30rpx 30rpx 0rpx;
  261. width: 25%;
  262. display: flex;
  263. justify-content: center;
  264. align-items: center;
  265. background-color: #fff;
  266. color: #4F575A;
  267. font-size: 28upx;
  268. font-weight: bold;
  269. font-family: PingFang SC;
  270. }
  271. .active{
  272. background-color: #C39A58;
  273. color: #fff;
  274. }
  275. }
  276. }
  277. .ad{
  278. margin-bottom: 50rpx;
  279. width: 100%;
  280. padding: 15rpx;
  281. }
  282. }
  283. </style>