user.vue 16 KB

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