index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <view class="my">
  3. <view class="top-box">
  4. <view class="user-info">
  5. <image class="image" :src="userInfo.imgPath || defaultImg" lazy-load mode=""></image>
  6. <view class="info">
  7. <view class="user-name">{{userInfo.nickname ||'用户'}}</view>
  8. <view class="tel">{{userInfo.phoneNum ||'-'}}</view>
  9. </view>
  10. <image class="setting" src="../../static/setting.png" @click="setting" mode=""></image>
  11. </view>
  12. <view class="level-box">
  13. <view class="level-content">
  14. <image class="level" :src="`../../static/level${userInfo.setMealId || 0}.png`" mode=""></image>
  15. <view class="num" :style="{color:filterMeal(userInfo.setMealId)}">
  16. 已为您节省0元
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="btn-group">
  22. <view class="item" @click="jump('../../my/order/index')">
  23. <image class="icon" src="../../static/icon1.png" mode=""></image>
  24. <view class="label">
  25. 全部订单
  26. </view>
  27. </view>
  28. <view class="item" @click="jump('../../my/order/index?type=WAIT_PAYMENT')">
  29. <image class="icon" src="../../static/icon2.png" mode=""></image>
  30. <view class="label">
  31. 待付款
  32. </view>
  33. </view>
  34. <view class="item" @click="jump('../../my/order/index?type=WAIT_USE')">
  35. <image class="icon" src="../../static/icon3.png" mode=""></image>
  36. <view class="label">
  37. 待使用
  38. </view>
  39. </view>
  40. <view class="item" @click="jump('../../my/order/index?type=APPLY_REFUND')">
  41. <image class="icon" src="../../static/icon4.png" mode=""></image>
  42. <view class="label">
  43. 退款
  44. </view>
  45. </view>
  46. </view>
  47. <view class="type-box">
  48. <view class="type-item" @click="jump('../../my/memberCenter/index')">
  49. <view class="left">
  50. <view class="title">
  51. 会员中心
  52. </view>
  53. <view class="desc">
  54. 会员享受更多优惠
  55. </view>
  56. </view>
  57. <image class="icon" src="../../static/type-icon1.png" mode=""></image>
  58. </view>
  59. <view class="type-item" @click="jump('/invite/index')">
  60. <view class="left">
  61. <view class="title">
  62. 推广邀请
  63. </view>
  64. <view class="desc">
  65. 百万佣金发放中
  66. </view>
  67. </view>
  68. <image class="icon" src="../../static/type-icon2.png" mode=""></image>
  69. </view>
  70. </view>
  71. <u-cell-group :border="false">
  72. <!-- <u-cell title="优惠券" @click="jump('../../my/coupon/index')" :border="false" :isLink="true" arrow-direction="right">
  73. <image slot="icon" class="cell-icon" src="../../static/icon7.png" mode=""></image>
  74. </u-cell> -->
  75. <u-cell title="研学MBTI测试" @click="jump('../../study/test')" :border="false" :isLink="true" arrow-direction="right">
  76. <image slot="icon" class="cell-icon" src="../../static/icon8.png" mode=""></image>
  77. </u-cell>
  78. </u-cell-group>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. getUserDetail
  84. } from '@/api/common.js'
  85. export default {
  86. data() {
  87. return {
  88. active: 1,
  89. keyword: '',
  90. userId: '',
  91. loading: false,
  92. status: 'more',
  93. defaultImg: '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',
  94. userInfo: {
  95. imgPath: null,
  96. lastLogin: "",
  97. level: null,
  98. nickname: null,
  99. openId: "",
  100. phoneNum: "",
  101. sex: 0,
  102. userId: "",
  103. valid: 0
  104. },
  105. }
  106. },
  107. onShow() {
  108. if (uni.getStorageSync('token')) {
  109. this.getUserDetail()
  110. }else{
  111. this.userInfo = {
  112. imgPath: null,
  113. lastLogin: "",
  114. level: null,
  115. nickname: null,
  116. openId: "",
  117. phoneNum: "",
  118. sex: 0,
  119. userId: "",
  120. valid: 0
  121. },
  122. uni.showModal({
  123. title:'请登录',
  124. confirmText:'去登录',
  125. success(res){
  126. console.log(res);
  127. if(res.confirm){
  128. uni.navigateTo({
  129. url:'../../login/login/login'
  130. })
  131. }
  132. }
  133. })
  134. }
  135. },
  136. onLoad() {
  137. },
  138. methods: {
  139. filterMeal(val) {
  140. if(val == 1){
  141. return '#3E5C91'
  142. }else if(val == 2){
  143. return '#FF532A'
  144. }else if(val == 3){
  145. return '#F3CC90'
  146. }
  147. },
  148. // 点击设置
  149. setting() {
  150. if (uni.getStorageSync('token')) {
  151. uni.navigateTo({
  152. url: '../../my/edit/edit'
  153. })
  154. } else {
  155. uni.showModal({
  156. title:'请登录',
  157. confirmText:'去登录',
  158. success(res){
  159. console.log(res);
  160. if(res.confirm){
  161. uni.navigateTo({
  162. url:'../../login/login/login?redirect=/pages/my/index'
  163. })
  164. }
  165. }
  166. })
  167. }
  168. },
  169. jump(url) {
  170. if(!uni.getStorageSync('token')){
  171. return uni.showModal({
  172. title:'请登录',
  173. confirmText:'去登录',
  174. success(res){
  175. console.log(res);
  176. if(res.confirm){
  177. uni.navigateTo({
  178. url:'../../login/login/login?redirect=/pages/my/index'
  179. })
  180. }
  181. }
  182. })
  183. }
  184. uni.navigateTo({
  185. url
  186. })
  187. },
  188. // 获取用户详情
  189. getUserDetail() {
  190. getUserDetail().then(res => {
  191. if(res.state == 'Success'){
  192. this.userInfo = res.content
  193. uni.setStorageSync('userInfo', JSON.stringify(this.userInfo))
  194. }
  195. })
  196. },
  197. }
  198. }
  199. </script>
  200. <style lang="scss">
  201. .my {
  202. height: 100vh;
  203. padding: 0 30rpx;
  204. background: #F9F9F9;
  205. .top-box {
  206. width: 750rpx;
  207. height: 460rpx;
  208. margin-left: -30rpx;
  209. padding: 150rpx 30rpx 0;
  210. box-sizing: border-box;
  211. background: url('../../static/top-bg.png') no-repeat;
  212. background-size: 100% 500rpx;
  213. position: relative;
  214. .user-info {
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. padding: 15rpx 0;
  219. color: #222222;
  220. .image {
  221. width: 108rpx;
  222. height: 108rpx;
  223. background: #f1f1f1;
  224. border-radius: 50%;
  225. }
  226. .info {
  227. flex: 1;
  228. margin-left: 30rpx;
  229. .user-name {
  230. font-size: 32rpx;
  231. font-weight: bold;
  232. }
  233. .tel {
  234. font-size: 24rpx;
  235. margin-top: 10rpx;
  236. }
  237. }
  238. .setting {
  239. width: 60rpx;
  240. height: 60rpx;
  241. }
  242. }
  243. .level-box {
  244. position: absolute;
  245. left: 0;
  246. bottom: 0;
  247. padding: 0 35rpx 22rpx;
  248. width: 750rpx;
  249. box-sizing: border-box;
  250. .level-content {
  251. width: 686rpx;
  252. height: 100rpx;
  253. position: absolute;
  254. bottom: 0rpx;
  255. left: 50%;
  256. transform: translateX(-50%);
  257. .level {
  258. width: 100%;
  259. height: 100%;
  260. }
  261. .num {
  262. font-size: 28rpx;
  263. color: #F3CC90;
  264. position: absolute;
  265. right: 25rpx;
  266. top: 50%;
  267. transform: translateY(-50%);
  268. }
  269. }
  270. }
  271. }
  272. .btn-group {
  273. display: flex;
  274. align-items: center;
  275. padding: 30rpx 20rpx;
  276. margin-top: 20rpx;
  277. border-radius: 16rpx;
  278. background: #fff;
  279. width: 690rpx;
  280. box-sizing: border-box;
  281. .item {
  282. flex: 1;
  283. display: flex;
  284. flex-direction: column;
  285. align-items: center;
  286. .icon {
  287. width: 100rpx;
  288. height: 100rpx;
  289. }
  290. .label {
  291. font-size: 24rpx;
  292. color: #121212;
  293. }
  294. }
  295. }
  296. .type-box {
  297. display: flex;
  298. justify-content: space-between;
  299. .type-item {
  300. width: 335rpx;
  301. border-radius: 16rpx;
  302. background: #FFFFFF;
  303. padding: 32rpx 24rpx;
  304. margin-top: 20rpx;
  305. box-sizing: border-box;
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. .left {
  310. .title {
  311. font-weight: bold;
  312. color: #181818;
  313. font-size: 32rpx;
  314. }
  315. .desc {
  316. color: #AAAAAA;
  317. font-size: 24rpx;
  318. margin-top: 16rpx;
  319. }
  320. }
  321. .icon {
  322. width: 80rpx;
  323. height: 80rpx;
  324. }
  325. }
  326. }
  327. .cell-icon {
  328. width: 48rpx;
  329. height: 48rpx;
  330. }
  331. .u-cell-group {
  332. margin-top: 20rpx;
  333. background: #fff;
  334. }
  335. }
  336. </style>