my.vue 7.9 KB

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