user.vue 15 KB

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