center.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view class="container">
  3. <hx-navbar :status-bar="true" :back="false" barPlaceholder="hidden" :fixed="true" :title.sync="pageTitle"
  4. :color="['#ffffff','#666666']" transparent="auto" :background-color="[255,255,255]"
  5. @click-left="navTo(userSettingUrl)">
  6. <!-- <view slot="left">
  7. <view style="margin-left: 26upx;font-size: 22px;">
  8. <i class="hxicon-settings"></i>
  9. </view>
  10. </view>
  11. <view slot="right">
  12. <view style="margin-right: 16upx;font-size: 22px;">
  13. <i class="hxicon-mark"></i>
  14. </view>
  15. </view> -->
  16. </hx-navbar>
  17. <view class="user-section ">
  18. <image class="bg" src="/static/img/user/user-bg.jpg"></image>
  19. <view class="user-info-box">
  20. <view class="portrait-box" @click="userBash">
  21. <image class="portrait" :src="memberInfo.face || defaultFace"></image>
  22. </view>
  23. <view class="info-box" @click="userBash">
  24. <text class="username">{{memberInfo.nickname || '登录/注册'}}</text>
  25. </view>
  26. </view>
  27. <!-- <view class="vip-card-box">
  28. <image class="card-bg" src="/static/img/user/vip-card-bg.png" mode=""></image>
  29. <view class="b-btn">
  30. 立即开通
  31. </view>
  32. <view class="tit">
  33. <text class="hxicon-iLinkapp-"></text>
  34. DCloud会员
  35. </view>
  36. <text class="e-m">DCloud Union</text>
  37. <text class="e-b">开通会员开发无bug 一测就上线</text>
  38. </view> -->
  39. </view>
  40. <view class="cover-container" :style="[{
  41. transform: coverTransform,
  42. transition: coverTransition
  43. }]" @touchstart="coverTouchstart" @touchmove="coverTouchmove" @touchend="coverTouchend">
  44. <image class="arc" src="/static/img/user/arc.png"></image>
  45. <!-- <view class="tj-sction">
  46. <view class="tj-item">
  47. <text class="num">128.8</text>
  48. <text>余额</text>
  49. </view>
  50. <view class="tj-item" @click="navTo('/pages/user/coupon/coupon')">
  51. <text class="num">0</text>
  52. <text>优惠券</text>
  53. </view>
  54. <view class="tj-item">
  55. <text class="num">20</text>
  56. <text>积分</text>
  57. </view>
  58. </view> -->
  59. <!-- 订单 -->
  60. <!-- <view class="order-section">
  61. <navigator class="order-item" url="/pages/order/order?state=1" open-type="switchTab"
  62. hover-class="common-hover" :hover-stay-time="50">
  63. <text class="hxicon-pay"></text>
  64. <text>待付款</text>
  65. </navigator>
  66. <navigator class="order-item" url="/pages/order/order?state=2" open-type="switchTab"
  67. hover-class="common-hover" :hover-stay-time="50">
  68. <text class="hxicon-deliver"></text>
  69. <text>待收货</text>
  70. </navigator>
  71. <navigator class="order-item" url="/pages/order/order?state=3" open-type="switchTab"
  72. hover-class="common-hover" :hover-stay-time="50">
  73. <text class="hxicon-comment"></text>
  74. <text>待评价</text>
  75. </navigator>
  76. <navigator class="order-item" url="/pages/order/order?state=4" open-type="switchTab"
  77. hover-class="common-hover" :hover-stay-time="50">
  78. <text class="hxicon-refund"></text>
  79. <text>退款/售后</text>
  80. </navigator>
  81. <navigator class="order-item" url="/pages/order/order?state=0" open-type="switchTab"
  82. hover-class="common-hover" :hover-stay-time="50">
  83. <text class="hxicon-form"></text>
  84. <text>全部订单</text>
  85. </navigator>
  86. </view> -->
  87. <!-- 浏览历史 -->
  88. <view class="history-section icon">
  89. <!-- <view class="sec-header">
  90. <text class="hxicon-lishijilu"></text>
  91. <text>浏览历史</text>
  92. </view> -->
  93. <!-- <scroll-view scroll-x class="h-list">
  94. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/8.jpg"
  95. mode="aspectFill"></image>
  96. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/9.jpg"
  97. mode="aspectFill"></image>
  98. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/10.jpg"></image>
  99. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/11.jpg"
  100. mode="aspectFill"></image>
  101. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/12.jpg"></image>
  102. <image @click="navTo('/pages/product/product')" src="//imgs.1op.cn/i/hxshop/goods/13.jpg"
  103. mode="aspectFill"></image>
  104. </scroll-view> -->
  105. <list-cell icon="hxicon-moneybagfill" iconColor="#e07472" title="我的钱包"></list-cell>
  106. <list-cell icon="hxicon-locationfill" iconColor="#5fcda2" title="地址管理"
  107. @eventClick="navTo('/pages/user/address/address')"></list-cell>
  108. <!-- <list-cell icon="hxicon-round_pay_fill" iconColor="#9789f7" title="分享" tips="邀请好友赢10万大礼"></list-cell> -->
  109. <!-- <list-cell icon="hxicon-message_fill_light" iconColor="#ee883b" title="晒单" tips="晒单抢红包"></list-cell> -->
  110. <!-- <list-cell icon="hxicon-round_favor_fill" iconColor="#54b4ef" title="我的收藏"></list-cell> -->
  111. <list-cell icon="hxicon-settings" iconColor="#e07472" title="设置" border=""
  112. @eventClick="navTo('/pages/user/setting/setting')"></list-cell>
  113. </view>
  114. </view>
  115. </view>
  116. </template>
  117. <script>
  118. import hxNavbar from "@/components/hx-navbar/hx-navbar.vue"
  119. import listCell from '@/components/mix-list-cell';
  120. import {
  121. mapState
  122. } from 'vuex';
  123. let startY = 0,
  124. moveY = 0,
  125. pageAtTop = true;
  126. export default {
  127. components: {
  128. listCell,
  129. hxNavbar
  130. },
  131. data() {
  132. return {
  133. pageTitle: "我的",
  134. coverTransform: 'translateY(0px)',
  135. coverTransition: '0s',
  136. moving: false,
  137. defaultFace: '/static/img/user/missing-face.png',
  138. userSettingUrl: '/pages/user/setting/setting',
  139. memberInfo: {
  140. face: '',
  141. nickname: "",
  142. }
  143. }
  144. },
  145. onLoad() {
  146. },
  147. onReady() {
  148. },
  149. onShow() {
  150. let member = this.userData.member;
  151. if (member) {
  152. this.memberInfo = {
  153. face: member.facke,
  154. nickname: member.nickname
  155. }
  156. } else {
  157. this.memberInfo = {
  158. face: '',
  159. nickname: ''
  160. }
  161. }
  162. },
  163. // #ifndef MP
  164. onNavigationBarButtonTap(e) {
  165. const index = e.index;
  166. if (index === 0) {
  167. this.navTo('/pages/user/setting/setting');
  168. } else if (index === 1) {
  169. // #ifdef APP-PLUS
  170. const pages = getCurrentPages();
  171. const page = pages[pages.length - 1];
  172. const currentWebview = page.$getAppWebview();
  173. currentWebview.hideTitleNViewButtonRedDot({
  174. index
  175. });
  176. // #endif
  177. uni.navigateTo({
  178. url: '/pages/notice/notice'
  179. })
  180. }
  181. },
  182. // #endif
  183. computed: {
  184. ...mapState(['hasLogin', 'userData'])
  185. },
  186. methods: {
  187. //个人信息
  188. userBash() {
  189. if (this.userData) {
  190. this.navTo('/pages/user/bash/bash')
  191. } else {
  192. uni.navigateTo({
  193. url: '/pages/user/login/login'
  194. });
  195. }
  196. },
  197. /**
  198. * 会员卡下拉和回弹
  199. * 1.关闭bounce避免ios端下拉冲突
  200. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  201. * transition设置0.1秒延迟,让css来过渡这段空窗期
  202. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  203. */
  204. coverTouchstart(e) {
  205. if (pageAtTop === false) {
  206. return;
  207. }
  208. this.coverTransition = 'transform .1s linear';
  209. startY = e.touches[0].clientY;
  210. },
  211. coverTouchmove(e) {
  212. moveY = e.touches[0].clientY;
  213. let moveDistance = moveY - startY;
  214. if (moveDistance < 0) {
  215. this.moving = false;
  216. return;
  217. }
  218. this.moving = true;
  219. if (moveDistance >= 80 && moveDistance < 100) {
  220. moveDistance = 80;
  221. }
  222. if (moveDistance > 0 && moveDistance <= 80) {
  223. this.coverTransform = `translateY(${moveDistance}px)`;
  224. }
  225. },
  226. coverTouchend() {
  227. if (this.moving === false) {
  228. return;
  229. }
  230. this.moving = false;
  231. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  232. this.coverTransform = 'translateY(0px)';
  233. },
  234. }
  235. }
  236. </script>
  237. <style lang='scss'>
  238. %flex-center {
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: center;
  242. align-items: center;
  243. }
  244. %section {
  245. display: flex;
  246. justify-content: space-around;
  247. align-content: center;
  248. background: #fff;
  249. border-radius: 10upx;
  250. }
  251. .user-section {
  252. height: 520upx;
  253. padding: 100upx 30upx 0;
  254. position: relative;
  255. .bg {
  256. position: absolute;
  257. left: 0;
  258. top: 0;
  259. width: 100%;
  260. height: 100%;
  261. filter: blur(1px);
  262. }
  263. }
  264. .user-info-box {
  265. height: 180upx;
  266. display: flex;
  267. align-items: center;
  268. position: relative;
  269. z-index: 1;
  270. .portrait {
  271. width: 128upx;
  272. height: 128upx;
  273. /* border:5upx solid #fff; */
  274. border-radius: 50%;
  275. box-shadow: 0 0px 12px #848484;
  276. }
  277. .username {
  278. font-size: $font-lg + 4upx;
  279. color: $font-color-dark;
  280. margin-left: 20upx;
  281. font-weight: bold;
  282. }
  283. }
  284. .vip-card-box {
  285. display: none;
  286. flex-direction: column;
  287. color: #f7d680;
  288. height: 240upx;
  289. background: linear-gradient(to right, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
  290. border-radius: 16upx 16upx 0 0;
  291. overflow: hidden;
  292. position: relative;
  293. padding: 20upx 24upx;
  294. .card-bg {
  295. position: absolute;
  296. top: 20upx;
  297. right: 0;
  298. width: 380upx;
  299. height: 260upx;
  300. }
  301. .b-btn {
  302. position: absolute;
  303. right: 20upx;
  304. top: 16upx;
  305. width: 132upx;
  306. height: 40upx;
  307. text-align: center;
  308. line-height: 40upx;
  309. font-size: 22upx;
  310. color: #36343c;
  311. border-radius: 20px;
  312. background: linear-gradient(to right, #f9e6af, #ffd465);
  313. z-index: 1;
  314. }
  315. .tit {
  316. font-size: $font-base+2upx;
  317. color: #f7d680;
  318. margin-bottom: 28upx;
  319. [class*="hxicon-"] {
  320. color: #f6e5a3;
  321. margin-right: 16upx;
  322. }
  323. }
  324. .e-b {
  325. font-size: $font-sm;
  326. color: #d8cba9;
  327. margin-top: 10upx;
  328. }
  329. }
  330. .cover-container {
  331. background: $page-color-base;
  332. margin-top: -150upx;
  333. padding: 0 30upx;
  334. position: relative;
  335. background: #f5f5f5;
  336. padding-bottom: 20upx;
  337. .arc {
  338. position: absolute;
  339. left: 0;
  340. top: -34upx;
  341. width: 100%;
  342. height: 36upx;
  343. }
  344. }
  345. .tj-sction {
  346. @extend %section;
  347. .tj-item {
  348. @extend %flex-center;
  349. flex-direction: column;
  350. height: 140upx;
  351. font-size: $font-sm;
  352. color: #75787d;
  353. }
  354. .num {
  355. font-size: $font-lg;
  356. color: $font-color-dark;
  357. margin-bottom: 8upx;
  358. }
  359. }
  360. .order-section {
  361. @extend %section;
  362. padding: 28upx 0;
  363. margin-top: 20upx;
  364. .order-item {
  365. @extend %flex-center;
  366. width: 120upx;
  367. height: 120upx;
  368. border-radius: 10upx;
  369. font-size: $font-sm;
  370. color: $font-color-dark;
  371. }
  372. [class*="hxicon-"] {
  373. font-size: 48upx;
  374. margin-bottom: 18upx;
  375. color: #ffd21c;
  376. }
  377. .icon-shouhoutuikuan {
  378. font-size: 44upx;
  379. }
  380. }
  381. .history-section {
  382. padding: 30upx 0 0;
  383. margin-top: 20upx;
  384. background: #fff;
  385. border-radius: 10upx;
  386. .sec-header {
  387. display: flex;
  388. align-items: center;
  389. font-size: $font-base;
  390. color: $font-color-dark;
  391. line-height: 40upx;
  392. margin-left: 30upx;
  393. [class*="hxicon-"] {
  394. font-size: 44upx;
  395. color: #5eba8f;
  396. margin-right: 16upx;
  397. line-height: 40upx;
  398. }
  399. }
  400. .h-list {
  401. white-space: nowrap;
  402. padding: 30upx 30upx 0;
  403. image {
  404. display: inline-block;
  405. width: 160upx;
  406. height: 160upx;
  407. margin-right: 20upx;
  408. border-radius: 10upx;
  409. }
  410. }
  411. }
  412. </style>