user.vue 14 KB

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