user.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <view class="container">
  3. <view class="content-box">
  4. <view class="user-section">
  5. <view class="avatar" @click="navTo('/pages/set/userinfo')">
  6. <image class="image" :src="user.avatar|| urlFile+`/static/error/missing-face.png`"
  7. mode="scaleToFill"></image>
  8. </view>
  9. <view class="flex-center phone">
  10. {{user.nickname || '游客'}}
  11. <!-- <template v-if="user.phone">
  12. {{((''+user.phone).split('').splice(3,4,'****')).join('')}}
  13. </template> -->
  14. </view>
  15. <view class="tj-sction">
  16. <view class="tj-item" @click="navTo('/pages/user_home/award/award')">
  17. <text class="num">{{ user.brokerage_price || '0.00' }}</text>
  18. <text>我的佣金</text>
  19. </view>
  20. <view class="tj-item" @click="navTo('/pages/user_home/money/qxq')">
  21. <text class="num">{{ user.certificate || '0.00' }}</text>
  22. <text>我的骑行券</text>
  23. </view>
  24. <view class="tj-item" @click="navTo('/pages/user_home/money/wallet')">
  25. <text class="num">{{user.now_money || '0.00' }}</text>
  26. <text>我的卡券</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="cover-container">
  31. <view class="item-box">
  32. <view class="box-title flex">
  33. <view class="title"><text>我的订单</text></view>
  34. <view class="link flex" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover">
  35. <text class="margin-r-10">全部</text>
  36. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  37. </view>
  38. </view>
  39. <view class="order-section">
  40. <view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"
  41. :hover-stay-time="50">
  42. <view class=" icon position-relative">
  43. <image class="icon-img" src="../../static/icon/userorder1.png" mode="aspectFit">
  44. </image>
  45. <view class="corner" v-if="user.unpaid_count > 0">
  46. <text>{{ user.unpaid_count }}</text>
  47. </view>
  48. </view>
  49. <text>待付款</text>
  50. </view>
  51. <view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover"
  52. :hover-stay-time="50">
  53. <view class="icon position-relative">
  54. <image class="icon-img" src="../../static/icon/userorder2.png" mode="aspectFit">
  55. </image>
  56. <view class="corner" v-if="user.received_count > 0">
  57. <text>{{ user.received_count }}</text>
  58. </view>
  59. </view>
  60. <text>待核销</text>
  61. </view>
  62. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover"
  63. :hover-stay-time="50">
  64. <view class=" icon position-relative">
  65. <image class="icon-img" src="../../static/icon/userorder3.png" mode="aspectFit">
  66. </image>
  67. </view>
  68. <text>已完成</text>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="listBox">
  73. <view class="list">
  74. <view class="flex listItem" @click="navTo('/pages/user_home/myRent')">
  75. <view class="flex titleBox">
  76. <image class="listIconImg" src="../../static/icon/in1.png" mode="widthFix"></image>
  77. <text class="title">我的电池</text>
  78. </view>
  79. <view class="right flex">
  80. <text></text>
  81. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  82. </view>
  83. </view>
  84. <view class="flex listItem" @click="navTo('/pages/user_home/actionList')">
  85. <view class="flex titleBox">
  86. <image class="listIconImg" src="../../static/icon/actiont.png" mode="widthFix"></image>
  87. <text class="title">活动</text>
  88. </view>
  89. <view class="right flex">
  90. <text></text>
  91. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  92. </view>
  93. </view>
  94. <view class="flex listItem" @click="navTo('/pages/user_home/myAction')">
  95. <view class="flex titleBox">
  96. <image class="listIconImg" src="../../static/icon/myaction.png" mode="widthFix"></image>
  97. <text class="title">我的活动</text>
  98. </view>
  99. <view class="right flex">
  100. <text></text>
  101. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  102. </view>
  103. </view>
  104. <!-- <view class="flex listItem" @click="navTo('/pages/user_home/myAction')">
  105. <view class="flex titleBox">
  106. <image class="listIconImg" src="../../static/icon/htong.png" mode="widthFix"></image>
  107. <text class="title">下载合同</text>
  108. </view>
  109. <view class="right flex">
  110. <text></text>
  111. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  112. </view>
  113. </view> -->
  114. <view class="flex listItem" @click="smsh" v-if="userInfo && userInfo.adminid == 1">
  115. <view class="flex titleBox">
  116. <image class="listIconImg" src="../../static/icon/userhx.png" mode="widthFix"></image>
  117. <text class="title">核销</text>
  118. </view>
  119. <view class="right flex">
  120. <text></text>
  121. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  122. </view>
  123. </view>
  124. <view class="flex listItem" @click="navTo('/pages/shop/attestation')"
  125. v-if="userInfo && userInfo.is_real != 1">
  126. <view class="flex titleBox">
  127. <image class="listIconImg" src="../../static/icon/userreal.png" mode="widthFix"></image>
  128. <text class="title">实名认证</text>
  129. </view>
  130. <view class="right flex">
  131. <text></text>
  132. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  133. </view>
  134. </view>
  135. <button hover-class="none" class="flex listItem" open-type='contact'>
  136. <view class="flex titleBox">
  137. <image class="listIconImg" src="../../static/icon/userkf.png" mode="widthFix"></image>
  138. <text class="title">客服</text>
  139. </view>
  140. <view class="right flex">
  141. <text></text>
  142. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  143. </view>
  144. </button>
  145. <view class="flex listItem" @click="navTo('/pages/user_home/shareQrCode')">
  146. <view class="flex titleBox">
  147. <image class="listIconImg" src="../../static/icon/usergg.png" mode="widthFix"></image>
  148. <text class="title">邀请好友</text>
  149. </view>
  150. <view class="right flex">
  151. <text></text>
  152. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  153. </view>
  154. </view>
  155. <view class="flex listItem" @click="navTo('/pages/set/set')">
  156. <view class="flex titleBox">
  157. <image class="listIconImg" src="../../static/icon/userset.png" mode="widthFix"></image>
  158. <text class="title">设置</text>
  159. </view>
  160. <view class="right flex">
  161. <text></text>
  162. <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. </view>
  168. </view>
  169. <!-- 核销弹窗 -->
  170. <uni-popup ref="popuphx" class="agree-wrapper">
  171. <view class="hx-wrapper">
  172. <view class="hx-img">
  173. <image src="../../static/img/hxbg.png" mode=""></image>
  174. </view>
  175. <view class="hx-body">
  176. <view class="nav-hx">
  177. <text @click="hxtype = 0" :class="{'action': hxtype == 0}">商品核销</text ><text @click="hxtype = 1" :class="{'action': hxtype ==1}">电池核销</text>
  178. </view>
  179. <!-- <view class="hx-title">
  180. 核销码
  181. </view> -->
  182. <input type="text" v-model="code" placeholder="请输入核销码" placeholder-class="hx-placeholder" />
  183. <!-- <image src="../../static/icon/scend.png" mode=""></image> -->
  184. <input type="text" v-model="dcode" placeholder="请输入电池编号" placeholder-class="hx-placeholder" v-if="hxtype == 1"/>
  185. <view class="hx-btn" @click="qhx">
  186. 立即核销
  187. </view>
  188. </view>
  189. <view class="hx-close" @click="close">
  190. <image src="../../static/icon/close.png" mode=""></image>
  191. </view>
  192. </view>
  193. </uni-popup>
  194. </view>
  195. </template>
  196. <script>
  197. // #ifdef H5
  198. import weixinObj from "@/plugin/jweixin-module/index.js";
  199. // #endif
  200. import {
  201. mapState,
  202. mapMutations
  203. } from 'vuex';
  204. import {
  205. share
  206. } from '@/api/wx';
  207. import {
  208. getUser
  209. } from '@/api/user.js';
  210. import {
  211. articleList,
  212. notify,
  213. rentVerific,
  214. orderVerific
  215. } from '@/api/index.js';
  216. import {
  217. saveUrl,
  218. interceptor
  219. } from '@/utils/loginUtils.js';
  220. export default {
  221. data() {
  222. return {
  223. hxLoading: false,
  224. hxtype: 0, //0普通核销1电池核销
  225. dcode: '', //电池编号
  226. code: '', //商品核销码
  227. user: {
  228. avatar: '', //头像
  229. nickname: '', //昵称
  230. phone: ''
  231. },
  232. shareData: {}
  233. };
  234. },
  235. computed: {
  236. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  237. ...mapState(['baseURL', 'urlFile']),
  238. ...mapState(['fx']),
  239. // 总消息条数
  240. notic() {
  241. return this.user.question_sum + this.user.notice_sum;
  242. },
  243. },
  244. // 创建时获取分享信息
  245. onLoad() {
  246. // share().then((res) => {
  247. // this.shareData = res.data.data
  248. // }).catch((res) => {
  249. // console.log(res, '分享加载失败');
  250. // })
  251. },
  252. onShow() {
  253. this.getUser();
  254. },
  255. methods: {
  256. ...mapMutations('user', ['setUserInfo']),
  257. qhx() {
  258. let that = this
  259. if (that.hxLoading) {
  260. return
  261. }
  262. if (that.code == '') {
  263. return that.$api.msg('请输入核销码')
  264. }
  265. if (that.hxtype == 0) {
  266. that.hxLoading = true
  267. orderVerific({
  268. verify_code: that.code,
  269. is_confirm: 1
  270. }).then(res => {
  271. uni.showToast({
  272. title: '核销成功',
  273. mask: true,
  274. duration: 1500
  275. });
  276. that.close()
  277. that.hxLoading = false
  278. }).catch(err => [
  279. that.hxLoading = false
  280. ])
  281. } else {
  282. if (that.dcode == '') {
  283. return that.$api.msg('请输入电池编号')
  284. }
  285. that.hxLoading = false
  286. rentVerific({
  287. verify_code: that.code,
  288. battery_number: that.dcode,
  289. is_confirm: 1
  290. }).then(res => {
  291. uni.showToast({
  292. title: '核销成功',
  293. mask: true,
  294. duration: 1500
  295. });
  296. that.close()
  297. that.hxLoading = false
  298. })
  299. }
  300. },
  301. openHx() {
  302. this.$refs.popuphx.open()
  303. },
  304. close() {
  305. this.code = ''
  306. this.dcode = ''
  307. this.$refs.popuphx.close()
  308. },
  309. // 扫码
  310. smsh() {
  311. let that = this
  312. // #ifdef H5
  313. try {
  314. weixinObj.scanQRCode({
  315. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  316. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  317. success: function(res) {
  318. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  319. let arr = result.split('&');
  320. if(arr.length > 1) {
  321. that.code = arr[0];
  322. that.dcode = arr[1] || '';
  323. that.hxtype = 1;
  324. }else {
  325. that.code = arr[0];
  326. that.hxtype = 0;
  327. }
  328. that.openHx();
  329. // 判断是否为电池核销
  330. }
  331. });
  332. } catch (err) {
  333. console.log(err)
  334. that.openHx();
  335. }
  336. // #endif
  337. // #ifndef H5
  338. uni.scanCode({
  339. success: (res) => {
  340. let result = res.result
  341. let arr = result.split('&')
  342. if(arr.length > 1) {
  343. that.code = arr[0];
  344. that.dcode = arr[1] || '';
  345. that.hxtype = 1;
  346. }else {
  347. that.code = arr[0];
  348. that.hxtype = 0;
  349. }
  350. that.openHx();
  351. }
  352. })
  353. // #endif
  354. },
  355. // 跳转卡片页面
  356. navcard() {
  357. // 判断是否已经认证
  358. if (this.user.work_type_id <= 0) {
  359. this.navTo('/pages/user/model/modelrz')
  360. } else {
  361. if (this.user.show_template_id) {
  362. this.navTo('/pages/user/model/model?mtype=' + this.user.show_template_id + '&look=1')
  363. } else {
  364. this.navTo('/pages/user/model/model')
  365. }
  366. }
  367. },
  368. //#ifdef APP
  369. shareDomApp() {
  370. uni.share({
  371. provider: 'weixin',
  372. type: 0,
  373. title: '母婴界严选',
  374. summary: '',
  375. imageUrl: this.shareData.img,
  376. href: this.baseURL + this.urlFile + '/pages/public/register?spread=' + this.userInfo.uid
  377. })
  378. },
  379. //#endif
  380. // 获取用户数据
  381. getUser() {
  382. console.log('data')
  383. const that = this;
  384. getUser({}).then((e) => {
  385. this.user = e.data;
  386. this.setUserInfo(e.data)
  387. }).catch((e) => {
  388. console.log(e, 'sj');
  389. })
  390. // 系统消息
  391. // articleList({}, 1).then((e) => {
  392. // that.user.question_sum = e.data.count
  393. // console.log(that, 1);
  394. // }).catch((e) => {
  395. // console.log(e);
  396. // })
  397. // 报警消息
  398. // notify().then((e) => {
  399. // that.user.notice_sum = e.data.count
  400. // }).catch((e) => {
  401. // console.log(e);
  402. // })
  403. },
  404. changeTab() {
  405. this.$emit('tab', true)
  406. },
  407. navTo(url) {
  408. console.log(this.hasLogin, 'this.hasLogin');
  409. if (!this.hasLogin) {
  410. // 保存地址
  411. saveUrl();
  412. // 登录拦截
  413. interceptor();
  414. } else {
  415. uni.navigateTo({
  416. url,
  417. fail(e) {
  418. console.log(e);
  419. }
  420. });
  421. }
  422. },
  423. }
  424. };
  425. </script>
  426. <style lang="scss">
  427. %section {
  428. display: flex;
  429. justify-content: space-around;
  430. align-content: center;
  431. border-radius: 10rpx;
  432. }
  433. %flex-center {
  434. display: flex;
  435. flex-direction: column;
  436. justify-content: center;
  437. align-items: center;
  438. }
  439. .listBox {
  440. margin-top: 20rpx;
  441. overflow: hidden;
  442. }
  443. .list {
  444. .listItem {
  445. padding: 35rpx 40rpx;
  446. margin-bottom: 15rpx;
  447. background-color: #FFFFFF;
  448. border-radius: 20rpx;
  449. border: none;
  450. line-height: 1;
  451. &::after {
  452. border: none;
  453. }
  454. }
  455. .listIconImg {
  456. width: 36rpx;
  457. height: 36rpx;
  458. }
  459. .right {
  460. .img {
  461. width: 26rpx;
  462. }
  463. }
  464. .titleBox {
  465. .title {
  466. padding-left: 20rpx;
  467. color: $font-color-base;
  468. font-size: $font-base;
  469. }
  470. }
  471. }
  472. .container {
  473. background-color: $page-color-base;
  474. background-image: url('../../static/image/userbg.png');
  475. background-repeat: no-repeat;
  476. background-size: 100% auto;
  477. padding-top: 100rpx;
  478. padding-bottom: 50rpx;
  479. }
  480. .user-section {
  481. background-color: #FFF;
  482. border-radius: 20rpx;
  483. margin: 0 $page-row-spacing;
  484. padding: 40rpx 0;
  485. .avatar {
  486. width: 130rpx;
  487. height: 130rpx;
  488. margin: 0 auto;
  489. border-radius: 100rpx;
  490. overflow: hidden;
  491. margin-bottom: 30rpx;
  492. .image {
  493. width: 100%;
  494. height: 100%;
  495. }
  496. }
  497. .phone {
  498. height: 1rem;
  499. margin-bottom: 30rpx;
  500. }
  501. }
  502. .cover-container {
  503. padding: 0 30rpx;
  504. position: relative;
  505. padding-bottom: 20rpx;
  506. }
  507. .tj-sction {
  508. @extend %section;
  509. .tj-item {
  510. @extend %flex-center;
  511. flex-direction: column;
  512. height: 100rpx;
  513. font-size: $font-sm;
  514. color: $font-color-light;
  515. }
  516. .num {
  517. font-size: $font-lg + 4rpx;
  518. color: $font-color-dark;
  519. margin-bottom: 8rpx;
  520. font-weight: bold;
  521. }
  522. }
  523. .item-box {
  524. border-radius: 20rpx;
  525. background-color: white;
  526. margin-top: 20rpx;
  527. .box-title {
  528. line-height: 1;
  529. padding: 30rpx 40rpx;
  530. .title {
  531. font-size: $font-lg;
  532. font-weight: bold;
  533. }
  534. .link {
  535. font-size: $font-base - 2rpx;
  536. color: $font-color-light;
  537. .img {
  538. width: 26rpx;
  539. }
  540. }
  541. }
  542. .order-section {
  543. @extend %section;
  544. padding: 28rpx 0;
  545. padding-top: 0;
  546. .order-item {
  547. @extend %flex-center;
  548. width: 120rpx;
  549. height: 120rpx;
  550. border-radius: 10rpx;
  551. font-size: $font-sm;
  552. color: $font-color-dark;
  553. }
  554. .iconfont {
  555. font-size: 48rpx;
  556. margin-bottom: 18rpx;
  557. color: #fa436a;
  558. }
  559. .icon-shouhoutuikuan {
  560. font-size: 44rpx;
  561. }
  562. .icon {
  563. height: 50rpx;
  564. width: 48rpx;
  565. margin-bottom: 18rpx;
  566. background-size: 100%;
  567. background-repeat: no-repeat;
  568. background-position: center;
  569. .icon-img {
  570. width: 100%;
  571. height: 100%;
  572. }
  573. }
  574. }
  575. }
  576. .hx-wrapper {
  577. width: 536rpx;
  578. // height: 630rpx;
  579. position: relative;
  580. padding-bottom: 40rpx;
  581. background-color: #fff;
  582. border-radius: 20rpx;
  583. .hx-img {
  584. width: 536rpx;
  585. height: 281rpx;
  586. image {
  587. width: 536rpx;
  588. height: 281rpx;
  589. }
  590. }
  591. .hx-close {
  592. position: absolute;
  593. left: 243rpx;
  594. bottom: -80rpx;
  595. width: 52rpx;
  596. height: 52rpx;
  597. image {
  598. width: 52rpx;
  599. height: 52rpx;
  600. }
  601. }
  602. .hx-body {
  603. width: 536rpx;
  604. // min-height: 349rpx;
  605. background-color: #fff;
  606. border-radius: 0 0 10rpx 10rpx;
  607. padding-top: 40rpx;
  608. .hx-title {
  609. width: 536rpx;
  610. font-size: 36rpx;
  611. font-weight: 500;
  612. color: #333333;
  613. line-height: 1;
  614. padding-top: 42rpx;
  615. text-align: center;
  616. padding-bottom: 10rpx;
  617. }
  618. input {
  619. width: 439rpx;
  620. height: 68rpx;
  621. background: #f1faf6;
  622. border-radius: 10rpx;
  623. margin: 0 auto 40rpx;
  624. padding-left: 26rpx;
  625. .hx-placeholder {
  626. font-size: 26rpx;
  627. font-weight: 500;
  628. color: $base-color;
  629. }
  630. }
  631. .hx-btn {
  632. margin: 44rpx auto 0;
  633. width: 353rpx;
  634. height: 71rpx;
  635. background: $base-color;
  636. border-radius: 34rpx;
  637. font-size: 36rpx;
  638. font-weight: 500;
  639. color: #F8F9F9;
  640. line-height: 71rpx;
  641. text-align: center;
  642. }
  643. }
  644. }
  645. .nav-hx {
  646. display: flex;
  647. justify-content: center;
  648. margin-bottom: 20rpx;
  649. text {
  650. font-size:28rpx;
  651. padding: 10rpx;
  652. }
  653. .action {
  654. color: $base-color;
  655. font-weight: bold;
  656. }
  657. }
  658. </style>