index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <image src="/static/user/user-bg.png" mode="widthFix" class="bg"/>
  3. <block>
  4. <view class="container" :style="containerStyle">
  5. <view class="header flex-column">
  6. <view class="flex-grow flex-center">
  7. <image
  8. src="/static/user/round.png"
  9. mode="heightFix"
  10. style="width: 12orpx;height: 120rpx"
  11. />
  12. </view>
  13. <view class="main flex-shrink">
  14. <view
  15. class="avatar"
  16. @click="toPage(2)"
  17. :style="{
  18. 'background-image': `url(${user.avatar})`,
  19. }"
  20. ></view>
  21. <view class="phone fs-40 fw-500">{{ user.mobilePhoneFormat }}</view>
  22. <view class="money" @click="toPage({path: '/pages-user/account/index'})">
  23. <uv-icon name="red-packet" size="24"></uv-icon>
  24. <view>¥{{ user.balance }}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="body">
  29. <block v-for="(item, index) in menu" :key="index">
  30. <view
  31. class="menu-item"
  32. @click="toPage(item)">
  33. <view class="menu-item_left">
  34. <image :src="item.icon"></image>
  35. <view class="menu-item_left-title">{{ item.title }}</view>
  36. </view>
  37. <view class="menu-item_right">
  38. <uv-icon name="arrow-right" size="16"></uv-icon>
  39. </view>
  40. </view>
  41. </block>
  42. </view>
  43. </view>
  44. </block>
  45. <tab-bar :index="4"/>
  46. </template>
  47. <script setup lang="ts">
  48. import {onLoad, onShow} from "@dcloudio/uni-app";
  49. import {ref} from "vue";
  50. import TabBar from "@/components/tab-bar";
  51. const containerStyle = ref({});
  52. const user = ref<any>({
  53. avatar: "",
  54. mobilePhoneFormat: '15012341234',
  55. balance: '2345.67',
  56. });
  57. const service = ref("15012341234");
  58. const menu = ref([
  59. {
  60. title: "个人信息",
  61. path: "/pages-user/profile/index",
  62. icon: '/static/user/profile.png'
  63. },
  64. {
  65. title: "我的卡包",
  66. path: "/pages/coupon/index",
  67. icon: '/static/user/coupon.png'
  68. },
  69. {
  70. title: "洗车订单",
  71. path: "/pages/order/index",
  72. icon: '/static/user/order.png'
  73. },
  74. {
  75. title: "我的收藏",
  76. path: "/pages-user/fav/index",
  77. icon: '/static/user/fav.png'
  78. },
  79. {
  80. title: "联系我们",
  81. path: "/pages-user/contact/index",
  82. icon: '/static/user/contact.png'
  83. },
  84. {
  85. title: "常见问题",
  86. path: "/pages-user/faq/index",
  87. icon: '/static/user/faq.png'
  88. },
  89. {
  90. title: "纠错上报",
  91. path: "/pages-user/feedback/index",
  92. icon: '/static/user/feedback.png'
  93. },
  94. ]);
  95. const toPage = (item: any) => {
  96. let {title, path} = item;
  97. if (path.includes('contact')) {
  98. uni.makePhoneCall({
  99. phoneNumber: service.value,
  100. fail: (error) => {
  101. console.log(error)
  102. }
  103. });
  104. return;
  105. }else if(path.includes("order")||path.includes("coupon")){
  106. uni.switchTab({
  107. url:path
  108. })
  109. }
  110. uni.navigateTo({
  111. url: item.path,
  112. });
  113. };
  114. onLoad(() => {
  115. uni.setNavigationBarTitle({title: '个人中心'})
  116. const bound = uni.getMenuButtonBoundingClientRect();
  117. containerStyle.value = {
  118. top: `${bound.bottom + 10}px`,
  119. };
  120. // fetchContact().then((res) => {
  121. // if (res && res.mobile) {
  122. // service.value = res.mobile;
  123. // }
  124. // });
  125. });
  126. onShow(() => {
  127. // fetchProfile().then((res) => {
  128. // res.mobilePhoneFormat =
  129. // res.mobilePhone.slice(0, 3) + "****" + res.mobilePhone.slice(7);
  130. // res.avatar = res.avatar
  131. // ? res.avatar
  132. // : "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0";
  133. // user.value = res;
  134. // });
  135. });
  136. </script>
  137. <style lang="scss" scope>
  138. .bg {
  139. position: absolute;
  140. left: 0;
  141. top: 0;
  142. width: 100%;
  143. height: 660rpx;
  144. }
  145. .container {
  146. position: absolute;
  147. left: 0;
  148. top: 0;
  149. height: 100vh;
  150. width: 100%;
  151. overflow-y: auto;
  152. }
  153. .header {
  154. //height: 400rpx;
  155. width: 100%;
  156. .main {
  157. height: 334rpx;
  158. background: rgba(254, 255, 255, 0.7);
  159. border-radius: 40rpx 40rpx 0 0;
  160. position: relative;
  161. text-align: center;
  162. .avatar {
  163. position: absolute;
  164. left: 50%;
  165. transform: translateX(-50%);
  166. top: -90rpx;
  167. width: 110rpx;
  168. height: 110rpx;
  169. border: 2rpx solid #ffffff;
  170. filter: drop-shadow(0px 4rpx 8rpx rgba(0, 24, 60, 0.1));
  171. background-size: cover;
  172. background-repeat: no-repeat;
  173. border-radius: 50%;
  174. }
  175. .phone {
  176. padding-top: 78rpx;
  177. color: #000;
  178. }
  179. .money {
  180. //position: absolute;
  181. //left: 0;
  182. //bottom: 0;
  183. width: 690rpx;
  184. height: 118rpx;
  185. background: #feffff;
  186. border-radius: 120rpx;
  187. margin: 0 auto;
  188. margin-top: 30rpx;
  189. color: #000000;
  190. padding: 0 24rpx 0 40rpx;
  191. display: flex;
  192. align-content: center;
  193. align-items: center;
  194. justify-content: space-between;
  195. }
  196. }
  197. }
  198. .body {
  199. width: 100%;
  200. background-color: #fff;
  201. //padding: 0rpx 30rpx;
  202. .menu-item {
  203. display: inline-flex;
  204. justify-content: space-between;
  205. background-color: #fff;
  206. height: 90rpx;
  207. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  208. align-items: center;
  209. width: 100%;
  210. &_left {
  211. display: flex;
  212. align-items: center;
  213. align-content: center;
  214. margin-left: 20rpx;
  215. image {
  216. width: 42rpx;
  217. height: 42rpx;
  218. margin-right: 20rpx;
  219. }
  220. &-title {
  221. font-size: 13px;
  222. }
  223. }
  224. &_right {
  225. text-align: right;
  226. width: 60rpx;
  227. }
  228. &:last-child {
  229. border-bottom: none;
  230. }
  231. }
  232. }
  233. </style>