index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <view>
  3. <!-- index.wxml -->
  4. <com-header :page-title="pageTitle" v-if="showHeader"></com-header>
  5. <view class="wrap">
  6. <view class="banner_wrap">
  7. <image class="banner" src="/static/statics/img/user/top_bg.png"></image>
  8. </view>
  9. <view class="tag" :style="'top:' + (setBgHeight + 10) + 'px'" @tap="goShopInfo" v-if="role">商家中心</view>
  10. <view class="wrap_nr" :style="'top:' + (setBgHeight + 10) + 'px'">
  11. <view class="user_info">
  12. <image class="user_thumb" :src="userInfo.thumb"></image>
  13. <view class="user_info_l">
  14. <view class="user_name">Hey,{{ userInfo.nickname }}</view>
  15. <view class="user_tips">与你相识的第{{ fromToNowDays }}天</view>
  16. </view>
  17. </view>
  18. <view class="user_vip">
  19. <image src="/static/statics/img/user/vip_bg.png" alt="" class="vip_bg" />
  20. <view class="vip_con" v-if="!userInfo.is_member">
  21. <view class="con_text">开通会员,立即享受会员价</view>
  22. <view class="con_btn" @tap="toVipCard">立即开通</view>
  23. </view>
  24. <view class="vip_con flex_end" v-if="userInfo.is_member">
  25. <view class="con_text">{{ userInfo.end_at }} 后到期</view>
  26. </view>
  27. </view>
  28. <view class="order_wrap">
  29. <view class="order_wrap_bg">
  30. <image class="bg_tu" src="/static/statics/img/user/order_bg.png"></image>
  31. </view>
  32. <view class="order_wrap_con">
  33. <view class="order_t">
  34. <view class="order_t_l">
  35. <image class="order_icon" src="/static/statics/img/user/order_icon.png"></image>
  36. 我的订单
  37. </view>
  38. <view class="order_t_r" @tap="toOrderList" data-type="-1">
  39. 全部订单
  40. <van-icon name="arrow" />
  41. </view>
  42. </view>
  43. <view class="order_list">
  44. <view class="order_item" @tap="toOrderList" data-type="0">
  45. <view class="item_icon">
  46. <image class="icon" src="/static/statics/img/user/pay_icon.png"></image>
  47. <view class="num" v-if="userInfo.order_wait_pay">{{ userInfo.order_wait_pay }}</view>
  48. </view>
  49. <view class="item_name">待支付</view>
  50. </view>
  51. <view class="order_item" @tap="toOrderList" data-type="1">
  52. <view class="item_icon">
  53. <image class="icon" src="/static/statics/img/user/send_icon.png"></image>
  54. <view class="num" v-if="userInfo.order_wait_ship">{{ userInfo.order_wait_ship }}</view>
  55. </view>
  56. <view class="item_name">待发货</view>
  57. </view>
  58. <!-- <view class="order_item">
  59. <view class="item_icon">
  60. <image class="icon" src="/statics/img/user/receive_icon.png"></image>
  61. <view class="num">2</view>
  62. </view>
  63. <view class="item_name">待收货</view>
  64. </view> -->
  65. <view class="order_item" @tap="toOrderList" data-type="2">
  66. <view class="item_icon">
  67. <image class="icon" src="/static/statics/img/user/pickup_icon.png"></image>
  68. <view class="num" v-if="userInfo.order_wait_ziti">{{ userInfo.order_wait_ziti }}</view>
  69. </view>
  70. <view class="item_name">待自提</view>
  71. </view>
  72. <view class="order_item" @tap="toOrderList" data-type="3">
  73. <view class="item_icon">
  74. <image class="icon" src="/static/statics/img/user/receive_icon.png"></image>
  75. </view>
  76. <view class="item_name">已完成</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="section_wrap">
  82. <view class="section" @tap="goPage" data-url="/pages/user/coupons/index">
  83. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/quan_icon.png"></image>
  84. <view class="sec_r">
  85. <view class="sec_name">优惠券</view>
  86. <view class="sec_num">{{ userInfo.coupon }}</view>
  87. </view>
  88. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  89. </view>
  90. <view class="section cash" @tap="goPage" data-url="/pages/user/cash/index">
  91. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/cash_icon.png"></image>
  92. <view class="sec_r">
  93. <view class="sec_name">余额</view>
  94. <view class="sec_num">{{ userInfo.money }}</view>
  95. </view>
  96. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  97. </view>
  98. <view class="section" @tap="goPage" data-url="/pages/user/address/list/index">
  99. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/dizhi_icon.png"></image>
  100. <view class="sec_r">
  101. <view class="sec_name">地址管理</view>
  102. </view>
  103. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  104. </view>
  105. <view class="section" @tap="goPage" data-url="/pages/user/info/index">
  106. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/ziliao_icon.png"></image>
  107. <view class="sec_r">
  108. <view class="sec_name">资料编辑</view>
  109. </view>
  110. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  111. </view>
  112. <view class="section" @tap="goPage" data-url="/pages/joinus/index">
  113. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/join_icon.png"></image>
  114. <view class="sec_r">
  115. <view class="sec_name">加盟咨询</view>
  116. <view class="sec_tip">查看加盟信息</view>
  117. </view>
  118. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  119. </view>
  120. <view class="section" @tap="goPage" data-url="/pages/feedback/index">
  121. <image class="sec_icon" mode="aspectFit" src="/static/statics/img/user/feedback_icon.png"></image>
  122. <view class="sec_r">
  123. <view class="sec_name">意见建议</view>
  124. <view class="sec_tip">发表使用意见</view>
  125. </view>
  126. <image class="sec_logo" src="/static/statics/img/user/sec_logo.png"></image>
  127. </view>
  128. <!-- <view class="section" bind:tap="goPage" data-url="/pages/take-coupons/index">
  129. <image class="sec_icon" mode="aspectFit" src="/statics/img/user/feedback_icon.png"></image>
  130. <view class="sec_r">
  131. <view class="sec_name">领券</view>
  132. <view class="sec_tip">领取优惠券</view>
  133. </view>
  134. <image class="sec_logo" src="/statics/img/user/sec_logo.png"></image>
  135. </view> -->
  136. </view>
  137. <view class="tu_wrap">
  138. <image class="tu" src="/static/statics/img/user/logo_text.png"></image>
  139. <view class="version">v1.0.91</view>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. // index.js
  147. let myPro = require('../../../utils/wxRequest.js');
  148. let util = require('../../../utils/util.js');
  149. export default {
  150. data() {
  151. return {
  152. userInfo: null,
  153. role: null,
  154. // 1为商家
  155. pageTitle: '我的',
  156. showHeader: false,
  157. setBgHeight: getApp().globalData.setBgHeight,
  158. percentLevel: 0,
  159. // 等级进度百分比
  160. fromToNowDays: '' // 相识天数(当前时间-注册时间)
  161. };
  162. },
  163. onLoad: function (options) {
  164. // Do some initialize when page load.
  165. let that = this;
  166. that.setData({
  167. role: getApp().globalData.role
  168. });
  169. },
  170. onShow: function () {
  171. // Do something when page show.
  172. let that = this;
  173. that.getUserInfo();
  174. },
  175. onReady: function () {
  176. // Do something when page ready.
  177. let that = this;
  178. },
  179. onHide: function () {
  180. // Do something when page hide.
  181. },
  182. onUnload: function () {
  183. // Do something when page close.
  184. },
  185. onPullDownRefresh: function () {
  186. // Do something when pull down.
  187. },
  188. onReachBottom: function () {
  189. // Do something when page reach bottom.
  190. },
  191. onShareAppMessage: function () {
  192. // return custom share data when user share.
  193. },
  194. onPageScroll: function (event) {
  195. // Do something when page scroll
  196. let that = this;
  197. let scrollTop = event.scrollTop;
  198. if (scrollTop >= that.setBgHeight) {
  199. that.setData({
  200. showHeader: true
  201. });
  202. } else {
  203. that.setData({
  204. showHeader: false
  205. });
  206. }
  207. },
  208. onResize: function () {
  209. // Do something when page resize
  210. },
  211. methods: {
  212. // 页面跳转
  213. goPage(event) {
  214. let that = this;
  215. console.log(event);
  216. let url = event.currentTarget.dataset.url;
  217. uni.navigateTo({
  218. url: url
  219. });
  220. },
  221. // 用户信息
  222. getUserInfo() {
  223. let that = this;
  224. myPro
  225. .wxRequest('user/v2/userinfo', 'GET', {})
  226. .then((res) => {
  227. that.setData({
  228. userInfo: res.result
  229. }); // 计算相识天数
  230. let createStr = res.result.created_at; // 为兼容ios
  231. let createTimesmap = new Date(createStr.replace(/-/g, '/')).getTime();
  232. let currentTimesmap = new Date().getTime();
  233. that.setData({
  234. fromToNowDays: util.computeDays(createTimesmap, currentTimesmap) + 1 // 从注册当天算第1天
  235. });
  236. })
  237. .catch((err) => {
  238. console.log('报错信息', err);
  239. uni.showToast({
  240. title: err,
  241. icon: 'none'
  242. });
  243. });
  244. },
  245. // 去商家中心
  246. goShopInfo() {
  247. uni.navigateTo({
  248. url: '/pages/shopRole/info/index'
  249. });
  250. },
  251. // 订单
  252. toOrderList(event) {
  253. let that = this; // console.log(event)
  254. let type = event.currentTarget.dataset.type;
  255. uni.reLaunch({
  256. url: '/pages/user/order/list/index?type=' + type
  257. });
  258. },
  259. // 去买会员卡
  260. toVipCard() {
  261. let that = this;
  262. uni.navigateTo({
  263. url: '/pages/user/vipcard/index'
  264. });
  265. }
  266. }
  267. };
  268. </script>
  269. <style>
  270. /**index.wxss**/
  271. .wrap {
  272. width: 750rpx;
  273. min-height: 100vh;
  274. /* background: #f6f6f6; */
  275. }
  276. .banner_wrap .banner {
  277. width: 750rpx;
  278. height: 501rpx;
  279. }
  280. .wrap_nr {
  281. padding: 0 30rpx;
  282. /* margin-top: -200rpx; */
  283. position: relative;
  284. }
  285. .banner_wenzi {
  286. width: 675rpx;
  287. height: 193rpx;
  288. position: absolute;
  289. top: -170rpx;
  290. left: 50%;
  291. transform: translateX(-50%);
  292. }
  293. .user_wrap {
  294. padding: 20rpx 40rpx;
  295. position: absolute;
  296. left: 0;
  297. /* background: #FFFFFF;
  298. border-radius: 15rpx; */
  299. }
  300. .user_info {
  301. display: flex;
  302. align-items: center;
  303. /* justify-content: space-between; */
  304. }
  305. .user_info .user_name {
  306. font-size: 40rpx;
  307. color: #ffffff;
  308. }
  309. .user_info .user_tips {
  310. padding-top: 16rpx;
  311. font-size: 26rpx;
  312. color: rgba(255, 255, 255, 0.8);
  313. }
  314. .user_info .user_thumb {
  315. width: 120rpx;
  316. height: 120rpx;
  317. border-radius: 50%;
  318. margin-right: 20rpx;
  319. }
  320. .user_level {
  321. margin-top: 26rpx;
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-between;
  325. }
  326. .user_level .level_l {
  327. width: 98rpx;
  328. height: 46rpx;
  329. background: linear-gradient(90deg, #e4bc88, #d2901e);
  330. border-radius: 23rpx;
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. }
  335. .user_level .level_l .level_icon {
  336. width: 27rpx;
  337. height: 24rpx;
  338. }
  339. .user_level .level_l .level_num {
  340. font-size: 29rpx;
  341. font-weight: 600;
  342. font-style: italic;
  343. color: #ffffff;
  344. }
  345. .user_level .level_r {
  346. width: 490rpx;
  347. }
  348. .user_level .level_wenzi {
  349. padding-top: 10rpx;
  350. font-size: 22rpx;
  351. color: #333333;
  352. display: flex;
  353. align-items: center;
  354. justify-content: space-between;
  355. }
  356. .section_wrap {
  357. display: flex;
  358. align-items: center;
  359. justify-content: space-between;
  360. flex-wrap: wrap;
  361. }
  362. .section {
  363. width: 335rpx;
  364. height: 158rpx;
  365. border-radius: 10rpx;
  366. padding: 0 34rpx 0;
  367. margin-top: 20rpx;
  368. display: flex;
  369. align-items: center;
  370. font-size: 30rpx;
  371. color: #000000;
  372. /* background: #FFFFFF; */
  373. background: #ffd761;
  374. position: relative;
  375. }
  376. .section .sec_icon {
  377. width: 75rpx;
  378. height: 76rpx;
  379. }
  380. .section .sec_r {
  381. padding-left: 15rpx;
  382. display: flex;
  383. flex-direction: column;
  384. justify-content: center;
  385. color: #295c56;
  386. }
  387. .section .sec_num {
  388. font-size: 36rpx;
  389. font-weight: 600;
  390. color: rgba(0, 0, 0, 0.8);
  391. padding-top: 8rpx;
  392. }
  393. .section .sec_tip {
  394. font-size: 24rpx;
  395. color: rgba(0, 0, 0, 0.54);
  396. }
  397. .section .sec_logo {
  398. width: 36rpx;
  399. height: 36rpx;
  400. position: absolute;
  401. bottom: 30rpx;
  402. right: 30rpx;
  403. }
  404. /* 底图 */
  405. .tu_wrap {
  406. width: 100%;
  407. padding: 100rpx 0 40rpx;
  408. }
  409. .tu_wrap .tu {
  410. width: 124rpx;
  411. height: 57rpx;
  412. display: block;
  413. margin: 0 auto;
  414. }
  415. /* 版本号 */
  416. .version {
  417. text-align: center;
  418. color: #333333;
  419. font-size: 20rpx;
  420. padding-top: 20rpx;
  421. }
  422. /* 商户角色切换 */
  423. .banner_wrap {
  424. position: fixed;
  425. }
  426. .tag {
  427. width: 130rpx;
  428. height: 45rpx;
  429. background: linear-gradient(-90deg, #295c56, rgba(255, 255, 255, 0.3));
  430. border-radius: 23rpx 0rpx 0rpx 23rpx;
  431. font-size: 28rpx;
  432. color: #ffffff;
  433. display: flex;
  434. align-items: center;
  435. justify-content: center;
  436. position: absolute;
  437. top: 160rpx;
  438. right: 0;
  439. z-index: 1;
  440. }
  441. /* 订单 */
  442. .order_wrap {
  443. /* background: #FFFFFF;
  444. border-radius: 10rpx;
  445. color: #000000;
  446. font-size: 28rpx;
  447. padding: 30rpx 0;
  448. position: relative;
  449. z-index: 1; */
  450. width: 690rpx;
  451. height: 256rpx;
  452. position: relative;
  453. }
  454. .order_wrap .order_wrap_bg {
  455. position: absolute;
  456. top: 0;
  457. left: 0;
  458. }
  459. .order_wrap .order_wrap_bg .bg_tu {
  460. width: 690rpx;
  461. height: 256rpx;
  462. }
  463. .order_wrap .order_wrap_con {
  464. width: 690rpx;
  465. height: 256rpx;
  466. position: absolute;
  467. top: 0;
  468. left: 0;
  469. display: flex;
  470. flex-direction: column;
  471. justify-content: center;
  472. }
  473. .order_wrap .order_t {
  474. display: flex;
  475. align-items: center;
  476. justify-content: space-between;
  477. padding: 0 30rpx;
  478. color: #ffffff;
  479. }
  480. .order_wrap .order_t .order_t_l {
  481. font-size: 30rpx;
  482. display: flex;
  483. align-items: center;
  484. }
  485. .order_wrap .order_t .order_t_l .order_icon {
  486. width: 30rpx;
  487. height: 30rpx;
  488. margin-right: 6rpx;
  489. }
  490. .order_wrap .order_t .order_t_r {
  491. font-size: 26rpx;
  492. /* color: rgba(0,0,0,.54); */
  493. }
  494. .order_wrap .order_list {
  495. display: flex;
  496. margin-top: 30rpx;
  497. }
  498. .order_wrap .order_item {
  499. /* flex: 1; */
  500. width: 25%;
  501. display: flex;
  502. flex-direction: column;
  503. align-items: center;
  504. }
  505. .order_wrap .order_item .item_icon {
  506. position: relative;
  507. }
  508. .order_wrap .order_item .item_icon .icon {
  509. width: 90rpx;
  510. height: 90rpx;
  511. }
  512. .order_wrap .order_item .item_icon .num {
  513. min-width: 34rpx;
  514. height: 34rpx;
  515. border-radius: 50%;
  516. background: #ffd102;
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. position: absolute;
  521. top: -14rpx;
  522. right: -12rpx;
  523. font-size: 24rpx;
  524. font-weight: bold;
  525. color: #000000;
  526. }
  527. .order_wrap .order_item .item_name {
  528. /* padding-top: 10rpx; */
  529. }
  530. /* 开通会员 */
  531. .user_vip {
  532. width: 648rpx;
  533. height: 82rpx;
  534. position: relative;
  535. left: 20rpx;
  536. top: 0rpx;
  537. margin-top: 20rpx;
  538. }
  539. .user_vip .vip_bg {
  540. width: 648rpx;
  541. height: 82rpx;
  542. position: absolute;
  543. top: 0;
  544. left: 0;
  545. }
  546. .user_vip .vip_con {
  547. width: 648rpx;
  548. height: 82rpx;
  549. padding: 0 40rpx 0 116rpx;
  550. font-size: 24rpx;
  551. color: #f3d4b3;
  552. position: absolute;
  553. top: 0;
  554. left: 0;
  555. display: flex;
  556. align-items: center;
  557. justify-content: space-between;
  558. }
  559. .user_vip .vip_con.flex_end {
  560. justify-content: flex-end;
  561. }
  562. .user_vip .con_btn {
  563. width: 135rpx;
  564. height: 48rpx;
  565. background: #ffd1a2;
  566. border-radius: 24rpx;
  567. font-size: 24rpx;
  568. color: #5d3921;
  569. display: flex;
  570. align-items: center;
  571. justify-content: center;
  572. }
  573. </style>