user.vue 14 KB

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