index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view class="mine-container" :style="{ height: `${windowHeight}px` }">
  3. <!--顶部个人信息栏-->
  4. <view class="header-section">
  5. <view class="flex padding justify-between">
  6. <view class="flex align-center">
  7. <view v-if="!avatar" class="cu-avatar xl round bg-white">
  8. <view class="iconfont icon-people text-gray icon"></view>
  9. </view>
  10. <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"> </image>
  11. <view v-if="!data.name" @click="handleToLogin" class="login-tip"> 点击登录 </view>
  12. <view v-if="data.name" class="user-info">
  13. <view class="u_title"> {{ data.name }} </view>
  14. <view class="u_title"> {{ data.phone }} </view>
  15. </view>
  16. </view>
  17. <view class="flex align-center"> </view>
  18. </view>
  19. <view class="vip-card-box"> </view>
  20. </view>
  21. <view
  22. class="content-section"
  23. :style="[
  24. {
  25. transform: coverTransform,
  26. transition: coverTransition,
  27. },
  28. ]"
  29. @touchstart="coverTouchstart"
  30. @touchmove="coverTouchmove"
  31. @touchend="coverTouchend"
  32. >
  33. <image class="mine-image" src="@/static/images/mine/arc.png"></image>
  34. <!-- <view class="mine-actions grid col-4 text-center">
  35. <view class="action-item" @click="handleJiaoLiuQun">
  36. <view class="iconfont icon-friendfill text-pink icon"></view>
  37. <text class="text">客服QQ</text>
  38. </view>
  39. <view class="action-item" @click="handleBuilding">
  40. <view class="iconfont icon-service text-blue icon"></view>
  41. <text class="text">在线客服</text>
  42. </view>
  43. <view class="action-item" @click="handleBuilding">
  44. <view class="iconfont icon-community text-mauve icon"></view>
  45. <text class="text">反馈社区</text>
  46. </view>
  47. <view class="action-item" @click="handleBuilding">
  48. <view class="iconfont icon-dianzan text-green icon"></view>
  49. <text class="text">点赞我们</text>
  50. </view>
  51. </view> -->
  52. <view class="menu-list">
  53. <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
  54. <view class="menu-item-box">
  55. <view class="iconfont icon-user menu-icon"></view>
  56. <view>个人资料</view>
  57. </view>
  58. </view>
  59. <view class="list-cell list-cell-arrow" @click="handleToPwd">
  60. <view class="menu-item-box">
  61. <view class="iconfont icon-password menu-icon"></view>
  62. <view>修改密码</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="menu-list">
  67. <view class="list-cell list-cell-arrow" @click="handleAbout">
  68. <view class="menu-item-box">
  69. <view class="iconfont icon-aixin menu-icon"></view>
  70. <view>关于我们</view>
  71. </view>
  72. </view>
  73. <view class="list-cell list-cell-arrow" @click="handleHelp">
  74. <view class="menu-item-box">
  75. <view class="iconfont icon-help menu-icon"></view>
  76. <view>常见问题</view>
  77. </view>
  78. </view>
  79. <view class="list-cell list-cell-arrow" @click="handleCleanTmp">
  80. <view class="menu-item-box">
  81. <view class="iconfont icon-clean menu-icon"></view>
  82. <view>清理缓存</view>
  83. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ settings.$state.currentSize }}</view>
  84. </view>
  85. </view>
  86. <view class="list-cell list-cell-arrow" @click="handleToUpgrade">
  87. <view class="menu-item-box">
  88. <view class="iconfont icon-refresh menu-icon"></view>
  89. <view>检查更新</view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="cu-list menu">
  94. <view class="cu-item item-box">
  95. <view class="content text-center" @click="handleLogout">
  96. <text class="text-black">退出登录</text>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script setup>
  104. import config from "@/config";
  105. import storage from "@/utils/storage";
  106. import { onLoad, onShow, onHide, onLaunch, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  107. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  108. import useStores from "@/store/modules/user.js";
  109. import settingStore from "@/store/modules/setting.js";
  110. const useStore = useStores();
  111. const settings = settingStore();
  112. const { proxy } = getCurrentInstance();
  113. const avatar = computed(() => {
  114. return useStore.$state.avatar;
  115. });
  116. const windowHeight = computed(() => {
  117. return uni.getSystemInfoSync().windowHeight - 50;
  118. });
  119. const data = reactive({
  120. name: useStore.$state.name,
  121. phone: useStore.$state.phonenumber,
  122. version: getApp().globalData.config.appInfo.version,
  123. coverTransform: "translateY(0px)",
  124. coverTransition: "0s",
  125. moving: false,
  126. });
  127. const { coverTransform, coverTransition, moving } = toRefs(data);
  128. /**
  129. * @点击登录
  130. */
  131. function handleToLogin() {
  132. proxy.$tab.reLaunch("/pages/login");
  133. }
  134. /**
  135. * @点击头像
  136. */
  137. function handleToAvatar() {
  138. proxy.$tab.navigateTo("/pages/mine/avatar/index");
  139. }
  140. /**
  141. * @退出登录
  142. */
  143. function handleLogout() {
  144. proxy.$modal.confirm("确定注销并退出系统吗?").then(() => {
  145. useStore.LogOut().then(() => {
  146. proxy.$tab.reLaunch("/pages/index");
  147. });
  148. });
  149. }
  150. /**
  151. * @常见问题
  152. */
  153. function handleHelp() {
  154. proxy.$tab.navigateTo("/pages/mine/help/index");
  155. }
  156. /**
  157. * @个人资料
  158. */
  159. function handleToEditInfo() {
  160. proxy.$tab.navigateTo("/pages/mine/info/index");
  161. }
  162. /**
  163. * @修改密码
  164. */
  165. function handleToPwd() {
  166. proxy.$tab.navigateTo("/pages/mine/pwd/index");
  167. }
  168. /**
  169. * @检查更新
  170. */
  171. function handleToUpgrade() {
  172. proxy.$modal.showToast("模块建设中~");
  173. }
  174. /**
  175. * @关于我们
  176. */
  177. function handleAbout() {
  178. proxy.$tab.navigateTo("/pages/mine/about/index");
  179. }
  180. /**
  181. * @清理缓存
  182. */
  183. function handleCleanTmp() {
  184. // #ifdef H5
  185. proxy.$modal.showToast("H5暂不支持此功能");
  186. // #endif
  187. // #ifdef APP-PLUS
  188. proxy.$setting.clearCache();
  189. // #endif
  190. }
  191. let startY = 0,
  192. moveY = 0,
  193. pageAtTop = true;
  194. function coverTouchstart(e) {
  195. if (pageAtTop === false) {
  196. return;
  197. }
  198. coverTransition.value = "transform .1s linear";
  199. startY = e.touches[0].clientY;
  200. }
  201. function coverTouchmove(e) {
  202. moveY = e.touches[0].clientY;
  203. let moveDistance = moveY - startY;
  204. if (moveDistance < 0) {
  205. moving.value = false;
  206. return;
  207. }
  208. moving.value = true;
  209. if (moveDistance >= 80 && moveDistance < 100) {
  210. moveDistance = 80;
  211. }
  212. if (moveDistance > 0 && moveDistance <= 80) {
  213. coverTransform.value = `translateY(${moveDistance}px)`;
  214. }
  215. }
  216. function coverTouchend() {
  217. if (moving.value === false) {
  218. return;
  219. }
  220. moving.value = false;
  221. coverTransition.value = "transform 0.3s cubic-bezier(.21,1.93,.53,.64)";
  222. coverTransform.value = "translateY(0px)";
  223. }
  224. onLoad((options) => {});
  225. // 自定义导航事件
  226. onNavigationBarButtonTap((e) => {
  227. console.log(e);
  228. if (e.float == "right") {
  229. proxy.$tab.navigateTo("/pages/mine/setting/index");
  230. }
  231. });
  232. </script>
  233. <style lang="scss">
  234. .mine-container {
  235. width: 100%;
  236. height: 100%;
  237. .header-section {
  238. padding: 55px 15px 0 15px;
  239. background-color: #149eff;
  240. color: white;
  241. .login-tip {
  242. font-size: 18px;
  243. margin-left: 10px;
  244. }
  245. .cu-avatar {
  246. border: 2px solid #eaeaea;
  247. .icon {
  248. font-size: 40px;
  249. }
  250. }
  251. .user-info {
  252. margin-left: 15px;
  253. .u_title {
  254. font-size: 18px;
  255. line-height: 30px;
  256. }
  257. }
  258. .vip-card-box {
  259. display: flex;
  260. flex-direction: column;
  261. color: #f7d680;
  262. height: 132px;
  263. background: url("@/static/images/mine/vip-card.png");
  264. background-size: 100% 100%;
  265. border-radius: 8px 8px 0 0;
  266. overflow: hidden;
  267. position: relative;
  268. padding: 11px 13px;
  269. }
  270. }
  271. .content-section {
  272. position: relative;
  273. margin-top: -85px;
  274. background-color: #f8f8f8;
  275. .mine-image {
  276. position: absolute;
  277. left: 0;
  278. top: -16px;
  279. width: 100%;
  280. height: 36upx;
  281. }
  282. .mine-actions {
  283. margin: 0.625rem 0.625rem;
  284. padding: 20px 0px;
  285. border-radius: 8px;
  286. background-color: white;
  287. .action-item {
  288. .icon {
  289. font-size: 28px;
  290. }
  291. .text {
  292. display: block;
  293. font-size: 13px;
  294. margin: 8px 0px;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>
  301. <style lang="scss" scoped>
  302. .item-box {
  303. background-color: #ffffff;
  304. margin: 30rpx;
  305. display: flex;
  306. flex-direction: row;
  307. justify-content: center;
  308. align-items: center;
  309. padding: 10rpx;
  310. border-radius: 8rpx;
  311. color: #303133;
  312. font-size: 32rpx;
  313. }
  314. </style>