index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. this.$util.navigateTo(url);
  208. },
  209. // 编辑页面
  210. goEdit() {
  211. if (this.isLogin == false) {
  212. this.openAuto();
  213. } else {
  214. uni.navigateTo({
  215. animationType: animationType.type,
  216. animationDuration: animationType.duration,
  217. url: '/pages/users/user_info/index'
  218. })
  219. }
  220. },
  221. },
  222. }
  223. </script>
  224. <style scoped>
  225. .order-nav {
  226. font-weight: 500;
  227. font-size: 35rpx;
  228. color: #FFFFFF;
  229. background-color: #FF6702;
  230. text-align: center;
  231. }
  232. .item-settled {
  233. background: linear-gradient(135deg, #FED0A7 0%, #FFF3E2 52%, #FAEDD3 100%);
  234. border-radius: 8rpx;
  235. padding: 20rpx;
  236. box-shadow: 0 0 0 2rpx rgba(255, 220, 135, 1);
  237. position: relative;
  238. top: -90rpx;
  239. margin: 0 20rpx;
  240. display: flex;
  241. align-items: center;
  242. }
  243. .item-settled::after {
  244. content: "";
  245. position: absolute;
  246. top: -2rpx;
  247. left: -2rpx;
  248. right: -2rpx;
  249. bottom: -2rpx;
  250. background: linear-gradient(200deg, rgba(255, 220, 135, 1), rgba(255, 172, 33, 1), rgba(255, 201, 24, 1));
  251. border-radius: 10rpx;
  252. z-index: -1;
  253. pointer-events: none;
  254. }
  255. .card {
  256. position: relative;
  257. display: flex;
  258. /* 启用flex布局 */
  259. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  260. padding: 40rpx 30rpx 120rpx 30rpx;
  261. box-sizing: border-box;
  262. background: linear-gradient(225deg, #ECF3FE 0%, #FEFEFE 100%);
  263. border-radius: 23rpx;
  264. top: -20rpx;
  265. }
  266. .card-left {
  267. position: relative;
  268. }
  269. .card-right {
  270. flex: 1;
  271. }
  272. .avatar {
  273. position: absolute;
  274. top: -80rpx;
  275. left: 0;
  276. width: 131rpx;
  277. height: 131rpx;
  278. background-color: #D8D8D8;
  279. border: 4rpx solid #FFFFFF;
  280. border-radius: 50%;
  281. object-fit: cover;
  282. }
  283. .username {
  284. margin-top: 70rpx;
  285. color: #141414;
  286. font-size: 35rpx;
  287. font-weight: bold;
  288. }
  289. .code {
  290. width: 31rpx;
  291. height: 31rpx;
  292. margin-left: 20rpx;
  293. }
  294. .card-content {
  295. display: flex;
  296. justify-content: space-between;
  297. }
  298. .content-item {
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. width: 33%;
  303. }
  304. .content-icon {
  305. width: 70rpx;
  306. height: 70rpx;
  307. margin-bottom: 15rpx;
  308. }
  309. .content-text1 {
  310. font-size: 23rpx;
  311. background: linear-gradient(90deg, #FFB908 0%, #DC7A11 100%);
  312. -webkit-background-clip: text;
  313. background-clip: text;
  314. color: transparent;
  315. }
  316. .content-text2 {
  317. font-size: 23rpx;
  318. background: linear-gradient(90deg, #93B0FF 0%, #1B4EFF 100%);
  319. -webkit-background-clip: text;
  320. background-clip: text;
  321. color: transparent;
  322. }
  323. .content-text3 {
  324. font-size: 23rpx;
  325. background: linear-gradient(90deg, #F4D600 0%, #FF9100 100%);
  326. -webkit-background-clip: text;
  327. background-clip: text;
  328. color: transparent;
  329. }
  330. .phone-info {
  331. font-size: 21rpx;
  332. padding-top: 10rpx;
  333. }
  334. .phone-info text {
  335. margin-right: 14rpx;
  336. }
  337. .phone-info image {
  338. width: 27rpx;
  339. height: 27rpx;
  340. vertical-align: middle;
  341. }
  342. .profile-link {
  343. margin-top: 20rpx;
  344. font-size: 23rpx;
  345. font-weight: 600;
  346. line-height: 21rpx;
  347. text-align: right;
  348. }
  349. .profile-link img {
  350. width: 24rpx;
  351. height: 24rpx;
  352. vertical-align: middle;
  353. margin-left: 12rpx;
  354. }
  355. .grid-container {
  356. display: flex;
  357. flex-wrap: wrap;
  358. gap: 0;
  359. /* 改用 margin 控制间距 */
  360. padding: 20rpx;
  361. /* 父容器内边距 */
  362. box-sizing: border-box;
  363. /* 包含 padding 在宽度内 */
  364. }
  365. .grid-item {
  366. width: 25%;
  367. /* 直接 25% 无需 calc */
  368. display: flex;
  369. flex-direction: column;
  370. align-items: center;
  371. margin-bottom: 30rpx;
  372. /* 行间距 */
  373. padding: 0 10rpx;
  374. /* 左右间隙(替代 gap) */
  375. box-sizing: border-box;
  376. /* 关键 */
  377. }
  378. .grid-img {
  379. width: 58rpx;
  380. height: 58rpx;
  381. margin-bottom: 8rpx;
  382. }
  383. .grid-text {
  384. font-size: 24rpx;
  385. color: #333;
  386. }
  387. .item-features {
  388. background: #FFFFFF;
  389. border-radius: 23rpx;
  390. margin: -60rpx 20rpx 20rpx 20rpx;
  391. }
  392. .item-features-title {
  393. padding: 20rpx;
  394. font-weight: 600;
  395. font-size: 27rpx;
  396. color: #2E261E;
  397. line-height: 38rpx;
  398. }
  399. </style>