my.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="my-page">
  3. <view class="user-section">
  4. <!-- 自定义头部 -->
  5. <view class="custom-header" :style="{paddingTop: statusBarHeight + 'px'}">
  6. <view class="header-content">
  7. <view class="back-btn" @click="goBack">
  8. <u-icon name="arrow-left" color="#000000" size="20"></u-icon>
  9. </view>
  10. <text class="title">个人中心</text>
  11. <view class="placeholder"></view>
  12. </view>
  13. </view>
  14. <view class="bg"></view>
  15. <view class="user-info-box" :style="{marginTop: (statusBarHeight + 44) + 'px'}">
  16. <view class="portrait-box" @click="checkLogin">
  17. <image class="portrait" :src="userInfo.avatar || defaultAvatar" mode="aspectFill"></image>
  18. </view>
  19. <view class="info-box" @click="checkLogin">
  20. <text
  21. class="username ellipsis2">{{isLogin ? (userInfo.nickName || '用户' + userInfo.userId) : '请登录'}}</text>
  22. <text class="user-id" v-if="isLogin">ID: {{userInfo.userId}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="cover-container">
  27. <scroll-view scroll-y class="scroll-content" @scrolltolower="getGoodsProducts">
  28. <!-- 我的订单 -->
  29. <view v-if="orderMenu.length>0" class="order-section">
  30. <view class="sec-header" @click="navTo('/pages_user/user/storeOrder?status=')">
  31. <text class="sec-title">我的订单</text>
  32. <view class="more">
  33. <text>全部订单</text>
  34. <u-icon name="arrow-right" size="26rpx" color="#999"></u-icon>
  35. </view>
  36. </view>
  37. <view class="order-grid">
  38. <view class="order-item" v-for="(item, index) in orderMenu" :key="index"
  39. @click="handleMenu(item)">
  40. <image :src="item.icon" mode="aspectFit" class="order-icon"></image>
  41. <text>{{item.name}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 常用工具 -->
  46. <view v-if="toolMenu.length>0" class="order-section">
  47. <view class="sec-header">
  48. <text class="sec-title">常用工具</text>
  49. </view>
  50. <view class="order-grid" style="padding: 0;">
  51. <view class="order-item" style="width: 25%;" v-for="(item, index) in toolMenu" :key="index"
  52. @click="navToToolPages(item)">
  53. <image :src="item.icon" mode="aspectFit" class="order-icon" style="width: 52rpx;height: 52rpx;"></image>
  54. <text>{{item.name}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <view v-if="false" class="history-section icon">
  59. <view class="list-item" @click="navTo('/pages/user/address')">
  60. <image class="es-icon-48" src="/static/image/my/address_management_icon.png" mode=""></image>
  61. <text>地址管理</text>
  62. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  63. </view>
  64. <view class="list-item" @click="navTo('/pages_shopping/shopping/myCoupon')">
  65. <image class="es-icon-48" src="/static/image/my/coupon_collection.png" mode=""></image>
  66. <text>优惠券</text>
  67. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  68. </view>
  69. <view class="list-item" @click="navTo('/pages/user/about')">
  70. <image class="es-icon-48" src="/static/image/my/feedback_icon.png" mode=""></image>
  71. <text>关于我们</text>
  72. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  73. </view>
  74. <!-- <view class="list-item" @click="navTo('/pages/user/wallet/wallet')">
  75. <u-icon name="wallet" size="20" color="#e07472"></u-icon>
  76. <text>我的钱包</text>
  77. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  78. </view> -->
  79. <!-- <view class="list-item">
  80. <u-icon name="server-fill" size="20" color="#5fcda2"></u-icon>
  81. <text>联系客服</text>
  82. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  83. </view> -->
  84. <!-- <view class="list-item">
  85. <u-icon name="setting" size="20" color="#9789f7"></u-icon>
  86. <text>设置</text>
  87. <u-icon name="arrow-right" size="14" color="#999" class="arrow"></u-icon>
  88. </view> -->
  89. </view>
  90. <view class="login-btn" @click="showLogout">退出登录</view>
  91. <view v-if="likeGoodsList.length>0" class="like-product">
  92. <view class="likeTitleTextClass">猜你喜欢</view>
  93. <GoodsList :list="likeGoodsList" :loading="likeGoodsLoading" style="padding: 0;"
  94. :has-more="likeGoodsList.length >= total ? false :true" @itemClick="showProduct"
  95. @loadMore="getGoodsProducts" />
  96. </view>
  97. </scroll-view>
  98. </view>
  99. <view class="complaintViewClass" @click="navTo('/pages/user/feedback')">
  100. <image src="/static/image/my/complaint_icon.png" mode="aspectFill"></image>
  101. <view class="complaintViewTextClass">客服投诉</view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import IMSDK, {
  107. SessionType
  108. } from "openim-uniapp-polyfill";
  109. import {
  110. Igexin
  111. } from '@/pages_im/util/common.js';
  112. import {
  113. getUserInfo
  114. } from '@/api/user'
  115. import GoodsList from './components/GoodsList.vue'
  116. import {
  117. getGoodsProducts
  118. } from '@/api/product'
  119. export default {
  120. data() {
  121. return {
  122. statusBarHeight: 20,
  123. defaultAvatar: '/static/image/hall/my_heads_icon.png',
  124. isLogin: false,
  125. userInfo: {},
  126. orderMenu: [{
  127. name: '待付款',
  128. icon: '/static/image/mall/payment.png',
  129. state: 0
  130. },
  131. {
  132. name: '待发货',
  133. icon: '/static/image/mall/send_goods.png',
  134. state: 1
  135. },
  136. {
  137. name: '待收货',
  138. icon: '/static/image/mall/sou_goods.png',
  139. state: 2
  140. },
  141. {
  142. name: '已完成',
  143. icon: '/static/image/mall/completed.png',
  144. state: 3
  145. },
  146. {
  147. name: '售后/退款',
  148. icon: '/static/image/mall/after_sales.png',
  149. url: '/pages_user/user/refundOrderList'
  150. }
  151. ],
  152. toolMenu: [{
  153. name: '收货地址',
  154. icon: '/static/image/my/address_management_icon.png',
  155. url: '/pages_user/user/address'
  156. },
  157. {
  158. name: '积分商城',
  159. icon: '/static/image/my/points_mall.png',
  160. url: '/pages_points/integralGoodsList'
  161. },
  162. {
  163. name: '优惠券',
  164. icon: "/static/image/my/coupon_collection.png",
  165. url: "/pages_shopping/shopping/myCoupon"
  166. },
  167. {
  168. name: '我的足迹',
  169. icon: '/static/image/my/my_footprints.png',
  170. url: '/pages_user/user/storeProductRelation'
  171. },
  172. {
  173. name: '专属客服',
  174. icon: '/static/image/my/customer_service.png',
  175. isService: true,
  176. url: ''
  177. },
  178. {
  179. name: '制单管理',
  180. icon: '/static/image/my/document_management.png',
  181. documentPreparation: true,
  182. url: ''
  183. },
  184. {
  185. name: '销售管理',
  186. icon: '/static/image/my/sales_management.png',
  187. salesManagement: true,
  188. url: ''
  189. },
  190. ],
  191. likeGoodsList: [],
  192. likeGoodsLoading: false,
  193. likeGoodsHasMore: false,
  194. page: {
  195. page: 1,
  196. pageSize: 10
  197. },
  198. total: 0,
  199. }
  200. },
  201. components: {
  202. GoodsList
  203. },
  204. created() {
  205. this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  206. this.checkLoginStatus();
  207. this.getGoodsProducts()
  208. },
  209. methods: {
  210. showLogout() {
  211. //this.show=true;
  212. let that = this;
  213. uni.showActionSheet({
  214. title: "确认退出吗",
  215. itemList: ["确定"],
  216. success: function(res) {
  217. that.logout();
  218. that.isLogin = that.$isLogin()
  219. // uni.navigateTo({
  220. // url: '/pages/auth/loginIndex'
  221. // })
  222. }
  223. });
  224. },
  225. logout() {
  226. uni.clearStorage()
  227. this.$logout();
  228. let IMUserID = uni.getStorageSync('IMUserID');
  229. IMSDK.asyncApi(IMSDK.IMMethods.Logout, IMSDK.uuid()).then(() => {
  230. callingModule?.endCall();
  231. meetingModule?.endCall();
  232. }).catch((err) => console.log(err))
  233. .finally(() => {
  234. Igexin.unbindAlias(IMUserID);
  235. uni.removeStorage({
  236. key: "IMToken"
  237. });
  238. uni.removeStorage({
  239. key: "IMUserID"
  240. });
  241. uni.removeStorage({
  242. key: "IMHasLogin"
  243. });
  244. });
  245. this.user = this.defUser;
  246. this.coupons.expiredCount = 0;
  247. this.coupons.notUsedCount = 0;
  248. this.coupons.usedCount = 0;
  249. },
  250. getGoodsProducts() {
  251. var that = this;
  252. if (that.likeGoodsHasMore == true || that.likeGoodsLoading == true) return;
  253. that.likeGoodsLoading = true;
  254. uni.showLoading({
  255. title: "加载中..."
  256. })
  257. getGoodsProducts(that.page).then(
  258. res => {
  259. if (res.code == 200) {
  260. that.total = res.data.total;
  261. that.likeGoodsList.push.apply(that.likeGoodsList, res.data.list);
  262. that.likeGoodsLoading = false;
  263. that.likeGoodsHasMore = that.likeGoodsList.length < that.total ? false : true;
  264. that.page.page = that.page.page + 1;
  265. uni.hideLoading()
  266. }
  267. },
  268. err => {
  269. uni.hideLoading()
  270. uni.showToast({
  271. title: err.msg,
  272. icon: 'none',
  273. duration: 2000
  274. });
  275. }
  276. );
  277. },
  278. showProduct(item) {
  279. uni.navigateTo({
  280. url: '/pages/shopping/productDetails?productId=' + item.productId
  281. })
  282. },
  283. goBack() {
  284. uni.showTabBar()
  285. uni.switchTab({
  286. //url: '/pages_im/pages/conversation/conversationList/index'
  287. url: '/pages/index/index'
  288. })
  289. },
  290. checkLoginStatus() {
  291. const token = uni.getStorageSync('AppToken');
  292. if (token) {
  293. this.isLogin = true;
  294. this.getUserInfo();
  295. } else {
  296. this.isLogin = false;
  297. this.userInfo = {};
  298. }
  299. },
  300. checkLogin() {
  301. if (!this.isLogin) {
  302. uni.navigateTo({
  303. url: '/pages/auth/loginIndex'
  304. });
  305. }
  306. },
  307. getUserInfo() {
  308. getUserInfo().then(res => {
  309. if (res.code == 200 && res.user) {
  310. this.userInfo = res.user;
  311. }
  312. });
  313. },
  314. navTo(url) {
  315. uni.navigateTo({
  316. url: url
  317. });
  318. },
  319. navToToolPages(e) {
  320. if (e.isService && !e.url) {
  321. this.toCompany()
  322. return
  323. }
  324. if (e.documentPreparation && !e.url) {
  325. this.documentPreparationFun()
  326. return
  327. }
  328. if (e.salesManagement && !e.url) {
  329. this.toManagerCourse()
  330. return
  331. }
  332. uni.navigateTo({
  333. url: e.url
  334. });
  335. },
  336. documentPreparationFun() {
  337. if (this.$checkCompanyUserLoginState()) {
  338. uni.navigateTo({
  339. url: '/pages_company/index'
  340. })
  341. } else {
  342. uni.navigateTo({
  343. url: '/pages_company/auth/login'
  344. })
  345. }
  346. },
  347. toManagerCourse() {
  348. if (uni.getStorageSync('ManageToken')) {
  349. uni.navigateTo({
  350. url: '/pages_manage/index'
  351. })
  352. } else {
  353. uni.navigateTo({
  354. url: '/pages_manage/login'
  355. })
  356. }
  357. },
  358. toCompany() {
  359. if (this.$isLogin()) {
  360. var token = uni.getStorageSync('CompanyUserToken');
  361. if (token) {
  362. uni.navigateTo({
  363. url: '/pages/company/index'
  364. })
  365. } else {
  366. uni.navigateTo({
  367. url: '/pages/company/login'
  368. })
  369. }
  370. } else {
  371. this.$showLoginPage();
  372. }
  373. },
  374. handleMenu(item) {
  375. if (!this.isLogin) {
  376. uni.navigateTo({
  377. url: '/pages/auth/loginIndex'
  378. });
  379. return;
  380. }
  381. if (item.url) {
  382. return uni.navigateTo({
  383. url: item.url
  384. });
  385. }
  386. uni.navigateTo({
  387. url: `/pages_user/user/storeOrder?status=${item.state}`
  388. })
  389. }
  390. }
  391. }
  392. </script>
  393. <style scoped lang="scss">
  394. @mixin u-flex($flexD, $alignI, $justifyC) {
  395. display: flex;
  396. flex-direction: $flexD;
  397. align-items: $alignI;
  398. justify-content: $justifyC;
  399. }
  400. .my-page {
  401. height: 100%;
  402. background-color: #F4F6F7;
  403. position: relative;
  404. }
  405. .custom-header {
  406. position: absolute;
  407. top: 0;
  408. left: 0;
  409. right: 0;
  410. z-index: 10;
  411. .header-content {
  412. height: 44px;
  413. display: flex;
  414. align-items: center;
  415. justify-content: space-between;
  416. padding: 0 24rpx;
  417. .title {
  418. font-size: 34rpx;
  419. color: #070707;
  420. }
  421. .back-btn,
  422. .placeholder {
  423. width: 40rpx;
  424. height: 40rpx;
  425. display: flex;
  426. align-items: center;
  427. justify-content: center;
  428. }
  429. }
  430. }
  431. .user-section {
  432. height: 430rpx;
  433. position: relative;
  434. overflow: hidden;
  435. .bg {
  436. position: absolute;
  437. left: 0;
  438. top: 0;
  439. width: 100%;
  440. height: 100%;
  441. // background: linear-gradient(to bottom, #FF233C, #FFF5F5);
  442. background-image: url("@/static/images/bg.png");
  443. background-size: contain;
  444. background-repeat: no-repeat;
  445. background-position: top;
  446. }
  447. .user-info-box {
  448. display: flex;
  449. align-items: center;
  450. position: relative;
  451. z-index: 1;
  452. padding: 0 46rpx;
  453. .portrait-box {
  454. width: 150rpx;
  455. height: 150rpx;
  456. border: 4rpx solid #FFFFFF;
  457. border-radius: 50%;
  458. overflow: hidden;
  459. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  460. background: #fff;
  461. .portrait {
  462. width: 100%;
  463. height: 100%;
  464. }
  465. }
  466. .info-box {
  467. width: calc(100vw - 260rpx);
  468. display: flex;
  469. flex-direction: column;
  470. margin-left: 20rpx;
  471. .username {
  472. font-size: 40rpx;
  473. font-weight: bold;
  474. color: #000000D9;
  475. text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  476. }
  477. .user-id {
  478. font-size: 32rpx;
  479. color: rgba(0, 0, 0, 0.85);
  480. margin-top: 20rpx;
  481. }
  482. }
  483. }
  484. }
  485. .cover-container {
  486. margin-top: -70rpx;
  487. padding: 0 24rpx;
  488. position: relative;
  489. padding-bottom: 120rpx;
  490. .order-section {
  491. background: #fff;
  492. border-radius: 24rpx;
  493. padding: 30rpx 24rpx 40rpx 24rpx;
  494. margin-bottom: 30rpx;
  495. .sec-header {
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. .sec-title {
  500. font-weight: bold;
  501. font-size: 40rpx;
  502. color: rgba(0, 0, 0, 0.85);
  503. }
  504. .more {
  505. display: flex;
  506. align-items: center;
  507. text {
  508. font-size: 32rpx;
  509. color: rgba(0, 0, 0, 0.65);
  510. margin-right: 10rpx;
  511. }
  512. }
  513. }
  514. .order-grid {
  515. display: flex;
  516. // justify-content: space-around;
  517. flex-wrap: wrap;
  518. padding: 0 10rpx;
  519. .order-item {
  520. width: 33.3%;
  521. display: flex;
  522. flex-direction: column;
  523. align-items: center;
  524. margin-top: 30rpx;
  525. .order-icon {
  526. width: 60rpx;
  527. height: 60rpx;
  528. margin-bottom: 10rpx;
  529. }
  530. text {
  531. font-size: 36rpx;
  532. color: rgba(0, 0, 0, 0.85);
  533. }
  534. }
  535. }
  536. }
  537. .history-section {
  538. background: #fff;
  539. border-radius: 20rpx;
  540. margin-top: 24rpx;
  541. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  542. padding: 10rpx 0;
  543. .list-item {
  544. display: flex;
  545. align-items: center;
  546. padding: 30rpx 30rpx;
  547. border-bottom: 1rpx solid #f5f5f5;
  548. position: relative;
  549. &:last-child {
  550. border-bottom: none;
  551. }
  552. text {
  553. flex: 1;
  554. font-size: 30rpx;
  555. color: #333;
  556. margin-left: 24rpx;
  557. font-weight: 500;
  558. }
  559. .arrow {
  560. margin-left: auto;
  561. opacity: 0.5;
  562. }
  563. }
  564. }
  565. }
  566. .scroll-content {
  567. height: calc(100vh - 450rpx);
  568. }
  569. .login-btn {
  570. display: flex;
  571. align-items: center;
  572. justify-content: center;
  573. flex: 1;
  574. height: 110rpx;
  575. background: #fff;
  576. border-radius: 24rpx;
  577. font-family: PingFang SC;
  578. font-weight: 400;
  579. font-size: 36rpx;
  580. color: rgba(0, 0, 0, 0.65);
  581. }
  582. .like-product {
  583. width: 100%;
  584. margin-top: 40rpx;
  585. }
  586. .likeTitleTextClass {
  587. font-weight: bold;
  588. font-size: 40rpx;
  589. color: #222222;
  590. margin-bottom: 30rpx;
  591. }
  592. .complaintViewClass {
  593. @include u-flex(column, center, center);
  594. position: fixed;
  595. right: 22rpx;
  596. bottom: 400rpx;
  597. image {
  598. width: 132rpx;
  599. height: 112rpx;
  600. }
  601. .complaintViewTextClass {
  602. @include u-flex(row, center, center);
  603. width: 152rpx;
  604. height: 52rpx;
  605. background: linear-gradient(135deg, #FF5B6E 1.51%, #FC1D37 100%);
  606. border-radius: 26rpx;
  607. font-family: DOUYINSANSBOLD, DOUYINSANSBOLD;
  608. font-weight: normal;
  609. font-size: 30rpx;
  610. color: #FFFFFF;
  611. margin-top: -13rpx;
  612. z-index: 10;
  613. }
  614. }
  615. </style>