my.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <!-- 个人信息 -->
  3. <view class="page-container">
  4. <!-- 背景图片 -->
  5. <image class="bg-image " src="@/static/images/bg.png" mode="aspectFill"></image>
  6. <!-- 内容区域 -->
  7. <view class="content-area">
  8. <!-- 访客信息表单 -->
  9. <view class="visitor-form" @tap="goLogin">
  10. <view v-if="isLogin">
  11. <view class="form-item">
  12. <text class="label">姓名</text>
  13. <text class="value">{{user.account || '-'}}</text>
  14. </view>
  15. <view class="form-item">
  16. <text class="label">手机号</text>
  17. <text class="value">{{user.phone || '-'}}</text>
  18. </view>
  19. <view class="form-item">
  20. <text class="label">公司名称</text>
  21. <text class="value">{{user.company || '-'}}</text>
  22. </view>
  23. <view class="form-item">
  24. <text class="label">部门</text>
  25. <text class="value">{{user.department || '-'}}</text>
  26. </view>
  27. </view>
  28. <view v-else class="login-container">
  29. <view class="login-prompt">
  30. <text class="login-title">欢迎使用知己访客</text>
  31. <text class="login-subtitle">登录后可使用更多功能</text>
  32. </view>
  33. <view class="login-button" @tap="goLogin">
  34. <text class="login-text">点击登录</text>
  35. <text class="login-arrow">></text>
  36. </view>
  37. </view>
  38. </view>
  39. <view v-if="isLogin" class="edit-button" @tap="goUserDetail">
  40. <text class="edit-text">编辑</text>
  41. </view>
  42. <!-- 功能菜单 -->
  43. </view>
  44. <uni-popup ref="checkLoginDialog" type="dialog">
  45. <uni-popup-dialog type="warn" cancelText="继续浏览" confirmText="确认" title="提示" content="体验更多功能,请先登录"
  46. @confirm="goLogin()"></uni-popup-dialog>
  47. </uni-popup>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. getUserInfo,
  53. memberPetList,
  54. carouselQueryAll,
  55. getOrderStatusCounts,
  56. } from '../../config/api';
  57. import {
  58. mapActions,
  59. mapGetters
  60. } from 'vuex';
  61. import store from '@/store';
  62. import customNavbar from '../../components/custom-navbar/custom-navbar.vue'
  63. import {
  64. shareImg
  65. } from '@/common/config.js'
  66. export default {
  67. data() {
  68. return {
  69. user: {}
  70. }
  71. },
  72. computed: {
  73. ...mapGetters(['isLogin', 'userInfo', 'access_token', 'refresh_token'])
  74. },
  75. onLoad() {
  76. },
  77. onShow() {
  78. this.detail()
  79. },
  80. // 微信小程序分享配置
  81. onShareAppMessage() {
  82. return {
  83. title: `邀请您加入知己访客`,
  84. path: `/pages/index/index`,
  85. imageUrl: shareImg // 分享图片,需要添加
  86. }
  87. },
  88. onShareTimeline(res) {
  89. let that = this;
  90. let shareInfo = store.state.vuex_shareInfo;
  91. let query = shareInfo.query;
  92. //携带当前页面资源ID参数
  93. let currentPage = getCurrentPages()[getCurrentPages().length - 1];
  94. let options = currentPage.options;
  95. if (JSON.stringify(options) != '{}' && options.id) {
  96. query += `&id=${options.id}`;
  97. }
  98. return {
  99. title: shareInfo.title,
  100. query: query,
  101. imageUrl: shareImg,
  102. success(res) {
  103. uni.showToast({
  104. title: '分享成功'
  105. })
  106. },
  107. fail(res) {
  108. uni.showToast({
  109. title: '分享失败',
  110. icon: 'none'
  111. })
  112. },
  113. complete() {}
  114. }
  115. },
  116. methods: {
  117. ...mapActions(['logout', 'setToken', 'setUserInfo']),
  118. // async detail() {
  119. // const data = await memberDetail()
  120. // if (data.code == 200) {
  121. // this.user = data.data
  122. // uni.setStorageSync('user', this.user)
  123. // }
  124. // },
  125. async getUserInfo() {
  126. // const user = uni.getStorageSync('user');
  127. // if (user) {
  128. // this.user = user;
  129. // } else {
  130. // await this.detail();
  131. // }
  132. },
  133. // 登录处理
  134. goLogin() {
  135. if (!this.isLogin) {
  136. uni.navigateTo({
  137. url: '/pagesA/public/login'
  138. });
  139. } else {
  140. this.$route('/pagesA/public/login');
  141. }
  142. },
  143. // 跳转用户信息
  144. goUserDetail() {
  145. uni.navigateTo({
  146. url: '/pagesA/user/index'
  147. });
  148. },
  149. handlerLogout() {
  150. this.logout()
  151. },
  152. },
  153. }
  154. </script>
  155. <style>
  156. /* 页面容器 */
  157. .page-container {
  158. min-height: 100vh;
  159. background-color: #F5F5F5;
  160. }
  161. /* 背景图片 */
  162. .bg-image {
  163. top: 0;
  164. left: 0;
  165. width: 100%;
  166. height: 300rpx;
  167. z-index: 0;
  168. }
  169. /* 内容区域 */
  170. .content-area {
  171. position: relative;
  172. z-index: 1;
  173. padding: 32rpx;
  174. }
  175. /* 访客信息表单 */
  176. .visitor-form {
  177. background: #FFFFFF;
  178. border-radius: 24rpx;
  179. padding: 0 32rpx;
  180. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  181. }
  182. .form-item {
  183. display: flex;
  184. align-items: center;
  185. min-height: 120rpx;
  186. border-bottom: 1rpx solid #F5F5F5;
  187. }
  188. .form-item:last-child {
  189. border-bottom: none;
  190. }
  191. .label {
  192. width: 140rpx;
  193. font-size: 28rpx;
  194. color: #999999;
  195. }
  196. .value {
  197. flex: 1;
  198. font-size: 28rpx;
  199. color: #333333;
  200. }
  201. /* 未登录状态样式 */
  202. .login-container {
  203. padding: 40rpx 0;
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. justify-content: center;
  208. gap: 40rpx;
  209. }
  210. .login-prompt {
  211. display: flex;
  212. flex-direction: column;
  213. align-items: center;
  214. gap: 16rpx;
  215. }
  216. .login-title {
  217. font-size: 36rpx;
  218. color: #333333;
  219. font-weight: 600;
  220. }
  221. .login-subtitle {
  222. font-size: 28rpx;
  223. color: #999999;
  224. }
  225. .login-button {
  226. width: 100%;
  227. height: 88rpx;
  228. background: linear-gradient(90deg, #FF5B05 0%, #FF8E3C 100%);
  229. border-radius: 44rpx;
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. gap: 8rpx;
  234. box-shadow: 0 4rpx 16rpx rgba(255, 91, 5, 0.2);
  235. }
  236. .login-text {
  237. color: #FFFFFF;
  238. font-size: 32rpx;
  239. font-weight: 500;
  240. }
  241. .login-arrow {
  242. color: #FFFFFF;
  243. font-size: 32rpx;
  244. font-weight: 500;
  245. margin-left: 8rpx;
  246. }
  247. .edit-button {
  248. margin: 80rpx 32rpx 0;
  249. height: 88rpx;
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. border: 2rpx solid #FF5B05;
  254. border-radius: 44rpx;
  255. }
  256. .edit-text {
  257. color: #FF5B05;
  258. font-size: 32rpx;
  259. }
  260. </style>