index.vue 9.6 KB

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