user.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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">
  39. <view class="menu-item">
  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. kfPop(){
  85. const isLogin = uni.getStorageSync("user_token");
  86. if (!isLogin) {
  87. this.$refs.loginCom.open();
  88. return ;
  89. }
  90. const data = uni.getStorageSync("contact");
  91. this.$refs.kfService.open(data);
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .content{
  98. position: fixed;
  99. z-index: 1;
  100. top: 0;
  101. left: 0;
  102. bottom: 0;
  103. right: 0;
  104. background-color: #ededed;
  105. display: flex;
  106. flex-direction: column;
  107. }
  108. .user-menu{
  109. background-color: #fff;
  110. width: 95%;
  111. margin: 20rpx auto;
  112. border-radius: 20rpx;
  113. .title{
  114. font-size: 32rpx;
  115. font-weight: 800;
  116. color: #333;
  117. padding: 20rpx;
  118. }
  119. .menu-item{
  120. height: 100upx;
  121. line-height: 100upx;
  122. display: flex;
  123. align-items: center;
  124. font-size: 28upx;
  125. color: #333;
  126. padding: 0 20upx;
  127. border-bottom: 2upx solid #f8f8f8;
  128. .icon{
  129. margin-right: 20upx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. image{
  134. width: 40upx;
  135. height: 40upx;
  136. }
  137. }
  138. .right{
  139. margin-right: 0;
  140. margin-left: auto;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. image{
  145. width: 40upx;
  146. height: 40upx;
  147. }
  148. }
  149. }
  150. }
  151. .user-header{
  152. background-color: $main-color;
  153. padding: 20rpx;
  154. display: flex;
  155. align-items: center;
  156. gap: 20rpx;
  157. .info {
  158. .name {
  159. color: #fff;
  160. font-size: 32rpx;
  161. font-weight: 700;
  162. }
  163. .desc {
  164. color: $main-sub-color;
  165. font-size: 28rpx;
  166. margin-top: 10rpx;
  167. }
  168. }
  169. .avatar {
  170. image {
  171. background-color: #fff;
  172. padding: 4rpx;
  173. width: 100rpx;
  174. height: 100rpx;
  175. border-radius: 20rpx;
  176. }
  177. }
  178. }
  179. .user-body{
  180. height: 0;
  181. flex: 1;
  182. }
  183. </style>