user.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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. <view class="flex dcm" v-if="hxtype == 1">
  184. <input type="text" v-model="dcode" placeholder="请输入电池编号" placeholder-class="hx-placeholder" />
  185. <image src="../../static/icon/scend.png" mode="widthFix" style="width: 50rpx;" @click="smdc"></image>
  186. </view>
  187. <view class="hx-btn" @click="qhx">
  188. 立即核销
  189. </view>
  190. </view>
  191. <view class="hx-close" @click="close">
  192. <image src="../../static/icon/close.png" mode=""></image>
  193. </view>
  194. </view>
  195. </uni-popup>
  196. </view>
  197. </template>
  198. <script>
  199. // #ifdef H5
  200. import weixinObj from "@/plugin/jweixin-module/index.js";
  201. // #endif
  202. import {
  203. mapState,
  204. mapMutations
  205. } from 'vuex';
  206. import {
  207. share
  208. } from '@/api/wx';
  209. import {
  210. getUser
  211. } from '@/api/user.js';
  212. import {
  213. articleList,
  214. notify,
  215. rentVerific,
  216. orderVerific
  217. } from '@/api/index.js';
  218. import {
  219. saveUrl,
  220. interceptor
  221. } from '@/utils/loginUtils.js';
  222. export default {
  223. data() {
  224. return {
  225. hxLoading: false,
  226. hxtype: 0, //0普通核销1电池核销
  227. dcode: '', //电池编号
  228. code: '', //商品核销码
  229. user: {
  230. avatar: '', //头像
  231. nickname: '', //昵称
  232. phone: ''
  233. },
  234. shareData: {}
  235. };
  236. },
  237. computed: {
  238. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  239. ...mapState(['baseURL', 'urlFile']),
  240. ...mapState(['fx']),
  241. // 总消息条数
  242. notic() {
  243. return this.user.question_sum + this.user.notice_sum;
  244. },
  245. },
  246. // 创建时获取分享信息
  247. onLoad() {
  248. // share().then((res) => {
  249. // this.shareData = res.data.data
  250. // }).catch((res) => {
  251. // console.log(res, '分享加载失败');
  252. // })
  253. },
  254. onShow() {
  255. this.getUser();
  256. },
  257. methods: {
  258. ...mapMutations('user', ['setUserInfo']),
  259. qhx() {
  260. let that = this
  261. if (that.hxLoading) {
  262. return
  263. }
  264. if (that.code == '') {
  265. return that.$api.msg('请输入核销码')
  266. }
  267. if (that.hxtype == 0) {
  268. that.hxLoading = true
  269. orderVerific({
  270. verify_code: that.code,
  271. is_confirm: 1
  272. }).then(res => {
  273. uni.showToast({
  274. title: '核销成功',
  275. mask: true,
  276. duration: 1500
  277. });
  278. that.close()
  279. that.hxLoading = false
  280. }).catch(err => [
  281. that.hxLoading = false
  282. ])
  283. } else {
  284. if (that.dcode == '') {
  285. return that.$api.msg('请输入电池编号')
  286. }
  287. that.hxLoading = false
  288. rentVerific({
  289. verify_code: that.code,
  290. battery_number: that.dcode,
  291. is_confirm: 1
  292. }).then(res => {
  293. uni.showToast({
  294. title: '核销成功',
  295. mask: true,
  296. duration: 1500
  297. });
  298. that.close()
  299. that.hxLoading = false
  300. })
  301. }
  302. },
  303. openHx() {
  304. this.$refs.popuphx.open()
  305. },
  306. close() {
  307. this.code = ''
  308. this.dcode = ''
  309. this.$refs.popuphx.close()
  310. },
  311. // 扫码
  312. smsh() {
  313. let that = this
  314. // #ifdef H5
  315. try {
  316. weixinObj.scanQRCode({
  317. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  318. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  319. success: function(res) {
  320. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  321. let arr = result.split('&');
  322. if(arr.length > 1) {
  323. that.code = arr[0];
  324. that.dcode = arr[1] || '';
  325. that.hxtype = 1;
  326. }else {
  327. that.code = arr[0];
  328. that.hxtype = 0;
  329. }
  330. that.openHx();
  331. // 判断是否为电池核销
  332. }
  333. });
  334. } catch (err) {
  335. console.log(err)
  336. that.openHx();
  337. }
  338. // #endif
  339. // #ifndef H5
  340. uni.scanCode({
  341. success: (res) => {
  342. let result = res.result
  343. let arr = result.split('&')
  344. if(arr.length > 1) {
  345. that.code = arr[0];
  346. that.dcode = arr[1] || '';
  347. that.hxtype = 1;
  348. }else {
  349. that.code = arr[0];
  350. that.hxtype = 0;
  351. }
  352. that.openHx();
  353. }
  354. })
  355. // #endif
  356. },
  357. smdc() {
  358. // #ifndef H5
  359. uni.scanCode({
  360. autoDecodeCharset:true,
  361. success: (res) => {
  362. console.log(res);
  363. let str = res.result.split('编号:')
  364. this.dcode = str[1]
  365. }
  366. })
  367. // #endif
  368. },
  369. // 跳转卡片页面
  370. navcard() {
  371. // 判断是否已经认证
  372. if (this.user.work_type_id <= 0) {
  373. this.navTo('/pages/user/model/modelrz')
  374. } else {
  375. if (this.user.show_template_id) {
  376. this.navTo('/pages/user/model/model?mtype=' + this.user.show_template_id + '&look=1')
  377. } else {
  378. this.navTo('/pages/user/model/model')
  379. }
  380. }
  381. },
  382. //#ifdef APP
  383. shareDomApp() {
  384. uni.share({
  385. provider: 'weixin',
  386. type: 0,
  387. title: '母婴界严选',
  388. summary: '',
  389. imageUrl: this.shareData.img,
  390. href: this.baseURL + this.urlFile + '/pages/public/register?spread=' + this.userInfo.uid
  391. })
  392. },
  393. //#endif
  394. // 获取用户数据
  395. getUser() {
  396. console.log('data')
  397. const that = this;
  398. getUser({}).then((e) => {
  399. this.user = e.data;
  400. this.setUserInfo(e.data)
  401. }).catch((e) => {
  402. console.log(e, 'sj');
  403. })
  404. // 系统消息
  405. // articleList({}, 1).then((e) => {
  406. // that.user.question_sum = e.data.count
  407. // console.log(that, 1);
  408. // }).catch((e) => {
  409. // console.log(e);
  410. // })
  411. // 报警消息
  412. // notify().then((e) => {
  413. // that.user.notice_sum = e.data.count
  414. // }).catch((e) => {
  415. // console.log(e);
  416. // })
  417. },
  418. changeTab() {
  419. this.$emit('tab', true)
  420. },
  421. navTo(url) {
  422. console.log(this.hasLogin, 'this.hasLogin');
  423. if (!this.hasLogin) {
  424. // 保存地址
  425. saveUrl();
  426. // 登录拦截
  427. interceptor();
  428. } else {
  429. uni.navigateTo({
  430. url,
  431. fail(e) {
  432. console.log(e);
  433. }
  434. });
  435. }
  436. },
  437. }
  438. };
  439. </script>
  440. <style lang="scss">
  441. %section {
  442. display: flex;
  443. justify-content: space-around;
  444. align-content: center;
  445. border-radius: 10rpx;
  446. }
  447. %flex-center {
  448. display: flex;
  449. flex-direction: column;
  450. justify-content: center;
  451. align-items: center;
  452. }
  453. .listBox {
  454. margin-top: 20rpx;
  455. overflow: hidden;
  456. }
  457. .list {
  458. .listItem {
  459. padding: 35rpx 40rpx;
  460. margin-bottom: 15rpx;
  461. background-color: #FFFFFF;
  462. border-radius: 20rpx;
  463. border: none;
  464. line-height: 1;
  465. &::after {
  466. border: none;
  467. }
  468. }
  469. .listIconImg {
  470. width: 36rpx;
  471. height: 36rpx;
  472. }
  473. .right {
  474. .img {
  475. width: 26rpx;
  476. }
  477. }
  478. .titleBox {
  479. .title {
  480. padding-left: 20rpx;
  481. color: $font-color-base;
  482. font-size: $font-base;
  483. }
  484. }
  485. }
  486. .container {
  487. background-color: $page-color-base;
  488. background-image: url('../../static/image/userbg.png');
  489. background-repeat: no-repeat;
  490. background-size: 100% auto;
  491. padding-top: 100rpx;
  492. padding-bottom: 50rpx;
  493. }
  494. .user-section {
  495. background-color: #FFF;
  496. border-radius: 20rpx;
  497. margin: 0 $page-row-spacing;
  498. padding: 40rpx 0;
  499. .avatar {
  500. width: 130rpx;
  501. height: 130rpx;
  502. margin: 0 auto;
  503. border-radius: 100rpx;
  504. overflow: hidden;
  505. margin-bottom: 30rpx;
  506. .image {
  507. width: 100%;
  508. height: 100%;
  509. }
  510. }
  511. .phone {
  512. height: 1rem;
  513. margin-bottom: 30rpx;
  514. }
  515. }
  516. .cover-container {
  517. padding: 0 30rpx;
  518. position: relative;
  519. padding-bottom: 20rpx;
  520. }
  521. .tj-sction {
  522. @extend %section;
  523. .tj-item {
  524. @extend %flex-center;
  525. flex-direction: column;
  526. height: 100rpx;
  527. font-size: $font-sm;
  528. color: $font-color-light;
  529. }
  530. .num {
  531. font-size: $font-lg + 4rpx;
  532. color: $font-color-dark;
  533. margin-bottom: 8rpx;
  534. font-weight: bold;
  535. }
  536. }
  537. .item-box {
  538. border-radius: 20rpx;
  539. background-color: white;
  540. margin-top: 20rpx;
  541. .box-title {
  542. line-height: 1;
  543. padding: 30rpx 40rpx;
  544. .title {
  545. font-size: $font-lg;
  546. font-weight: bold;
  547. }
  548. .link {
  549. font-size: $font-base - 2rpx;
  550. color: $font-color-light;
  551. .img {
  552. width: 26rpx;
  553. }
  554. }
  555. }
  556. .order-section {
  557. @extend %section;
  558. padding: 28rpx 0;
  559. padding-top: 0;
  560. .order-item {
  561. @extend %flex-center;
  562. width: 120rpx;
  563. height: 120rpx;
  564. border-radius: 10rpx;
  565. font-size: $font-sm;
  566. color: $font-color-dark;
  567. }
  568. .iconfont {
  569. font-size: 48rpx;
  570. margin-bottom: 18rpx;
  571. color: #fa436a;
  572. }
  573. .icon-shouhoutuikuan {
  574. font-size: 44rpx;
  575. }
  576. .icon {
  577. height: 50rpx;
  578. width: 48rpx;
  579. margin-bottom: 18rpx;
  580. background-size: 100%;
  581. background-repeat: no-repeat;
  582. background-position: center;
  583. .icon-img {
  584. width: 100%;
  585. height: 100%;
  586. }
  587. }
  588. }
  589. }
  590. .hx-wrapper {
  591. width: 536rpx;
  592. // height: 630rpx;
  593. position: relative;
  594. padding-bottom: 40rpx;
  595. background-color: #fff;
  596. border-radius: 20rpx;
  597. .hx-img {
  598. width: 536rpx;
  599. height: 281rpx;
  600. image {
  601. width: 536rpx;
  602. height: 281rpx;
  603. }
  604. }
  605. .hx-close {
  606. position: absolute;
  607. left: 243rpx;
  608. bottom: -80rpx;
  609. width: 52rpx;
  610. height: 52rpx;
  611. image {
  612. width: 52rpx;
  613. height: 52rpx;
  614. }
  615. }
  616. .hx-body {
  617. width: 536rpx;
  618. // min-height: 349rpx;
  619. background-color: #fff;
  620. border-radius: 0 0 10rpx 10rpx;
  621. padding-top: 40rpx;
  622. .hx-title {
  623. width: 536rpx;
  624. font-size: 36rpx;
  625. font-weight: 500;
  626. color: #333333;
  627. line-height: 1;
  628. padding-top: 42rpx;
  629. text-align: center;
  630. padding-bottom: 10rpx;
  631. }
  632. input {
  633. width: 439rpx;
  634. height: 68rpx;
  635. background: #f1faf6;
  636. border-radius: 10rpx;
  637. margin: 0 auto 40rpx;
  638. padding-left: 26rpx;
  639. .hx-placeholder {
  640. font-size: 26rpx;
  641. font-weight: 500;
  642. color: $base-color;
  643. }
  644. }
  645. .dcm {
  646. width: 439rpx;
  647. margin: 0 auto;
  648. input {
  649. flex-grow: 1;
  650. height: 68rpx;
  651. background: #f1faf6;
  652. border-radius: 10rpx;
  653. margin: 0 10rpx 0 0;
  654. padding-left: 26rpx;
  655. }
  656. image {
  657. flex-shrink: 0;
  658. }
  659. }
  660. .hx-btn {
  661. margin: 44rpx auto 0;
  662. width: 353rpx;
  663. height: 71rpx;
  664. background: $base-color;
  665. border-radius: 34rpx;
  666. font-size: 36rpx;
  667. font-weight: 500;
  668. color: #F8F9F9;
  669. line-height: 71rpx;
  670. text-align: center;
  671. }
  672. }
  673. }
  674. .nav-hx {
  675. display: flex;
  676. justify-content: center;
  677. margin-bottom: 20rpx;
  678. text {
  679. font-size:28rpx;
  680. padding: 10rpx;
  681. }
  682. .action {
  683. color: $base-color;
  684. font-weight: bold;
  685. }
  686. }
  687. </style>