index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="home">
  3. <view class="bg-box" :style="{height:bgHeight + 'px'}"></view>
  4. <view id="computed-box">
  5. <capsule @getHeight="getCapusleHeight"></capsule>
  6. <view class="header-top" :style="{ height: menuButtonHeight + 'px' }">
  7. <view class="shop-title">{{ shopInfo.shopName }}</view>
  8. <view class="shop-state">
  9. <tui-icon
  10. style="margin-top: 4rpx;"
  11. name="circle-fill"
  12. :color="shopInfo.trade?'rgb(70,208,88)':'rgba(239, 83, 14, 0.63)'"
  13. :size="20"
  14. ></tui-icon>
  15. <text>{{ shopInfo.trade || '营业中' }}</text>
  16. </view>
  17. </view>
  18. <view class="main" >
  19. <view class="main-tool">
  20. <view class="tool-list">
  21. <view
  22. class="tool-item"
  23. v-for="item in toolList"
  24. :key="item.title"
  25. @click="scanCode(item.url)"
  26. >
  27. <view class="item-img" :style="{ background: item.background }">
  28. <image class="" :src="item.img" />
  29. </view>
  30. <view class="item-text">{{ item.title }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="main-container">
  35. <view class="tube-list">
  36. <view
  37. class="tube-item"
  38. v-for="item in tobeList"
  39. :key="item.title"
  40. @click="tobeNavigate(item)"
  41. >
  42. <image :src="item.img" />
  43. <text>{{ item.title }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- <view class="header-content"></view>
  50. <view class="main-tool">
  51. <view class="tool-list">
  52. <view class="tool-item" v-for="item in toolList" :key="item.title" @click="scanCode(item.url)">
  53. <image :src="item.img" alt="" />
  54. <text>{{ item.title }}</text>
  55. </view>
  56. </view>
  57. </view> -->
  58. <view class="summarize-box">
  59. <view class="summarize-left">经营概括</view>
  60. <view class="summarize-right" @click="navigateTo('/pages_module/operateData/index')">
  61. <text>更多</text>
  62. <tui-icon name="arrowright" :size="24"></tui-icon>
  63. </view>
  64. </view>
  65. <view class="statistics-list">
  66. <view
  67. class="statistics-item"
  68. v-for="(item, index) in statisticsList"
  69. :key="index"
  70. >
  71. <view class="statistics-trans">{{ item.title }}</view>
  72. <view class="statistics-price">
  73. <view class="price">{{ todayData[item.price] >= 0 && !Object.is(todayData[item.price], null) ? todayData[item.price] : '--' }}</view>
  74. <!-- <view class="text">较昨日</view> -->
  75. </view>
  76. <view class="proportion" v-if="item.state !== 2">
  77. <view class="proportion-box">
  78. <text :style="{ color: item.state == 0 ? '#42D373' : '#EF530E' }"
  79. >{{ item.proportion }}%</text
  80. >
  81. <image
  82. :src="
  83. item.state == 0
  84. ? require('@/static/image/home/decline-icon.png')
  85. : require('@/static/image/home/rise-icon.png')
  86. "
  87. alt=""
  88. />
  89. </view>
  90. </view>
  91. <view class="chart-img" v-if="todayData[item.price]">
  92. <template v-if="item.state == 0">
  93. <image
  94. :src="
  95. item.proportion <= 16
  96. ? require('@/static/image/home/green.png')
  97. : require('@/static/image/home/green-more.png')
  98. "
  99. alt=""
  100. />
  101. </template>
  102. <template v-if="item.state == 1">
  103. <image src="@/static/image/home/red.png" alt="" />
  104. </template>
  105. </view>
  106. <view class="empty" v-else>
  107. <view class="left"></view>
  108. <view class="bottom"></view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import { getShopDetail,getBusinessData } from "@/config/index.js";
  116. import { toolList, tobeList, statisticsList } from "./data";
  117. export default {
  118. mounted() {
  119. //.box获取class为box的元素,如果使用的id= 'box' 则使用'#box'
  120. uni
  121. .createSelectorQuery()
  122. .select("#computed-box")
  123. .boundingClientRect((data) => {
  124. console.log(data);
  125. this.bgHeight = data.height
  126. console.log(this.bgHeight,98989898);
  127. }).exec();
  128. },
  129. created() {
  130. // 获取胶囊的高度
  131. // #ifdef MP-WEIXIN
  132. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  133. this.menuButtonHeight = menuButtonInfo.height;
  134. // #endif
  135. // 请求获取店铺的信息
  136. this.getShop();
  137. // 获取经营数据信息
  138. this.getData()
  139. },
  140. data() {
  141. return {
  142. // 背景高度
  143. bgHeight:0,
  144. // 胶囊的高度
  145. menuButtonHeight: null,
  146. toolList: toolList,
  147. tobeList: tobeList,
  148. statisticsList: statisticsList,
  149. // 店铺信息
  150. shopInfo: {},
  151. // 动态计算 main 的高度
  152. mainHeight: 0,
  153. todayData:{}
  154. };
  155. },
  156. onLoad() {},
  157. methods: {
  158. // 获取经营数据
  159. async getData(){
  160. let res = await getBusinessData({});
  161. this.todayData = res.data;
  162. },
  163. getCapusleHeight(e) {
  164. // this.mainHeight = 327 - e - this.menuButtonHeight + 16;
  165. console.log(this.mainHeight);
  166. },
  167. // 底部菜单跳转
  168. tobeNavigate(item) {
  169. if (item.title == "订单管理") {
  170. uni.switchTab({
  171. url: item.url,
  172. });
  173. } else if (item.url) {
  174. this.navigateTo(item.url);
  175. } else {
  176. this.$showToast("功能暂未开放");
  177. }
  178. },
  179. // 获取店铺详情
  180. async getShop() {
  181. let { data } = await getShopDetail({});
  182. this.shopInfo = data;
  183. // 将店铺存到本地
  184. uni.setStorageSync("shopInfo", data);
  185. },
  186. // 扫码
  187. scanCode(url) {
  188. if(!url){
  189. this.$showToast("功能暂未开放");
  190. return
  191. }
  192. uni.navigateTo({
  193. url: url,
  194. });
  195. },
  196. },
  197. };
  198. </script>
  199. <style lang="scss" scoped>
  200. @import "./index.scss";
  201. </style>