index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view>
  3. <view class="top-cont">
  4. <image class="bg" src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/bg_mine.png" mode="widthFix"></image>
  5. <view class="top-inner">
  6. <!-- 这里是状态栏 -->
  7. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  8. <view class="content">
  9. <view class="user-info">
  10. <view class="left">
  11. <view class="head-img" @click="isLogin">
  12. <image :src="userInfo.avatar?userInfo.avatar:'https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/my_heads_icon.png'"
  13. mode="aspectFill">
  14. </image>
  15. </view>
  16. <view class="name-phone">
  17. <view class="x-f">
  18. <view class="name" v-if="userInfo && userInfo.userId">{{userInfo.nickName||'未命名'}}</view>
  19. <view class="name" v-else>请先登录</view>
  20. <view class="lable" v-if="userInfo && userInfo.deptName">{{userInfo.deptName}}</view>
  21. </view>
  22. </view>
  23. <view class="txt" v-if="userInfo && userInfo.userId">您已加入小蜜蜂{{joinDays||'0'}}天了~</view>
  24. </view>
  25. </view>
  26. <view class="task-list">
  27. <view class="item" v-for="(item,index) in tabs" :key="index" @click="openLink(item)">
  28. <view class="left">
  29. <image :src="item.icon" mode=""></image>
  30. <view class="title-l">{{item.name||''}}</view>
  31. </view>
  32. <view class="right">
  33. <image src="https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_my_more.png" mode=""></image>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. getUserInfo
  45. } from '@/api/user'
  46. export default {
  47. data() {
  48. return {
  49. isGirl: false,
  50. count0: 0,
  51. count1: 0,
  52. count2: 0,
  53. afterSalesCount: 0,
  54. tabs: [
  55. {
  56. name: '个人信息',
  57. num: 3,
  58. icon: 'https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_my_information.png',
  59. url: '/pages_user/userInfo'
  60. },
  61. {
  62. name: '设置中心',
  63. num: 8,
  64. icon: 'https://ysrw-1395926010.cos.ap-chengdu.myqcloud.com/image/icon_my_set.png',
  65. url: '/pages/auth/setting'
  66. },
  67. ],
  68. userInfo: {},
  69. user: {
  70. isPromoter: 0,
  71. isWeixinAuth: 0,
  72. phone: "",
  73. nickname: "用户昵称",
  74. avatarUrl: "/static/images/detault_head.png"
  75. },
  76. // 状态栏的高度
  77. statusBarHeight: uni.getStorageSync('menuInfo')?.statusBarHeight || '0px',
  78. // 消息数量
  79. msgNum: 0,
  80. isShow: true,
  81. UserInfo: uni.getStorageSync('AppToken')
  82. };
  83. },
  84. onLoad() {
  85. console.log("onload")
  86. },
  87. onShow() {
  88. console.log("onshow")
  89. // 从本地缓存加载用户信息
  90. const userInfo = uni.getStorageSync('userInfo')
  91. if (userInfo) {
  92. this.userInfo = typeof userInfo === 'string' ? JSON.parse(userInfo) : userInfo
  93. }
  94. // 更新登录状态
  95. this.UserInfo = uni.getStorageSync('AppToken')
  96. },
  97. onReachBottom() {
  98. console.log("onReachBottom")
  99. if (this.$refs.product) {
  100. this.$refs.product.getGoodsProducts();
  101. }
  102. },
  103. methods: {
  104. isLogin(){
  105. console.log("是否登录")
  106. console.log("是否登录222",this.userInfo)
  107. if(!this.userInfo || !this.userInfo.userId){
  108. console.log("未登录,跳转到登录页面")
  109. uni.navigateTo({
  110. url:'/pages/auth/login'
  111. })
  112. } else {
  113. console.log("已登录,跳转到个人信息页面")
  114. uni.navigateTo({
  115. url:'/pages_user/userInfo'
  116. })
  117. }
  118. },
  119. seeChange() {
  120. this.isShow = !this.isShow
  121. },
  122. callService() {
  123. uni.makePhoneCall({
  124. phoneNumber: "4000717770",
  125. success: function() {
  126. console.log('拨打电话成功');
  127. },
  128. fail() {
  129. console.log('打电话失败了');
  130. }
  131. })
  132. },
  133. openLink(item) {
  134. if (item.name == '用户协议') {
  135. this.openH5()
  136. return;
  137. }
  138. uni.navigateTo({
  139. url: item.url
  140. })
  141. },
  142. toManager() {
  143. if (this.utils && this.utils.checkCompanyUserLoginState) {
  144. if (this.utils.checkCompanyUserLoginState()) {
  145. uni.navigateTo({
  146. url: '/pages_company/index'
  147. })
  148. } else {
  149. uni.navigateTo({
  150. url: '/pages_company/auth/login'
  151. })
  152. }
  153. }
  154. },
  155. openH5(url) {
  156. var requestPath = uni.getStorageSync('requestPath');
  157. uni.setStorageSync('url', requestPath + url);
  158. uni.navigateTo({
  159. url: '../home/web'
  160. })
  161. },
  162. getUserInfo() {
  163. getUserInfo().then(
  164. res => {
  165. if (res.code == 200) {
  166. if (res.user != null) {
  167. this.user = res.user;
  168. } else {
  169. if (this.utils && this.utils.loginOut) {
  170. this.utils.loginOut();
  171. }
  172. }
  173. } else {
  174. uni.showToast({
  175. icon: 'none',
  176. title: "请求失败",
  177. });
  178. }
  179. },
  180. rej => {}
  181. );
  182. },
  183. // 跳转页面
  184. navgetTo(url) {
  185. if (this.utils && this.utils.isLogin) {
  186. this.utils.isLogin().then(res => {
  187. if (res) {
  188. uni.navigateTo({
  189. url: url + '?userId=' + this.user.userId
  190. })
  191. }
  192. })
  193. }
  194. },
  195. // 查看订单
  196. showOrder(status) {
  197. uni.navigateTo({
  198. url: '/pages_user/user/storeOrder?status=' + status
  199. })
  200. }
  201. },
  202. computed: {
  203. joinDays() {
  204. if (!this.userInfo.createTime) return 0
  205. const createDate = new Date(this.userInfo.createTime.replace(/-/g, '/'))
  206. const now = new Date()
  207. const diffTime = now - createDate
  208. const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24))
  209. return diffDays
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="scss">
  215. .top-cont {
  216. width: 100%;
  217. height: 600rpx;
  218. position: relative;
  219. .bg {
  220. width: 100%;
  221. position: absolute;
  222. top: 0;
  223. left: 0;
  224. }
  225. .top-inner {
  226. width: 100%;
  227. height: 100%;
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. z-index: 2;
  232. }
  233. }
  234. .content {
  235. background: linear-gradient(360deg, rgba(244, 249, 255, 0.6) 0%, #FFFFFF 100%);
  236. border-radius: 40rpx 40rpx 24rpx 24rpx;
  237. border: 2rpx solid #FFFFFF;
  238. margin-top: 222upx;
  239. align-items: center;
  240. justify-content: center;
  241. position: relative;
  242. .user-info {
  243. position: relative;
  244. top: -72rpx;
  245. left: 46rpx;
  246. z-index: 4;
  247. .left {
  248. position: relative;
  249. display: flex;
  250. flex-direction: column;
  251. .head-img {
  252. width: 112upx;
  253. height: 112upx;
  254. border-radius: 50%;
  255. margin-right: 32upx;
  256. border: 4upx solid #FFFFFF;
  257. position: relative;
  258. image {
  259. width: 112upx;
  260. height: 112upx;
  261. border-radius: 50%;
  262. }
  263. .gender {
  264. width: 36rpx;
  265. height: 36rpx;
  266. position: absolute;
  267. right: 0;
  268. bottom: 0;
  269. }
  270. }
  271. .name-phone {
  272. display: flex;
  273. align-items: flex-start;
  274. flex-direction: column;
  275. justify-content: space-around;
  276. margin-top: 30rpx;
  277. .name {
  278. font-size: 40upx;
  279. font-family: PingFang SC;
  280. font-weight: bold;
  281. color: #111111;
  282. line-height: 1;
  283. }
  284. text {
  285. font-family: PingFang SC, PingFang SC;
  286. font-weight: 600;
  287. font-size: 28rpx;
  288. }
  289. .lable {
  290. padding: 4rpx 16rpx;
  291. font-weight: 500;
  292. font-size: 22rpx;
  293. color: #FFFFFF;
  294. background: #FAAB0C;
  295. margin-left: 18rpx;
  296. border-radius: 38rpx 38rpx 38rpx 38rpx;
  297. }
  298. .phone {
  299. width: 220rpx;
  300. height: 48rpx;
  301. margin-top: 30upx;
  302. background: linear-gradient(90deg, #FEA501 0%, #FECB8A 100%);
  303. border-radius: 24rpx 24rpx 24rpx 24rpx;
  304. border: 1rpx solid #FEDDB9;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. text {
  309. font-size: 24upx;
  310. font-family: PingFang SC;
  311. font-weight: 500;
  312. color: #fff;
  313. line-height: 1;
  314. margin-left: 4rpx;
  315. }
  316. }
  317. }
  318. .txt {
  319. font-size: 28rpx;
  320. color: #666666;
  321. margin-top: 12rpx;
  322. }
  323. }
  324. .right {
  325. display: flex;
  326. align-items: center;
  327. justify-content: center;
  328. .set {
  329. width: 48rpx;
  330. height: 48rpx;
  331. }
  332. }
  333. }
  334. .task-list {
  335. display: flex;
  336. align-items: center;
  337. flex-direction: column;
  338. justify-content: flex-start;
  339. width: 100%;
  340. .item {
  341. width: 100%;
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-between;
  345. padding: 28rpx 24rpx;
  346. box-sizing: border-box;
  347. .left {
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. image {
  352. width: 48rpx;
  353. height: 48rpx;
  354. margin-right: 32rpx;
  355. }
  356. .title-l {
  357. font-family: PingFang SC, PingFang SC;
  358. font-weight: 400;
  359. font-size: 32rpx;
  360. color: #333333;
  361. }
  362. }
  363. .right {
  364. display: flex;
  365. align-items: center;
  366. .num {
  367. text-align: center;
  368. width: 50rpx;
  369. height: 36rpx;
  370. line-height: 36rpx;
  371. background: rgba(56, 139, 255, 0.16);
  372. border-radius: 34rpx 34rpx 34rpx 34rpx;
  373. font-family: PingFang SC, PingFang SC;
  374. font-weight: 400;
  375. font-size: 24rpx;
  376. color: #388BFF;
  377. }
  378. image {
  379. width: 32rpx;
  380. height: 32rpx;
  381. margin-left: 12rpx;
  382. }
  383. }
  384. }
  385. }
  386. .used-tools {
  387. box-sizing: border-box;
  388. background: #FFFFFF;
  389. border-radius: 16upx;
  390. padding: 40upx 30upx;
  391. .title {
  392. font-size: 36upx;
  393. font-family: PingFang SC;
  394. font-weight: bold;
  395. color: #222222;
  396. line-height: 1;
  397. }
  398. .tools-list {
  399. margin-top: 50upx;
  400. display: flex;
  401. flex-wrap: wrap;
  402. width: 100%;
  403. .item {
  404. box-sizing: border-box;
  405. width: 25%;
  406. display: flex;
  407. flex-direction: column;
  408. align-items: center;
  409. justify-content: center;
  410. margin-bottom: 50upx;
  411. position: relative;
  412. image {
  413. width: 48upx;
  414. height: 48upx;
  415. }
  416. .text {
  417. font-size: 24upx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #333;
  421. line-height: 1;
  422. margin-top: 20upx;
  423. }
  424. .contact-btn {
  425. display: inline-block;
  426. position: absolute;
  427. top: 0;
  428. left: 0;
  429. width: 100%;
  430. height: 100%;
  431. opacity: 0;
  432. }
  433. }
  434. }
  435. }
  436. .log-out {
  437. height: 88upx;
  438. line-height: 88upx;
  439. text-align: center;
  440. font-family: PingFang SC, PingFang SC;
  441. font-weight: 500;
  442. font-size: 28rpx;
  443. color: #666666;
  444. background: #FFFFFF;
  445. border-radius: 16upx;
  446. margin-top: 52upx;
  447. }
  448. }
  449. .sub-btn {
  450. position: absolute;
  451. width: 100%;
  452. height: 100%;
  453. opacity: 0;
  454. }
  455. .like-product {
  456. padding: 0 20rpx;
  457. }
  458. .banner {
  459. padding: 20rpx 20rpx 0rpx 20rpx;
  460. height: 200rpx;
  461. position: relative;
  462. display: flex;
  463. align-items: center;
  464. justify-content: center;
  465. image {
  466. width: 100%;
  467. height: 100%;
  468. border-radius: 16rpx 16rpx 16rpx 16rpx;
  469. }
  470. .tel_btn {
  471. width: 100%;
  472. height: 100%;
  473. top: 0upx;
  474. position: absolute;
  475. opacity: 0.0;
  476. }
  477. }
  478. </style>