user.vue 14 KB

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