my.vue 5.5 KB

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