index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="home-index2">
  3. <view class="BanContain">
  4. <view
  5. class="status_bar"
  6. :style="{ height: statusBarHeight + 'px' }"
  7. ></view>
  8. <view class="navBar" :style="{ height: titleBarHeight + 'px' }">
  9. <image class="logo" :src="require('@/assets/logo.png')" mode=""></image>
  10. </view>
  11. </view>
  12. <view :style="{ marginTop: BarHeight + 'px' }"></view>
  13. <swiper
  14. v-if="modules.lunbo && modules.lunbo.length"
  15. class="swiper"
  16. circular
  17. indicator-dots
  18. autoplay
  19. >
  20. <swiper-item v-for="item in modules.lunbo" :key="item.module_id">
  21. <image
  22. class="swiper-item"
  23. :src="item.img"
  24. mode=""
  25. @click="jumpModuleAll(item.url)"
  26. ></image>
  27. </swiper-item>
  28. </swiper>
  29. <view
  30. class="icon-list"
  31. v-if="modules.quick_links && modules.quick_links.length"
  32. >
  33. <view
  34. v-for="item in modules.quick_links"
  35. :key="item.module_id"
  36. class="icon-item"
  37. @click="jumpModuleAll(item.url)"
  38. >
  39. <image class="icon" :src="item.img"></image>
  40. {{ item.name }}
  41. </view>
  42. </view>
  43. <view class="title">最新推荐</view>
  44. <view
  45. v-if="modules.latest_recommend && modules.latest_recommend.length"
  46. class="base-list"
  47. >
  48. <list-item
  49. v-for="item in modules.latest_recommend"
  50. :key="item.module_id"
  51. :item="item"
  52. class="base-list-item"
  53. @click="jumpModuleAll(item.url)"
  54. >
  55. </list-item>
  56. </view>
  57. <!-- <view class="fixed-btns">
  58. <image
  59. class="fixed-btn"
  60. :src="require('@/assets/icon/icon-btn-service.png')"
  61. @click="jumpModuleAll('/pages/help/help_contact')"
  62. ></image>
  63. <image
  64. class="fixed-btn"
  65. :src="require('@/assets/icon/icon-btn-message.png')"
  66. @click="jumpModuleAll('/pages/my/messages')"
  67. ></image>
  68. <image
  69. v-if="showTask"
  70. class="fixed-btn"
  71. :src="require('@/assets/icon/icon-btn-sign.png')"
  72. @click="jumpModuleAll('/pages/task/index')"
  73. ></image>
  74. </view>
  75. -->
  76. </view>
  77. </template>
  78. <script>
  79. import login from "@/lib/utils/login";
  80. import { homeModules } from "@/lib/api/home";
  81. // import { getSingInfo } from "@/lib/api/task";
  82. import listItem from "@/components/list-item/list-item.vue";
  83. export default {
  84. name: "PageHome",
  85. components: {
  86. listItem,
  87. },
  88. data() {
  89. return {
  90. statusBarHeight: 0, // 自定义导航
  91. titleBarHeight: 44, // 自定义导航
  92. BarHeight: 0, // 自定义导航
  93. userInfo: {},
  94. modules: {},
  95. tabStyle: "",
  96. // showTask: false,
  97. };
  98. },
  99. async onLoad() {
  100. this.userInfo = await login.getUserInfo();
  101. uni.showLoading({
  102. title: "加载中",
  103. });
  104. this.loadModules().then(() => {
  105. uni.hideLoading();
  106. });
  107. this.showDialog();
  108. },
  109. // onShow() {
  110. // // this.getSingInfo();
  111. // },
  112. onShareAppMessage() {
  113. return {
  114. title: "云果国潮会员中心",
  115. imageUrl:
  116. "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
  117. path: "/pages/index/index",
  118. };
  119. },
  120. onShareTimeline() {
  121. return {
  122. title: "云果国潮会员中心",
  123. imageUrl:
  124. "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
  125. path: "/pages/index/index",
  126. };
  127. },
  128. async onPullDownRefresh() {
  129. await this.loadModules().catch((e) => console.log(e));
  130. uni.stopPullDownRefresh();
  131. },
  132. mounted() {
  133. const systemInfo = uni.getSystemInfoSync();
  134. this.statusBarHeight = systemInfo.statusBarHeight;
  135. // #ifdef MP
  136. this.statusBarHeight = systemInfo.statusBarHeight;
  137. // this.titleBarHeight = systemInfo.statusBarHeight;
  138. // #endif
  139. // #ifdef MP-WEIXIN
  140. this.statusBarHeight = systemInfo.statusBarHeight;
  141. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  142. this.titleBarHeight =
  143. (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 +
  144. menuButtonInfo.height;
  145. // #endif
  146. // #ifdef MP-ALIPAY
  147. this.statusBarHeight = systemInfo.statusBarHeight;
  148. this.titleBarHeight =
  149. systemInfo.statusBarHeight + systemInfo.titleBarHeight;
  150. // #endif
  151. // #ifdef APP-PLUS
  152. this.statusBarHeight = systemInfo.statusBarHeight;
  153. // this.titleBarHeight = 44;
  154. // #endif
  155. // #ifdef H5
  156. this.statusBarHeight = 0;
  157. // this.titleBarHeight = systemInfo.statusBarHeight;
  158. // #endif
  159. this.BarHeight = this.statusBarHeight + this.titleBarHeight;
  160. },
  161. methods: {
  162. showDialog() {
  163. if (this.userInfo && this.userInfo.type === "1") return;
  164. uni.showModal({
  165. title: "欢迎来到云果国潮",
  166. content: "您当前还不是VIP,立即加入享受多种优惠活动!",
  167. cancelText: "暂不开通",
  168. confirmText: "立即开通",
  169. success: function (res) {
  170. if (res.confirm) {
  171. uni.navigateTo({
  172. url: "/pages/vip/vip",
  173. });
  174. }
  175. },
  176. });
  177. },
  178. async loadModules() {
  179. try {
  180. const data = await homeModules();
  181. if (data.errno == 10000) {
  182. this.modules = data.data;
  183. // this.endTime = data.diff_time;
  184. // this.runCd();
  185. } else {
  186. uni.showToast({
  187. icon: "none",
  188. title: data.errmsg,
  189. duration: 3000,
  190. });
  191. }
  192. } catch (e) {
  193. uni.showToast({
  194. icon: "none",
  195. title: "出错啦,请稍后重试",
  196. duration: 3000,
  197. });
  198. }
  199. },
  200. // async getSingInfo() {
  201. // if (!this.userInfo.session) {
  202. // this.showTask = true;
  203. // return Promise.reject();
  204. // }
  205. // const data = await getSingInfo(this.userInfo.session);
  206. // this.showTask = !data.is_current_signin;
  207. // },
  208. jumpModuleAll(url) {
  209. if (!url) return;
  210. if (/^https?:\/\//i.test(url)) {
  211. uni.navigateTo({
  212. url: `../webview/webview?url=${encodeURIComponent(url)}`,
  213. });
  214. return;
  215. }
  216. if (
  217. [
  218. "/pages/index/index",
  219. "/pages/shop/index",
  220. "/pages/activity/index",
  221. "/pages/my/my",
  222. ].includes(url)
  223. ) {
  224. uni.switchTab({
  225. url,
  226. });
  227. } else {
  228. uni.navigateTo({
  229. url,
  230. });
  231. }
  232. },
  233. },
  234. };
  235. </script>
  236. <style lang="scss">
  237. @import "./index.scss";
  238. </style>