index.vue 10 KB

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