index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="22"></tui-icon>
  63. </view>
  64. </view>
  65. <view class="data-list">
  66. <view class="data-box" v-for="(item,index) in statisticsList" :key="index">
  67. <text>{{ item.title }}</text>
  68. <text>{{todayData[item.price]?todayData[item.price]:'0' + item.proportion}}</text>
  69. </view>
  70. </view>
  71. <!-- <view class=""></view> -->
  72. <!-- <view class="statistics-list">
  73. <view
  74. class="statistics-item"
  75. v-for="(item, index) in statisticsList"
  76. :key="index"
  77. >
  78. <view class="statistics-trans">{{ item.title }}</view>
  79. <view class="statistics-price">
  80. <view class="price">{{ todayData[item.price] >= 0 && !Object.is(todayData[item.price], null) ? todayData[item.price] : '--' }}</view>
  81. </view>
  82. <view class="proportion" v-if="item.state !== 2">
  83. <view class="proportion-box">
  84. <text :style="{ color: item.state == 0 ? '#42D373' : '#EF530E' }"
  85. >{{ item.proportion }}%</text
  86. >
  87. <image
  88. :src="
  89. item.state == 0
  90. ? require('@/static/image/home/decline-icon.png')
  91. : require('@/static/image/home/rise-icon.png')
  92. "
  93. alt=""
  94. />
  95. </view>
  96. </view>
  97. <view class="chart-img" v-if="todayData[item.price]">
  98. <template v-if="item.state == 0">
  99. <image
  100. :src="
  101. item.proportion <= 16
  102. ? require('@/static/image/home/green.png')
  103. : require('@/static/image/home/green-more.png')
  104. "
  105. alt=""
  106. />
  107. </template>
  108. <template v-if="item.state == 1">
  109. <image src="@/static/image/home/red.png" alt="" />
  110. </template>
  111. </view>
  112. <view class="empty" v-else>
  113. <view class="left"></view>
  114. <view class="bottom"></view>
  115. </view>
  116. </view>
  117. </view> -->
  118. </view>
  119. </template>
  120. <script>
  121. import { getShopDetail,getBusinessData } from "@/config/index.js";
  122. import { toolList, tobeList, statisticsList } from "./data";
  123. export default {
  124. mounted() {
  125. //.box获取class为box的元素,如果使用的id= 'box' 则使用'#box'
  126. uni
  127. .createSelectorQuery()
  128. .select("#computed-box")
  129. .boundingClientRect((data) => {
  130. console.log(data);
  131. this.bgHeight = data.height
  132. console.log(this.bgHeight,98989898);
  133. }).exec();
  134. },
  135. created() {
  136. // 获取胶囊的高度
  137. // #ifdef MP-WEIXIN
  138. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  139. this.menuButtonHeight = menuButtonInfo.height;
  140. // #endif
  141. // 请求获取店铺的信息
  142. this.getShop();
  143. // 获取经营数据信息
  144. this.getData()
  145. },
  146. data() {
  147. return {
  148. // 背景高度
  149. bgHeight:0,
  150. // 胶囊的高度
  151. menuButtonHeight: null,
  152. toolList: toolList,
  153. tobeList: tobeList,
  154. statisticsList: statisticsList,
  155. // 店铺信息
  156. shopInfo: {},
  157. // 动态计算 main 的高度
  158. mainHeight: 0,
  159. todayData:{}
  160. };
  161. },
  162. onLoad() {},
  163. methods: {
  164. // 获取经营数据
  165. async getData(){
  166. let res = await getBusinessData({});
  167. this.todayData = res.data;
  168. },
  169. getCapusleHeight(e) {
  170. // this.mainHeight = 327 - e - this.menuButtonHeight + 16;
  171. console.log(this.mainHeight);
  172. },
  173. // 底部菜单跳转
  174. tobeNavigate(item) {
  175. if (item.title == "订单管理") {
  176. uni.switchTab({
  177. url: item.url,
  178. });
  179. } else if (item.url) {
  180. this.navigateTo(item.url);
  181. } else {
  182. this.$showToast("功能暂未开放");
  183. }
  184. },
  185. // 获取店铺详情
  186. async getShop() {
  187. let { data } = await getShopDetail({});
  188. this.shopInfo = data;
  189. // 将店铺存到本地
  190. uni.setStorageSync("shopInfo", data);
  191. },
  192. // 扫码
  193. scanCode(url) {
  194. if(!url){
  195. this.$showToast("功能暂未开放");
  196. return
  197. }
  198. uni.navigateTo({
  199. url: url,
  200. });
  201. },
  202. },
  203. };
  204. </script>
  205. <style lang="scss" scoped>
  206. @import "./index.scss";
  207. </style>