index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="content">
  3. <view :style="{ paddingTop: navBarHeight }" class="profile-box">
  4. <view class="header">
  5. <view @click="init" class="avatar">
  6. <image
  7. :src="userInfo.imgPath || defaultImg"
  8. mode="aspectFill"
  9. class="avatar-img"
  10. />
  11. </view>
  12. <view @click="edit" class="info">
  13. <view class="name">
  14. <text>{{ userInfo.nickname || "用户" }}</text>
  15. </view>
  16. <view class="desc">
  17. <text>{{ userInfo.phoneNum || "请先登录" }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="vip-card">
  22. <!-- <view class="vip-title">会员专属</view> -->
  23. <view class="vip-btn" @click="jump('../../my/memberCenter/index')"
  24. >开通</view
  25. >
  26. </view>
  27. </view>
  28. <view
  29. style="font-size: 34rpx; font-weight: bold; margin: 30rpx 0 20rpx 30rpx"
  30. >我的订单</view
  31. >
  32. <u-grid :border="false" col="5" @click="click">
  33. <u-grid-item
  34. v-for="(baseListItem, baseListIndex) in baseList"
  35. :key="baseListIndex"
  36. @click="jump(baseListItem.path)"
  37. >
  38. <!-- <u-icon
  39. :customStyle="{ paddingTop: 20 + 'rpx' }"
  40. :name="baseListItem.name"
  41. :size="50"
  42. ></u-icon> -->
  43. <image
  44. style="height: 50rpx; width: 50rpx; padding-top: 20rpx"
  45. :src="baseListItem.src"
  46. >
  47. </image>
  48. <text class="grid-text">{{ baseListItem.title }}</text>
  49. </u-grid-item>
  50. </u-grid>
  51. <view style="font-size: 34rpx; font-weight: bold; margin: 30rpx 0 0 30rpx">
  52. 常用功能
  53. </view>
  54. <view class="setting">
  55. <u-cell-group :border="false">
  56. <u-cell
  57. @click="jump(item.path)"
  58. class="setting-cell"
  59. v-for="item in settingList"
  60. :rightIconStyle="{ fontSize: '15px' }"
  61. :isLink="true"
  62. :border="false"
  63. :title="item.title"
  64. >
  65. </u-cell>
  66. </u-cell-group>
  67. </view>
  68. <!-- <view class="btn-box"> 退出 </view> -->
  69. <zs-tab-bar :value="3"></zs-tab-bar>
  70. </view>
  71. </template>
  72. <script>
  73. import { getUserDetail } from "@/api/common.js";
  74. export default {
  75. data() {
  76. return {
  77. navBarHeight: 0,
  78. inOpter: false,
  79. defaultImg:
  80. "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fci.xiaohongshu.com%2Fc34b7b74-ba38-0456-982a-43c0f97522fe%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fci.xiaohongshu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1693532127&t=a2e186c12aecaab7723611cb52a6778f",
  81. userInfo: {
  82. nickName: "用户12332111",
  83. type: "尊享会员",
  84. },
  85. baseList: [
  86. {
  87. name: "order",
  88. title: "全部",
  89. src: "/static/icon/my/all.png",
  90. path: "../../my/order/index",
  91. },
  92. {
  93. name: "red-packet",
  94. title: "待付款",
  95. src: "/static/icon/my/obligations.png",
  96. path: "../../my/order/index?type=WAIT_PAYMENT",
  97. },
  98. {
  99. name: "car",
  100. title: "待发货",
  101. src: "/static/icon/my/shipments.png",
  102. },
  103. {
  104. name: "bag",
  105. title: "待收货",
  106. src: "/static/icon/my/receiving.png",
  107. },
  108. {
  109. name: "rmb-circle",
  110. title: "退款",
  111. src: "/static/icon/my/refund.png",
  112. path: "../../my/order/index?type=APPLY_REFUND",
  113. },
  114. ],
  115. settingList: [
  116. // 会员码 、 收获地址 、 我的收藏 、 我的优惠券
  117. {
  118. name: "vip",
  119. title: "会员码",
  120. path: "../../my/memberCenter/index",
  121. },
  122. {
  123. name: "location",
  124. title: "收货地址",
  125. },
  126. {
  127. name: "heart",
  128. title: "我的收藏",
  129. },
  130. {
  131. name: "coupon",
  132. title: "我的优惠券",
  133. path: "../../pay/coupon",
  134. },
  135. ],
  136. };
  137. },
  138. created() {
  139. this.navBarHeight = this.$navHight();
  140. },
  141. onShow() {
  142. this.init();
  143. },
  144. methods: {
  145. edit() {
  146. if (uni.getStorageSync("token")) {
  147. uni.navigateTo({
  148. url: "../../my/edit/edit",
  149. });
  150. } else {
  151. uni.showModal({
  152. title: "请登录",
  153. confirmText: "去登录",
  154. success(res) {
  155. console.log(res);
  156. if (res.confirm) {
  157. uni.navigateTo({
  158. url: "../../login/login/login?redirect=/pages/my/index",
  159. });
  160. }
  161. },
  162. });
  163. }
  164. },
  165. init() {
  166. if (uni.getStorageSync("token")) {
  167. this.getUserDetail();
  168. } else {
  169. (this.userInfo = {
  170. imgPath: null,
  171. lastLogin: "",
  172. level: null,
  173. nickname: null,
  174. openId: "",
  175. phoneNum: "",
  176. sex: 0,
  177. userId: "",
  178. valid: 0,
  179. }),
  180. uni.showModal({
  181. title: "请登录",
  182. confirmText: "去登录",
  183. success(res) {
  184. console.log(res);
  185. if (res.confirm) {
  186. uni.navigateTo({
  187. url: "../../login/login/login",
  188. });
  189. }
  190. },
  191. });
  192. }
  193. },
  194. // 获取用户详情
  195. getUserDetail() {
  196. getUserDetail().then((res) => {
  197. if (res.state == "Success") {
  198. this.userInfo = res.content;
  199. uni.setStorageSync("userInfo", JSON.stringify(this.userInfo));
  200. }
  201. });
  202. },
  203. jump(url) {
  204. if (!uni.getStorageSync("token")) {
  205. return uni.showModal({
  206. title: "请登录",
  207. confirmText: "去登录",
  208. success(res) {
  209. console.log(res);
  210. if (res.confirm) {
  211. uni.navigateTo({
  212. url: "../../login/login/login?redirect=/pages/my/index",
  213. });
  214. }
  215. },
  216. });
  217. }
  218. uni.navigateTo({
  219. url,
  220. });
  221. },
  222. },
  223. };
  224. </script>
  225. <style>
  226. page {
  227. background-color: #ffffff;
  228. }
  229. </style>
  230. <style lang="scss" scoped>
  231. .content {
  232. .profile-box {
  233. background: url("https://oss.dev.zonelife.cn/static/guida/img/my/background.png") no-repeat;
  234. background-size: 100% 100%;
  235. overflow: hidden;
  236. border-bottom-left-radius: 40% 5%;
  237. border-bottom-right-radius: 40% 5%;
  238. .header {
  239. display: flex;
  240. align-items: center;
  241. padding: 40rpx;
  242. height: 300rpx;
  243. .avatar {
  244. width: 150rpx;
  245. height: 150rpx;
  246. margin-top: -40rpx;
  247. .avatar-img {
  248. width: 100%;
  249. height: 100%;
  250. border-radius: 50%;
  251. }
  252. }
  253. }
  254. .info {
  255. margin-left: 20rpx;
  256. display: flex;
  257. margin-top: -40rpx;
  258. flex-direction: column;
  259. justify-content: center;
  260. .name {
  261. font-size: 35rpx;
  262. font-weight: bold;
  263. }
  264. .desc {
  265. margin-top: 20rpx;
  266. min-width: 85rpx;
  267. background: #8b8b8b;
  268. font-size: 20rpx;
  269. color: white;
  270. padding: 5rpx 10rpx;
  271. border-radius: 12px;
  272. }
  273. }
  274. }
  275. .vip-card {
  276. display: flex;
  277. justify-content: flex-end;
  278. margin: -88rpx 20rpx 0 20rpx;
  279. padding: 20rpx;
  280. height: 80rpx;
  281. color: white;
  282. background: url("https://oss.dev.zonelife.cn/static/guida/img/my/vip.png") no-repeat;
  283. background-size: 100% 100%;
  284. border-radius: 10px 10px 0 0;
  285. .vip-btn {
  286. background: #fde9c7;
  287. padding: 20rpx 40rpx;
  288. line-height: 20rpx;
  289. height: 21rpx;
  290. color: #d6a873;
  291. border-radius: 17px;
  292. font-size: 30rpx;
  293. }
  294. }
  295. .grid-text {
  296. font-size: 14px;
  297. color: #909399;
  298. padding: 10rpx 0 20rpx 0rpx;
  299. /* #ifndef APP-PLUS */
  300. box-sizing: border-box;
  301. /* #endif */
  302. }
  303. .setting:not(:nth-child(1)) {
  304. font-size: 30rpx;
  305. font-weight: bold;
  306. // margin-top: 40rpx;
  307. background-color: white;
  308. border-radius: 20px;
  309. .setting-cell {
  310. margin-top: 40rpx;
  311. }
  312. }
  313. .btn-box {
  314. position: fixed;
  315. bottom: 15%;
  316. margin-left: 20rpx;
  317. width: 90%;
  318. height: 80rpx;
  319. background-color: rgba(#000000, 0.2);
  320. color: black;
  321. padding-left: 30rpx;
  322. line-height: 80rpx;
  323. font-size: 30rpx;
  324. border-radius: 5px;
  325. }
  326. }
  327. </style>