index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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_goods_collection/index')">
  33. <text class="num">{{userInfo.total_collect_product || 0}}</text>
  34. <view class="txt">我的收藏</view>
  35. </view>
  36. <view v-if="hide_mer_status == 0" class="num-item" @click="goMenuPage('/pages/users/user_store_attention/index')">
  37. <text class="num">{{userInfo.total_collect_store || 0}}</text>
  38. <view class="txt">关注店铺</view>
  39. </view>
  40. <view class="num-item" @click="goMenuPage('/pages/users/browsingHistory/index')">
  41. <text class="num">{{userInfo.total_visit_product || 0}}</text>
  42. <view class="txt">浏览记录</view>
  43. </view>
  44. <view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
  45. <text class="num">{{userInfo.total_coupon || 0}}</text>
  46. <view class="txt">优惠券</view>
  47. </view>
  48. </view>
  49. <view class="right-btn">
  50. <view class="iconfont icon-shezhi" @click="goEdit()" v-if="userInfo.phone"></view>
  51. <navigator class="btn" url="/pages/chat/customer_list/index?type=0" hover-class="none">
  52. <view class="iconfont icon-xiaoxi"></view>
  53. <text class="iconnum" v-if="userInfo.total_unread">{{userInfo.total_unread}}</text>
  54. </navigator>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="wrapper">
  59. <view class="order-wrapper">
  60. <view class="order-hd flex">
  61. <view class="left">我的订单</view>
  62. <navigator class="right flex" hover-class="none" url="/pages/users/order_list/index" open-type="navigate">
  63. 全部订单
  64. <text class="iconfont icon-xiangyou"></text>
  65. </navigator>
  66. </view>
  67. <view class="order-bd">
  68. <block v-for="(item,index) in orderMenu" :key="index">
  69. <navigator class="order-item" hover-class="none" :url="item.url">
  70. <view class="pic">
  71. <image :src="item.img" mode=""></image>
  72. <text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
  73. </view>
  74. <view class="txt">{{item.title}}</view>
  75. </navigator>
  76. </block>
  77. </view>
  78. </view>
  79. <!-- 轮播 -->
  80. <view class="slider-wrapper" v-if="imgUrls.length>0">
  81. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
  82. indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  83. <block v-for="(item,index) in imgUrls" :key="index">
  84. <swiper-item>
  85. <navigator :url='item.url' class='slide-navigator acea-row row-between-wrapper' hover-class='none'>
  86. <image :src="item.pic" class="slide-image"></image>
  87. </navigator>
  88. </swiper-item>
  89. </block>
  90. </swiper>
  91. </view>
  92. <!-- 会员菜单 -->
  93. <view class="user-menus" style="margin-top: 20rpx;">
  94. <view class="title">我的服务</view>
  95. <view class="menu-box" v-if="isLogin">
  96. <navigator url="/pages/users/user_money/index" class="item" hover-class="none" v-if="balance_func_status == 1">
  97. <image src="/static/images/user-menu-001.png"></image>
  98. <text>我的余额</text>
  99. </navigator>
  100. <navigator url="/pages/users/user_spread_user/index" class="item" hover-class="none" v-if="is_promoter == 1 && extension_status == 1">
  101. <image src="/static/images/user_menu11.png"></image>
  102. <text>分销推广</text>
  103. </navigator>
  104. <navigator url="/pages/users/distributor/index" class="item" hover-class="none" v-if="is_promoter == 0 && extension_status == 1">
  105. <image src="/static/images/user_menu11.png"></image>
  106. <text>分销推广</text>
  107. </navigator>
  108. <view class="item" @click="goUrl(item.url)"
  109. v-for="(item,index) in MyMenus" :key="index">
  110. <image :src="item.pic"></image>
  111. <text>{{item.name}}</text>
  112. </view>
  113. <navigator url="/pages/admin/order/index" class="item" hover-class="none" v-if="userInfo.service && userInfo.service.customer === 1">
  114. <image src="/static/images/user-menu-002.png"></image>
  115. <text>订单管理</text>
  116. </navigator>
  117. <navigator url="/pages/store/settled/index" class="item" hover-class="none" v-if="mer_intention_open == 1 && hide_mer_status == 0">
  118. <image src="/static/images/user-menu-003.png"></image>
  119. <text>商家入驻</text>
  120. </navigator>
  121. <navigator class="item" hover-class="none" url="/pages/admin/order_cancellation/index" v-if="userInfo.service && userInfo.service.is_verify">
  122. <block v-if="userInfo.service.is_verify == 1">
  123. <image src="/static/images/user_menu10.png"></image>
  124. <text>订单核销</text>
  125. </block>
  126. </navigator>
  127. <navigator url="/pages/activity/assist_record/index" class="item" hover-class="none">
  128. <image src="/static/images/user-menu-004.png"></image>
  129. <text>助力记录</text>
  130. </navigator>
  131. <view class="item" hover-class="none" @click="goChat" v-if="userInfo.service">
  132. <image src="/static/images/user_menu08.png"></image>
  133. <text>联系客服</text>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. <view style="height: 50rpx;"></view>
  139. <!-- #ifdef MP -->
  140. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  141. <!-- #endif -->
  142. </view>
  143. </template>
  144. <script>
  145. import {
  146. getMenuList,
  147. getUserInfo,
  148. setVisit
  149. } from '@/api/user.js';
  150. import {
  151. toLogin
  152. } from '@/libs/login.js';
  153. import {
  154. orderData
  155. } from '@/api/order.js'
  156. import {
  157. getconfig, login
  158. } from '@/api/public.js'
  159. import {
  160. mapGetters
  161. } from "vuex";
  162. // #ifdef MP
  163. import authorize from '@/components/Authorize';
  164. // #endif
  165. const app = getApp();
  166. export default {
  167. components: {
  168. // #ifdef MP
  169. authorize
  170. // #endif
  171. },
  172. computed: mapGetters(['isLogin']),
  173. data() {
  174. return {
  175. orderMenu: [{
  176. img: '/static/images/order1.png',
  177. title: '待付款',
  178. url: '/pages/users/order_list/index?status=0',
  179. num: 0
  180. },
  181. {
  182. img: '/static/images/order2.png',
  183. title: '待发货',
  184. url: '/pages/users/order_list/index?status=1',
  185. num: 0
  186. },
  187. {
  188. img: '/static/images/order3.png',
  189. title: '待收货',
  190. url: '/pages/users/order_list/index?status=2',
  191. num: 0
  192. },
  193. {
  194. img: '/static/images/order4.png',
  195. title: '待评价',
  196. url: '/pages/users/order_list/index?status=3',
  197. num: 0
  198. },
  199. {
  200. img: '/static/images/order5.png',
  201. title: '售后/退款',
  202. url: '/pages/users/refund/list',
  203. num: 0
  204. },
  205. ],
  206. imgUrls: [],
  207. userMenu: [],
  208. autoplay: true,
  209. circular: true,
  210. interval: 3000,
  211. duration: 500,
  212. isAuto: false, //没有授权的不会自动授权
  213. isShowAuth: false, //是否隐藏授权
  214. orderStatusNum: {},
  215. userInfo: {},
  216. MyMenus: [],
  217. balance_func_status: 0, //余额开关 1开
  218. is_promoter: 0, //推广人开关 1开
  219. extension_status: 0,
  220. mer_intention_open: 0,
  221. hide_mer_status: 1,
  222. }
  223. },
  224. onLoad() {
  225. getconfig().then(res => {
  226. this.balance_func_status = res.data.balance_func_status
  227. this.mer_intention_open = res.data.mer_intention_open
  228. this.hide_mer_status = res.data.hide_mer_status
  229. try {
  230. uni.setStorageSync('SUBSCRIBE_MESSAGE', res.data.tempid);
  231. } catch (e) {
  232. // error
  233. }
  234. // #ifdef H5
  235. this.setOpenShare(res.data);
  236. // #endif
  237. }).catch(err => {})
  238. let that = this;
  239. // #ifdef H5 || APP-PLUS
  240. if (that.isLogin == false) {
  241. toLogin();
  242. }
  243. // #endif
  244. },
  245. onReady() {
  246. uni.$on('update',(data)=>{
  247. this.balance_func_status = data.balance_func_status
  248. this.mer_intention_open = data.mer_intention_open
  249. this.hide_mer_status = data.hide_mer_status
  250. })
  251. },
  252. mounted: function() {
  253. const app = getApp();
  254. this.$nextTick(() => {
  255. this.hide_mer_status = app.globalData.hide_mer_status
  256. this.balance_func_status = app.globalData.balance_func_status
  257. this.mer_intention_open = app.globalData.mer_intention_open
  258. this.hide_mer_status = app.globalData.hide_mer_status
  259. });
  260. },
  261. onShow: function() {
  262. console.log('ddddddddddddd')
  263. let that = this;
  264. if (that.isLogin) {
  265. this.getUserInfo();
  266. this.orderNum();
  267. this.getMyMenus();
  268. // this.setVisit();
  269. } else {
  270. // #ifdef H5 || APP-PLUS
  271. toLogin();
  272. // #endif
  273. }
  274. },
  275. methods: {
  276. goUrl(url){
  277. // if(url == '/pages/users/user_address_list/index'){
  278. // window.location.href = url
  279. // }else{
  280. // uni.navigateTo({
  281. // url
  282. // })
  283. // }
  284. uni.navigateTo({
  285. url
  286. })
  287. },
  288. // 去聊天列表
  289. goChat() {
  290. let type = this.userInfo.service ? 1 : 0
  291. uni.navigateTo({
  292. url: `/pages/chat/customer_list/index?type=${type}`
  293. })
  294. },
  295. // 记录会员访问
  296. setVisit() {
  297. setVisit({
  298. url: '/pages/user/index'
  299. }).then(res => {})
  300. },
  301. // 打开授权
  302. openAuto() {
  303. this.isAuto = true;
  304. this.isShowAuth = true
  305. },
  306. // 授权回调
  307. onLoadFun() {
  308. this.getUserInfo();
  309. this.getMyMenus();
  310. this.orderNum();
  311. this.isShowAuth = false
  312. },
  313. Setting: function() {
  314. uni.openSetting({
  315. success: function(res) {
  316. console.log(res.authSetting)
  317. }
  318. });
  319. },
  320. // 授权关闭
  321. authColse: function(e) {
  322. this.isShowAuth = e
  323. },
  324. // 绑定手机
  325. bindPhone() {
  326. uni.navigateTo({
  327. url: '/pages/users/user_phone/index'
  328. })
  329. },
  330. /**
  331. * 获取个人用户信息
  332. */
  333. getUserInfo: function() {
  334. let that = this;
  335. getUserInfo().then(res => {
  336. that.userInfo = res.data,
  337. that.is_promoter = res.data.is_promoter
  338. that.extension_status = res.data.extension_status
  339. console.log(that.userInfo,'that.userInfo++++++')
  340. if(!that.userInfo.phone){
  341. uni.showModal({
  342. title: "请绑定手机号",
  343. content: "为了方便您的取货和我们的送货,并获取更多优惠活动,需要您的手机授权!",
  344. showCancel: false,
  345. success(){
  346. // uni.navigateTo({
  347. // url: 'pages/users/user_phone/index'
  348. // })
  349. that.bindPhone()
  350. }
  351. })
  352. }
  353. });
  354. },
  355. // 订单数字
  356. orderNum() {
  357. orderData().then(({
  358. data
  359. }) => {
  360. this.orderMenu.forEach((item, index) => {
  361. console.log('item')
  362. switch (item.title) {
  363. case '待付款':
  364. item.num = data.noPay
  365. break
  366. case '待发货':
  367. item.num = data.noPostage
  368. break
  369. case '待收货':
  370. item.num = data.noDeliver
  371. break
  372. case '待评价':
  373. item.num = data.noComment
  374. break
  375. case '售后/退款':
  376. item.num = data.refund
  377. break
  378. }
  379. })
  380. })
  381. },
  382. /**
  383. *
  384. * 获取个人中心图标
  385. */
  386. getMyMenus: function() {
  387. let that = this;
  388. if (this.MyMenus.length) return;
  389. getMenuList().then(res => {
  390. that.$set(that, 'MyMenus', res.data.menu);
  391. this.imgUrls = res.data.banner
  392. });
  393. },
  394. // 编辑页面
  395. goEdit() {
  396. uni.navigateTo({
  397. url: '/pages/users/user_info/index'
  398. })
  399. },
  400. // 签到
  401. goSignIn() {
  402. uni.navigateTo({
  403. url: '/pages/users/user_sgin/index'
  404. })
  405. },
  406. // goMenuPage
  407. goMenuPage(url) {
  408. if (this.isLogin) {
  409. uni.navigateTo({
  410. url
  411. })
  412. } else {
  413. // #ifdef MP
  414. this.openAuto()
  415. // #endif
  416. }
  417. }
  418. }
  419. }
  420. </script>
  421. <style lang="scss">
  422. .new-users {
  423. .head {
  424. background: #fff;
  425. .user-card {
  426. position: relative;
  427. width: 100%;
  428. padding: 35rpx 0 70rpx;
  429. background: linear-gradient(90deg, #EB3C3C 0%, #FF5D43 100%);
  430. .bg {
  431. position: absolute;
  432. left: 0;
  433. top: 0;
  434. width: 100%;
  435. height: 100%;
  436. background-image: url('~@/static/images/user_bg.png');
  437. background-size: 100% 100%;
  438. }
  439. .user-info {
  440. z-index: 20;
  441. position: relative;
  442. display: flex;
  443. padding: 0 28rpx;
  444. .avatar {
  445. width: 120rpx;
  446. height: 120rpx;
  447. border-radius: 50%;
  448. }
  449. .info {
  450. flex: 1;
  451. display: flex;
  452. flex-direction: column;
  453. justify-content: space-between;
  454. margin-left: 20rpx;
  455. padding: 15rpx 0;
  456. .name {
  457. display: flex;
  458. align-items: center;
  459. color: #fff;
  460. font-size: 31rpx;
  461. .vip {
  462. display: flex;
  463. align-items: center;
  464. height: 36rpx;
  465. padding: 0 20rpx;
  466. background: rgba(0, 0, 0, 0.2);
  467. border-radius: 18px;
  468. font-size: 20rpx;
  469. margin-left: 12rpx;
  470. image {
  471. width: 27rpx;
  472. height: 27rpx;
  473. }
  474. }
  475. }
  476. .num {
  477. display: flex;
  478. align-items: center;
  479. font-size: 26rpx;
  480. color: rgba(255, 255, 255, 0.6);
  481. image {
  482. width: 22rpx;
  483. height: 23rpx;
  484. margin-left: 20rpx;
  485. }
  486. }
  487. }
  488. }
  489. .num-wrapper {
  490. z-index: 30;
  491. position: relative;
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. margin-top: 30rpx;
  496. // padding: 0 47rpx;
  497. color: #fff;
  498. .num-item {
  499. width: 25%;
  500. text-align: center;
  501. .num {
  502. font-size: 42rpx;
  503. font-weight: bold;
  504. }
  505. .txt {
  506. margin-top: 8rpx;
  507. font-size: 22rpx;
  508. color: rgba(255, 255, 255, 0.6);
  509. }
  510. }
  511. }
  512. .sign {
  513. z-index: 200;
  514. position: absolute;
  515. right: -12rpx;
  516. top: 80rpx;
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. width: 120rpx;
  521. height: 60rpx;
  522. background: linear-gradient(90deg, rgba(255, 225, 87, 1) 0%, rgba(238, 193, 15, 1) 100%);
  523. border-radius: 29rpx 4rpx 4rpx 29rpx;
  524. color: #282828;
  525. font-size: 28rpx;
  526. font-weight: bold;
  527. }
  528. }
  529. }
  530. .wrapper {
  531. position: relative;
  532. top: -44rpx;
  533. padding: 0 20rpx;
  534. }
  535. .order-wrapper {
  536. background-color: #fff;
  537. border-radius: 12rpx;
  538. .order-hd {
  539. height: 80rpx;
  540. align-items: center;
  541. justify-content: space-between;
  542. border-bottom: 1px dashed #DDDDDD;
  543. padding: 0 30rpx;
  544. font-size: 30rpx;
  545. color: #282828;
  546. .right {
  547. align-items: center;
  548. color: #666666;
  549. font-size: 26rpx;
  550. .icon-xiangyou {
  551. margin-left: 5rpx;
  552. margin-top: 6rpx;
  553. font-size: 26rpx;
  554. }
  555. }
  556. }
  557. .order-bd {
  558. display: flex;
  559. // padding: 0 24rpx;
  560. .order-item {
  561. display: flex;
  562. flex-direction: column;
  563. justify-content: center;
  564. align-items: center;
  565. width: 20%;
  566. height: 160rpx;
  567. .pic {
  568. position: relative;
  569. text-align: center;
  570. image {
  571. width: 56rpx;
  572. height: 56rpx;
  573. }
  574. }
  575. .txt {
  576. margin-top: 15rpx;
  577. font-size: 26rpx;
  578. color: #454545;
  579. }
  580. }
  581. }
  582. }
  583. .slider-wrapper {
  584. margin: 20rpx 0;
  585. height: 130rpx;
  586. swiper,
  587. swiper-item {
  588. height: 100%;
  589. }
  590. image {
  591. width: 100%;
  592. height: 130rpx;
  593. }
  594. }
  595. .user-menus {
  596. padding-bottom: 30rpx;
  597. background-color: #fff;
  598. .title {
  599. height: 80rpx;
  600. line-height: 80rpx;
  601. padding: 0 30rpx;
  602. border-bottom: 1px dashed #DDDDDD;
  603. }
  604. .item {
  605. position: relative;
  606. display: flex;
  607. flex-direction: column;
  608. align-items: center;
  609. justify-content: space-between;
  610. width: 25%;
  611. line-height: 28rpx;
  612. height: 90rpx;
  613. margin-top: 30rpx;
  614. text-align: center;
  615. image {
  616. width: 52rpx;
  617. height: 52rpx;
  618. }
  619. text {
  620. margin-top: 10rpx;
  621. font-size: 26rpx;
  622. color: #282828;
  623. text-overflow: ellipsis;
  624. overflow: hidden;
  625. white-space: nowrap;
  626. width: 78%;
  627. }
  628. &:last-child::before {
  629. display: none;
  630. }
  631. }
  632. button {
  633. font-size: 28rpx;
  634. }
  635. }
  636. .phone {
  637. color: #fff;
  638. }
  639. .order-status-num {
  640. min-width: 12rpx;
  641. background-color: #fff;
  642. color: #ee5a52;
  643. border-radius: 15px;
  644. position: absolute;
  645. right: -14rpx;
  646. top: -15rpx;
  647. font-size: 20rpx;
  648. padding: 0 8rpx;
  649. border: 1px solid #ee5a52;
  650. }
  651. }
  652. .copy-right {
  653. display: flex;
  654. flex-direction: column;
  655. justify-content: center;
  656. align-items: center;
  657. color: #CCCCCC;
  658. font-size: 22rpx;
  659. .iconfont {
  660. font-size: 60rpx;
  661. }
  662. }
  663. .menu-box {
  664. display: flex;
  665. flex-wrap: wrap;
  666. }
  667. .right-btn {
  668. z-index: 99;
  669. position: absolute;
  670. right: 30rpx;
  671. top: 40rpx;
  672. display: flex;
  673. align-items: center;
  674. color: #fff;
  675. .iconfont {
  676. font-size: 40rpx;
  677. margin-left: 33rpx;
  678. }
  679. .btn {
  680. position: relative;
  681. }
  682. .iconnum {
  683. min-width: 6px;
  684. background-color: #fff;
  685. color: $theme-color;
  686. border-radius: 15rpx;
  687. position: absolute;
  688. right: -10rpx;
  689. top: -10rpx;
  690. font-size: 10px;
  691. padding: 0 4px;
  692. }
  693. }
  694. </style>