index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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${levelImgNameObj[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 title="订阅" @click="Subscribe" :border="false" :isLink="true" arrow-direction="right">
  90. <image slot="icon" class="cell-icon" src="../../static/service-icon.png" mode=""></image>
  91. </u-cell> -->
  92. </u-cell-group>
  93. </view>
  94. </template>
  95. <script>
  96. import {
  97. getUserDetail
  98. } from '@/api/common.js'
  99. import {mealList} from '@/api/combo.js'
  100. import {levelImgName} from '@/utils/config.js'
  101. export default {
  102. data() {
  103. return {
  104. active: 1,
  105. keyword: '',
  106. userId: '',
  107. loading: false,
  108. status: 'more',
  109. 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',
  110. userInfo: {
  111. imgPath: null,
  112. lastLogin: "",
  113. level: null,
  114. nickname: null,
  115. openId: "",
  116. phoneNum: "",
  117. sex: 0,
  118. userId: "",
  119. valid: 0,
  120. setMealCode:0
  121. },
  122. levelImgNameObj:levelImgName,
  123. list:[],//套餐列表
  124. }
  125. },
  126. onShow() {
  127. if (uni.getStorageSync('token')) {
  128. this.getUserDetail()
  129. }else{
  130. this.userInfo = {
  131. imgPath: null,
  132. lastLogin: "",
  133. level: null,
  134. nickname: null,
  135. openId: "",
  136. phoneNum: "",
  137. sex: 0,
  138. userId: "",
  139. valid: 0
  140. },
  141. uni.showModal({
  142. title:'请登录',
  143. confirmText:'去登录',
  144. success(res){
  145. if(res.confirm){
  146. uni.navigateTo({
  147. url:'../../login/login/login?redirect=/pages/my/index'
  148. })
  149. }
  150. }
  151. })
  152. }
  153. },
  154. onLoad() {
  155. this.mealList()
  156. },
  157. methods: {
  158. Subscribe(){
  159. wx.requestSubscribeMessage({
  160. tmplIds: ['2MWtGXO1dOgEieVbIoBicAdLUj945Nv__4K2vh-Pk9Q'],
  161. success (res) {
  162. console.log(res);
  163. uni.showToast({
  164. title:'订阅成功'
  165. })
  166. },
  167. fail(){
  168. uni.showToast({
  169. title:'订阅失败'
  170. })
  171. }
  172. })
  173. },
  174. filterMeal(val) {
  175. let color
  176. let bgColor
  177. let setMealName
  178. this.list.filter(item=>{
  179. if(item.setMealCode == val){
  180. color = item.colour
  181. bgColor = item.backColour
  182. setMealName = item.setMealName
  183. }
  184. })
  185. return {
  186. color,bgColor,setMealName
  187. }
  188. },
  189. // 点击设置
  190. setting() {
  191. if (uni.getStorageSync('token')) {
  192. uni.navigateTo({
  193. url: '../../my/edit/edit'
  194. })
  195. } else {
  196. uni.showModal({
  197. title:'请登录',
  198. confirmText:'去登录',
  199. success(res){
  200. console.log(res);
  201. if(res.confirm){
  202. uni.navigateTo({
  203. url:'../../login/login/login?redirect=/pages/my/index'
  204. })
  205. }
  206. }
  207. })
  208. }
  209. },
  210. jump(url) {
  211. if(!uni.getStorageSync('token')){
  212. return uni.showModal({
  213. title:'请登录',
  214. confirmText:'去登录',
  215. success(res){
  216. console.log(res);
  217. if(res.confirm){
  218. uni.navigateTo({
  219. url:'../../login/login/login?redirect=/pages/my/index'
  220. })
  221. }
  222. }
  223. })
  224. }
  225. uni.navigateTo({
  226. url
  227. })
  228. },
  229. // 获取用户详情
  230. getUserDetail() {
  231. getUserDetail().then(res => {
  232. if(res.state == 'Success'){
  233. this.userInfo = res.content
  234. uni.setStorageSync('userInfo', JSON.stringify(this.userInfo))
  235. }
  236. })
  237. },
  238. // 获取套餐列表
  239. mealList(){
  240. mealList({currentPage:1,pageSize:99,status:1}).then(res=>{
  241. if (res.state == 'Success') {
  242. this.list = res.content.records
  243. }
  244. })
  245. },
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. .my {
  251. height: 100vh;
  252. padding: 0 24rpx;
  253. background: #F9F9F9;
  254. .top-box {
  255. width: 750rpx;
  256. height: 460rpx;
  257. margin-left: -24rpx;
  258. padding: 150rpx 30rpx 0;
  259. box-sizing: border-box;
  260. background: url('https://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/CXvU8kSyyCxUe83c049e4ddb2b66e0c80f6cb5c6b4b1.png/1.png') no-repeat;
  261. background-size: 100% 460rpx;
  262. position: relative;
  263. .user-info {
  264. display: flex;
  265. align-items: center;
  266. justify-content: space-between;
  267. padding: 15rpx 0;
  268. color: #222222;
  269. .image {
  270. width: 108rpx;
  271. height: 108rpx;
  272. background: #f1f1f1;
  273. border-radius: 50%;
  274. }
  275. .info {
  276. flex: 1;
  277. margin-left: 30rpx;
  278. .user-name {
  279. font-size: 32rpx;
  280. font-weight: bold;
  281. }
  282. .tel {
  283. font-size: 20rpx;
  284. margin-top: 10rpx;
  285. display: inline-block;
  286. padding: 0 12rpx;
  287. line-height: 36rpx;
  288. border-radius: 18rpx 18rpx 18rpx 18rpx;
  289. box-sizing: border-box;
  290. background: #423625;
  291. color: #F3CC90;
  292. }
  293. }
  294. .setting {
  295. width: 40rpx;
  296. height: 40rpx;
  297. }
  298. }
  299. .level-box {
  300. position: absolute;
  301. left: 0;
  302. bottom: -24rpx;
  303. padding: 0 35rpx 22rpx;
  304. width: 750rpx;
  305. box-sizing: border-box;
  306. .level-content {
  307. width: 702rpx;
  308. height: 134rpx;
  309. position: absolute;
  310. bottom: 0rpx;
  311. left: 50%;
  312. transform: translateX(-50%);
  313. .level {
  314. width: 702rpx;
  315. height: 134rpx;
  316. }
  317. .num {
  318. font-size: 28rpx;
  319. color: #F3CC90;
  320. position: absolute;
  321. right: 25rpx;
  322. top: 30rpx;
  323. }
  324. }
  325. }
  326. }
  327. .box{
  328. background: #fff;
  329. padding-top: 10rpx;
  330. .box-title{
  331. font-size: 32rpx;
  332. font-weight: bold;
  333. color: #222222;
  334. padding-top: 20rpx;
  335. margin-left: 24rpx;
  336. }
  337. .btn-group {
  338. display: flex;
  339. align-items: center;
  340. padding: 30rpx 20rpx;
  341. // margin-top: 20rpx;
  342. border-radius: 0 0 16rpx 16rpx;
  343. width: 690rpx;
  344. box-sizing: border-box;
  345. .item {
  346. flex: 1;
  347. display: flex;
  348. flex-direction: column;
  349. align-items: center;
  350. .icon {
  351. width: 100rpx;
  352. height: 100rpx;
  353. }
  354. .label {
  355. font-size: 24rpx;
  356. color: #121212;
  357. }
  358. }
  359. }
  360. }
  361. .type-box {
  362. display: flex;
  363. justify-content: space-between;
  364. .type-item+.type-item{
  365. background: linear-gradient( 91deg, rgba(132,176,255,0.2) 0%, #FFFFFF 100%);
  366. }
  367. .type-item {
  368. width: 335rpx;
  369. border-radius: 16rpx;
  370. background: linear-gradient( 91deg, rgba(254,198,92,0.3) 0%, #FFFFFF 100%);
  371. padding: 32rpx 24rpx;
  372. margin-top: 20rpx;
  373. box-sizing: border-box;
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. .left {
  378. .title {
  379. font-weight: bold;
  380. color: #181818;
  381. font-size: 32rpx;
  382. }
  383. .desc {
  384. color: #AAAAAA;
  385. font-size: 24rpx;
  386. margin-top: 16rpx;
  387. }
  388. }
  389. .icon {
  390. width: 80rpx;
  391. height: 80rpx;
  392. }
  393. }
  394. }
  395. .cell-icon {
  396. width: 48rpx;
  397. height: 48rpx;
  398. }
  399. .u-cell-group {
  400. margin-top: 20rpx;
  401. background: #fff;
  402. }
  403. }
  404. </style>