index.vue 18 KB

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