list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="wrap">
  3. <view v-if="list && list.length" class="list">
  4. <navigator
  5. class="item"
  6. v-for="item in list"
  7. :key="item.id"
  8. :url="`/pages/shop/detail?id=${item.id}`"
  9. >
  10. <image class="item-img" :src="item.banner" mode="aspectFit"></image>
  11. <view class="item-body">
  12. <view class="item-name">{{ item.name }}</view>
  13. <view class="item-desc" v-if="item.address">{{ item.address }}</view>
  14. </view>
  15. </navigator>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import login from "@/lib/utils/login";
  21. import { getShopList } from "@/lib/api/shop";
  22. export default {
  23. name: "PageHome",
  24. data() {
  25. return {
  26. statusBarHeight: 0, // 自定义导航
  27. titleBarHeight: 44, // 自定义导航
  28. BarHeight: 0, // 自定义导航
  29. userInfo: {},
  30. list: [],
  31. tabStyle: "",
  32. // showTask: false,
  33. };
  34. },
  35. async onLoad() {
  36. this.userInfo = await login.getUserInfo();
  37. uni.showLoading({
  38. title: "加载中",
  39. });
  40. this.loadList().then(() => {
  41. uni.hideLoading();
  42. });
  43. },
  44. // onShow() {
  45. // // this.getSingInfo();
  46. // },
  47. onShareAppMessage() {
  48. return {
  49. title: "云果国潮会员中心",
  50. imageUrl:
  51. "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
  52. path: "/pages/index/index",
  53. };
  54. },
  55. onShareTimeline() {
  56. return {
  57. title: "云果国潮会员中心",
  58. imageUrl:
  59. "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
  60. path: "/pages/index/index",
  61. };
  62. },
  63. async onPullDownRefresh() {
  64. await this.loadList().catch((e) => console.log(e));
  65. uni.stopPullDownRefresh();
  66. },
  67. methods: {
  68. async loadList() {
  69. try {
  70. const data = await getShopList();
  71. if (data.errno == 10000) {
  72. this.list = data.data;
  73. // this.endTime = data.diff_time;
  74. // this.runCd();
  75. } else {
  76. uni.showToast({
  77. icon: "none",
  78. title: data.errmsg,
  79. duration: 3000,
  80. });
  81. }
  82. } catch (e) {
  83. uni.showToast({
  84. icon: "none",
  85. title: "出错啦,请稍后重试",
  86. duration: 3000,
  87. });
  88. }
  89. },
  90. // async getSingInfo() {
  91. // if (!this.userInfo.session) {
  92. // this.showTask = true;
  93. // return Promise.reject();
  94. // }
  95. // const data = await getSingInfo(this.userInfo.session);
  96. // this.showTask = !data.is_current_signin;
  97. // },
  98. jumpModuleAll(url) {
  99. if (!url) return;
  100. if (/^https?:\/\//i.test(url)) {
  101. uni.navigateTo({
  102. url: `../webview/webview?url=${encodeURIComponent(url)}`,
  103. });
  104. return;
  105. }
  106. if (
  107. [
  108. "/pages/index/index",
  109. "/pages/shop/index",
  110. "/pages/activity/index",
  111. "/pages/my/my",
  112. ].includes(url)
  113. ) {
  114. uni.switchTab({
  115. url,
  116. });
  117. } else {
  118. uni.navigateTo({
  119. url,
  120. });
  121. }
  122. },
  123. },
  124. };
  125. </script>
  126. <style lang="scss">
  127. @import "./list.scss";
  128. </style>