index.vue 15 KB

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