riderMy.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view class="bg">
  3. <view class="content">
  4. <!-- <u-navbar :is-back="true" :title="title"></u-navbar> -->
  5. <!-- 顶部 -->
  6. <view class="header">
  7. <!-- #ifdef MP-WEIXIN -->
  8. <view class="head_image">
  9. <button
  10. v-if="userId"
  11. open-type="chooseAvatar"
  12. @chooseavatar="onChooseAvatar"
  13. style="background-color: rgba(255, 255, 255, 0) !important; border: none !important; margin-top: 30rpx"
  14. >
  15. <image :src="avatar ? avatar : '../../static/logo.png'" style="border-radius: 50%"></image>
  16. </button>
  17. <image v-else :src="avatar ? avatar : '../../static/logo.png'" style="border-radius: 50%"></image>
  18. </view>
  19. <!-- #endif -->
  20. <!-- #ifndef MP-WEIXIN -->
  21. <view class="head_image">
  22. <image v-if="userId" @click="upavatar()" :src="avatar ? avatar : '../../static/logo.png'" style="border-radius: 50%"></image>
  23. <image v-else :src="avatar ? avatar : '../../static/logo.png'" style="border-radius: 50%"></image>
  24. </view>
  25. <!-- #endif -->
  26. <view class="head_name" v-if="userId">
  27. <view class="name" @click="upNickName()">{{ nickName }}</view>
  28. <view v-if="XCXIsSelect != '否'">
  29. <view class="approve" v-if="checkCertification == '0'">实名认证审核中</view>
  30. <view class="approve" v-if="checkCertification == '1'">已实名</view>
  31. <view class="approve" @click="bindapprove" v-if="checkCertification == '2'">实名认证未通过</view>
  32. <view class="approve" @click="bindapprove" v-if="checkCertification == null">未实名认证</view>
  33. </view>
  34. </view>
  35. <view class="head_name" v-if="!userId">
  36. <button class="logins" @click="goLogin">登录</button>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 收入和订单 -->
  41. <view style="border-radius: 24rpx; overflow: hidden; width: 93%; margin: 0 auto; background: #ffffff" v-if="XCXIsSelect != '否'">
  42. <view class="user_box">
  43. <view class="box">
  44. <view class="user_name">
  45. <u-section title="今日收入" :right="false" line-color="#FE3B27"></u-section>
  46. </view>
  47. <view class="user_price">
  48. {{ indent.incomeday ? indent.incomeday : 0 }}
  49. <text>元</text>
  50. </view>
  51. <view class="user_tit">今日收入金额</view>
  52. </view>
  53. <view class="box">
  54. <view class="user_name">
  55. <u-section title="本月收入" :right="false" line-color="#009C66"></u-section>
  56. </view>
  57. <view class="user_price">
  58. {{ indent.incomemonth ? indent.incomemonth : 0 }}
  59. <text>元</text>
  60. </view>
  61. <view class="user_tit">本月收入金额</view>
  62. </view>
  63. </view>
  64. <view class="user_box">
  65. <view class="box">
  66. <view class="user_name">
  67. <u-section title="累计收入" :right="false" line-color="#FE3B27"></u-section>
  68. </view>
  69. <view class="user_price">
  70. {{ indent.incomesum ? indent.incomesum : 0 }}
  71. <text>元</text>
  72. </view>
  73. <view class="user_tit">累计收入金额</view>
  74. </view>
  75. <view class="box" @click="myOrders()">
  76. <view class="user_name">
  77. <u-section title="订单统计" :right="false" line-color="#009C66"></u-section>
  78. </view>
  79. <view class="user_price">
  80. {{ indent.indentCount ? indent.indentCount : 0 }}
  81. <text>单</text>
  82. </view>
  83. <view class="user_tit">今日完成单量</view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 我的列表 -->
  88. <view class="mylist">
  89. <view v-if="XCXIsSelect != '否'" class="list_box" v-for="(item, index) in mylist" :key="index" @click="bindmy(item.name)">
  90. <view class="list_left">
  91. <view class="list_img">
  92. <image :src="item.image" mode="scaleToFill"></image>
  93. </view>
  94. <view class="list_name">{{ item.name }}</view>
  95. </view>
  96. <view class="list_right">
  97. <view v-if="item.messageCount" class="bott">{{ item.messageCount }}</view>
  98. <image src="../../static/my/icon_go.png"></image>
  99. </view>
  100. </view>
  101. <view v-if="XCXIsSelect == '否'" class="list_box" v-for="(item, index) in datalist" :key="index" @click="bindmy(item.name)">
  102. <view class="list_left">
  103. <view class="list_img">
  104. <image :src="item.image"></image>
  105. </view>
  106. <view class="list_name">{{ item.name }}</view>
  107. </view>
  108. <view class="list_right">
  109. <image src="../../static/my/icon_go.png"></image>
  110. </view>
  111. </view>
  112. </view>
  113. <!-- 用于图片压缩的canvas画布 -->
  114. <canvas
  115. :style="{
  116. width: cw + 'px',
  117. height: cw + 'px',
  118. position: 'absolute',
  119. zIndex: -1,
  120. left: '-10000rpx',
  121. top: '-10000rpx'
  122. }"
  123. canvas-id="zipCanvas"
  124. ></canvas>
  125. <!--画布结束-->
  126. </view>
  127. </template>
  128. <script>
  129. import configurl from '../../common/config.js'
  130. import getLessLimitSizeImage from '@/utils/imageCompress.js'
  131. export default {
  132. onShareAppMessage(res) {
  133. //发送给朋友
  134. return {
  135. title: this.tuiguang,
  136. path: '/pages/index/index',
  137. imageUrl: this.tuiguangImg
  138. }
  139. },
  140. onShareTimeline(res) {
  141. //分享到朋友圈
  142. return {
  143. title: this.tuiguang,
  144. path: '/pages/index/index',
  145. imageUrl: this.tuiguangImg
  146. }
  147. },
  148. data() {
  149. return {
  150. tuiguang: '',
  151. tuiguangImg: '',
  152. show: false,
  153. title: '我的',
  154. mylist: [
  155. {
  156. id: 1,
  157. name: '我的订单',
  158. image: '../../static/rider/77.png'
  159. },
  160. {
  161. id: 2,
  162. name: '资金账户',
  163. image: '../../static/rider/22.png'
  164. },
  165. {
  166. id: 3,
  167. name: '我的评价',
  168. image: '../../static/rider/33.png'
  169. },
  170. {
  171. id: 4,
  172. name: '违规申诉',
  173. image: '../../static/rider/44.png'
  174. },
  175. {
  176. id: 5,
  177. name: '联系客服',
  178. image: '../../static/my/8.png'
  179. },
  180. {
  181. id: 6,
  182. name: '消息中心',
  183. image: '../../static/rider/liaotin.png',
  184. messageCount: ''
  185. },
  186. {
  187. id: 7,
  188. name: '意见反馈',
  189. image: '../../static/rider/66.png'
  190. },
  191. {
  192. id: 9,
  193. name: '系统设置',
  194. image: '../../static/rider/55.png'
  195. }
  196. ],
  197. datalist: [
  198. {
  199. id: 3,
  200. name: '我的评价',
  201. image: '../../static/rider/33.png'
  202. },
  203. {
  204. id: 4,
  205. name: '违规申诉',
  206. image: '../../static/rider/44.png'
  207. },
  208. {
  209. id: 5,
  210. name: '消息中心',
  211. image: '../../static/rider/liaotin.png'
  212. },
  213. // {
  214. // id: 6,
  215. // name: '用户协议',
  216. // image: '../../static/rider/66.png'
  217. // },
  218. // {
  219. // id: 7,
  220. // name: '隐私政策',
  221. // image: '../../static/rider/77.png'
  222. // },
  223. {
  224. id: 9,
  225. name: '系统设置',
  226. image: '../../static/rider/55.png'
  227. }
  228. ],
  229. information: {}, //个人信息
  230. daySr: '',
  231. orders: '',
  232. indent: {},
  233. avatar: '',
  234. nickName: '匿名',
  235. checkCertification: '',
  236. userId: '',
  237. token: '',
  238. XCXIsSelect: '否',
  239. //messageCount: ''
  240. //画板边长默认是屏幕宽度,正方形画布
  241. cw: uni.getSystemInfoSync().windowWidth
  242. }
  243. },
  244. onLoad() {
  245. this.$Request.getT('/app/common/type/331').then((res) => {
  246. if (res.code === 0) {
  247. uni.setStorageSync('tuiguang', res.data.value)
  248. this.tuiguang = res.data.value
  249. }
  250. })
  251. this.$Request.getT('/app/common/type/332').then((res) => {
  252. if (res.code === 0) {
  253. uni.setStorageSync('tuiguangImg', res.data.value)
  254. this.tuiguangImg = res.data.value
  255. }
  256. })
  257. },
  258. onShow() {
  259. this.mylist[5].messageCount = uni.getStorageSync('messageCount')
  260. this.XCXIsSelect = this.$queue.getData('XCXIsSelect')
  261. this.token = this.$queue.getData('token')
  262. this.userId = this.$queue.getData('userId')
  263. if (this.token) {
  264. this.shouru()
  265. this.getUserInfo(this.userId)
  266. } else {
  267. // this.goLogin();
  268. }
  269. },
  270. methods: {
  271. //微信填写能力获取头像
  272. onChooseAvatar(e) {
  273. console.log(e.detail.avatarUrl)
  274. let that = this
  275. let token = uni.getStorageSync('token')
  276. uni.showLoading({
  277. title: '上传中...',
  278. mask: true // 是否显示透明蒙层,防止触摸穿透
  279. })
  280. uni.uploadFile({
  281. // url: config.APIHOST1 + '/alioss/upload', //仅为示例,非真实的接口地址
  282. url: configurl.APIHOST2 + '/alioss/upload', //仅为示例,非真实的接口地址
  283. filePath: e.detail.avatarUrl,
  284. header: {
  285. token: token
  286. },
  287. name: 'file',
  288. success: (uploadFileRes) => {
  289. let url = JSON.parse(uploadFileRes.data).data
  290. that.$Request.postJson('/app/user/updateUserImageUrl?avatar=' + url).then((res) => {
  291. uni.hideLoading()
  292. if (res.code === 0) {
  293. that.$queue.showToast('更新成功')
  294. that.getUserInfo()
  295. }
  296. })
  297. },
  298. fail: (res) => {
  299. uni.showToast({
  300. title: res,
  301. icon: 'error'
  302. })
  303. }
  304. })
  305. },
  306. //修改用户名
  307. upNickName() {
  308. uni.navigateTo({
  309. url: './updateNickName'
  310. })
  311. },
  312. //修改用户头像
  313. upavatar() {
  314. let that = this
  315. var url = null
  316. let userId = this.$queue.getData('userId')
  317. uni.showActionSheet({
  318. // itemList按钮的文字接受的是数组
  319. itemList: ['查看头像', '从相册选择图片'],
  320. success(e) {
  321. var index = e.tapIndex
  322. if (index === 0) {
  323. // 用户点击了预览当前图片
  324. // 可以自己实现当前头像链接的读取
  325. let url = that.avatar
  326. let arr = []
  327. arr.push(url)
  328. uni.previewImage({
  329. // 预览功能图片也必须是数组的
  330. urls: arr
  331. })
  332. } else if (index === 1) {
  333. uni.chooseImage({
  334. count: 1,
  335. sourceType: ['album'],
  336. success: (res) => {
  337. let token = uni.getStorageSync('token')
  338. for (let i = 0; i < res.tempFiles.length; i++) {
  339. //这里的id和页面中写的html代码的canvas的id要一致
  340. let canvasId = 'zipCanvas'
  341. //原图的路径
  342. let imagePath = res.tempFiles[i].path
  343. //大小限制
  344. let limitSize = 1024 * 2
  345. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  346. let drawWidth = uni.getSystemInfoSync().windowWidth
  347. let that = this
  348. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  349. uni.showLoading({
  350. title: '上传中'
  351. })
  352. uni.uploadFile({
  353. url: 'https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload',
  354. filePath: resPath,
  355. header: {
  356. token: token
  357. },
  358. name: 'file',
  359. success: (uploadFileRes) => {
  360. url = JSON.parse(uploadFileRes.data).data
  361. that.$Request.postJson('/app/user/updateUserImageUrl?avatar=' + url).then((res) => {
  362. uni.hideLoading()
  363. if (res.code === 0) {
  364. that.$queue.showToast('更新成功')
  365. that.getUserInfo()
  366. }
  367. })
  368. },
  369. fail: () => {
  370. uni.showToast({
  371. title: '上传失败',
  372. icon: 'error'
  373. })
  374. }
  375. })
  376. })
  377. }
  378. }
  379. })
  380. }
  381. }
  382. })
  383. },
  384. // 查看今日收入
  385. profit() {
  386. if (!this.userId) {
  387. uni.navigateTo({
  388. url: '/pages/login/login'
  389. })
  390. return
  391. }
  392. uni.navigateTo({
  393. url: '/pages/riderMy/profit'
  394. })
  395. },
  396. // 查看订单统计
  397. myOrders() {
  398. if (!this.userId) {
  399. uni.navigateTo({
  400. url: '/pages/login/login'
  401. })
  402. return
  403. }
  404. uni.navigateTo({
  405. url: '/pages/riderMy/order'
  406. })
  407. },
  408. bindapprove() {
  409. uni.navigateTo({
  410. url: '/pages/riderMy/approve/approve'
  411. })
  412. },
  413. bindmy(name) {
  414. console.log(name)
  415. let that = this
  416. if (!that.token) {
  417. uni.navigateTo({
  418. url: '/pages/login/login'
  419. })
  420. return
  421. }
  422. if (name == '资金账户') {
  423. uni.navigateTo({
  424. url: '/pages/riderMy/myAccount/myAccount'
  425. })
  426. } else if (name == '我的订单') {
  427. uni.navigateTo({
  428. url: '/pages/riderMy/order'
  429. })
  430. } else if (name == '我的评价') {
  431. uni.navigateTo({
  432. url: '/pages/riderMy/myComment/myComment'
  433. })
  434. } else if (name == '联系客服') {
  435. uni.navigateTo({
  436. url: '/pages/riderMy/kefu/chat'
  437. })
  438. } else if (name == '用户协议') {
  439. uni.navigateTo({
  440. url: '/pages/riderMy/xieyi'
  441. })
  442. } else if (name == '隐私政策') {
  443. uni.navigateTo({
  444. url: '/pages/riderMy/mimi'
  445. })
  446. } else if (name == '违规申诉') {
  447. uni.navigateTo({
  448. url: '/pages/riderMy/myComplain/myComplain'
  449. })
  450. } else if (name == '培训中心') {
  451. uni.navigateTo({
  452. url: '/pages/riderMy/trainingList'
  453. })
  454. } else if (name == '消息中心') {
  455. uni.navigateTo({
  456. url: '/pages/riderMy/kefu/liaotian'
  457. })
  458. } else if (name == '系统设置') {
  459. uni.navigateTo({
  460. url: '/pages/riderMy/set/set'
  461. })
  462. } else if (name == '意见反馈') {
  463. uni.navigateTo({
  464. url: '/pages/riderMy/set/yijian'
  465. })
  466. }
  467. },
  468. //检测是否登录
  469. checkLogin() {},
  470. // 获取个人信息
  471. getUserInfo(userId) {
  472. this.$Request.getT('/app/tbindent/findUserInfoById').then((res) => {
  473. if (res.code == 0) {
  474. this.$nextTick(function () {
  475. this.avatar = res.data.avatar ? res.data.avatar : '../../static/logo.png'
  476. this.nickName = res.data.nickName
  477. uni.setStorageSync('userName', res.data.userName)
  478. uni.setStorageSync('phone', res.data.phone)
  479. this.checkCertification = res.data.checkCertification
  480. console.log(this.checkCertification, '实名认证')
  481. this.userId = res.data.userId
  482. })
  483. } else {
  484. this.$queue.logout()
  485. uni.showModal({
  486. showCancel: false,
  487. title: '登录失败',
  488. content: res.msg
  489. })
  490. }
  491. })
  492. },
  493. // 今日收入、订单量
  494. shouru() {
  495. this.$Request.getT('/app/userinfo/findIncome').then((res) => {
  496. if (res.code == 0) {
  497. // this.daySr = res.data.income
  498. // this.orders = res.data.indentCount
  499. this.indent = res.data
  500. }
  501. console.log('res', res)
  502. })
  503. },
  504. // 跳转去登录
  505. goLogin() {
  506. // this.$queue.setData('href', '/pages/my/index');
  507. uni.navigateTo({
  508. url: '/pages/login/login'
  509. })
  510. }
  511. }
  512. }
  513. </script>
  514. <style>
  515. button::after {
  516. border: none;
  517. /* background-color: none; */
  518. }
  519. .u-icon__icon {
  520. font-size: 35rpx !important;
  521. font-weight: bold !important;
  522. }
  523. .u-title {
  524. color: #000000 !important;
  525. }
  526. .u-navbar-fixed {
  527. background: none !important;
  528. }
  529. body {
  530. background: #f5f5f5;
  531. }
  532. .bg {
  533. }
  534. .logins {
  535. border: none;
  536. background: #f8501f;
  537. color: #fff;
  538. width: 200rpx;
  539. margin: 70rpx 20rpx;
  540. height: 70rpx;
  541. line-height: 70rpx;
  542. }
  543. .content {
  544. background: linear-gradient(0deg, #f5f5f5 0%, #fed9ba 100%);
  545. width: 100%;
  546. }
  547. /* 顶部 */
  548. .header {
  549. width: 100%;
  550. height: 200rpx;
  551. display: flex;
  552. }
  553. .head_image {
  554. flex: 1;
  555. display: flex;
  556. justify-content: center;
  557. align-items: center;
  558. }
  559. .head_image image {
  560. width: 90rpx;
  561. height: 90rpx;
  562. }
  563. .head_name {
  564. flex: 4;
  565. position: relative;
  566. margin-left: -14rpx;
  567. }
  568. .name {
  569. position: absolute;
  570. top: 65rpx;
  571. }
  572. .approve {
  573. position: absolute;
  574. top: 100rpx;
  575. font-size: 24rpx;
  576. color: #999999;
  577. }
  578. /* 用户信息 */
  579. .user_box {
  580. display: flex;
  581. height: 210rpx;
  582. position: relative;
  583. top: -15rpx;
  584. padding: 0 20rpx;
  585. }
  586. .box {
  587. flex: 1;
  588. /* margin-left: 40rpx; */
  589. margin-top: 40rpx;
  590. }
  591. .user_price {
  592. font-size: 44rpx;
  593. margin-top: 10rpx;
  594. }
  595. .user_price text {
  596. font-size: 21rpx;
  597. margin-left: 10rpx;
  598. }
  599. .user_tit {
  600. color: #b3b3b3;
  601. font-size: 21rpx;
  602. margin-top: 10rpx;
  603. }
  604. .u-section__title {
  605. font-weight: 500 !important;
  606. color: #333333 !important;
  607. font-size: 14px !important;
  608. padding-left: 10px;
  609. }
  610. /* 我的列表 */
  611. .mylist {
  612. width: 93%;
  613. margin: 0 auto;
  614. background-color: #ffffff;
  615. margin-top: 10rpx;
  616. border-radius: 23rpx;
  617. }
  618. .list_box {
  619. width: 90%;
  620. margin: 0 auto;
  621. display: flex;
  622. height: 95rpx;
  623. }
  624. .list_left {
  625. flex: 1;
  626. display: flex;
  627. justify-content: left;
  628. align-items: center;
  629. }
  630. .list_img {
  631. margin-right: 10rpx;
  632. margin-top: 10rpx;
  633. }
  634. .list_img image {
  635. width: 32rpx;
  636. height: 32rpx;
  637. }
  638. .list_name {
  639. font-size: 25rpx;
  640. letter-spacing: 2rpx;
  641. }
  642. .list_right {
  643. flex: 1;
  644. display: flex;
  645. justify-content: flex-end;
  646. align-items: center;
  647. }
  648. .list_right image {
  649. width: 12rpx;
  650. height: 20rpx;
  651. }
  652. .bott {
  653. background: red;
  654. color: #ffffff;
  655. padding: 5rpx 10rpx;
  656. border-radius: 60%;
  657. font-size: 23rpx;
  658. margin-right: 15rpx;
  659. }
  660. </style>