user.vue 16 KB

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