index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view :data-theme="'theme-' + proxy.$settingStore.themeColor.name" class="info-container">
  3. <u-sticky class="shadow-default" bgColor="#fff">
  4. <u-tabs :list="tabsList" :current="tabsCurrent" @click="tabsClick" lineColor="#333" :activeStyle="{ color: '#333' }" :inactiveStyle="{ color: '#909399' }" :scrollable="false"></u-tabs>
  5. </u-sticky>
  6. <view class="content-section" v-show="tabsCurrent == 0">
  7. <view class="menu-list margin-t-0 margin-lr-0">
  8. <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToAvatar(2)">
  9. <view class="menu-item-box">
  10. <view class="title">头像</view>
  11. <image style="margin: 0 15px 0 auto" v-if="avatar" :src="avatar" class="cu-avatar radius"> </image>
  12. </view>
  13. </view>
  14. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改昵称')">
  15. <view class="menu-item-box">
  16. <view class="title">昵称</view>
  17. <view class="content" style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.nickName }}</view>
  18. </view>
  19. </view>
  20. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改手机号')">
  21. <view class="menu-item-box">
  22. <view class="title">手机号码</view>
  23. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.phonenumber }}</view>
  24. </view>
  25. </view>
  26. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改邮箱')">
  27. <view class="menu-item-box">
  28. <view class="title">邮箱</view>
  29. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.email }}</view>
  30. </view>
  31. </view>
  32. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改性别')">
  33. <view class="menu-item-box">
  34. <view class="title">性别</view>
  35. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.sex == "0" ? "男" : "女" }}</view>
  36. </view>
  37. </view>
  38. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  39. <view class="menu-item-box">
  40. <view class="title">我的名片</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="menu-list margin-t-0 margin-lr-0">
  45. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  46. <view class="menu-item-box">
  47. <view>个人实名认证</view>
  48. </view>
  49. </view>
  50. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  51. <view class="menu-item-box">
  52. <view>更多</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- <view class="user-section" :class="'bg-' + proxy.$settingStore.themeColor.name" :style="{ paddingTop: proxy.$settingStore.barHightTop }">
  58. <image class="bg" src="@/static/images/mine/user-bg.png"></image>
  59. <view class="portrait-box">
  60. <image v-if="!avatar" @click="proxy.$settingStore.handleToAvatar(1)" class="portrait" src="@/static/images/mine/missing-face.png"></image>
  61. <image v-if="avatar" @click="proxy.$settingStore.handleToAvatar(2)" :src="avatar" class="portrait cu-avatar xl round"> </image>
  62. </view>
  63. </view> -->
  64. <!-- <uni-list>
  65. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'person-filled' }" title="昵称" :rightText="user.nickName" />
  66. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'phone-filled' }" title="手机号码" :rightText="user.phonenumber" />
  67. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'email-filled' }" title="邮箱" :rightText="user.email" />
  68. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'auth-filled' }" title="岗位" :rightText="postGroup" />
  69. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'staff-filled' }" title="角色" :rightText="roleGroup" />
  70. <uni-list-item showExtraIcon="true" :extraIcon="{ type: 'calendar-filled' }" title="创建日期" :rightText="user.createTime" />
  71. </uni-list> -->
  72. <!-- <view class="example">
  73. <uni-forms ref="form" :model="user" labelWidth="80px">
  74. <uni-forms-item label="用户昵称" name="nickName">
  75. <uni-easyinput v-model="user.nickName" placeholder="请输入昵称" />
  76. </uni-forms-item>
  77. <uni-forms-item label="手机号码" name="phonenumber">
  78. <uni-easyinput v-model="user.phonenumber" placeholder="请输入手机号码" />
  79. </uni-forms-item>
  80. <uni-forms-item label="邮箱" name="email">
  81. <uni-easyinput v-model="user.email" placeholder="请输入邮箱" />
  82. </uni-forms-item>
  83. <uni-forms-item label="性别" name="sex" required>
  84. <uni-data-checkbox v-model="user.sex" :localdata="sexs" />
  85. </uni-forms-item>
  86. </uni-forms>
  87. <button type="primary" class="round text-dfl" @click="submit">修改资料</button>
  88. </view> -->
  89. </view>
  90. <u-modal :show="modalShow" :showConfirmButton="true" :showCancelButton="true" @cancel="modalShow = false" @confirm="handleConfirm">
  91. <view class="slot-content" style="width: 100%">
  92. <view class="margin-b-15" style="color: #909399">{{ modalTitle }}</view>
  93. <view v-if="modalTitle === '修改昵称'">
  94. <u--input v-model="userArr.nickName" :maxlength="5" :placeholder="modalTitle" border="bottom" clearable></u--input>
  95. </view>
  96. <view v-if="modalTitle === '修改手机号'">
  97. <u--input type="number" v-model="userArr.phonenumber" :maxlength="11" :placeholder="modalTitle" border="bottom" clearable></u--input>
  98. </view>
  99. <view v-if="modalTitle === '修改邮箱'">
  100. <u--input v-model="userArr.email" :placeholder="modalTitle" border="bottom" clearable></u--input>
  101. </view>
  102. <view v-if="modalTitle === '修改性别'">
  103. <u-radio-group v-model="userArr.sex" placement="row">
  104. <u-radio v-for="se in sexs" :key="se" :activeColor="proxy.$settingStore.themeColor.color" :label="se.text" :name="se.value" style="margin-right: 15px"></u-radio>
  105. </u-radio-group>
  106. </view>
  107. </view>
  108. </u-modal>
  109. </template>
  110. <script setup>
  111. import config from "@/config";
  112. import storage from "@/utils/storage";
  113. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  114. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  115. import { publicStores, useStores } from "@/store/modules/index";
  116. import { updateUserProfile, getUserProfile } from "@/api/system/user";
  117. const useStore = useStores();
  118. const { proxy } = getCurrentInstance();
  119. const avatar = computed(() => {
  120. return useStore.$state.avatar;
  121. });
  122. const user = computed(() => {
  123. return useStore.$state.user;
  124. });
  125. const userArr = computed(() => {
  126. return useStore.$state.userArr;
  127. });
  128. const postGroup = computed(() => {
  129. return useStore.$state.postGroup;
  130. });
  131. const roleGroup = computed(() => {
  132. return useStore.$state.roleGroup;
  133. });
  134. const data = reactive({
  135. tabsList: [
  136. {
  137. name: "个人信息",
  138. },
  139. // {
  140. // name: "其它信息",
  141. // },
  142. {
  143. name: "企业/团队",
  144. },
  145. ],
  146. tabsCurrent: 0,
  147. sexs: [
  148. {
  149. text: "男",
  150. value: "0",
  151. },
  152. {
  153. text: "女",
  154. value: "1",
  155. },
  156. ],
  157. modalShow: false,
  158. modalTitle: "",
  159. });
  160. const { name, phone, tabsList, tabsCurrent, sexs, modalShow, modalTitle } = toRefs(data);
  161. const form = ref(null);
  162. function handleUserModal(title) {
  163. modalShow.value = true;
  164. modalTitle.value = title;
  165. }
  166. function handleConfirm() {
  167. if (modalTitle.value == "修改昵称") {
  168. if (!userArr.value.nickName) {
  169. proxy.$modal.showToast("昵称不能为空");
  170. return;
  171. }
  172. }
  173. if (modalTitle.value == "修改手机号") {
  174. if (!userArr.value.phonenumber) {
  175. proxy.$modal.showToast("手机号码不能为空");
  176. return;
  177. }
  178. if (!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(userArr.value.phonenumber)) {
  179. proxy.$modal.showToast("请输入正确的手机号码");
  180. return;
  181. }
  182. }
  183. if (modalTitle.value == "修改邮箱") {
  184. if (!userArr.value.email) {
  185. proxy.$modal.showToast("邮箱不能为空");
  186. return;
  187. }
  188. if (!/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(userArr.value.email)) {
  189. proxy.$modal.showToast("请输入正确的邮箱地址");
  190. return;
  191. }
  192. }
  193. if (modalTitle.value == "修改性别") {
  194. if (!userArr.value.sex) {
  195. proxy.$modal.showToast("请选择性别");
  196. return;
  197. }
  198. }
  199. updateUserProfile(userArr.value).then((response) => {
  200. proxy.$tab.reLaunch("/pages/mine");
  201. useStore.getUser();
  202. });
  203. }
  204. function submit(ref) {}
  205. /**
  206. * @tabs点击事件
  207. */
  208. function tabsClick(e) {
  209. tabsCurrent.value = e.index;
  210. }
  211. onLoad((options) => {
  212. useStore.getUser();
  213. });
  214. onReady(() => {
  215. // form.value.setRules(rules.value);
  216. });
  217. onShow(() => {
  218. //调用系统主题颜色
  219. proxy.$settingStore.systemThemeColor([1]);
  220. });
  221. // 自定义导航事件
  222. onNavigationBarButtonTap((e) => {
  223. if (e.float == "right") {
  224. proxy.$tab.navigateTo("/pages/mine/setting/index");
  225. }
  226. });
  227. </script>
  228. <style lang="scss" scoped>
  229. :deep(.uni-page-head__title) {
  230. opacity: 1 !important;
  231. }
  232. .info-container {
  233. .user-section {
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. height: 240px;
  238. padding-top: 44px;
  239. overflow: hidden;
  240. position: relative;
  241. .bg {
  242. position: absolute;
  243. left: 0;
  244. top: 0;
  245. width: 100vw;
  246. opacity: 0.84;
  247. }
  248. .portrait {
  249. position: relative;
  250. width: 104px;
  251. height: 104px;
  252. border-radius: 50%;
  253. border: 3px solid #fff;
  254. }
  255. }
  256. .example {
  257. padding: 15px;
  258. background-color: #fff;
  259. }
  260. .segmented-control {
  261. margin-bottom: 15px;
  262. }
  263. .button-group {
  264. margin-top: 15px;
  265. display: flex;
  266. justify-content: space-around;
  267. }
  268. .form-item {
  269. display: flex;
  270. align-items: center;
  271. flex: 1;
  272. }
  273. .button {
  274. display: flex;
  275. align-items: center;
  276. height: 35px;
  277. line-height: 35px;
  278. margin-left: 10px;
  279. }
  280. }
  281. </style>