index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="user">
  3. <capsule :showBorder="true" bgColor="#FFFFFF">
  4. <template v-slot:top>
  5. <view class="user-box">个人中心</view>
  6. </template>
  7. </capsule>
  8. <view class="seize"></view>
  9. <view class="picture-bg">
  10. <view class="bg-icon">
  11. <tui-icon name="notice" :size="24" color="#FFFFFF"></tui-icon>
  12. <tui-icon
  13. name="setup"
  14. :size="24"
  15. color="#FFFFFF"
  16. @click="navigateTo('/user_module/businessInfo/index')"
  17. ></tui-icon>
  18. </view>
  19. <view class="bg-image">
  20. <image class="" :src="shopInfo.shopLogo" mode="center" />
  21. </view>
  22. <view class="bg-info">
  23. <view class="info-image">
  24. <view class="img">
  25. <image class="" :src="shopInfo.shopLogo" />
  26. </view>
  27. <view class="info-switch">
  28. <image class="" src="@/static/image/user/switch.png" />
  29. </view>
  30. </view>
  31. <view class="info-text">
  32. <view class="text-title">{{ shopInfo.shopName }}</view>
  33. <view class="text-lable">
  34. <view class="lable">{{ shopInfo.shopReturn.returnPerson }}</view>
  35. <view class="lable">{{ shopInfo.shopPhone }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="user-container">
  41. <view class="user-flowing">
  42. <view class="flowing-box left">
  43. <view class="flowing-txt">营业额</view>
  44. <view class="flowing-price">¥{{ turnover }}元</view>
  45. </view>
  46. <view class="flowing-box left">
  47. <view class="flowing-txt">途中金额</view>
  48. <view class="flowing-price">¥{{ frozenMoney }}元</view>
  49. </view>
  50. <view class="flowing-box">
  51. <view class="flowing-txt">已到账金额</view>
  52. <view class="flowing-price">¥{{ withdrawableMoney }}元</view>
  53. </view>
  54. </view>
  55. <view class="user-account">
  56. <view class="account-top">
  57. <text>我的账户</text>
  58. <tui-icon name="arrowright" :size="26" colo="#666666"></tui-icon>
  59. </view>
  60. <view class="account-bottom">
  61. <view
  62. class="bottom-box"
  63. v-for="item in accountList"
  64. :key="item.title"
  65. @click="userAccount(item)"
  66. >
  67. <image class="" :src="item.image" />
  68. <text>{{ item.title }}</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import { getFinanceCount, getShopDetail } from "@/config/index.js";
  77. export default {
  78. created() {
  79. this.getFinance();
  80. },
  81. onShow() {
  82. // 本地获取店铺信息
  83. this.shopInfo = uni.getStorageSync("shopInfo");
  84. // 如果没有店铺信息 请求店铺信息
  85. if (!this.shopInfo) {
  86. this.getShop();
  87. }
  88. },
  89. data() {
  90. return {
  91. shopInfo: null,
  92. turnover: 0,
  93. frozenMoney: 0,
  94. withdrawableMoney: 0,
  95. accountList: [
  96. {
  97. title: "商家入驻",
  98. image: require("@/static/image/user/account_01.png"),
  99. },
  100. {
  101. title: "商家码",
  102. image: require("@/static/image/user/account_02.png"),
  103. url: "/user_module/merchantCode/index",
  104. },
  105. {
  106. title: "员工账户",
  107. image: require("@/static/image/user/account_03.png"),
  108. },
  109. {
  110. title: "官方客服",
  111. image: require("@/static/image/user/account_04.png"),
  112. },
  113. ],
  114. financeInfo: {},
  115. };
  116. },
  117. methods: {
  118. // 获取流水
  119. async getFinance() {
  120. let res = await getFinanceCount({ condition: "1", time: "" });
  121. this.financeInfo = res.data;
  122. this.animateNumber("turnover", res.data.turnover);
  123. this.animateNumber("frozenMoney", res.data.frozenMoney);
  124. this.animateNumber("withdrawableMoney", res.data.withdrawableMoney);
  125. },
  126. // 获取店铺详情
  127. async getShop() {
  128. let { data } = await getShopDetail({});
  129. this.shopInfo = data;
  130. // 将店铺存到本地
  131. uni.setStorageSync("shopInfo", data);
  132. },
  133. // 流水动画
  134. animateNumber(str, targetNum) {
  135. const duration = 2000; // 动画时长,单位毫秒
  136. const interval = 20; // 动画间隔时间,单位毫秒
  137. const distance = targetNum - this[str];
  138. const steps = duration / interval;
  139. const step = distance / steps;
  140. let currentStep = 0;
  141. const timer = setInterval(() => {
  142. if (!targetNum) return;
  143. currentStep++;
  144. this[str] = parseFloat((this[str] + step).toFixed(2));
  145. if (currentStep >= steps) {
  146. this[str] = targetNum;
  147. clearInterval(timer);
  148. }
  149. }, interval);
  150. },
  151. // 下方功能页面跳转
  152. userAccount(item) {
  153. if (!item.url) {
  154. this.$showToast("功能暂未开放");
  155. return;
  156. }
  157. this.navigateTo(item.url);
  158. },
  159. },
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. @import "./index.scss";
  164. </style>