index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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" @click="navigateTo('/user_module/myAccount/index')">
  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. url: "/user_module/webview/index?type=1",
  100. },
  101. {
  102. title: "商家码",
  103. image: require("@/static/image/user/account_02.png"),
  104. url: "/user_module/merchantCode/index",
  105. },
  106. {
  107. title: "会员管理",
  108. image: require("@/static/image/user/account_03.png"),
  109. url: "/user_module/memberManage/index",
  110. },
  111. {
  112. title: "官方客服",
  113. image: require("@/static/image/user/account_04.png"),
  114. url: "/user_module/webview/index?type=2",
  115. },
  116. ],
  117. financeInfo: {},
  118. };
  119. },
  120. methods: {
  121. // 获取流水
  122. async getFinance() {
  123. let res = await getFinanceCount({ condition: "1", time: "" });
  124. this.financeInfo = res.data;
  125. this.animateNumber("turnover", res.data.turnover);
  126. this.animateNumber("frozenMoney", res.data.frozenMoney);
  127. this.animateNumber("withdrawableMoney", res.data.withdrawableMoney);
  128. },
  129. // 获取店铺详情
  130. async getShop() {
  131. let { data } = await getShopDetail({});
  132. this.shopInfo = data;
  133. // 将店铺存到本地
  134. uni.setStorageSync("shopInfo", data);
  135. },
  136. // 流水动画
  137. animateNumber(str, targetNum) {
  138. const duration = 2000; // 动画时长,单位毫秒
  139. const interval = 20; // 动画间隔时间,单位毫秒
  140. const distance = targetNum - this[str];
  141. const steps = duration / interval;
  142. const step = distance / steps;
  143. let currentStep = 0;
  144. const timer = setInterval(() => {
  145. if (!targetNum) return;
  146. currentStep++;
  147. this[str] = parseFloat((this[str] + step).toFixed(2));
  148. if (currentStep >= steps) {
  149. this[str] = targetNum;
  150. clearInterval(timer);
  151. }
  152. }, interval);
  153. },
  154. // 下方功能页面跳转
  155. userAccount(item) {
  156. if (!item.url) {
  157. this.$showToast("功能暂未开放");
  158. return;
  159. }
  160. this.navigateTo(item.url);
  161. },
  162. },
  163. };
  164. </script>
  165. <style lang="scss" scoped>
  166. @import "./index.scss";
  167. </style>