my.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="page-container">
  3. <view class="profile-header">
  4. <view class="avatar-wrapper">
  5. <image class="avatar" :src="userInfo.avatarUrl" mode="aspectFill"></image>
  6. <view class="badge">{{ userInfo.role }}</view>
  7. </view>
  8. <view class="phone-number">{{ userInfo.phone }}</view>
  9. </view>
  10. <view class="content-card">
  11. <view class="list-item" @click="navigateToAction('points')">
  12. <view class="item-left">
  13. <image class="item-icon" :src="imgurl+'/cjx/hexiao/my_jifen.png'" mode="aspectFit"></image>
  14. <text class="item-label">我的积分</text>
  15. </view>
  16. <view class="item-right">
  17. <text class="item-value">{{ formatNumber(userInfo.points) }}</text>
  18. <!-- <uni-icons type="right" size="16" color="#c0c0c0"></uni-icons>-->
  19. </view>
  20. </view>
  21. <view class="list-item" @click="navigateToAction('shops')">
  22. <view class="item-left">
  23. <image class="item-icon" :src="imgurl+'/cjx/hexiao/my_mendian.png'" mode="aspectFit"></image>
  24. <text class="item-label">我的店铺</text>
  25. </view>
  26. <view class="item-right">
  27. <text class="item-value">{{ userInfo.shopCount }}</text>
  28. <!-- <uni-icons type="right" size="16" color="#c0c0c0"></uni-icons>-->
  29. </view>
  30. </view>
  31. <!-- <view class="list-item">-->
  32. <!-- <view class="item-left">-->
  33. <!-- <uni-icons type="arrow-up-circle" size="22" color="#666"></uni-icons>-->
  34. <!-- <text class="item-label">当前版本</text>-->
  35. <!-- </view>-->
  36. <!-- <view class="item-right">-->
  37. <!-- <text class="item-value">{{ appVersion }}</text>-->
  38. <!-- </view>-->
  39. <!-- </view>-->
  40. <!-- <view class="list-item" @click="callSupport">-->
  41. <!-- <view class="item-left">-->
  42. <!-- <uni-icons type="phone-filled" size="22" color="#666"></uni-icons>-->
  43. <!-- <text class="item-label">客服电话</text>-->
  44. <!-- </view>-->
  45. <!-- <view class="item-right">-->
  46. <!-- <text class="item-value primary-color">{{ supportPhone }}</text>-->
  47. <!-- </view>-->
  48. <!-- </view>-->
  49. </view>
  50. <view class="footer">
  51. <button class="logout-button" @click="logout">退出登录</button>
  52. </view>
  53. <CustomTabbar :current="2"/>
  54. </view>
  55. </template>
  56. <script>
  57. import CustomTabbar from '@/components/cjx/tabbar_hexiao_ywy.vue';
  58. import {clearAdminToken, getAdminInfo} from "../../../../utils/auth";
  59. import {getAdminUserInfo} from "../../../../api/hexiao";
  60. export default {
  61. components: {
  62. CustomTabbar
  63. },
  64. data() {
  65. return {
  66. imgurl:"https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu",
  67. // 用户信息 - 通常从登录后的storage或API获取
  68. userInfo: {
  69. avatarUrl: 'https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/user-info.png', // 默认头像
  70. phone: '',
  71. role: '',
  72. points: 0,
  73. shopCount: 0
  74. },
  75. appVersion: '1.0',
  76. supportPhone: '40012547856'
  77. };
  78. },
  79. onLoad(){
  80. let info = getAdminInfo();
  81. this.userInfo.phone = info.phone;
  82. this.userInfo.role = info.roleName;
  83. },
  84. onShow(){
  85. getAdminUserInfo().then(res=>{
  86. this.userInfo.shopCount = res.data.storeCount;
  87. this.userInfo.points = res.data.pointTotal;
  88. })
  89. },
  90. methods: {
  91. // 格式化数字,添加逗号
  92. formatNumber(num) {
  93. if (num === undefined || num === null) return '';
  94. return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  95. },
  96. // 列表项点击事件
  97. navigateToAction(action) {
  98. switch(action) {
  99. case 'points':
  100. console.log('跳转到我的积分页面');
  101. uni.navigateTo({ url: '/pages/points/points' }); // 请替换为您的积分页面路径
  102. break;
  103. case 'shops':
  104. console.log('跳转到我的店铺页面');
  105. uni.navigateTo({ url: '/pages/shops/shops' }); // 请替换为您的店铺页面路径
  106. break;
  107. }
  108. },
  109. // 拨打客服电话
  110. callSupport() {
  111. uni.makePhoneCall({
  112. phoneNumber: this.supportPhone,
  113. success: () => {
  114. console.log('拨打电话成功');
  115. },
  116. fail: (err) => {
  117. console.log('拨打电话失败', err);
  118. uni.showModal({
  119. title: '拨号失败',
  120. content: `无法拨打电话,请手动拨打客服热线:${this.supportPhone}`,
  121. showCancel: false
  122. })
  123. }
  124. });
  125. },
  126. // 退出登录
  127. logout() {
  128. uni.showModal({
  129. title: '提示',
  130. content: '您确定要退出登录吗?',
  131. success: (res) => {
  132. if (res.confirm) {
  133. console.log('用户点击确定,执行退出登录操作');
  134. clearAdminToken();
  135. // 跳转到登录页
  136. uni.reLaunch({
  137. url: '/pages/cjx/hexiao/login' // 请替换为您的登录页路径
  138. });
  139. }
  140. }
  141. });
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. // 页面整体背景
  148. .page-container {
  149. background-color: #f5f6fa;
  150. min-height: 100vh;
  151. position: relative;
  152. box-sizing: border-box; /* 确保 padding 不会增加总高度 */
  153. /* --- 关键改动 2 --- */
  154. /* 增加底部内边距,为“退出登录”按钮和自定义tabBar都留出空间 */
  155. &.with-padding-bottom {
  156. padding-bottom: 280rpx;
  157. }
  158. }
  159. // 顶部用户信息区
  160. .profile-header {
  161. background: linear-gradient(135deg, #6ca1ff, #87d7dc);
  162. height: 400rpx;
  163. display: flex;
  164. flex-direction: column;
  165. align-items: center;
  166. justify-content: center;
  167. padding-bottom: 80rpx; // 为下方卡片留出重叠空间
  168. }
  169. .avatar-wrapper {
  170. position: relative;
  171. .avatar {
  172. width: 150rpx;
  173. height: 150rpx;
  174. border-radius: 50%;
  175. border: 4rpx solid rgba(255, 255, 255, 0.5);
  176. }
  177. .badge {
  178. position: absolute;
  179. bottom: 0;
  180. right: -10rpx;
  181. background-color: #ff9900;
  182. color: #ffffff;
  183. font-size: 22rpx;
  184. padding: 4rpx 12rpx;
  185. border-radius: 20rpx;
  186. border: 2rpx solid #ffffff;
  187. }
  188. }
  189. .phone-number {
  190. color: #ffffff;
  191. font-size: 36rpx;
  192. font-weight: bold;
  193. margin-top: 20rpx;
  194. letter-spacing: 1rpx;
  195. }
  196. .item-icon {
  197. width: 44rpx;
  198. height: 44rpx;
  199. margin-right: 15rpx; /* 图标和文字的间距 */
  200. }
  201. // 内容卡片
  202. .content-card {
  203. background-color: #ffffff;
  204. margin: -80rpx 30rpx 0 30rpx; // 负margin实现向上重叠效果
  205. border-radius: 20rpx;
  206. padding: 20rpx 30rpx;
  207. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  208. position: relative; // 确保在header之上
  209. z-index: 10;
  210. }
  211. .list-item {
  212. display: flex;
  213. justify-content: space-between;
  214. align-items: center;
  215. padding: 35rpx 0;
  216. border-bottom: 1rpx solid #f5f5f5;
  217. &:last-child {
  218. border-bottom: none;
  219. }
  220. .item-left {
  221. display: flex;
  222. align-items: center;
  223. .item-label {
  224. margin-left: 25rpx;
  225. font-size: 30rpx;
  226. color: #333;
  227. }
  228. }
  229. .item-right {
  230. display: flex;
  231. align-items: center;
  232. .item-value {
  233. font-size: 28rpx;
  234. color: #999;
  235. margin-right: 10rpx;
  236. }
  237. .primary-color {
  238. color: #6ca1ff; // 客服电话用主题色突出
  239. font-weight: 500;
  240. }
  241. }
  242. }
  243. // 底部
  244. .footer {
  245. position: fixed;
  246. /* bottom值 = 自定义tabBar的高度(100rpx) + iPhone等机型的底部安全区 */
  247. bottom: calc(100rpx + constant(safe-area-inset-bottom));
  248. bottom: calc(100rpx + env(safe-area-inset-bottom));
  249. left: 0;
  250. width: 100%;
  251. padding: 30rpx;
  252. box-sizing: border-box;
  253. background-color: #f5f6fa; // 设置背景色防止透明
  254. z-index: 90; // 比 tabBar 低,比页面内容高
  255. }
  256. .logout-button {
  257. background-color: #ffffff;
  258. color: #555555;
  259. border-radius: 50rpx;
  260. font-weight: normal;
  261. font-size: 32rpx;
  262. border: 1rpx solid #e0e0e0;
  263. &::after {
  264. border: none;
  265. }
  266. }
  267. </style>