index.vue 8.5 KB

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