index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <view>
  3. <!-- 状态栏高度 -->
  4. <view :style="{ height: `${statusBarHeight}px` }"></view>
  5. <!-- 导航栏 -->
  6. <view :style="{ height: `${navigationBarHeight}px`,lineHeight: `${navigationBarHeight}px`}" class="order-nav">
  7. 个人中心
  8. </view>
  9. <view style="background-color: #FF6702;height: 60rpx;"></view>
  10. <view class="card">
  11. <view class="card-left">
  12. <view class="name" v-if="!isLogin" @tap="openAuto">
  13. <image class="avatar tui-skeleton-rect" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
  14. <image v-else class="avatar tui-skeleton-rect" :src="urlDomain+'crmebimage/presets/morenT.png'" mode="" @click="goEdit()">
  15. </image>
  16. <view class="username">请点击登录</view>
  17. </view>
  18. <template v-else>
  19. <image class="avatar tui-skeleton-rect" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
  20. <image v-else class="avatar tui-skeleton-rect" :src="urlDomain+'crmebimage/presets/morenT.png'" mode="" @click="goEdit()">
  21. </image>
  22. <view class="username">
  23. {{userInfo.nickname}}
  24. <!-- <image src="/static/img/ic-code.png" class="code"></image> -->
  25. </view>
  26. <view class="phone-info">
  27. <text>绑定手机号:{{userInfo.phone}}</text>
  28. <image src="/static/img/ic-copy.png">
  29. </image>
  30. </view>
  31. </template>
  32. </view>
  33. <view class="card-right">
  34. <view class="card-content">
  35. <view class="content-item">
  36. <img class="content-icon" src="/static/img/ic-tickets.png" alt="我的票劵">
  37. <view class="content-text1">我的票劵</view>
  38. </view>
  39. <view class="content-item" @click="menusTap('/pages/goods/order_list/index')">
  40. <img class="content-icon" src="/static/img/ic-order.png" alt="我的订单">
  41. <view class="content-text2">我的订单</view>
  42. </view>
  43. <view class="content-item">
  44. <img class="content-icon" src="/static/img/ic-gold.png" alt="我的金币">
  45. <view class="content-text3">我的金币</view>
  46. </view>
  47. </view>
  48. <!-- <view class="profile-link">
  49. <text>个人中心</text>
  50. <img src="/static/img/ic-right.png" />
  51. </view> -->
  52. </view>
  53. </view>
  54. <view class="item-settled">
  55. <image @tap="menusTap('/pages/users/settled/index')" src="/static/img/ic-settled-left.png" style="width: 350rpx;height: 116rpx;"></image>
  56. <image src="/static/img/ic-bg-line.png" style="width: 4rpx;height: 154rpx;margin: 0 20rpx;"></image>
  57. <image @tap="menusRider('/pages/users/user_rider/index')" src="/static/img/ic-settled-right.png" style="width: 350rpx;height: 116rpx;"></image>
  58. </view>
  59. <view class="item-features" v-if="isLogin">
  60. <view class="item-features-title">我的功能</view>
  61. <div class="grid-container">
  62. <!-- 示例:12 个格子(3行x4列) -->
  63. <div class="grid-item" v-for="item in featuresList" :key="item.id" @click="menusTap(item.url)">
  64. <img class="grid-img" :src="item.icon">
  65. <div class="grid-text">{{item.text}}</div>
  66. </div>
  67. </div>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  73. let app = getApp();
  74. import {
  75. userCenterInfo,
  76. copyrightImageApi
  77. } from '@/api/user.js';
  78. import Cache from '@/utils/cache';
  79. import {
  80. toLogin
  81. } from '@/libs/login.js';
  82. import {
  83. mapGetters
  84. } from "vuex";
  85. import {
  86. BACK_URL
  87. } from '@/config/cache';
  88. import animationType from '@/utils/animationType.js'
  89. export default {
  90. computed: mapGetters(['isLogin']),
  91. data() {
  92. return {
  93. statusBarHeight: app.globalData.statusBarHeight,
  94. navigationBarHeight: 0,
  95. userInfo: {},
  96. urlDomain: this.$Cache.get("imgHost"),
  97. featuresList: [{
  98. id: 1,
  99. icon: '/static/img/ic-express.png',
  100. text: '我的快递',
  101. url: ''
  102. },
  103. {
  104. id: 2,
  105. icon: '/static/img/ic-address.png',
  106. text: '通用地址',
  107. url: '/pages/address/user_address_list/index'
  108. },
  109. {
  110. id: 3,
  111. icon: '/static/img/ic-comments.png',
  112. text: '我的评论',
  113. url: ''
  114. },
  115. {
  116. id: 4,
  117. icon: '/static/img/ic-collection.png',
  118. text: '我的收藏',
  119. url: '/pages/goods/user_goods_collection/index'
  120. },
  121. {
  122. id: 5,
  123. icon: '/static/img/ic-buy.png',
  124. text: '我的团购',
  125. url: ''
  126. },
  127. {
  128. id: 6,
  129. icon: '/static/img/ic-vouchers.png',
  130. text: '我的卡券',
  131. url: '/pages/users/user_coupon/index'
  132. },
  133. {
  134. id: 7,
  135. icon: '/static/img/ic-distribution.png',
  136. text: '我的分销',
  137. url: '/pages/users/user_spread_user/index'
  138. },
  139. {
  140. id: 8,
  141. icon: '/static/img/ic-friend.png',
  142. text: '邀请好友',
  143. url: ''
  144. },
  145. {
  146. id: 9,
  147. icon: '/static/img/ic-feedback.png',
  148. text: '帮助反馈',
  149. url: ''
  150. },
  151. {
  152. id: 10,
  153. icon: '/static/img/ic-security-settings.png',
  154. text: '安全设置',
  155. url: '/pages/users/user_setting/index'
  156. }
  157. ],
  158. }
  159. },
  160. onLoad(options) {
  161. let that = this;
  162. //首页数据加载
  163. // this.getIndexConfig();
  164. // #ifdef MP-WEIXIN
  165. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  166. const custom = wx.getMenuButtonBoundingClientRect()
  167. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  168. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  169. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  170. // #endif
  171. },
  172. onShow: function() {
  173. if (this.isLogin) {
  174. this.getUserCenterInfo();
  175. }
  176. },
  177. methods: {
  178. /**
  179. *
  180. * 获取个人中心详情
  181. */
  182. getUserCenterInfo: function() {
  183. userCenterInfo().then(res => {
  184. let data = res.data;
  185. this.userInfo = data;
  186. console.log(this, UserInfo)
  187. // this.showSkeleton = false;
  188. }).catch(err => {
  189. // this.showSkeleton = false;
  190. });
  191. },
  192. menusTap(url) {
  193. if (!this.isLogin) {
  194. this.openAuto();
  195. } else {
  196. if (url === '') return
  197. this.$util.navigateTo(url);
  198. }
  199. },
  200. // 打开授权
  201. openAuto() {
  202. Cache.set(BACK_URL, '')
  203. toLogin();
  204. },
  205. // 跳转骑手
  206. menusRider(url) {
  207. if (!this.isLogin) {
  208. this.openAuto();
  209. } else {
  210. if (url === '') return
  211. this.$util.navigateTo(url);
  212. }
  213. },
  214. // 编辑页面
  215. goEdit() {
  216. if (this.isLogin == false) {
  217. this.openAuto();
  218. } else {
  219. uni.navigateTo({
  220. animationType: animationType.type,
  221. animationDuration: animationType.duration,
  222. url: '/pages/users/user_info/index'
  223. })
  224. }
  225. },
  226. },
  227. }
  228. </script>
  229. <style scoped>
  230. .order-nav {
  231. font-weight: 500;
  232. font-size: 35rpx;
  233. color: #FFFFFF;
  234. background-color: #FF6702;
  235. text-align: center;
  236. }
  237. .item-settled {
  238. background: linear-gradient(135deg, #FED0A7 0%, #FFF3E2 52%, #FAEDD3 100%);
  239. border-radius: 8rpx;
  240. padding: 20rpx;
  241. box-shadow: 0 0 0 2rpx rgba(255, 220, 135, 1);
  242. position: relative;
  243. top: -90rpx;
  244. margin: 0 20rpx;
  245. display: flex;
  246. align-items: center;
  247. }
  248. .item-settled::after {
  249. content: "";
  250. position: absolute;
  251. top: -2rpx;
  252. left: -2rpx;
  253. right: -2rpx;
  254. bottom: -2rpx;
  255. background: linear-gradient(200deg, rgba(255, 220, 135, 1), rgba(255, 172, 33, 1), rgba(255, 201, 24, 1));
  256. border-radius: 10rpx;
  257. z-index: -1;
  258. pointer-events: none;
  259. }
  260. .card {
  261. position: relative;
  262. display: flex;
  263. /* 启用flex布局 */
  264. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  265. padding: 40rpx 30rpx 120rpx 30rpx;
  266. box-sizing: border-box;
  267. background: linear-gradient(225deg, #ECF3FE 0%, #FEFEFE 100%);
  268. border-radius: 23rpx;
  269. top: -20rpx;
  270. }
  271. .card-left {
  272. position: relative;
  273. }
  274. .card-right {
  275. flex: 1;
  276. }
  277. .avatar {
  278. position: absolute;
  279. top: -80rpx;
  280. left: 0;
  281. width: 131rpx;
  282. height: 131rpx;
  283. background-color: #D8D8D8;
  284. border: 4rpx solid #FFFFFF;
  285. border-radius: 50%;
  286. object-fit: cover;
  287. }
  288. .username {
  289. margin-top: 70rpx;
  290. color: #141414;
  291. font-size: 35rpx;
  292. font-weight: bold;
  293. }
  294. .code {
  295. width: 31rpx;
  296. height: 31rpx;
  297. margin-left: 20rpx;
  298. }
  299. .card-content {
  300. display: flex;
  301. justify-content: space-between;
  302. }
  303. .content-item {
  304. display: flex;
  305. flex-direction: column;
  306. align-items: center;
  307. width: 33%;
  308. }
  309. .content-icon {
  310. width: 70rpx;
  311. height: 70rpx;
  312. margin-bottom: 15rpx;
  313. }
  314. .content-text1 {
  315. font-size: 23rpx;
  316. background: linear-gradient(90deg, #FFB908 0%, #DC7A11 100%);
  317. -webkit-background-clip: text;
  318. background-clip: text;
  319. color: transparent;
  320. }
  321. .content-text2 {
  322. font-size: 23rpx;
  323. background: linear-gradient(90deg, #93B0FF 0%, #1B4EFF 100%);
  324. -webkit-background-clip: text;
  325. background-clip: text;
  326. color: transparent;
  327. }
  328. .content-text3 {
  329. font-size: 23rpx;
  330. background: linear-gradient(90deg, #F4D600 0%, #FF9100 100%);
  331. -webkit-background-clip: text;
  332. background-clip: text;
  333. color: transparent;
  334. }
  335. .phone-info {
  336. font-size: 21rpx;
  337. padding-top: 10rpx;
  338. }
  339. .phone-info text {
  340. margin-right: 14rpx;
  341. }
  342. .phone-info image {
  343. width: 27rpx;
  344. height: 27rpx;
  345. vertical-align: middle;
  346. }
  347. .profile-link {
  348. margin-top: 20rpx;
  349. font-size: 23rpx;
  350. font-weight: 600;
  351. line-height: 21rpx;
  352. text-align: right;
  353. }
  354. .profile-link img {
  355. width: 24rpx;
  356. height: 24rpx;
  357. vertical-align: middle;
  358. margin-left: 12rpx;
  359. }
  360. .grid-container {
  361. display: flex;
  362. flex-wrap: wrap;
  363. gap: 0;
  364. /* 改用 margin 控制间距 */
  365. padding: 20rpx;
  366. /* 父容器内边距 */
  367. box-sizing: border-box;
  368. /* 包含 padding 在宽度内 */
  369. }
  370. .grid-item {
  371. width: 25%;
  372. /* 直接 25% 无需 calc */
  373. display: flex;
  374. flex-direction: column;
  375. align-items: center;
  376. margin-bottom: 30rpx;
  377. /* 行间距 */
  378. padding: 0 10rpx;
  379. /* 左右间隙(替代 gap) */
  380. box-sizing: border-box;
  381. /* 关键 */
  382. }
  383. .grid-img {
  384. width: 58rpx;
  385. height: 58rpx;
  386. margin-bottom: 8rpx;
  387. }
  388. .grid-text {
  389. font-size: 24rpx;
  390. color: #333;
  391. }
  392. .item-features {
  393. background: #FFFFFF;
  394. border-radius: 23rpx;
  395. margin: -60rpx 20rpx 20rpx 20rpx;
  396. }
  397. .item-features-title {
  398. padding: 20rpx;
  399. font-weight: 600;
  400. font-size: 27rpx;
  401. color: #2E261E;
  402. line-height: 38rpx;
  403. }
  404. </style>