my.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. mapMutations,
  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. // 登录处理
  126. goLogin() {
  127. if (!this.isLogin) {
  128. uni.navigateTo({
  129. url: '/pagesA/public/login'
  130. });
  131. } else {
  132. this.$route('/packageUser/pages/user-info/index');
  133. }
  134. },
  135. // 跳转用户信息
  136. goUserDetail() {
  137. uni.navigateTo({
  138. url: '/pagesA/user/index'
  139. });
  140. },
  141. handlerLogout() {
  142. this.logout()
  143. },
  144. },
  145. }
  146. </script>
  147. <style>
  148. /* 页面容器 */
  149. .page-container {
  150. min-height: 100vh;
  151. background-color: #F5F5F5;
  152. }
  153. /* 背景图片 */
  154. .bg-image {
  155. top: 0;
  156. left: 0;
  157. width: 100%;
  158. height: 300rpx;
  159. z-index: 0;
  160. }
  161. /* 内容区域 */
  162. .content-area {
  163. position: relative;
  164. z-index: 1;
  165. padding: 32rpx;
  166. }
  167. /* 访客信息表单 */
  168. .visitor-form {
  169. background: #FFFFFF;
  170. border-radius: 24rpx;
  171. padding: 0 32rpx;
  172. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  173. }
  174. .form-item {
  175. display: flex;
  176. align-items: center;
  177. min-height: 120rpx;
  178. border-bottom: 1rpx solid #F5F5F5;
  179. }
  180. .form-item:last-child {
  181. border-bottom: none;
  182. }
  183. .label {
  184. width: 140rpx;
  185. font-size: 28rpx;
  186. color: #999999;
  187. }
  188. .value {
  189. flex: 1;
  190. font-size: 28rpx;
  191. color: #333333;
  192. }
  193. /* 未登录状态样式 */
  194. .login-container {
  195. padding: 40rpx 0;
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. justify-content: center;
  200. gap: 40rpx;
  201. }
  202. .login-prompt {
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. gap: 16rpx;
  207. }
  208. .login-title {
  209. font-size: 36rpx;
  210. color: #333333;
  211. font-weight: 600;
  212. }
  213. .login-subtitle {
  214. font-size: 28rpx;
  215. color: #999999;
  216. }
  217. .login-button {
  218. width: 100%;
  219. height: 88rpx;
  220. background: linear-gradient(90deg, #FF5B05 0%, #FF8E3C 100%);
  221. border-radius: 44rpx;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. gap: 8rpx;
  226. box-shadow: 0 4rpx 16rpx rgba(255, 91, 5, 0.2);
  227. }
  228. .login-text {
  229. color: #FFFFFF;
  230. font-size: 32rpx;
  231. font-weight: 500;
  232. }
  233. .login-arrow {
  234. color: #FFFFFF;
  235. font-size: 32rpx;
  236. font-weight: 500;
  237. margin-left: 8rpx;
  238. }
  239. .edit-button {
  240. margin: 80rpx 32rpx 0;
  241. height: 88rpx;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. border: 2rpx solid #FF5B05;
  246. border-radius: 44rpx;
  247. }
  248. .edit-text {
  249. color: #FF5B05;
  250. font-size: 32rpx;
  251. }
  252. </style>