index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view class="new-users">
  3. <view class="head">
  4. <view class="user-card">
  5. <view class="bg"></view>
  6. <view class="user-info">
  7. <image class="avatar" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
  8. <image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"></image>
  9. <view class="info">
  10. <!-- #ifdef MP -->
  11. <view class="name" v-if="!userInfo.uid" @tap="openAuto">
  12. 请点击授权
  13. </view>
  14. <!-- #endif -->
  15. <view class="name" v-if="userInfo.uid">
  16. {{userInfo.nickname}}
  17. <view class="vip" v-if="userInfo.vip">
  18. <image :src="userInfo.vip_icon" alt="">
  19. <view style="margin-left: 10rpx;" class="vip-txt">{{userInfo.vip_name}}</view>
  20. </view>
  21. </view>
  22. <view class="num" v-if="userInfo.phone" @click="goEdit()">
  23. <view class="num-txt">ID:{{userInfo.uid}}</view>
  24. <view class="icon">
  25. <image src="/static/images/edit.png" mode=""></image>
  26. </view>
  27. </view>
  28. <view class="phone" v-if="!userInfo.phone && isLogin" @tap="bindPhone">绑定手机号</view>
  29. </view>
  30. </view>
  31. <view class="num-wrapper">
  32. <view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
  33. <text class="num">{{userInfo.now_money || 0}}</text>
  34. <view class="txt">余额</view>
  35. </view>
  36. <view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
  37. <text class="num">{{userInfo.integral || 0}}</text>
  38. <view class="txt">积分</view>
  39. </view>
  40. <view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
  41. <text class="num">{{userInfo.couponCount || 0}}</text>
  42. <view class="txt">优惠券</view>
  43. </view>
  44. </view>
  45. <view class="sign" @click="goSignIn">签到</view>
  46. </view>
  47. <view class="order-wrapper">
  48. <view class="order-hd flex">
  49. <view class="left">订单中心</view>
  50. <navigator class="right flex" hover-class="none" url="/pages/users/order_list/index" open-type="navigate">
  51. 查看全部
  52. <text class="iconfont icon-xiangyou"></text>
  53. </navigator>
  54. </view>
  55. <view class="order-bd">
  56. <block v-for="(item,index) in orderMenu" :key="index">
  57. <navigator class="order-item" hover-class="none" :url="item.url">
  58. <view class="pic">
  59. <image :src="item.img" mode=""></image>
  60. <text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
  61. </view>
  62. <view class="txt">{{item.title}}</view>
  63. </navigator>
  64. </block>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 轮播 -->
  69. <view class="slider-wrapper" v-if="imgUrls.length>0">
  70. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
  71. indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  72. <block v-for="(item,index) in imgUrls" :key="index">
  73. <swiper-item>
  74. <navigator :url='item.url' class='slide-navigator acea-row row-between-wrapper' hover-class='none'>
  75. <image :src="item.pic" class="slide-image"></image>
  76. </navigator>
  77. </swiper-item>
  78. </block>
  79. </swiper>
  80. </view>
  81. <!-- 会员菜单 -->
  82. <view class="user-menus" style="margin-top: 20rpx;">
  83. <block v-for="(item,index) in MyMenus" :key="index">
  84. <navigator class="item" :url="item.url" hover-class="none" v-if="item.url!='#' && item.url!='/pages/service/index'">
  85. <view class="left">
  86. <image :src="item.pic"></image>
  87. <text>{{item.name}}</text>
  88. </view>
  89. <view class="iconfont icon-xiangyou"></view>
  90. </navigator>
  91. </block>
  92. <!-- #ifdef H5 -->
  93. <navigator class="item" url="/pages/customer_list/index" hover-class="none">
  94. <view class="left">
  95. <image src="/static/images/user_menu08.png"></image>
  96. <text>联系客服</text>
  97. </view>
  98. <view class="iconfont icon-xiangyou"></view>
  99. </navigator>
  100. <!-- #endif -->
  101. <!-- #ifdef MP -->
  102. <button class="item" open-type='contact' hover-class='none'>
  103. <view class="left">
  104. <image src="/static/images/user_menu08.png"></image>
  105. <text>联系客服</text>
  106. </view>
  107. <view class="iconfont icon-xiangyou"></view>
  108. </button>
  109. <!-- #endif -->
  110. </view>
  111. <view style="height: 50rpx;"></view>
  112. <!-- #ifdef MP -->
  113. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  114. <!-- #endif -->
  115. </view>
  116. </template>
  117. <script>
  118. import {
  119. getMenuList,
  120. getUserInfo,
  121. setVisit
  122. } from '@/api/user.js';
  123. import {
  124. toLogin
  125. } from '@/libs/login.js';
  126. import {
  127. mapGetters
  128. } from "vuex";
  129. // #ifdef MP
  130. import authorize from '@/components/Authorize';
  131. // #endif
  132. const app = getApp();
  133. export default {
  134. components: {
  135. // #ifdef MP
  136. authorize
  137. // #endif
  138. },
  139. computed: mapGetters(['isLogin']),
  140. data() {
  141. return {
  142. orderMenu: [{
  143. img: '/static/images/order1.png',
  144. title: '待付款',
  145. url: '/pages/users/order_list/index?status=0'
  146. },
  147. {
  148. img: '/static/images/order2.png',
  149. title: '待发货',
  150. url: '/pages/users/order_list/index?status=1'
  151. },
  152. {
  153. img: '/static/images/order3.png',
  154. title: '待收货',
  155. url: '/pages/users/order_list/index?status=2'
  156. },
  157. {
  158. img: '/static/images/order4.png',
  159. title: '待评价',
  160. url: '/pages/users/order_list/index?status=3'
  161. },
  162. {
  163. img: '/static/images/order5.png',
  164. title: '售后/退款',
  165. url: '/pages/users/user_return_list/index'
  166. },
  167. ],
  168. imgUrls: [],
  169. userMenu: [{
  170. icon: '/static/images/user_menu01.png',
  171. title: '会员中心',
  172. url: '/pages/users/user_vip/index'
  173. },
  174. {
  175. icon: '/static/images/user_menu02.png',
  176. title: '我的推广',
  177. url: '/pages/users/user_spread_user/index'
  178. },
  179. {
  180. icon: '/static/images/user_menu03.png',
  181. title: '优惠券',
  182. url: '/pages/users/user_coupon/index'
  183. },
  184. {
  185. icon: '/static/images/user_menu04.png',
  186. title: '砍价记录',
  187. url: '/pages/activity/bargain/index'
  188. },
  189. {
  190. icon: '/static/images/user_menu05.png',
  191. title: '我的余额',
  192. url: '/pages/users/user_money/index'
  193. },
  194. {
  195. icon: '/static/images/user_menu06.png',
  196. title: '我的收藏',
  197. url: '/pages/users/user_goods_collection/index'
  198. },
  199. {
  200. icon: '/static/images/user_menu07.png',
  201. title: '地址管理',
  202. url: '/pages/users/user_address_list/index'
  203. },
  204. ],
  205. autoplay: true,
  206. circular: true,
  207. interval: 3000,
  208. duration: 500,
  209. isAuto: false, //没有授权的不会自动授权
  210. isShowAuth: false, //是否隐藏授权
  211. orderStatusNum: {},
  212. userInfo: {},
  213. MyMenus: []
  214. }
  215. },
  216. onLoad() {
  217. let that = this;
  218. that.$set(that, 'MyMenus', app.globalData.MyMenus);
  219. // #ifdef H5 || APP-PLUS
  220. if (that.isLogin == false) {
  221. toLogin();
  222. }
  223. // #endif
  224. },
  225. onShow: function() {
  226. let that = this;
  227. if (that.isLogin) {
  228. this.getUserInfo();
  229. this.getMyMenus();
  230. this.setVisit();
  231. }
  232. },
  233. methods: {
  234. // 记录会员访问
  235. setVisit(){
  236. setVisit({
  237. url:'/pages/user/index'
  238. }).then(res=>{})
  239. },
  240. // 打开授权
  241. openAuto() {
  242. this.isAuto = true;
  243. this.isShowAuth = true
  244. },
  245. // 授权回调
  246. onLoadFun() {
  247. this.getUserInfo();
  248. this.getMyMenus();
  249. this.setVisit();
  250. },
  251. Setting: function() {
  252. uni.openSetting({
  253. success: function(res) {
  254. console.log(res.authSetting)
  255. }
  256. });
  257. },
  258. // 授权关闭
  259. authColse: function(e) {
  260. this.isShowAuth = e
  261. },
  262. // 绑定手机
  263. bindPhone() {
  264. uni.navigateTo({
  265. url: '/pages/users/user_phone/index'
  266. })
  267. },
  268. /**
  269. * 获取个人用户信息
  270. */
  271. getUserInfo: function() {
  272. let that = this;
  273. getUserInfo().then(res => {
  274. that.userInfo = res.data
  275. that.$store.commit("SETUID", res.data.uid);
  276. that.orderMenu.forEach((item, index) => {
  277. switch (item.title) {
  278. case '待付款':
  279. item.num = res.data.orderStatusNum.unpaid_count
  280. break
  281. case '待发货':
  282. item.num = res.data.orderStatusNum.unshipped_count
  283. break
  284. case '待收货':
  285. item.num = res.data.orderStatusNum.received_count
  286. break
  287. case '待评价':
  288. item.num = res.data.orderStatusNum.evaluated_count
  289. break
  290. case '售后/退款':
  291. item.num = res.data.orderStatusNum.refund_count
  292. break
  293. }
  294. })
  295. });
  296. },
  297. /**
  298. *
  299. * 获取个人中心图标
  300. */
  301. getMyMenus: function() {
  302. let that = this;
  303. if (this.MyMenus.length) return;
  304. getMenuList().then(res => {
  305. that.$set(that, 'MyMenus', res.data.routine_my_menus);
  306. this.imgUrls = res.data.routine_my_banner
  307. });
  308. },
  309. // 编辑页面
  310. goEdit() {
  311. uni.navigateTo({
  312. url: '/pages/users/user_info/index'
  313. })
  314. },
  315. // 签到
  316. goSignIn() {
  317. uni.navigateTo({
  318. url: '/pages/users/user_sgin/index'
  319. })
  320. },
  321. // goMenuPage
  322. goMenuPage(url){
  323. if(this.isLogin){
  324. uni.navigateTo({
  325. url
  326. })
  327. }else{
  328. // #ifdef MP
  329. this.openAuto()
  330. // #endif
  331. }
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="scss">
  337. .new-users {
  338. .head {
  339. padding-top: 30rpx;
  340. background: #fff;
  341. .user-card {
  342. position: relative;
  343. width: 710rpx;
  344. height: 340rpx;
  345. margin: 0 auto;
  346. padding: 35rpx 28rpx;
  347. background: linear-gradient(90deg, $bg-star 0%, $bg-end 100%);
  348. box-shadow: 0px 10rpx 20rpx 0px rgba(255, 2, 0, 0.2);
  349. border-radius: 24rpx;
  350. .bg {
  351. position: absolute;
  352. left: 0;
  353. top: 0;
  354. width: 100%;
  355. height: 100%;
  356. background-image: url('~@/static/images/user_bg.png');
  357. background-size: 100% 100%;
  358. }
  359. .user-info {
  360. z-index: 20;
  361. position: relative;
  362. display: flex;
  363. .avatar {
  364. width: 120rpx;
  365. height: 120rpx;
  366. border-radius: 50%;
  367. }
  368. .info {
  369. flex: 1;
  370. display: flex;
  371. flex-direction: column;
  372. justify-content: space-between;
  373. margin-left: 20rpx;
  374. padding: 15rpx 0;
  375. .name {
  376. display: flex;
  377. align-items: center;
  378. color: #fff;
  379. font-size: 31rpx;
  380. .vip {
  381. display: flex;
  382. align-items: center;
  383. height: 36rpx;
  384. padding: 0 20rpx;
  385. background: rgba(0, 0, 0, 0.2);
  386. border-radius: 18px;
  387. font-size: 20rpx;
  388. margin-left: 12rpx;
  389. image {
  390. width: 27rpx;
  391. height: 27rpx;
  392. }
  393. }
  394. }
  395. .num {
  396. display: flex;
  397. align-items: center;
  398. font-size: 26rpx;
  399. color: rgba(255, 255, 255, 0.6);
  400. image {
  401. width: 22rpx;
  402. height: 23rpx;
  403. margin-left: 20rpx;
  404. }
  405. }
  406. }
  407. }
  408. .num-wrapper {
  409. z-index: 30;
  410. position: relative;
  411. display: flex;
  412. align-items: center;
  413. justify-content: space-between;
  414. margin-top: 60rpx;
  415. // padding: 0 47rpx;
  416. color: #fff;
  417. .num-item {
  418. width: 33.33%;
  419. text-align: center;
  420. .num {
  421. font-size: 42rpx;
  422. font-weight: bold;
  423. }
  424. .txt {
  425. margin-top: 8rpx;
  426. font-size: 26rpx;
  427. color: rgba(255, 255, 255, 0.6);
  428. }
  429. }
  430. }
  431. .sign {
  432. z-index: 200;
  433. position: absolute;
  434. right: -12rpx;
  435. top: 80rpx;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. width: 120rpx;
  440. height: 60rpx;
  441. background: linear-gradient(90deg, rgba(255, 225, 87, 1) 0%, rgba(238, 193, 15, 1) 100%);
  442. border-radius: 29rpx 4rpx 4rpx 29rpx;
  443. color: #282828;
  444. font-size: 28rpx;
  445. font-weight: bold;
  446. }
  447. }
  448. .order-wrapper {
  449. .order-hd {
  450. justify-content: space-between;
  451. padding: 0 20rpx 28rpx;
  452. margin-top: 33rpx;
  453. border-bottom: 1px solid #F5F5F5;
  454. font-size: 30rpx;
  455. color: #282828;
  456. .right {
  457. align-items: center;
  458. color: #666666;
  459. font-size: 26rpx;
  460. .icon-xiangyou {
  461. margin-left: 5rpx;
  462. margin-top: 6rpx;
  463. font-size: 26rpx;
  464. }
  465. }
  466. }
  467. .order-bd {
  468. display: flex;
  469. padding: 0 24rpx;
  470. .order-item {
  471. display: flex;
  472. flex-direction: column;
  473. justify-content: center;
  474. align-items: center;
  475. width: 20%;
  476. height: 160rpx;
  477. .pic {
  478. position: relative;
  479. text-align: center;
  480. image {
  481. width: 48rpx;
  482. height: 48rpx;
  483. }
  484. }
  485. .txt {
  486. margin-top: 15rpx;
  487. font-size: 26rpx;
  488. color: #454545;
  489. }
  490. }
  491. }
  492. }
  493. }
  494. .slider-wrapper {
  495. margin: 20rpx 0;
  496. height: 130rpx;
  497. swiper,
  498. swiper-item {
  499. height: 100%;
  500. }
  501. image {
  502. width: 100%;
  503. height: 130rpx;
  504. }
  505. }
  506. .user-menus {
  507. background-color: #fff;
  508. .item {
  509. position: relative;
  510. display: flex;
  511. align-items: center;
  512. justify-content: space-between;
  513. height: 90rpx;
  514. padding: 0 30rpx;
  515. .left {
  516. display: flex;
  517. align-items: center;
  518. image {
  519. width: 46rpx;
  520. height: 46rpx;
  521. margin-right: 25rpx;
  522. }
  523. }
  524. &::before {
  525. content: ' ';
  526. position: absolute;
  527. right: 0;
  528. bottom: 0;
  529. width: 655rpx;
  530. height: 1px;
  531. background-color: #EEEEEE;
  532. }
  533. &:last-child::before {
  534. display: none;
  535. }
  536. }
  537. button{
  538. font-size: 28rpx;
  539. }
  540. }
  541. .phone {
  542. color: #fff;
  543. }
  544. .order-status-num {
  545. min-width:12rpx;
  546. background-color: #fff;
  547. color: #ee5a52;
  548. border-radius: 15px;
  549. position: absolute;
  550. right:-14rpx;
  551. top: -15rpx;
  552. font-size: 20rpx;
  553. padding: 0 8rpx;
  554. border: 1px solid #ee5a52;
  555. }
  556. }
  557. </style>