index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="content">
  3. <view class="banner">
  4. <image :src="bannerSrc" alt="banner" mode="aspectFill"/>
  5. </view>
  6. <view class="cross-line"></view>
  7. <view class="menus">
  8. <view class="menu" v-for="(item,index) in miniProgramList" :key="index" @click="toDetail(item)">
  9. <image :src="item.pic_url" mode="aspectFill"/>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import md5 from "@/common/md5.js";
  16. export default {
  17. data() {
  18. return {
  19. bannerSrc: "",
  20. miniProgramList:[
  21. // {
  22. // appId:'wxec4343871c957260',
  23. // path:'pages/index/index',
  24. // src:'/static/service/1.png'
  25. // },
  26. // {
  27. // appId:'',
  28. // path:'',
  29. // src:'/static/service/2.png'
  30. // },
  31. ],
  32. };
  33. },
  34. onLoad() {
  35. this.getPageImg();
  36. this.getPageMiniProgram();
  37. },
  38. methods: {
  39. getPageImg() {
  40. let md5Sign = md5(
  41. "method=" +
  42. "common" +
  43. "&timestamp=" +
  44. getApp().globalData.globalTimestamp +
  45. "&secret=" +
  46. getApp().globalData.secret
  47. );
  48. let url =
  49. getApp().globalData.shareUrl +
  50. "api/api.php" +
  51. "?method=common&source=service_pics&action=list&timestamp=" +
  52. getApp().globalData.globalTimestamp +
  53. "&sign=" +
  54. md5Sign;
  55. uni.request({
  56. url: url,
  57. method: "POST",
  58. header: {
  59. "content-type": "application/x-www-form-urlencoded",
  60. },
  61. data: {
  62. },
  63. success: (res) => {
  64. if (res.data.code === 200) {
  65. this.bannerSrc = res.data.data.list.length ? getApp().globalData.shareUrl + res.data.data.list[0].pic_url : '/static/nodata.svg'
  66. }
  67. },
  68. fail: () => {
  69. console.log("连接失败");
  70. },
  71. });
  72. },
  73. getPageMiniProgram(){
  74. let md5Sign = md5(
  75. "method=" +
  76. "common" +
  77. "&timestamp=" +
  78. getApp().globalData.globalTimestamp +
  79. "&secret=" +
  80. getApp().globalData.secret
  81. );
  82. let url =
  83. getApp().globalData.shareUrl +
  84. "api/api.php" +
  85. "?method=common&source=service&action=list&timestamp=" +
  86. getApp().globalData.globalTimestamp +
  87. "&sign=" +
  88. md5Sign;
  89. uni.request({
  90. url: url,
  91. method: "POST",
  92. header: {
  93. "content-type": "application/x-www-form-urlencoded",
  94. },
  95. data: {
  96. s_show:1
  97. },
  98. success: (res) => {
  99. if (res.data.code === 200) {
  100. res.data.data.list.forEach((item) => {
  101. item.pic_url = getApp().globalData.shareUrl + item.pic_url;
  102. });
  103. this.miniProgramList = res.data.data.list;
  104. }
  105. },
  106. fail: () => {
  107. console.log("连接失败");
  108. },
  109. });
  110. },
  111. toDetail(item) {
  112. uni.navigateToMiniProgram({
  113. appId:item.app_id,
  114. path:item.app_path,
  115. success(res) {
  116. console.log(res,'打开成功')
  117. },
  118. fail(err) {
  119. console.log(err)
  120. }
  121. })
  122. },
  123. },
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .flex {
  128. display: flex;
  129. }
  130. .content {
  131. height:100%;
  132. .banner {
  133. height: 25%;
  134. margin-bottom:20rpx;
  135. image {
  136. width: 100%;
  137. height: 100%;
  138. }
  139. }
  140. .cross-line {
  141. width: 100%;
  142. height: 10rpx;
  143. background-color: #F2F2F2;
  144. }
  145. .menus {
  146. height: 15%;
  147. .menu {
  148. margin: 3%;
  149. height: 100%;
  150. border-radius: 20rpx;
  151. // box-shadow: 0rpx 10rpx 5rpx rgb(212, 212, 212);
  152. image {
  153. width: 100%;
  154. height: 100%;
  155. border-radius: 20rpx;
  156. }
  157. }
  158. }
  159. }
  160. </style>