myCenter.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="content">
  3. <view class="banner">
  4. <div class="custom-nav">我的</div>
  5. <div class="user-container">
  6. <view class="avatar">
  7. <image v-if="userAvatar" class="photo" :src="userAvatar" mode="widthFix" @error="userAvatar=defaultAvatar"></image>
  8. <image v-else class="photo" :src="defaultAvatar" mode="widthFix"></image>
  9. </view>
  10. <view class="bottom">
  11. <view class="name">
  12. <text>{{userName}}</text>
  13. </view>
  14. <div class="phone">{{phone}}</div>
  15. </view>
  16. </div>
  17. </view>
  18. <view class="zhcx-table">
  19. <uni-list>
  20. <uni-list-item title="个人资料"
  21. link="navigateTo" rightText="修改"
  22. to="/pages/myCenter/personalData/personalData"
  23. showArrow></uni-list-item>
  24. <uni-list-item title="所属院校"
  25. :rightText="school"
  26. link="navigateTo"
  27. to="/pages/myCenter/personalData/personalData"
  28. showArrow></uni-list-item>
  29. <!-- <uni-list-item title="人脸录入" @click="faceRecording" clickable showArrow></uni-list-item> -->
  30. </uni-list>
  31. </view>
  32. <div class="logoutBt" @click="logout">退出登录</div>
  33. <!-- <getPhone ref="getPhone" v-if="!isLogin" showByPlatform /> -->
  34. <view class="faceRecord-box" v-if="cameraModel">
  35. <camera device-position="front" flash="off" @error="error" class="camera"></camera>
  36. <button class="takePhotoBt" type="primary" @click="takePhoto">抓拍</button>
  37. <view>预览</view>
  38. <image class="facePhoto" mode="widthFix" :src="faceSrc"></image>
  39. <div class="camera-submit" @click="cameraSubmit">提交</div>
  40. <div class="camera-submit cancel" @click="cameraCancel">取消</div>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {logout} from '@/api/user.js'
  46. import { getToken } from '@/libs/auth';
  47. import getPhone from '@/components/getPhone.vue'
  48. export default{
  49. data(){
  50. return{
  51. defaultAvatar:"/static/components/avatar.png",
  52. userAvatar:"",
  53. userName:"--",
  54. phone:"--",
  55. school:"--",
  56. faceSrc:"",
  57. cameraModel:false,
  58. isLogin:true
  59. }
  60. },
  61. components:{
  62. getPhone
  63. },
  64. onShow() {
  65. this.init();
  66. },
  67. methods:{
  68. // initPhoneModal(){
  69. // const accountName=uni.getStorageSync('phone')
  70. // if(!accountName){
  71. // this.isLogin=false
  72. // this.$nextTick(()=>{
  73. // this.$refs['getPhone'].isAuthorize=false
  74. // })
  75. // }else{
  76. // this.isLogin=true
  77. // }
  78. // },
  79. init(){
  80. this.userName=uni.getStorageSync('accountId')
  81. // let user=uni.getStorageSync('accountInfo');
  82. // if(user){
  83. // user=JSON.parse(user)
  84. // this.userAvatar=user.avatar||this.defaultAvatar;
  85. // this.userName=user.name;
  86. // }
  87. },
  88. faceRecording(){
  89. this.cameraModel=true;
  90. },
  91. takePhoto(){
  92. const ctx = uni.createCameraContext();
  93. ctx.takePhoto({
  94. quality: 'high',
  95. success: (res) => {
  96. this.faceSrc = res.tempImagePath
  97. }
  98. });
  99. },
  100. cameraSubmit(){
  101. this.cameraModel=false;
  102. this.faceSrc = "";
  103. },
  104. cameraCancel(){
  105. this.cameraModel=false;
  106. this.faceSrc = "";
  107. },
  108. logout(){
  109. uni.showModal({
  110. title:'提示!',
  111. content:"是否要退出登录",
  112. success(res) {
  113. if (res.confirm) {
  114. logout().then(()=>{
  115. uni.clearStorageSync()
  116. uni.reLaunch({
  117. url:'/pages/login/index'
  118. })
  119. }).catch(()=>{
  120. /*token 异常未返回正确状态码*/
  121. uni.clearStorageSync()
  122. uni.reLaunch({
  123. url:'/pages/login/index'
  124. })
  125. })
  126. }
  127. }
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .content{
  135. position: relative;
  136. .banner{
  137. height: 580upx;
  138. background-image: url('/static/center/bg.png');
  139. background-repeat: no-repeat;
  140. background-size: 100% 100%;
  141. position: relative;
  142. &::after{
  143. position: absolute;
  144. content: "";
  145. display: block;
  146. width: 440rpx;
  147. height: 632rpx;
  148. right: 0;
  149. top: 20px;
  150. background-image:url('/static/center/bgmask.png');
  151. background-repeat: no-repeat;
  152. background-size: 100% 100%;
  153. z-index: 1;
  154. }
  155. .custom-nav{
  156. position: fixed;
  157. text-align: center;
  158. top: 24px;
  159. left: var(--window-left);
  160. right: var(--window-right);
  161. height: 88rpx;
  162. line-height: 88rpx;
  163. z-index: 998;
  164. color: #333333;
  165. background-color: transparent;
  166. font-size: 32rpx;
  167. font-weight: 400;
  168. box-sizing: border-box;
  169. font-family: PingFang SC;
  170. }
  171. .user-container{
  172. &{
  173. display: flex;
  174. justify-content: flex-start;
  175. align-items: center;
  176. position: absolute;
  177. bottom: 190rpx;
  178. left: 40rpx;
  179. }
  180. .avatar{
  181. width: 120rpx;
  182. height: 120rpx;
  183. border-radius: 50%;
  184. display: block;
  185. overflow: hidden;
  186. background: rgba(255,255,255,0.39);
  187. border: 2rpx solid #707070;
  188. .photo{
  189. width: 120rpx;
  190. height: 120rpx;
  191. border-radius: 50%;
  192. }
  193. }
  194. .bottom{
  195. &{
  196. padding-left: 20rpx;
  197. }
  198. .name{
  199. font-size: 36rpx;
  200. font-family: PingFang SC;
  201. font-weight: bold;
  202. line-height: 50rpx;
  203. color: #FFFFFF;
  204. }
  205. .phone{
  206. font-size: 28rpx;
  207. font-family: PingFang SC;
  208. font-weight: 400;
  209. line-height: 40rpx;
  210. color: #FFFFFF;
  211. padding-top: 14rpx;
  212. }
  213. }
  214. }
  215. }
  216. .zhcx-table{
  217. width: 710rpx;
  218. position: absolute;
  219. left: 20rpx;
  220. top: 440rpx;
  221. background-color: #fff;
  222. z-index: 99;
  223. border-radius: 12px;
  224. overflow: hidden;
  225. }
  226. .logoutBt{
  227. width: 424rpx;
  228. height: 72rpx;
  229. line-height: 72rpx;
  230. text-align: center;
  231. position: fixed;
  232. bottom: 130rpx;
  233. left: 50%;
  234. transform: translateX(-50%);
  235. background:#3D90F4;
  236. border-radius: 42rpx;
  237. font-size: 32rpx;
  238. font-family: PingFang SC;
  239. font-weight: 400;
  240. color: #FFFFFF;
  241. z-index: 999;
  242. }
  243. .faceRecord-box{
  244. position: fixed;
  245. top: 0;
  246. bottom: 0;
  247. left: 0;
  248. right: 0;
  249. z-index: 9999;
  250. background-color: #fff;
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. flex-direction: column;
  255. .camera,.facePhoto{
  256. width: 450rpx;
  257. height: 450rpx;
  258. border-radius: 50%;
  259. border:2rpx solid #eaeaea;
  260. }
  261. .takePhotoBt{
  262. display: inline-block;
  263. margin: 40rpx 0;
  264. }
  265. .camera-submit{
  266. width: 424rpx;
  267. height: 72rpx;
  268. line-height: 72rpx;
  269. text-align: center;
  270. background:#3D90F4;
  271. border-radius: 42rpx;
  272. font-size: 32rpx;
  273. font-family: PingFang SC;
  274. font-weight: 400;
  275. color: #FFFFFF;
  276. margin: 40rpx auto;
  277. &.cancel{
  278. color: #fff;
  279. background-color: #ED834A;
  280. border-color: #ED834A;
  281. margin: 0 auto 50rpx;
  282. }
  283. }
  284. }
  285. }
  286. </style>