user.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. <view @click="toLicense" 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. </view>
  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. const data = uni.getStorageSync("contact");
  77. if (!data) {
  78. return app.$dialog.showSuccess("请先从首页进入")
  79. }
  80. if (!app.isLogin) {
  81. this.$refs.loginCom.open();
  82. return ;
  83. }
  84. uni.navigateTo({
  85. url:"/pages/complaint/list?poi="+data.poi_id
  86. })
  87. },
  88. loginSuccess(token){
  89. app.isLogin = token;
  90. app.getUser()
  91. },
  92. outLogin(){
  93. app.$dialog.showError("确定要退出登录吗",function(res){
  94. if (res.confirm) {
  95. app.userInfo = null;
  96. uni.clearStorageSync();
  97. }
  98. })
  99. },
  100. toLicense(){
  101. const data = uni.getStorageSync("contact");
  102. if (!data) {
  103. return app.$dialog.showSuccess("请先从首页进入")
  104. }
  105. uni.navigateTo({
  106. url:"/pages/user/license?poi="+data.poi_id
  107. })
  108. },
  109. kfPop(){
  110. const isLogin = uni.getStorageSync("user_token");
  111. if (!isLogin) {
  112. this.$refs.loginCom.open();
  113. return ;
  114. }
  115. const data = uni.getStorageSync("contact");
  116. this.$refs.kfService.open(data);
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .content{
  123. position: fixed;
  124. z-index: 1;
  125. top: 0;
  126. left: 0;
  127. bottom: 0;
  128. right: 0;
  129. background-color: #ededed;
  130. display: flex;
  131. flex-direction: column;
  132. }
  133. .user-menu{
  134. background-color: #fff;
  135. width: 95%;
  136. margin: 20rpx auto;
  137. border-radius: 20rpx;
  138. .title{
  139. font-size: 32rpx;
  140. font-weight: 800;
  141. color: #333;
  142. padding: 20rpx;
  143. }
  144. .menu-item{
  145. height: 100upx;
  146. line-height: 100upx;
  147. display: flex;
  148. align-items: center;
  149. font-size: 28upx;
  150. color: #333;
  151. padding: 0 20upx;
  152. border-bottom: 2upx solid #f8f8f8;
  153. .icon{
  154. margin-right: 20upx;
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. image{
  159. width: 40upx;
  160. height: 40upx;
  161. }
  162. }
  163. .right{
  164. margin-right: 0;
  165. margin-left: auto;
  166. display: flex;
  167. align-items: center;
  168. justify-content: center;
  169. image{
  170. width: 40upx;
  171. height: 40upx;
  172. }
  173. }
  174. }
  175. }
  176. .user-header{
  177. background-color: $main-color;
  178. padding: 20rpx;
  179. display: flex;
  180. align-items: center;
  181. gap: 20rpx;
  182. .info {
  183. .name {
  184. color: #fff;
  185. font-size: 32rpx;
  186. font-weight: 700;
  187. }
  188. .desc {
  189. color: $main-sub-color;
  190. font-size: 28rpx;
  191. margin-top: 10rpx;
  192. }
  193. }
  194. .avatar {
  195. image {
  196. background-color: #fff;
  197. padding: 4rpx;
  198. width: 100rpx;
  199. height: 100rpx;
  200. border-radius: 20rpx;
  201. }
  202. }
  203. }
  204. .user-body{
  205. height: 0;
  206. flex: 1;
  207. }
  208. </style>