user.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="content">
  3. <view class="user-header" v-if="userInfo">
  4. <view class="avatar">
  5. <image :src="userInfo?userInfo.avatar:'https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png'"></image>
  6. </view>
  7. <view class="info">
  8. <view class="name">{{userInfo.nickname}}</view>
  9. <view class="desc">{{userInfo.mobile}}</view>
  10. </view>
  11. </view>
  12. <view class="user-header" @click="toLogin" v-else>
  13. <view class="avatar"><image src="/static/logo.jpg"></image></view>
  14. <view class="info">
  15. <view class="name">请先登录</view>
  16. <view class="desc"></view>
  17. </view>
  18. </view>
  19. <view class="user-body" scroll-y scroll-with-animation>
  20. <view class="user-menu">
  21. <view class="title">我的服务</view>
  22. <view class="menu-item" @click="toLink">
  23. <view class="icon"><image src="/static/image/rule-rule.png"></image></view>
  24. <view class="name">我的投诉</view>
  25. <view class="right"><image src="/static/image/right.svg"></image></view>
  26. </view>
  27. <view class="menu-item" @click="kfPop">
  28. <view class="icon"><image src="/static/image/service.png"></image></view>
  29. <view class="name">商家客服</view>
  30. <view class="right"><image src="/static/image/right.svg"></image></view>
  31. </view>
  32. <navigator hover-class="none" class="menu-item" url="/pages/user/license">
  33. <view class="icon"><image src="/static/image/zizhi.png"></image></view>
  34. <view class="name">服务资质</view>
  35. <view class="right"><image src="/static/image/right.svg"></image></view>
  36. </navigator>
  37. </view>
  38. <view class="user-menu" v-if="isLogin">
  39. <view class="menu-item" @click="outLogin">
  40. <view class="icon"><image src="/static/image/out.png"></image></view>
  41. <view class="name">退出</view>
  42. <view class="right"><image src="/static/image/right.svg"></image></view>
  43. </view>
  44. </view>
  45. </view>
  46. <halfLogin ref="loginCom" @success="loginSuccess"></halfLogin>
  47. <kfService ref="kfService"></kfService>
  48. </view>
  49. </template>
  50. <script>
  51. var app;
  52. export default {
  53. data() {
  54. return {
  55. userInfo:null,
  56. isLogin:null
  57. }
  58. },
  59. onShow() {
  60. this.getUser()
  61. },
  62. onLoad() {
  63. app = this;
  64. app.isLogin = uni.getStorageSync("user_token");
  65. },
  66. methods: {
  67. async getUser(){
  68. var resp = await app.$api.auth.check.get();
  69. if (resp.code !== 1) return ;
  70. app.userInfo = resp.data;
  71. },
  72. toLogin(){
  73. this.$refs.loginCom.open();
  74. },
  75. toLink(){
  76. if (!app.isLogin) {
  77. this.$refs.loginCom.open();
  78. return ;
  79. }
  80. },
  81. loginSuccess(token){
  82. app.getUser()
  83. },
  84. outLogin(){
  85. app.$dialog.showError("确定要退出登录吗",function(res){
  86. if (res.confirm) {
  87. app.userInfo = null;
  88. uni.clearStorageSync();
  89. }
  90. })
  91. },
  92. kfPop(){
  93. const isLogin = uni.getStorageSync("user_token");
  94. if (!isLogin) {
  95. this.$refs.loginCom.open();
  96. return ;
  97. }
  98. const data = uni.getStorageSync("contact");
  99. this.$refs.kfService.open(data);
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .content{
  106. position: fixed;
  107. z-index: 1;
  108. top: 0;
  109. left: 0;
  110. bottom: 0;
  111. right: 0;
  112. background-color: #ededed;
  113. display: flex;
  114. flex-direction: column;
  115. }
  116. .user-menu{
  117. background-color: #fff;
  118. width: 95%;
  119. margin: 20rpx auto;
  120. border-radius: 20rpx;
  121. .title{
  122. font-size: 32rpx;
  123. font-weight: 800;
  124. color: #333;
  125. padding: 20rpx;
  126. }
  127. .menu-item{
  128. height: 100upx;
  129. line-height: 100upx;
  130. display: flex;
  131. align-items: center;
  132. font-size: 28upx;
  133. color: #333;
  134. padding: 0 20upx;
  135. border-bottom: 2upx solid #f8f8f8;
  136. .icon{
  137. margin-right: 20upx;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. image{
  142. width: 40upx;
  143. height: 40upx;
  144. }
  145. }
  146. .right{
  147. margin-right: 0;
  148. margin-left: auto;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. image{
  153. width: 40upx;
  154. height: 40upx;
  155. }
  156. }
  157. }
  158. }
  159. .user-header{
  160. background-color: $main-color;
  161. padding: 20rpx;
  162. display: flex;
  163. align-items: center;
  164. gap: 20rpx;
  165. .info {
  166. .name {
  167. color: #fff;
  168. font-size: 32rpx;
  169. font-weight: 700;
  170. }
  171. .desc {
  172. color: $main-sub-color;
  173. font-size: 28rpx;
  174. margin-top: 10rpx;
  175. }
  176. }
  177. .avatar {
  178. image {
  179. background-color: #fff;
  180. padding: 4rpx;
  181. width: 100rpx;
  182. height: 100rpx;
  183. border-radius: 20rpx;
  184. }
  185. }
  186. }
  187. .user-body{
  188. height: 0;
  189. flex: 1;
  190. }
  191. </style>