my.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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/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.documentPreparationFun()
  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. toCompany() {
  348. if (this.$isLogin()) {
  349. var token = uni.getStorageSync('CompanyUserToken');
  350. if (token) {
  351. uni.navigateTo({
  352. url: '/pages/company/index'
  353. })
  354. } else {
  355. uni.navigateTo({
  356. url: '/pages/company/login'
  357. })
  358. }
  359. } else {
  360. this.$showLoginPage();
  361. }
  362. },
  363. handleMenu(item) {
  364. if (!this.isLogin) {
  365. uni.navigateTo({
  366. url: '/pages/auth/loginIndex'
  367. });
  368. return;
  369. }
  370. if (item.url) {
  371. return uni.navigateTo({
  372. url: item.url
  373. });
  374. }
  375. uni.navigateTo({
  376. url: `/pages_user/user/storeOrder?status=${item.state}`
  377. })
  378. }
  379. }
  380. }
  381. </script>
  382. <style scoped lang="scss">
  383. @mixin u-flex($flexD, $alignI, $justifyC) {
  384. display: flex;
  385. flex-direction: $flexD;
  386. align-items: $alignI;
  387. justify-content: $justifyC;
  388. }
  389. .my-page {
  390. height: 100%;
  391. background-color: #F4F6F7;
  392. position: relative;
  393. }
  394. .custom-header {
  395. position: absolute;
  396. top: 0;
  397. left: 0;
  398. right: 0;
  399. z-index: 10;
  400. .header-content {
  401. height: 44px;
  402. display: flex;
  403. align-items: center;
  404. justify-content: space-between;
  405. padding: 0 24rpx;
  406. .title {
  407. font-size: 34rpx;
  408. color: #070707;
  409. }
  410. .back-btn,
  411. .placeholder {
  412. width: 40rpx;
  413. height: 40rpx;
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. }
  418. }
  419. }
  420. .user-section {
  421. height: 430rpx;
  422. position: relative;
  423. overflow: hidden;
  424. .bg {
  425. position: absolute;
  426. left: 0;
  427. top: 0;
  428. width: 100%;
  429. height: 100%;
  430. // background: linear-gradient(to bottom, #FF233C, #FFF5F5);
  431. background-image: url("@/static/images/bg.png");
  432. background-size: contain;
  433. background-repeat: no-repeat;
  434. background-position: top;
  435. }
  436. .user-info-box {
  437. display: flex;
  438. align-items: center;
  439. position: relative;
  440. z-index: 1;
  441. padding: 0 46rpx;
  442. .portrait-box {
  443. width: 150rpx;
  444. height: 150rpx;
  445. border: 4rpx solid #FFFFFF;
  446. border-radius: 50%;
  447. overflow: hidden;
  448. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
  449. background: #fff;
  450. .portrait {
  451. width: 100%;
  452. height: 100%;
  453. }
  454. }
  455. .info-box {
  456. width: calc(100vw - 260rpx);
  457. display: flex;
  458. flex-direction: column;
  459. margin-left: 20rpx;
  460. .username {
  461. font-size: 40rpx;
  462. font-weight: bold;
  463. color: #000000D9;
  464. text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
  465. }
  466. .user-id {
  467. font-size: 32rpx;
  468. color: rgba(0, 0, 0, 0.85);
  469. margin-top: 20rpx;
  470. }
  471. }
  472. }
  473. }
  474. .cover-container {
  475. margin-top: -110rpx;
  476. padding: 0 24rpx;
  477. position: relative;
  478. padding-bottom: 120rpx;
  479. .order-section {
  480. background: #fff;
  481. border-radius: 24rpx;
  482. padding: 30rpx 24rpx 40rpx 24rpx;
  483. margin-bottom: 30rpx;
  484. .sec-header {
  485. display: flex;
  486. justify-content: space-between;
  487. align-items: center;
  488. .sec-title {
  489. font-weight: bold;
  490. font-size: 40rpx;
  491. color: rgba(0, 0, 0, 0.85);
  492. }
  493. .more {
  494. display: flex;
  495. align-items: center;
  496. text {
  497. font-size: 32rpx;
  498. color: rgba(0, 0, 0, 0.65);
  499. margin-right: 10rpx;
  500. }
  501. }
  502. }
  503. .order-grid {
  504. display: flex;
  505. // justify-content: space-around;
  506. flex-wrap: wrap;
  507. padding: 0 10rpx;
  508. .order-item {
  509. width: 33.3%;
  510. display: flex;
  511. flex-direction: column;
  512. align-items: center;
  513. margin-top: 30rpx;
  514. .order-icon {
  515. width: 60rpx;
  516. height: 60rpx;
  517. margin-bottom: 10rpx;
  518. }
  519. text {
  520. font-size: 36rpx;
  521. color: rgba(0, 0, 0, 0.85);
  522. }
  523. }
  524. }
  525. }
  526. .history-section {
  527. background: #fff;
  528. border-radius: 20rpx;
  529. margin-top: 24rpx;
  530. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  531. padding: 10rpx 0;
  532. .list-item {
  533. display: flex;
  534. align-items: center;
  535. padding: 30rpx 30rpx;
  536. border-bottom: 1rpx solid #f5f5f5;
  537. position: relative;
  538. &:last-child {
  539. border-bottom: none;
  540. }
  541. text {
  542. flex: 1;
  543. font-size: 30rpx;
  544. color: #333;
  545. margin-left: 24rpx;
  546. font-weight: 500;
  547. }
  548. .arrow {
  549. margin-left: auto;
  550. opacity: 0.5;
  551. }
  552. }
  553. }
  554. }
  555. .scroll-content {
  556. height: calc(100vh - 450rpx);
  557. }
  558. .login-btn {
  559. display: flex;
  560. align-items: center;
  561. justify-content: center;
  562. flex: 1;
  563. height: 110rpx;
  564. background: #fff;
  565. border-radius: 24rpx;
  566. font-family: PingFang SC;
  567. font-weight: 400;
  568. font-size: 36rpx;
  569. color: rgba(0, 0, 0, 0.65);
  570. }
  571. .like-product {
  572. width: 100%;
  573. margin-top: 40rpx;
  574. }
  575. .likeTitleTextClass {
  576. font-weight: bold;
  577. font-size: 40rpx;
  578. color: #222222;
  579. margin-bottom: 30rpx;
  580. }
  581. .complaintViewClass {
  582. @include u-flex(column, center, center);
  583. position: fixed;
  584. right: 22rpx;
  585. bottom: 400rpx;
  586. image {
  587. width: 132rpx;
  588. height: 112rpx;
  589. }
  590. .complaintViewTextClass {
  591. @include u-flex(row, center, center);
  592. width: 152rpx;
  593. height: 52rpx;
  594. background: linear-gradient(135deg, #FF5B6E 1.51%, #FC1D37 100%);
  595. border-radius: 26rpx;
  596. font-family: DOUYINSANSBOLD, DOUYINSANSBOLD;
  597. font-weight: normal;
  598. font-size: 30rpx;
  599. color: #FFFFFF;
  600. margin-top: -13rpx;
  601. z-index: 10;
  602. }
  603. }
  604. </style>