You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
4.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <view class="content" :style="{background:'url('+topBgUrl+') #F5F5F5 no-repeat', backgroundSize: '100% 552rpx' }">
  3. <avabtnBox/>
  4. <view class="padding">
  5. <view class="userInfo flex">
  6. <view class="avatar">
  7. <image :src="avaUrl" mode="" v-if="avaUrl"></image>
  8. </view>
  9. <view class="userTxt">
  10. <view class="" v-if="counterStore.token">
  11. <view class="name" > {{ counterStore.userInfo.name }} </view>
  12. <view class="phone">{{ counterStore.userInfo.userPhone }}</view>
  13. </view>
  14. <view class="name" v-else @click="$goPage('/pages/subPage/login/login')">登录/注册</view>
  15. </view>
  16. </view>
  17. <view class="card">
  18. <view class="li flex-b" v-for="(item,index) in configList" :key="index" @click="$goPage(item.url)">
  19. <view class="text">{{ item.text }}</view>
  20. <u-icon name="arrow-right"></u-icon>
  21. </view>
  22. <view class="li flex-b" >
  23. <button type="default" open-type="contact" class="cotact" ref="avatarRef">联系客服</button>
  24. <view class="text">联系客服</view>
  25. <u-icon name="arrow-right"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="logOutBtn padding" v-if="counterStore.token">
  30. <view class="btn" @click="logOutFn">退出登录</view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import siteObj from '@/config/site.config.js'
  36. const {imgUrl} = siteObj
  37. const topBgUrl = imgUrl + 'minebg.png'
  38. import { logOut } from '@/config/api.js'
  39. import { getUserInfo } from '@/config/api.js'
  40. import { onShow } from '@dcloudio/uni-app'
  41. import { userStore } from '@/store/index.js';
  42. const counterStore = userStore();
  43. import { ref, } from 'vue'
  44. const configList = ref([
  45. {text: '用户协议', url: '/pages/subPage/privacyAgreement/privacyAgreement?type=2'},
  46. {text: '隐私政策', url: '/pages/subPage/privacyAgreement/privacyAgreement?type=1'},
  47. ])
  48. function logOutFn() {
  49. uni.showModal({
  50. content: '确定要退出登录吗?',
  51. success: async function (res) {
  52. if (res.confirm) {
  53. await logOut()
  54. counterStore.goLogin()
  55. } else if (res.cancel) {
  56. console.log('用户点击取消');
  57. }
  58. }
  59. });
  60. }
  61. async function getUserInfoFn() {
  62. const {data: res} = await getUserInfo()
  63. counterStore.upDateUseInfo('name', res.userName)
  64. counterStore.upDateUseInfo('userPhone', res.userPhone)
  65. console.log(res)
  66. }
  67. onShow(()=>{
  68. counterStore.upDateUseInfo('name', '')
  69. if(counterStore.token && !counterStore.userInfo.name) {
  70. getUserInfoFn()
  71. }
  72. })
  73. // const userName = ref('')
  74. // uni.login({
  75. // provider: 'weixin',
  76. // success: function (loginRes) {
  77. // console.log(loginRes.authResult); // 打印登录凭证
  78. // // 使用登录凭证获取用户信息
  79. // console.log('来这里了吗?')
  80. // uni.getUserProfile({
  81. // provider: 'weixin',
  82. // success: function (infoRes) {
  83. // console.log(infoRes.userInfo); // 打印用户信息
  84. // console.log('用户昵称为: ' + infoRes.userInfo.nickName); // 打印用户昵称
  85. // userName.value = infoRes.userInfo.nickName
  86. // avatarUrl.value = infoRes.userInfo.avatarUrl
  87. // },
  88. // fail(err) {
  89. // console.log('失败了吗?')
  90. // console.log(err)
  91. // }
  92. // });
  93. // }
  94. // });
  95. </script>
  96. <style lang="scss" scoped>
  97. image {
  98. display: block;
  99. width: 100%;
  100. height: 100%;
  101. }
  102. .logOutBtn {
  103. position: fixed;
  104. bottom: 90rpx;
  105. left: 0;
  106. width: 100%;
  107. .btn {
  108. line-height: 80rpx;
  109. font-size: 30rpx;
  110. color: #ccc;
  111. text-align: center;
  112. border-radius: 10rpx;
  113. border: 1px solid #ccc;
  114. }
  115. }
  116. .content {
  117. width: 100%;
  118. // background: url('http://47.96.82.242/htmls/bigImg/minebg.png') #F5F5F5 no-repeat;
  119. min-height: 100vh;
  120. .userInfo {
  121. padding: 200rpx 0 40rpx 0;
  122. .avatar {
  123. width: 114rpx;
  124. height: 114rpx;
  125. background: url('../../../static/images/avatar.png') #F5F5F5 no-repeat;
  126. background-size: 100% 100%;
  127. border-radius: 50%;
  128. overflow: hidden;
  129. }
  130. .name {
  131. margin-left: 30rpx;
  132. font-size: 34rpx;
  133. font-weight: 700;
  134. color: #fff;
  135. }
  136. .phone {
  137. margin: 10px 0 0 30rpx;
  138. font-size: 26rpx;
  139. font-weight: 400;
  140. color: #fff;
  141. }
  142. }
  143. .card {
  144. background: #FFFFFF;
  145. border-radius: 14rpx;
  146. padding: 0 30rpx;
  147. .li {
  148. width: 100%;
  149. height: 108rpx;
  150. border-bottom: 1px solid #EFEFEF;
  151. position: relative;
  152. .cotact {
  153. position: absolute;
  154. left: 0;
  155. right: 0;
  156. top: 0;
  157. opacity: 0;
  158. }
  159. &:last-child {
  160. border: none;
  161. }
  162. .text {
  163. font-size: 28rpx;
  164. }
  165. u-icon {
  166. }
  167. }
  168. }
  169. }
  170. </style>