user.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class="container">
  3. <view class="user-section">
  4. <image class="bg" src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/55fe2551ab3fd04275f3e1cc384081de.png"></image>
  5. <view class="user-info-box">
  6. <view class="portrait-box">
  7. <image class="portrait" :src="userInfo.avatar ? userInfo.avatar : '/static/missing-face.png'"></image>
  8. </view>
  9. <view class="info-box">
  10. <text class="username">{{userInfo.username || '游客'}}</text>
  11. </view>
  12. </view>
  13. <view class="vip-card-box">
  14. <!-- <image class="card-bg" src="/static/vip-card-bg.png" mode=""></image> -->
  15. <!-- <view class="b-btn">
  16. 立即开通
  17. </view> -->
  18. <view class="tit" v-if="userInfo.group">
  19. <text class="yticon icon-iLinkapp-"></text>
  20. {{userInfo.group.name}}
  21. </view>
  22. <view v-else>
  23. <button class="get-user-info" @click="getUserInfo">提供资料成为会员</button>
  24. </view>
  25. </view>
  26. </view>
  27. <view
  28. class="cover-container"
  29. :style="[{
  30. transform: coverTransform,
  31. transition: coverTransition
  32. }]"
  33. @touchstart="coverTouchstart"
  34. @touchmove="coverTouchmove"
  35. @touchend="coverTouchend"
  36. >
  37. <image class="arc" src="/static/arc.png"></image>
  38. <!-- 订单 -->
  39. <view class="order-header">
  40. <view class="title">我的订单</view>
  41. <view class="item" @click="$api.navTo('/pages/order/order?state=0')" >查看全部订单
  42. <text class="yticon right icon-you"></text>
  43. </view>
  44. </view>
  45. <view class="order-section">
  46. <view class="order-item" @click="$api.navTo('/pages/order/order?state=1')" hover-class="common-hover" :hover-stay-time="50">
  47. <text class="yticon icon-daifukuan"></text>
  48. <text class="num" v-if="orderNum.unpaid > 0">{{orderNum.unpaid}}</text>
  49. <text>待付款</text>
  50. </view>
  51. <view class="order-item" @click="$api.navTo('/pages/order/order?state=2')" hover-class="common-hover" :hover-stay-time="50">
  52. <text class="yticon icon-daifahuo"></text>
  53. <text class="num" v-if="orderNum.undelivered > 0">{{orderNum.undelivered}}</text>
  54. <text>待发货</text>
  55. </view>
  56. <view class="order-item" @click="$api.navTo('/pages/order/order?state=3')" hover-class="common-hover" :hover-stay-time="50">
  57. <text class="yticon icon-daishouhuo"></text>
  58. <text class="num" v-if="orderNum.unreceived > 0">{{orderNum.unreceived}}</text>
  59. <text>待收货</text>
  60. </view>
  61. <view class="order-item" @click="$api.navTo('/pages/order/order?state=4')" hover-class="common-hover" :hover-stay-time="50">
  62. <text class="yticon icon-pingjia"></text>
  63. <text class="num" v-if="orderNum.uncomment > 0">{{orderNum.uncomment}}</text>
  64. <text>评价</text>
  65. </view>
  66. <view class="order-item" @click="$api.navTo('/pages/order/order?state=5')" hover-class="common-hover" :hover-stay-time="50">
  67. <text class="yticon icon-shouhou"></text>
  68. <text class="num" v-if="orderNum.refund > 0">{{orderNum.refund}}</text>
  69. <text>退款/售后</text>
  70. </view>
  71. </view>
  72. <!-- 浏览历史 -->
  73. <view class="history-section icon">
  74. <!-- <view class="sec-header">
  75. <text class="yticon icon-lishijilu"></text>
  76. <text>浏览历史</text>
  77. </view> -->
  78. <!-- <scroll-view scroll-x class="h-list">
  79. <image @click="navTo('/pages/product/product')" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553105186633&di=c121a29beece4e14269948d990f9e720&imgtype=0&src=http%3A%2F%2Fimg004.hc360.cn%2Fm8%2FM04%2FDE%2FDE%2FwKhQplZ-QteEBvsbAAAAADUkobU751.jpg" mode="aspectFill"></image>
  80. <image @click="navTo('/pages/product/product')" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553105231218&di=09534b9833b5243296630e6d5b728eff&imgtype=0&src=http%3A%2F%2Fimg002.hc360.cn%2Fm1%2FM05%2FD1%2FAC%2FwKhQcFQ3iN2EQTo8AAAAAHQU6_8355.jpg" mode="aspectFill"></image>
  81. <image @click="navTo('/pages/product/product')" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553105320890&di=c743386be51f2c4c0fd4b75754d14f3c&imgtype=0&src=http%3A%2F%2Fimg007.hc360.cn%2Fhb%2FMTQ1OTg4ODY0MDA3Ny05OTQ4ODY1NDQ%3D.jpg" mode="aspectFill"></image>
  82. <image @click="navTo('/pages/product/product')" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2691146630,2165926318&fm=26&gp=0.jpg" mode="aspectFill"></image>
  83. <image @click="navTo('/pages/product/product')" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553105443324&di=8141bf13f3f208c61524d67f9bb83942&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01ac9a5548d29b0000019ae98e6d98.jpg" mode="aspectFill"></image>
  84. <image @click="navTo('/pages/product/product')" src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=191678693,2701202375&fm=26&gp=0.jpg" mode="aspectFill"></image>
  85. </scroll-view> -->
  86. <list-cell icon="icon-daifukuan" iconColor="#e07472" title="我的积分" :tips="info.score" @eventClick="$api.navTo('/pages/wallet/integral')"></list-cell>
  87. <list-cell icon="icon-daifukuan" iconColor="#e07472" title="我的钱包" tips="查看余额,提现" @eventClick="$api.navTo('/pages/wallet/index')"></list-cell>
  88. <list-cell icon="icon-dizhi" iconColor="#5fcda2" title="地址管理" @eventClick="$api.navTo('/pages/address/address')"></list-cell>
  89. <list-cell icon="icon-shoucang-setting" iconColor="#54b4ef" title="我的收藏" @eventClick="$api.navTo('/pages/favorite/favorite')"></list-cell>
  90. <list-cell icon="icon-setting" iconColor="#e07472" title="我的团队" border="" @eventClick="$api.navTo('/pages/term/index')"></list-cell>
  91. <list-cell icon="icon-shoucang" iconColor="#9789f7" title="我的海报" @eventClick="$api.navTo('/pages/poster/index')"></list-cell>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import listCell from '@/components/mix-list-cell';
  98. import {
  99. mapMutations,
  100. mapState
  101. } from 'vuex';
  102. let startY = 0, moveY = 0, pageAtTop = true;
  103. export default {
  104. components: {
  105. listCell
  106. },
  107. data() {
  108. return {
  109. coverTransform: 'translateY(0px)',
  110. coverTransition: '0s',
  111. moving: false,
  112. orderNum: {
  113. unpaid: 0,
  114. undelivered: 0,
  115. unreceived: 0,
  116. uncomment: 0,
  117. refund: 0
  118. },
  119. info:""
  120. }
  121. },
  122. onLoad(){
  123. },
  124. onShow() {
  125. if (this.hasLogin) {
  126. this.getOrderNum();
  127. this.getinfo();
  128. }
  129. },
  130. // #ifndef MP
  131. onNavigationBarButtonTap(e) {
  132. const index = e.index;
  133. if (index === 0) {
  134. this.navTo('/pages/set/set');
  135. }else if(index === 1){
  136. // #ifdef APP-PLUS
  137. const pages = getCurrentPages();
  138. const page = pages[pages.length - 1];
  139. const currentWebview = page.$getAppWebview();
  140. currentWebview.hideTitleNViewButtonRedDot({
  141. index
  142. });
  143. // #endif
  144. uni.navigateTo({
  145. url: '/pages/notice/notice'
  146. })
  147. }
  148. },
  149. // #endif
  150. computed: {
  151. ...mapState(['hasLogin','userInfo'])
  152. },
  153. methods: {
  154. /**
  155. * 会员卡下拉和回弹
  156. * 1.关闭bounce避免ios端下拉冲突
  157. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  158. * transition设置0.1秒延迟,让css来过渡这段空窗期
  159. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  160. */
  161. ...mapMutations(['login', 'logout', 'setUserInfo']),
  162. coverTouchstart(e){
  163. if(pageAtTop === false){
  164. return;
  165. }
  166. this.coverTransition = 'transform .1s linear';
  167. startY = e.touches[0].clientY;
  168. },
  169. coverTouchmove(e){
  170. moveY = e.touches[0].clientY;
  171. let moveDistance = moveY - startY;
  172. if(moveDistance < 0){
  173. this.moving = false;
  174. return;
  175. }
  176. this.moving = true;
  177. if(moveDistance >= 80 && moveDistance < 100){
  178. moveDistance = 80;
  179. }
  180. if(moveDistance > 0 && moveDistance <= 80){
  181. this.coverTransform = `translateY(${moveDistance}px)`;
  182. }
  183. },
  184. coverTouchend(){
  185. if(this.moving === false){
  186. return;
  187. }
  188. this.moving = false;
  189. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  190. this.coverTransform = 'translateY(0px)';
  191. },
  192. async getUserInfo() {
  193. uni.getUserProfile({
  194. desc: '系统将获取你的用户信息',
  195. success: async (res) => {
  196. let [error, loginRes] = await uni.login({
  197. provider: 'weixin'
  198. });
  199. if (loginRes.hasOwnProperty('code')) {
  200. console.log(res.userInfo);
  201. console.log('#################');
  202. let data = await this.$api.request('/user/registerUserGroup?code=' + loginRes.code, 'POST', res.userInfo);
  203. const userInfo = await this.$wechatMiniLogin(true);
  204. this.login(userInfo)
  205. }
  206. },
  207. fail: (res) => {
  208. this.$api.msg('注册失败')
  209. }
  210. })
  211. },
  212. // 获取订单数量
  213. async getOrderNum(){
  214. let data = await this.$api.request('/order/count');
  215. if (data) {
  216. this.orderNum = {
  217. unpaid: data.unpaid ? data.unpaid : 0,
  218. undelivered: data.undelivered ? data.undelivered : 0,
  219. unreceived: data.unreceived ? data.unreceived : 0,
  220. uncomment: data.uncomment ? data.uncomment : 0,
  221. refund: data.refund ? data.refund : 0
  222. };
  223. }
  224. },
  225. async getinfo() {
  226. let data = await this.$api.request('/wallet/index');
  227. console.log(data)
  228. this.info = data;
  229. },
  230. }
  231. }
  232. </script>
  233. <style lang='scss'>
  234. page{
  235. background: #f5f5f5;
  236. }
  237. %flex-center {
  238. display:flex;
  239. flex-direction: column;
  240. justify-content: center;
  241. align-items: center;
  242. }
  243. %section {
  244. display:flex;
  245. justify-content: space-around;
  246. align-content: center;
  247. background: #fff;
  248. border-radius: 10upx;
  249. }
  250. .user-section{
  251. height: 520upx;
  252. padding: 100upx 30upx 0;
  253. position:relative;
  254. .bg{
  255. position:absolute;
  256. left: 0;
  257. top: 0;
  258. width: 100%;
  259. height: 100%;
  260. filter: blur(1px);
  261. }
  262. }
  263. .user-info-box{
  264. height: 150upx;
  265. display:flex;
  266. align-items:center;
  267. position:relative;
  268. z-index: 1;
  269. .portrait{
  270. width: 130upx;
  271. height: 130upx;
  272. border-radius: 50%;
  273. }
  274. .username{
  275. font-size: $font-lg + 6upx;
  276. color: $font-color-dark;
  277. margin-left: 20upx;
  278. }
  279. }
  280. .vip-card-box{
  281. display:flex;
  282. flex-direction: column;
  283. color: #f7d680;
  284. height: 240upx;
  285. background: linear-gradient(left, rgba(0,0,0,.7), rgba(0,0,0,.8));
  286. border-radius: 16upx 16upx 0 0;
  287. overflow: hidden;
  288. position: relative;
  289. padding: 20upx 24upx;
  290. .card-bg{
  291. position:absolute;
  292. top: 20upx;
  293. right: 0;
  294. width: 380upx;
  295. height: 260upx;
  296. }
  297. .b-btn{
  298. position: absolute;
  299. right: 20upx;
  300. top: 16upx;
  301. width: 132upx;
  302. height: 40upx;
  303. text-align: center;
  304. line-height: 40upx;
  305. font-size: 22upx;
  306. color: #36343c;
  307. border-radius: 20px;
  308. background: linear-gradient(left, #f9e6af, #ffd465);
  309. z-index: 1;
  310. }
  311. .tit{
  312. font-size: $font-base+2upx;
  313. color: #000000;
  314. margin-bottom: 28upx;
  315. .yticon{
  316. color: #f6e5a3;
  317. margin-right: 16upx;
  318. }
  319. }
  320. .e-b{
  321. font-size: $font-sm;
  322. color: #d8cba9;
  323. margin-top: 10upx;
  324. }
  325. }
  326. .cover-container{
  327. margin-top: -150upx;
  328. padding: 0 30upx;
  329. position:relative;
  330. background: #f5f5f5;
  331. padding-bottom: 20upx;
  332. .arc{
  333. position:absolute;
  334. left: 0;
  335. top: -34upx;
  336. width: 100%;
  337. height: 36upx;
  338. }
  339. }
  340. .tj-sction{
  341. @extend %section;
  342. .tj-item{
  343. @extend %flex-center;
  344. flex-direction: column;
  345. height: 140upx;
  346. font-size: $font-sm;
  347. color: #75787d;
  348. }
  349. .num{
  350. font-size: $font-lg;
  351. color: $font-color-dark;
  352. margin-bottom: 8upx;
  353. }
  354. }
  355. .order-header {
  356. @extend %section;
  357. padding: 28upx 0 0;
  358. border-radius: 10upx 10upx 0 0;
  359. margin-top: 20upx;
  360. font-size: $font-base;
  361. .title {
  362. width: 50%;
  363. color: $font-color-dark;
  364. margin-left: 30upx;
  365. }
  366. .item {
  367. width: 50%;
  368. color:$font-color-base;
  369. text-align: right;
  370. margin-right: 8upx;
  371. }
  372. }
  373. .order-section{
  374. @extend %section;
  375. border-radius: 0 0 10upx 10upx;
  376. padding: 28upx 0;
  377. .order-item {
  378. @extend %flex-center;
  379. width: 120upx;
  380. height: 120upx;
  381. border-radius: 10upx;
  382. font-size: $font-sm;
  383. color: $font-color-dark;
  384. position: relative;
  385. .num{
  386. border: 4rpx solid #fa436a;
  387. width: 40rpx;
  388. height: 40rpx;
  389. color: #fa436a;
  390. text-align: center;
  391. border-radius: 40rpx;
  392. position: absolute;
  393. background: #ffffff;
  394. top: 0;
  395. right: 18rpx;
  396. }
  397. }
  398. .yticon{
  399. font-size: 48upx;
  400. margin-bottom: 18upx;
  401. color: #fa436a;
  402. }
  403. .icon-shouhoutuikuan{
  404. font-size:44upx;
  405. }
  406. }
  407. .history-section{
  408. padding: 0;
  409. margin-top: 20upx;
  410. background: #fff;
  411. border-radius:10upx;
  412. .sec-header{
  413. display:flex;
  414. align-items: center;
  415. font-size: $font-base;
  416. color: $font-color-dark;
  417. line-height: 40upx;
  418. margin-left: 30upx;
  419. .yticon{
  420. font-size: 44upx;
  421. color: #5eba8f;
  422. margin-right: 16upx;
  423. line-height: 40upx;
  424. }
  425. }
  426. .h-list{
  427. white-space: nowrap;
  428. padding: 30upx 30upx 0;
  429. image{
  430. display:inline-block;
  431. width: 160upx;
  432. height: 160upx;
  433. margin-right: 20upx;
  434. border-radius: 10upx;
  435. }
  436. }
  437. }
  438. button.get-user-info {
  439. margin: 0px;
  440. width: 260rpx;
  441. height: 60rpx;
  442. line-height: 60rpx;
  443. font-size: 14px;
  444. }
  445. </style>