index.vue 10 KB

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