user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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="userInfo.avatar|| urlFile+`/static/error/missing-face.png`"
  7. 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">
  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="userInfo.unpaid_count > 0">
  44. <text>{{ userInfo.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="userInfo.received_count > 0">
  55. <text>{{ userInfo.received_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 class="flex listItem" @click="navTo('/pages/user_home/shareQrCode')">
  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 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 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_home/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_home/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. </view>
  158. </template>
  159. <script>
  160. // #ifdef H5
  161. import weixinObj from "@/plugin/jweixin-module/index.js";
  162. // #endif
  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. shareData: {}
  191. };
  192. },
  193. computed: {
  194. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  195. ...mapState(['baseURL', 'urlFile']),
  196. ...mapState(['fx']),
  197. // 总消息条数
  198. notic() {
  199. return this.user.question_sum + this.user.notice_sum;
  200. },
  201. },
  202. // 创建时获取分享信息
  203. onLoad() {
  204. // share().then((res) => {
  205. // this.shareData = res.data.data
  206. // }).catch((res) => {
  207. // console.log(res, '分享加载失败');
  208. // })
  209. },
  210. onShow() {
  211. this.getUser();
  212. },
  213. methods: {
  214. ...mapMutations('user', ['setUserInfo']),
  215. qhx() {
  216. let that = this
  217. if (that.hxLoading) {
  218. return
  219. }
  220. if (that.code == '') {
  221. return that.$api.msg('请输入核销码')
  222. }
  223. if (that.hxtype == 0) {
  224. that.hxLoading = true
  225. orderVerific({
  226. verify_code: that.code,
  227. is_confirm: 1
  228. }).then(res => {
  229. uni.showToast({
  230. title: '核销成功',
  231. mask: true,
  232. duration: 1500
  233. });
  234. that.close()
  235. that.hxLoading = false
  236. }).catch(err => [
  237. that.hxLoading = false
  238. ])
  239. } else {
  240. if (that.dcode == '') {
  241. return that.$api.msg('请输入电池编号')
  242. }
  243. that.hxLoading = false
  244. rentVerific({
  245. verify_code: that.code,
  246. battery_number: that.dcode,
  247. is_confirm: 1
  248. }).then(res => {
  249. uni.showToast({
  250. title: '核销成功',
  251. mask: true,
  252. duration: 1500
  253. });
  254. that.close()
  255. that.hxLoading = false
  256. })
  257. }
  258. },
  259. openHx() {
  260. this.$refs.popuphx.open()
  261. },
  262. close() {
  263. this.code = ''
  264. this.dcode = ''
  265. this.$refs.popuphx.close()
  266. },
  267. // 扫码
  268. smsh() {
  269. let that = this
  270. // #ifdef H5
  271. try {
  272. weixinObj.scanQRCode({
  273. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  274. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  275. success: function(res) {
  276. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  277. let arr = result.split('&');
  278. if (arr.length > 1) {
  279. that.code = arr[0];
  280. that.dcode = arr[1] || '';
  281. that.hxtype = 1;
  282. } else {
  283. that.code = arr[0];
  284. that.hxtype = 0;
  285. }
  286. that.openHx();
  287. // 判断是否为电池核销
  288. }
  289. });
  290. } catch (err) {
  291. console.log(err)
  292. that.openHx();
  293. }
  294. // #endif
  295. // #ifndef H5
  296. uni.scanCode({
  297. success: (res) => {
  298. let result = res.result
  299. let arr = result.split('&')
  300. if (arr.length > 1) {
  301. that.code = arr[0];
  302. that.dcode = arr[1] || '';
  303. that.hxtype = 1;
  304. } else {
  305. that.code = arr[0];
  306. that.hxtype = 0;
  307. }
  308. that.openHx();
  309. }
  310. })
  311. // #endif
  312. },
  313. // 跳转卡片页面
  314. navcard() {
  315. // 判断是否已经认证
  316. if (this.user.work_type_id <= 0) {
  317. this.navTo('/pages/user/model/modelrz')
  318. } else {
  319. if (this.user.show_template_id) {
  320. this.navTo('/pages/user/model/model?mtype=' + this.user.show_template_id + '&look=1')
  321. } else {
  322. this.navTo('/pages/user/model/model')
  323. }
  324. }
  325. },
  326. //#ifdef APP
  327. shareDomApp() {
  328. uni.share({
  329. provider: 'weixin',
  330. type: 0,
  331. title: '母婴界严选',
  332. summary: '',
  333. imageUrl: this.shareData.img,
  334. href: this.baseURL + this.urlFile + '/pages/public/register?spread=' + this.userInfo.uid
  335. })
  336. },
  337. //#endif
  338. // 获取用户数据
  339. getUser() {
  340. console.log('data')
  341. const that = this;
  342. getUser({}).then((e) => {
  343. this.setUserInfo(e.data)
  344. }).catch((e) => {
  345. console.log(e, 'sj');
  346. })
  347. // 系统消息
  348. // articleList({}, 1).then((e) => {
  349. // that.user.question_sum = e.data.count
  350. // console.log(that, 1);
  351. // }).catch((e) => {
  352. // console.log(e);
  353. // })
  354. // 报警消息
  355. // notify().then((e) => {
  356. // that.user.notice_sum = e.data.count
  357. // }).catch((e) => {
  358. // console.log(e);
  359. // })
  360. },
  361. changeTab() {
  362. this.$emit('tab', true)
  363. },
  364. navTo(url) {
  365. console.log(this.hasLogin, 'this.hasLogin');
  366. if (!this.hasLogin) {
  367. // 保存地址
  368. saveUrl();
  369. // 登录拦截
  370. interceptor();
  371. } else {
  372. uni.navigateTo({
  373. url,
  374. fail(e) {
  375. console.log(e);
  376. }
  377. });
  378. }
  379. },
  380. }
  381. };
  382. </script>
  383. <style lang="scss">
  384. .listBox {
  385. margin-top: 20rpx;
  386. overflow: hidden;
  387. }
  388. .list {
  389. .listItem {
  390. padding: 35rpx 40rpx;
  391. margin-bottom: 15rpx;
  392. background-color: #FFFFFF;
  393. border-radius: 20rpx;
  394. border: none;
  395. line-height: 1;
  396. &::after {
  397. border: none;
  398. }
  399. }
  400. .listIconImg {
  401. width: 36rpx;
  402. height: 36rpx;
  403. }
  404. .right {
  405. .img {
  406. width: 26rpx;
  407. }
  408. }
  409. .titleBox {
  410. .title {
  411. padding-left: 20rpx;
  412. color: $font-color-base;
  413. font-size: $font-base;
  414. }
  415. }
  416. }
  417. .container {
  418. background-color: $page-color-base;
  419. background-image: url('../../static/image/userbg.png');
  420. background-repeat: no-repeat;
  421. background-size: 100% auto;
  422. padding-top: 100rpx;
  423. padding-bottom: 150rpx;
  424. }
  425. .user-section {
  426. background-color: #FFF;
  427. border-radius: 20rpx;
  428. margin: 0 $page-row-spacing;
  429. padding: 40rpx 0;
  430. .avatar {
  431. width: 130rpx;
  432. height: 130rpx;
  433. margin: 0 auto;
  434. border-radius: 100rpx;
  435. overflow: hidden;
  436. margin-bottom: 30rpx;
  437. .image {
  438. width: 100%;
  439. height: 100%;
  440. }
  441. }
  442. .phone {
  443. height: 1rem;
  444. margin-bottom: 30rpx;
  445. }
  446. }
  447. .cover-container {
  448. padding: 0 30rpx;
  449. position: relative;
  450. padding-bottom: 20rpx;
  451. }
  452. .tj-sction {
  453. justify-content: space-around;
  454. .tj-item {
  455. flex-direction: column;
  456. height: 100rpx;
  457. font-size: $font-sm;
  458. color: $font-color-light;
  459. }
  460. .num {
  461. font-size: $font-lg + 4rpx;
  462. color: $font-color-dark;
  463. margin-bottom: 8rpx;
  464. font-weight: bold;
  465. }
  466. }
  467. .item-box {
  468. border-radius: 20rpx;
  469. background-color: white;
  470. margin-top: 20rpx;
  471. .box-title {
  472. line-height: 1;
  473. padding: 30rpx 40rpx;
  474. .title {
  475. font-size: $font-lg;
  476. font-weight: bold;
  477. }
  478. .link {
  479. font-size: $font-base - 2rpx;
  480. color: $font-color-light;
  481. .img {
  482. width: 26rpx;
  483. }
  484. }
  485. }
  486. .order-section {
  487. padding: 28rpx 0;
  488. padding-top: 0;
  489. justify-content: space-around;
  490. .order-item {
  491. width: 120rpx;
  492. height: 120rpx;
  493. border-radius: 10rpx;
  494. font-size: $font-sm;
  495. color: $font-color-dark;
  496. }
  497. .iconfont {
  498. font-size: 48rpx;
  499. margin-bottom: 18rpx;
  500. color: #fa436a;
  501. }
  502. .icon-shouhoutuikuan {
  503. font-size: 44rpx;
  504. }
  505. .icon {
  506. height: 50rpx;
  507. width: 48rpx;
  508. margin-bottom: 18rpx;
  509. background-size: 100%;
  510. background-repeat: no-repeat;
  511. background-position: center;
  512. .icon-img {
  513. width: 100%;
  514. height: 100%;
  515. }
  516. }
  517. }
  518. }
  519. </style>