mine.vue 13 KB

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