index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <template>
  2. <view>
  3. <zj-page-layout
  4. :isScroll="true"
  5. :isWxCustomPage="true"
  6. :isLoading="isLoading"
  7. :refresherTriggered="refresherTriggered"
  8. @refresherrefresh="refresherrefresh"
  9. >
  10. <!-- <template slot="header">
  11. <view class="header-container" :style="cuStyle">我的</view>
  12. </template> -->
  13. <view class="a-container">
  14. <view class="top-container">
  15. <view class="user" v-if="isLogin">
  16. <view class="left" @tap="navToPage('/packageMine/pages/userinfo')">
  17. <block v-if="userInfo.avatar">
  18. <image :src="userInfo.avatar" mode="aspectFill" v-if="userInfo.avatar.indexOf('http') >= 0"></image>
  19. <image :src="imageUrl + userInfo.avatar" mode="aspectFill" v-else></image>
  20. </block>
  21. <view class="main">
  22. <view class="name">{{ userInfo.nickName }}</view>
  23. <view class="text">点击修改个人资料<text class="iconfont icon-jinru"></text></view>
  24. </view>
  25. </view>
  26. <view class="right">
  27. <view class="it" v-if="(isServiceUser || isWorkerUser) && qrcode2" @tap="openCode">
  28. <text class="iconfont icon-erweima"></text>
  29. </view>
  30. <view class="it" @tap="navToPage('/packageMine/pages/notice/list')">
  31. <u-icon name="chat" size="30"></u-icon>
  32. <u-badge max="99" :value="noticeNum || 0" absolute :offset="[-2, -2]"></u-badge>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="user" @tap="navToPage('/pages/login/indexs')" v-else>
  37. <view class="left">
  38. <image :src="configInfo.minLogo3" mode="aspectFill"></image>
  39. <view class="main">
  40. <view class="name">请先登录</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="stats">
  45. <view
  46. class="item"
  47. v-for="(item, index) in statsList.filter(o => o.show)"
  48. :key="index"
  49. @tap="navToPage(item.link)"
  50. >
  51. <view class="value">{{ item.num }}</view>
  52. <view class="label">{{ item.name }}</view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="all-container">
  57. <view class="profit-container card" v-if="isLogin && (isServiceUser || isWorkerUser)">
  58. <view class="home-title">
  59. <view class="left">分销收益</view>
  60. <view class="right" @tap="navToPage('/packageMine/pages/profit/list', 1)">
  61. <text class="text">明细</text>
  62. <text class="iconfont icon-jinru"></text>
  63. </view>
  64. </view>
  65. <view class="list">
  66. <view
  67. class="item"
  68. v-for="(item, index) in shareProfitList"
  69. :key="index"
  70. @tap="navToPage('/packageMine/pages/profit/list', 1)"
  71. >
  72. <view class="num">{{ item.num | priceFilter }}</view>
  73. <view class="title">{{ item.title }}</view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="profit-container card" v-if="isLogin && isWorkerUser">
  78. <view class="home-title">
  79. <view class="left">销售收益</view>
  80. <view class="right" @tap="navToPage('/packageMine/pages/salesProfit/index', 1)">
  81. <text class="text">明细</text>
  82. <text class="iconfont icon-jinru"></text>
  83. </view>
  84. </view>
  85. <view class="list">
  86. <view
  87. class="item"
  88. v-for="(item, index) in salesProfitList"
  89. :key="index"
  90. @tap="navToPage('/packageMine/pages/salesProfit/index', 1)"
  91. >
  92. <view class="num">{{ item.num | priceFilter }}</view>
  93. <view class="title">{{ item.title }}</view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="order-container card">
  98. <view class="home-title">
  99. <view class="left">我的订单</view>
  100. <view class="right" @tap="navToPage('/packageMine/pages/order/list?tab=', 1)">
  101. <text class="text">全部订单</text>
  102. <text class="iconfont icon-jinru"></text>
  103. </view>
  104. </view>
  105. <view class="list">
  106. <view
  107. class="item"
  108. v-for="(item, index) in orderList"
  109. :key="index"
  110. @tap="navToPage(`/packageMine/pages/order/list?tab=${item.key}`, 1)"
  111. >
  112. <view class="icon">
  113. <text class="iconfont" :class="item.icon"></text>
  114. <u-badge max="99" :value="item.num" :absolute="true" :offset="[-4, -4]"></u-badge>
  115. </view>
  116. <view class="title">{{ item.title }}</view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="menu-container card">
  121. <view class="home-title">
  122. <view class="left">更多服务</view>
  123. </view>
  124. <view class="list">
  125. <block v-for="(item, index) in menuList.filter(o => o.show)" :key="index">
  126. <button
  127. v-if="item.fn == 'phone'"
  128. open-type="getPhoneNumber"
  129. @getphonenumber="getPhoneNumber"
  130. class="item"
  131. >
  132. <view class="icon"><text class="iconfont" :class="item.icon"></text></view>
  133. <view class="title">{{ item.name }}</view>
  134. <view class="right"><text class="iconfont icon-jinru"></text></view>
  135. </button>
  136. <button v-else-if="item.fn == 'contact'" open-type="contact" class="item">
  137. <view class="icon"><text class="iconfont" :class="item.icon"></text></view>
  138. <view class="title">{{ item.name }}</view>
  139. <view class="right"><text class="iconfont icon-jinru"></text></view>
  140. </button>
  141. <view
  142. v-else-if="item.icon == 'coupon'"
  143. class="item"
  144. @tap="item.link ? navToPage(item.link, 1) : actionFn(item.fn)"
  145. >
  146. <view class="icon"><u-icon size="20" :name="item.icon"></u-icon></view>
  147. <view class="title">{{ item.name }}</view>
  148. <view class="right"><text class="iconfont icon-jinru"></text></view>
  149. </view>
  150. <view v-else class="item" @tap="item.link ? navToPage(item.link, 1) : actionFn(item.fn)">
  151. <view class="icon"><text class="iconfont" :class="item.icon"></text></view>
  152. <view class="title">{{ item.name }}</view>
  153. <view class="right"><text class="iconfont icon-jinru"></text></view>
  154. </view>
  155. </block>
  156. </view>
  157. </view>
  158. <!-- <no-data v-if="!isLogin" :showText="'请先登录'" @tap="navToPage('/pages/login/indexs')"></no-data> -->
  159. <!-- <view class="logout" @tap="toLogout()" v-if="isLogin">退出登录</view> -->
  160. </view>
  161. </view>
  162. </zj-page-layout>
  163. </view>
  164. </template>
  165. <script>
  166. import { getNoticeNum, getOrderNum, selectionChange } from '@/common/utils/util.js'
  167. import { getStorage } from '@/common/utils/storage.js'
  168. export default {
  169. data() {
  170. return {
  171. isLoading: true,
  172. refresherTriggered: false, // 下拉刷新状态
  173. imageUrl: this.$imageUrl,
  174. configInfo: {},
  175. userInfo: {}, // 信息详情
  176. shareProfitList: [
  177. { title: '今日分销收益', num: 0 },
  178. { title: '累计分销收益', num: 0 }
  179. ],
  180. salesProfitList: [
  181. { title: '已结算金额', num: 0 },
  182. { title: '待结算金额', num: 0 }
  183. ],
  184. orderList: [
  185. { title: '待付款', icon: 'icon-daifukuan', key: 'NOPAY', num: 0 },
  186. { title: '进行中', icon: 'icon-daifuwu', key: 'YFH', num: 0 },
  187. { title: '待评价', icon: 'icon-daipingjia1', key: 'OVER', num: 0 },
  188. { title: '售后/退款', icon: 'icon-shouhou', key: 'REFUND', num: 0 }
  189. ],
  190. statsList: [],
  191. menuList: [],
  192. noticeNum: 0,
  193. qrcode2: ''
  194. }
  195. },
  196. computed: {
  197. cuStyle() {
  198. return `height: ${this.CustomBar - this.StatusBar}px; padding-top: ${this.StatusBar}px;`
  199. },
  200. isLogin() {
  201. return this.$store.state.user.token ? true : false
  202. },
  203. isWorkerUser() {
  204. // 是否师傅
  205. // return true;
  206. return this.userInfo && this.userInfo.type === 'WORKER'
  207. },
  208. isServiceUser() {
  209. // 是否业务员
  210. // return true;
  211. return this.userInfo && this.userInfo.type === 'SERVICE'
  212. },
  213. isHeadUser() {
  214. // 是否团长
  215. // return false;
  216. return this.userInfo && this.userInfo.promotionGroupLeader
  217. }
  218. },
  219. async onShow() {
  220. selectionChange()
  221. this.configInfo = await this.$getConfigInfo()
  222. // if(this.isLogin) {
  223. this.userInfo = await this.$getUserInfo()
  224. await this.getCouponList()
  225. this.initList()
  226. await this.getCount()
  227. await this.getShareProfitCount()
  228. await this.getSalesProfitCount()
  229. await this.getStats()
  230. this.getweixinpeizhi()
  231. // }
  232. this.noticeNum = await getNoticeNum()
  233. getOrderNum()
  234. this.isLoading = false
  235. },
  236. methods: {
  237. // 触发下拉刷新
  238. async refresherrefresh(e) {
  239. this.refresherTriggered = true
  240. this.configInfo = await this.$getConfigInfo()
  241. // if(this.isLogin) {
  242. this.userInfo = await this.$getUserInfo()
  243. await this.getCouponList()
  244. this.initList()
  245. await this.getCount()
  246. await this.getShareProfitCount()
  247. await this.getSalesProfitCount()
  248. await this.getStats()
  249. // }
  250. this.noticeNum = await getNoticeNum()
  251. this.isLoading = false
  252. this.refresherTriggered = false
  253. },
  254. initList() {
  255. this.statsList = [
  256. {
  257. name: '优惠券',
  258. num: 0,
  259. link: '/packageMine/pages/coupon/list',
  260. show: true
  261. },
  262. {
  263. name: '收藏',
  264. num: 0,
  265. link: '/packageMine/pages/collection',
  266. show: true
  267. },
  268. {
  269. name: '收益',
  270. num: 0,
  271. link: '/packageMine/pages/profit/list',
  272. show: this.isServiceUser || this.isWorkerUser || this.isHeadUser
  273. }
  274. ]
  275. this.menuList = [
  276. {
  277. name: '我的租赁',
  278. icon: 'coupon',
  279. link: '/packageWorkorder/pages/tenancyOrderList',
  280. show: this.userInfo.isShowLease
  281. },
  282. {
  283. name: '绑定手机号',
  284. icon: 'icon-kefu',
  285. link: '/packageMine/pages/phone',
  286. show: !this.userInfo.mobile
  287. },
  288. {
  289. name: '商城二维码',
  290. icon: 'icon-erweima',
  291. link: '/packageMine/pages/mallCode',
  292. show: this.isServiceUser || this.isWorkerUser
  293. },
  294. // {
  295. // name: '关注公众号',
  296. // icon: 'icon-gongzhonghao',
  297. // fn: 'toWxLink',
  298. // show: true
  299. // },
  300. {
  301. name: '地址管理',
  302. icon: 'icon-shouhuodizhi',
  303. link: '/packageMine/pages/address/list',
  304. show: true
  305. },
  306. {
  307. name: '销售排行榜',
  308. icon: 'icon-paihangbang',
  309. link: '/packageMine/pages/ranking/list',
  310. show: this.isServiceUser || this.isWorkerUser
  311. },
  312. // {
  313. // name: '在线客服',
  314. // icon: 'icon-kefu',
  315. // fn: 'contact',
  316. // show: true
  317. // },
  318. {
  319. name: '师傅入驻',
  320. icon: 'icon-kehu',
  321. link: '/packageMine/pages/myWebsit',
  322. show: true
  323. },
  324. {
  325. name: '成为分销员',
  326. icon: 'icon-kehu',
  327. link: '/packageMine/pages/distributorEnter',
  328. show: !this.isWorkerUser && !this.isServiceUser
  329. },
  330. {
  331. name: '我的安维费',
  332. icon: 'icon-kehu',
  333. link: '/packageMine/pages/wodeanwei',
  334. show: this.isWorkerUser
  335. }
  336. ]
  337. },
  338. actionFn(fn) {
  339. if (!fn) return false
  340. this[fn]()
  341. },
  342. // 授权手机号
  343. getPhoneNumber(e) {
  344. if (!e.detail.iv) {
  345. return this.$toast('获取手机号失败')
  346. }
  347. uni.login({
  348. provider: 'weixin',
  349. success: loginRes => {
  350. this.$api
  351. .post('/user/auth', {
  352. code: loginRes.code,
  353. phoneCode: e.detail.code
  354. })
  355. .then(async res => {
  356. this.$store.commit('user/set_token', res.data.token)
  357. this.$store.commit('user/set_openId', res.data.openId)
  358. this.$store.commit('user/set_name', res.data.nickName)
  359. this.$store.commit('user/set_avatar', res.data.avatar)
  360. this.$store.commit('user/set_userId', res.data.userId)
  361. this.$store.commit('user/set_mobile', res.data.mobile)
  362. this.$successToast('授权成功')
  363. })
  364. }
  365. })
  366. },
  367. // 获取订单数量
  368. async getCount() {
  369. return new Promise((resolve, reject) => {
  370. this.$api
  371. .get('/order/count', {
  372. userId: this.$store.state.user.userId
  373. })
  374. .then(res => {
  375. const data = res.data || {}
  376. this.orderList[0].num = data.noPay
  377. this.orderList[1].num = data.yfh
  378. this.orderList[2].num = data.ywc
  379. this.orderList[3].num = data.sh
  380. resolve(data)
  381. })
  382. .catch(res => {
  383. resolve(1)
  384. })
  385. })
  386. },
  387. // 获取统计数量
  388. async getStats() {
  389. return new Promise((resolve, reject) => {
  390. this.$api
  391. .get('/user/my/count', {
  392. userId: this.$store.state.user.userId
  393. })
  394. .then(res => {
  395. const data = res.data || {}
  396. this.statsList[0].num = data.coupon || 0
  397. this.statsList[1].num = data.collect || 0
  398. this.statsList[2].num = data.amount || 0
  399. resolve(data)
  400. })
  401. .catch(res => {
  402. resolve(1)
  403. })
  404. })
  405. },
  406. // 获取收益统计
  407. async getShareProfitCount() {
  408. return new Promise((resolve, reject) => {
  409. this.$api
  410. .get('/user/profit', {
  411. userId: this.$store.state.user.userId
  412. })
  413. .then(res => {
  414. const data = res.data || {}
  415. this.shareProfitList[0].num = data.today
  416. this.shareProfitList[1].num = data.totalAmount
  417. resolve(data)
  418. })
  419. .catch(res => {
  420. resolve(1)
  421. })
  422. })
  423. },
  424. // 获取销售收益统计
  425. async getSalesProfitCount() {
  426. return new Promise((resolve, reject) => {
  427. this.$api
  428. .post('/withdrawal/amount/count')
  429. .then(res => {
  430. const data = res.data || {}
  431. this.salesProfitList[0].num = data.yjs
  432. this.salesProfitList[1].num = data.djs
  433. resolve(data)
  434. })
  435. .catch(res => {
  436. resolve(1)
  437. })
  438. })
  439. },
  440. // 获取可领优惠券列表
  441. async getCouponList() {
  442. return new Promise((resolve, reject) => {
  443. this.$api
  444. .get('/coupon/list/all', {
  445. userId: this.$store.state.user.userId
  446. })
  447. .finally(res => {
  448. resolve(1)
  449. })
  450. })
  451. },
  452. getweixinpeizhi() {
  453. this.$api.get('/common/wechat/detail').then(res => {
  454. this.qrcode2 = res.data.qrcode2
  455. })
  456. },
  457. openCode() {
  458. this.$api
  459. .post('/common/get/mp/qrcode', {
  460. companyWechatId: getStorage('user').companyWechatId || '',
  461. userId: this.$store.state.user.userId
  462. })
  463. .then(res => {
  464. uni.previewImage({
  465. current: res.data.ticket
  466. ? `https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${res.data.ticket}`
  467. : this.qrcode2,
  468. urls: [
  469. res.data.ticket ? `https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${res.data.ticket}` : this.qrcode2
  470. ]
  471. })
  472. })
  473. },
  474. // 跳转微信公众号链接
  475. toWxLink() {
  476. let link = this.configInfo.pubOfficeAddr
  477. if (!link) return false
  478. this.navToPage('/pages/index/webview?link=' + link)
  479. },
  480. navToPage(url) {
  481. this.$navToPage({
  482. url
  483. })
  484. },
  485. toLogout() {
  486. this.$modal({
  487. content: '确定退出登录?'
  488. })
  489. .then(() => {
  490. this.$store.dispatch('user/resetToken')
  491. console.log(this.configInfo)
  492. // this.crossPage.$emit('loginout', '', 'H5');
  493. this.shareProfitList.forEach(item => {
  494. item.num = 0
  495. })
  496. this.orderList.forEach(item => {
  497. item.num = 0
  498. })
  499. this.statsList.forEach(item => {
  500. item.num = 0
  501. })
  502. })
  503. .catch(() => {})
  504. }
  505. }
  506. }
  507. </script>
  508. <style scoped lang="scss">
  509. .a-container {
  510. padding-bottom: 30rpx;
  511. }
  512. .header-container {
  513. background: linear-gradient(262deg, #daf8fa 0%, #d3e6fc 84%, #d2e2fc 100%);
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. font-weight: 500;
  518. }
  519. .top-container {
  520. background: linear-gradient(262deg, #daf8fa 0%, #d3e6fc 84%, #d2e2fc 100%);
  521. padding: 20rpx 20rpx 80rpx;
  522. .user {
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-between;
  526. padding-right: 10rpx;
  527. .left {
  528. display: flex;
  529. align-items: center;
  530. image {
  531. width: 120rpx;
  532. height: 120rpx;
  533. border-radius: 50%;
  534. margin-right: 20rpx;
  535. }
  536. .main {
  537. display: flex;
  538. flex-direction: column;
  539. .name {
  540. font-size: 32rpx;
  541. line-height: 36rpx;
  542. font-weight: 500;
  543. }
  544. .text {
  545. font-size: 24rpx;
  546. color: #0b2853;
  547. line-height: 30rpx;
  548. margin-top: 12rpx;
  549. opacity: 0.5;
  550. .iconfont {
  551. font-size: 20rpx;
  552. margin-left: 8rpx;
  553. }
  554. }
  555. }
  556. }
  557. .right {
  558. display: flex;
  559. align-items: center;
  560. .it {
  561. margin-left: 40rpx;
  562. position: relative;
  563. &:first-child {
  564. margin-left: 0;
  565. }
  566. .iconfont {
  567. display: block;
  568. font-size: 44rpx;
  569. }
  570. }
  571. }
  572. }
  573. .stats {
  574. display: flex;
  575. align-items: center;
  576. margin-top: 20rpx;
  577. .item {
  578. flex: 1;
  579. display: flex;
  580. flex-direction: column;
  581. align-items: center;
  582. .value {
  583. font-weight: 600;
  584. font-size: 36rpx;
  585. }
  586. .label {
  587. margin-top: 8rpx;
  588. font-size: 22rpx;
  589. color: #0b2853;
  590. opacity: 0.5;
  591. }
  592. }
  593. }
  594. }
  595. .all-container {
  596. padding: 1rpx 20rpx 20rpx;
  597. margin-top: -80rpx;
  598. }
  599. .home-title {
  600. display: flex;
  601. align-items: center;
  602. justify-content: space-between;
  603. .left {
  604. font-size: 34rpx;
  605. color: $main-font;
  606. font-weight: bold;
  607. }
  608. .right {
  609. display: flex;
  610. align-items: center;
  611. .text {
  612. font-size: 28rpx;
  613. color: $sec-font;
  614. }
  615. .iconfont {
  616. font-size: 24rpx;
  617. color: $sec-font;
  618. margin-left: 8rpx;
  619. }
  620. }
  621. }
  622. .card {
  623. @include zj-card;
  624. background: #ffffff;
  625. border-radius: 20rpx;
  626. overflow: hidden;
  627. padding: 30rpx;
  628. margin-top: 20rpx;
  629. }
  630. .profit-container {
  631. .list {
  632. display: flex;
  633. margin-top: 30rpx;
  634. .item {
  635. flex: 1;
  636. display: flex;
  637. flex-direction: column;
  638. align-items: center;
  639. .num {
  640. font-size: 36rpx;
  641. font-weight: 500;
  642. }
  643. .title {
  644. font-size: 24rpx;
  645. margin-top: 8rpx;
  646. }
  647. }
  648. }
  649. }
  650. .order-container {
  651. .list {
  652. display: flex;
  653. margin-top: 30rpx;
  654. .item {
  655. flex: 1;
  656. display: flex;
  657. flex-direction: column;
  658. align-items: center;
  659. .icon {
  660. position: relative;
  661. .iconfont {
  662. font-size: 52rpx;
  663. }
  664. }
  665. .title {
  666. font-size: 26rpx;
  667. margin-top: 10rpx;
  668. }
  669. }
  670. }
  671. }
  672. .menu-container {
  673. .list {
  674. margin-top: 20rpx;
  675. .item {
  676. padding: 0;
  677. background: none;
  678. text-align: left;
  679. display: flex;
  680. align-items: center;
  681. height: 100rpx;
  682. border-bottom: 1px solid #f5f5f5;
  683. color: #333333;
  684. &:last-child {
  685. border: none;
  686. }
  687. &::after {
  688. border: none;
  689. }
  690. .icon {
  691. margin-right: 20rpx;
  692. .iconfont {
  693. color: $reg-font;
  694. font-size: 40rpx;
  695. }
  696. }
  697. .title {
  698. flex: 1;
  699. font-size: 30rpx;
  700. }
  701. .right {
  702. .iconfont {
  703. font-size: 28rpx;
  704. color: $sec-font;
  705. }
  706. }
  707. }
  708. }
  709. }
  710. .logout {
  711. @include zj-card;
  712. background: #ffffff;
  713. border-radius: 20rpx;
  714. height: 100rpx;
  715. line-height: 100rpx;
  716. text-align: center;
  717. margin-top: 30rpx;
  718. font-size: 32rpx;
  719. font-weight: 400;
  720. color: $theme-color;
  721. }
  722. </style>