index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="mine-container">
  3. <!--顶部个人信息栏-->
  4. <view class="header-section" :class="'bg-' + proxy.$settingStore.themeColor.name" :style="{ paddingTop: proxy.$settingStore.StatusBar ? proxy.$settingStore.StatusBar + 44 + 'px' : '55px' }">
  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" @click="handleToAvatar(1)">
  8. <view class="iconfont icon-people text-gray icon"></view>
  9. </view>
  10. <image v-if="avatar" @click="handleToAvatar(2)" :src="avatar" class="cu-avatar xl round"> </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="menu-list">
  35. <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
  36. <view class="menu-item-box">
  37. <view class="iconfont icon-user menu-icon"></view>
  38. <view>个人资料</view>
  39. </view>
  40. </view>
  41. <view class="list-cell list-cell-arrow" @click="handleToPwd">
  42. <view class="menu-item-box">
  43. <view class="iconfont icon-password menu-icon"></view>
  44. <view>修改密码</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="menu-list">
  49. <view class="list-cell list-cell-arrow" @click="handleAbout">
  50. <view class="menu-item-box">
  51. <view class="iconfont icon-aixin menu-icon"></view>
  52. <view>关于我们</view>
  53. </view>
  54. </view>
  55. <view class="list-cell list-cell-arrow" @click="handleHelp">
  56. <view class="menu-item-box">
  57. <view class="iconfont icon-help menu-icon"></view>
  58. <view>常见问题</view>
  59. </view>
  60. </view>
  61. <view class="list-cell list-cell-arrow" @click="handleCleanTmp">
  62. <view class="menu-item-box">
  63. <view class="iconfont icon-clean menu-icon"></view>
  64. <view>清理缓存</view>
  65. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ proxy.$settingStore.currentSize }}</view>
  66. </view>
  67. </view>
  68. <view class="list-cell list-cell-arrow" @click="handleToUpgrade">
  69. <view class="menu-item-box">
  70. <view class="iconfont icon-refresh menu-icon"></view>
  71. <view>检查更新</view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="menu-list">
  76. <!-- <view class="list-cell list-cell-arrow" @click="goMessagePush()">
  77. <view class="menu-item-box">
  78. <view class="iconfont icon-aixin menu-icon"></view>
  79. <view>推送设置</view>
  80. </view>
  81. </view>
  82. <view class="list-cell list-cell-arrow" @click="goBuilding()">
  83. <view class="menu-item-box">
  84. <view class="iconfont icon-help menu-icon"></view>
  85. <view>建筑管理</view>
  86. </view>
  87. </view>
  88. <view class="list-cell list-cell-arrow" @click="goFunReport()">
  89. <view class="menu-item-box">
  90. <view class="iconfont icon-clean menu-icon"></view>
  91. <view>功能报备</view>
  92. </view>
  93. </view> -->
  94. </view>
  95. <view class="cu-list menu">
  96. <view class="cu-item" style="margin-top: 0; margin-bottom: 0">
  97. <view class="content flex align-center">
  98. <text class="iconfont ucicon-colorlens" :class="'text-' + proxy.$settingStore.themeColor.name"></text>
  99. <view class="padding solid radius shadow-blur" :class="'bg-' + proxy.$settingStore.themeColor.name" style="margin-left: 10px"></view>
  100. <view class="title" style="margin-left: 10px">
  101. 主题色:<text :class="'text-' + proxy.$settingStore.themeColor.name">{{ proxy.$settingStore.themeColor.title }}</text>
  102. </view>
  103. </view>
  104. <view class="action">
  105. <button class="cu-btn round shadow" @click="colorModal = true" :class="'bg-' + proxy.$settingStore.themeColor.name">
  106. <text class="iconfont ucicon-colorlens"></text>
  107. 选择主题
  108. </button>
  109. </view>
  110. </view>
  111. </view>
  112. <view class="cu-list menu">
  113. <view class="cu-item">
  114. <view class="content text-center" @click="handleLogout">
  115. <text class="text-black">退出登录</text>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="cu-list menu-avatar padding-lr-sm padding-top-sm">
  121. <!-- <view class="cu-item" @tap="goSiteManage" v-if="permissionLabel == 1">
  122. <view class="cu-avatar" style="background-image: url(@/static/images/setting/setting-icon2.png)"></view>
  123. <view class="content">
  124. <view class="">站点管理</view>
  125. </view>
  126. <view class="nav-right">
  127. <view class="text-grey">
  128. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  129. </view>
  130. </view>
  131. </view>
  132. <view class="cu-item" @tap="goAuthManage" v-if="permissionLabel == 1">
  133. <view class="cu-avatar" style="background-image: url(@/static/images/setting/setting-icon4.png)"></view>
  134. <view class="content">
  135. <view class="">权限管理</view>
  136. </view>
  137. <view class="nav-right">
  138. <view class="text-grey">
  139. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  140. </view>
  141. </view>
  142. </view> -->
  143. </view>
  144. <!-- 选择颜色模态框 -->
  145. <view class="cu-modal" :class="{ show: colorModal }">
  146. <view class="cu-dialog">
  147. <view class="cu-bar justify-end solid-bottom">
  148. <view class="content">选择颜色</view>
  149. <view class="action" @tap="colorModal = false">
  150. <u-icon name="close" size="14"></u-icon>
  151. <text class="cuIcon-close text-red"></text>
  152. </view>
  153. </view>
  154. <view class="grid col-5 padding">
  155. <view class="padding-xs" v-for="(item, index) in themeList" :key="index" @tap="SetColor(item)" :data-color="item.name">
  156. <view class="padding-tb radius" :class="'bg-' + item.name">
  157. {{ item.title }}
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. </view>
  164. </template>
  165. <script setup>
  166. import config from "@/config";
  167. import storage from "@/utils/storage";
  168. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  169. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  170. import { uploadAvatar, updateUserProfile } from "@/api/system/user";
  171. import { getAuthorization } from "@/api/setting/index.js";
  172. import useStores from "@/store/modules/user.js";
  173. const useStore = useStores();
  174. const { proxy } = getCurrentInstance();
  175. const avatar = computed(() => {
  176. return useStore.$state.avatar;
  177. });
  178. const windowHeight = computed(() => {
  179. return uni.getSystemInfoSync().windowHeight - 50;
  180. });
  181. const data = reactive({
  182. name: useStore.$state.name,
  183. phone: useStore.$state.phonenumber,
  184. version: getApp().globalData.config.appInfo.version,
  185. coverTransform: "translateY(0px)",
  186. coverTransition: "0s",
  187. moving: false,
  188. colorModal: false,
  189. themeList: proxy.$constData.themeList,
  190. });
  191. const { coverTransform, coverTransition, moving, colorModal, themeList } = toRefs(data);
  192. const permissionLabel = ref(0);
  193. function getAuthorizationApi(params) {
  194. getAuthorization(params).then((res) => {
  195. permissionLabel.value = res.data.permissionLabel;
  196. });
  197. }
  198. function goMessagePush() {
  199. uni.navigateTo({
  200. url: "/pages/setting/messagePush/messagePush",
  201. success: (res) => {},
  202. fail: () => {},
  203. complete: () => {},
  204. });
  205. }
  206. function goBuilding() {
  207. uni.navigateTo({
  208. url: "/pages/setting/building/building",
  209. success: (res) => {},
  210. fail: () => {},
  211. complete: () => {},
  212. });
  213. }
  214. function goFunReport() {
  215. uni.navigateTo({
  216. url: "/pages/setting/funReport/funReport",
  217. success: (res) => {},
  218. fail: () => {},
  219. complete: () => {},
  220. });
  221. }
  222. /**
  223. * @主题颜色选择
  224. */
  225. function SetColor(item) {
  226. colorModal.value = false;
  227. proxy.$settingStore.SET_THEMECOLOR(item);
  228. proxy.$settingStore.systemThemeColor([1, 2]);
  229. }
  230. /**
  231. * @点击登录
  232. */
  233. function handleToLogin() {
  234. proxy.$tab.reLaunch("/pages/login");
  235. }
  236. /**
  237. * @upload上传头像
  238. * @api接口请求
  239. */
  240. function uploadApi(res) {
  241. let data = { name: "file", filePath: res.tempFilePaths[0] };
  242. uploadAvatar(data).then((response) => {
  243. useStore.$state.avatar = response.data.url;
  244. updateUserProfile({
  245. avatar: response.data.url,
  246. }).then(() => {});
  247. });
  248. }
  249. /**
  250. * @点击头像
  251. */
  252. function handleToAvatar(type) {
  253. if (type == 1) {
  254. uni.chooseImage({
  255. count: 1, //默认9
  256. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  257. sourceType: ["album", "camera"], //从相册选择、摄像头
  258. success: function (res) {
  259. uploadApi(res);
  260. },
  261. });
  262. } else if (type == 2) {
  263. proxy.$tab.navigateTo("/pages/mine/avatar/index");
  264. }
  265. }
  266. /**
  267. * @退出登录
  268. */
  269. function handleLogout() {
  270. proxy.$modal.confirm("确定注销并退出系统吗?").then(() => {
  271. useStore.LogOut().then(() => {
  272. proxy.$tab.reLaunch("/pages/index");
  273. });
  274. });
  275. }
  276. /**
  277. * @常见问题
  278. */
  279. function handleHelp() {
  280. proxy.$tab.navigateTo("/pages/mine/help/index");
  281. }
  282. /**
  283. * @个人资料
  284. */
  285. function handleToEditInfo() {
  286. proxy.$tab.navigateTo("/pages/mine/info/index");
  287. }
  288. /**
  289. * @修改密码
  290. */
  291. function handleToPwd() {
  292. proxy.$tab.navigateTo("/pages/mine/pwd/index");
  293. }
  294. /**
  295. * @检查更新
  296. */
  297. function handleToUpgrade() {
  298. proxy.$modal.showToast("模块建设中~");
  299. }
  300. /**
  301. * @关于我们
  302. */
  303. function handleAbout() {
  304. proxy.$tab.navigateTo("/pages/mine/about/index");
  305. }
  306. /**
  307. * @清理缓存
  308. */
  309. function handleCleanTmp() {
  310. // #ifdef H5
  311. proxy.$modal.showToast("H5暂不支持此功能");
  312. // #endif
  313. // #ifdef APP-PLUS
  314. proxy.$setting.clearCache();
  315. // #endif
  316. }
  317. let startY = 0,
  318. moveY = 0,
  319. pageAtTop = true;
  320. /**
  321. * @触摸开始
  322. */
  323. function coverTouchstart(e) {
  324. if (pageAtTop === false) {
  325. return;
  326. }
  327. coverTransition.value = "transform .1s linear";
  328. startY = e.touches[0].clientY;
  329. }
  330. /**
  331. * @触摸移动
  332. */
  333. function coverTouchmove(e) {
  334. moveY = e.touches[0].clientY;
  335. let moveDistance = moveY - startY;
  336. if (moveDistance < 0) {
  337. moving.value = false;
  338. return;
  339. }
  340. moving.value = true;
  341. if (moveDistance >= 80 && moveDistance < 100) {
  342. moveDistance = 80;
  343. }
  344. if (moveDistance > 0 && moveDistance <= 80) {
  345. coverTransform.value = `translateY(${moveDistance}px)`;
  346. }
  347. }
  348. /**
  349. * @触摸结束
  350. */
  351. function coverTouchend() {
  352. if (moving.value === false) {
  353. return;
  354. }
  355. moving.value = false;
  356. coverTransition.value = "transform 0.3s cubic-bezier(.21,1.93,.53,.64)";
  357. coverTransform.value = "translateY(0px)";
  358. }
  359. onShow(() => {});
  360. onReady(() => {
  361. //调用系统主题颜色
  362. proxy.$settingStore.systemThemeColor([1, 2]);
  363. });
  364. onLoad((options) => {});
  365. // 自定义导航事件
  366. onNavigationBarButtonTap((e) => {
  367. if (e.float == "right") {
  368. proxy.$tab.navigateTo("/pages/mine/setting/index");
  369. }
  370. });
  371. </script>
  372. <style lang="scss" scoped>
  373. .mine-container {
  374. width: 100%;
  375. height: 100vh;
  376. background-color: #f8f8f8;
  377. .header-section {
  378. padding: 55px 15px 0 15px;
  379. color: white;
  380. .login-tip {
  381. font-size: 18px;
  382. margin-left: 10px;
  383. }
  384. .cu-avatar {
  385. border: 2px solid #eaeaea;
  386. .icon {
  387. font-size: 40px;
  388. }
  389. }
  390. .user-info {
  391. margin-left: 15px;
  392. .u_title {
  393. font-size: 18px;
  394. line-height: 30px;
  395. }
  396. }
  397. .vip-card-box {
  398. display: flex;
  399. flex-direction: column;
  400. color: #f7d680;
  401. height: 132px;
  402. background: url("@/static/images/mine/vip-card.png");
  403. background-size: 100% 100%;
  404. border-radius: 8px 8px 0 0;
  405. overflow: hidden;
  406. position: relative;
  407. padding: 11px 13px;
  408. }
  409. }
  410. .content-section {
  411. position: relative;
  412. margin-top: -85px;
  413. // #ifdef H5
  414. padding-bottom: 50px;
  415. // #endif
  416. background-color: #f8f8f8;
  417. .mine-image {
  418. position: absolute;
  419. left: 0;
  420. top: -16px;
  421. width: 100%;
  422. height: 36upx;
  423. }
  424. .mine-actions {
  425. margin: 0.625rem 0.625rem;
  426. padding: 20px 0px;
  427. border-radius: 8px;
  428. background-color: white;
  429. .action-item {
  430. .icon {
  431. font-size: 28px;
  432. }
  433. .text {
  434. display: block;
  435. font-size: 13px;
  436. margin: 8px 0px;
  437. }
  438. }
  439. }
  440. }
  441. .cu-list.menu-avatar .cu-item {
  442. border-radius: 5px;
  443. padding: 30rpx 0;
  444. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  445. .cu-avatar {
  446. background-color: rgba(0, 0, 0, 0);
  447. background-size: 100% 100%;
  448. left: 26rpx;
  449. }
  450. .content {
  451. left: 130rpx;
  452. font-size: 32rpx;
  453. }
  454. }
  455. }
  456. .item-box {
  457. background-color: #ffffff;
  458. margin: 30rpx;
  459. display: flex;
  460. flex-direction: row;
  461. justify-content: center;
  462. align-items: center;
  463. padding: 10rpx;
  464. border-radius: 8rpx;
  465. color: #303133;
  466. font-size: 32rpx;
  467. }
  468. </style>