index.vue 10 KB

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