user.vue 14 KB

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