index.vue 4.9 KB

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