my.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="my__main">
  3. <!-- 账号 -->
  4. <view class="my__main-top">
  5. <view class="top-content">
  6. <button class="top-left" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  7. <image class="img" :src="avatarUrl" mode="aspectFit"></image>
  8. </button>
  9. <view class="top-right">
  10. {{companyName}}
  11. </view>
  12. </view>
  13. </view>
  14. <!-- 功能部分 -->
  15. <view class="my__main-content">
  16. <view class="content-title">我的功能</view>
  17. <view class="content-cell">
  18. <u-cell-group :border="false">
  19. <u-cell class="content-cell-1" title="我的订单" isLink url="/pages/my/myOrder/myOrder">
  20. <u-icon slot="icon" size="18" name="list-dot"></u-icon>
  21. </u-cell>
  22. <u-cell class="content-cell-1" title="公司信息" isLink url="/pages/login/login">
  23. <u-icon slot="icon" size="18" name="man-add"></u-icon>
  24. </u-cell>
  25. <!-- <u-cell class="content-cell-1" isLink url="/pages/login/login">
  26. <view slot="title" class="u-slot-title">
  27. <view class="img">
  28. <image src="../../static/gongsimc.png" mode=""></image>
  29. </view>
  30. <view class="u-cell-text">公司信息</view>
  31. </view>
  32. </u-cell> -->
  33. <u-cell class="content-cell-1" :border="false" title="退出登录" @click="loginOut" isLink>
  34. <u-icon slot="icon" size="18" name="share-square"></u-icon>
  35. </u-cell>
  36. </u-cell-group>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. getUserInfo,
  44. } from '@/api/login.js'
  45. export default {
  46. data() {
  47. return {
  48. avatarUrl: "../../static/avatar.png",
  49. companyName: '',
  50. };
  51. },
  52. methods: {
  53. // 头像账号
  54. onChooseAvatar(e) {
  55. // console.log(e)
  56. this.avatarUrl = e.detail.avatarUrl
  57. uni.setStorageSync('avatarUrl', this.avatarUrl); // 将头像 URL 存储到本地缓存中
  58. },
  59. loginOut() {
  60. uni.showModal({
  61. title: '提示',
  62. content: '确定退出吗?',
  63. success: res => {
  64. if (res.confirm) {
  65. uni.showToast({
  66. title: '操作成功',
  67. icon: 'none',
  68. duration: 800,
  69. mask: true,
  70. success: () => {
  71. setTimeout(() => {
  72. // uni.removeStorageSync(
  73. // 'avatarUrl'); // 移除本地缓存中的头像 URL
  74. uni.removeStorageSync('openId'); // 移除本地缓存中的openid
  75. uni.removeStorageSync('userInfo'); // 移除本地缓存中的公司信息
  76. uni.removeStorageSync('token')
  77. // uni.reLaunch({
  78. // url: '/pages/login/index',
  79. // })
  80. uni.navigateTo({
  81. url: '/pages/login/index',
  82. })
  83. }, 800)
  84. }
  85. })
  86. }
  87. }
  88. })
  89. }
  90. },
  91. onShow() {
  92. const avatarUrl = uni.getStorageSync('avatarUrl');
  93. if (avatarUrl) {
  94. this.avatarUrl = avatarUrl;
  95. }
  96. getUserInfo().then(res => {
  97. this.companyName = res.data.companyName
  98. }).catch(err => {});
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .my__main {
  104. position: relative;
  105. width: 100%;
  106. height: 100%;
  107. background-color: #fff;
  108. // 顶部头像
  109. .my__main-top {
  110. height: 209px;
  111. // height: 132.4px;
  112. padding-top: 92px;
  113. // padding-top: 15.4px;
  114. background: linear-gradient(72deg, #2F74FF 28.55%, #4299FF 100.56%);
  115. .top-content {
  116. display: flex;
  117. width: 100%;
  118. height: 70px;
  119. .top-left {
  120. width: 70px;
  121. height: 70px;
  122. margin: 0px 17px 47px 20px;
  123. padding: 0 !important;
  124. border-radius: 50%;
  125. overflow: hidden;
  126. background: lightgray 50% / cover no-repeat;
  127. .img {
  128. width: 100%;
  129. height: 100%;
  130. // object-fit: contain;
  131. }
  132. }
  133. .top-right {
  134. color: #FFF;
  135. font-size: 20px;
  136. font-weight: 500;
  137. line-height: 70px;
  138. }
  139. }
  140. }
  141. // 功能列表
  142. .my__main-content {
  143. position: absolute;
  144. // top: 96.4px;
  145. top: 173px;
  146. width: 100%;
  147. border-radius: 22px;
  148. background-color: #fff;
  149. .content-title {
  150. color: #333;
  151. font-size: 18px;
  152. font-weight: 500;
  153. margin-left: 13px;
  154. margin-top: 16px;
  155. }
  156. .content-cell {
  157. padding: 0 16px;
  158. .content-cell-1 {
  159. height: 56px;
  160. }
  161. }
  162. }
  163. }
  164. .u-slot-title {
  165. display: flex;
  166. .img {
  167. width: 19.8px;
  168. height: 18px;
  169. margin-right: 9.2px;
  170. image {
  171. width: 100%;
  172. height: 100%;
  173. object-fit: contain;
  174. }
  175. }
  176. }
  177. ::v-deep .u-cell__body {
  178. padding: 16px 0px !important;
  179. }
  180. ::v-deep .u-icon__icon {
  181. margin-right: 9.2px;
  182. }
  183. </style>