user.vue 16 KB

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