user.vue 17 KB

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