index.vue 10 KB

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