riderMy.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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|| checkCertification==''">未实名认证</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 + '/app/new-file/upload', //仅为示例,非真实的接口地址
  282. url: configurl.APIHOST2 + '/app/new-file/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. let token = uni.getStorageSync('token')
  349. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  350. uni.showLoading({
  351. title: '上传中'
  352. })
  353. uni.uploadFile({
  354. url: configurl.APIHOST2 + '/app/new-file/upload',
  355. filePath: resPath,
  356. header: {
  357. token: token
  358. },
  359. name: 'file',
  360. success: (uploadFileRes) => {
  361. url = JSON.parse(uploadFileRes.data).data
  362. that.$Request.postJson('/app/user/updateUserImageUrl?avatar=' + url).then((res) => {
  363. uni.hideLoading()
  364. if (res.code === 0) {
  365. that.$queue.showToast('更新成功')
  366. that.getUserInfo()
  367. }
  368. })
  369. },
  370. fail: () => {
  371. uni.showToast({
  372. title: '上传失败',
  373. icon: 'error'
  374. })
  375. }
  376. })
  377. })
  378. }
  379. }
  380. })
  381. }
  382. }
  383. })
  384. },
  385. // 查看今日收入
  386. profit() {
  387. if (!this.userId) {
  388. uni.navigateTo({
  389. url: '/pages/login/login'
  390. })
  391. return
  392. }
  393. uni.navigateTo({
  394. url: '/pages/riderMy/profit'
  395. })
  396. },
  397. // 查看订单统计
  398. myOrders() {
  399. if (!this.userId) {
  400. uni.navigateTo({
  401. url: '/pages/login/login'
  402. })
  403. return
  404. }
  405. uni.navigateTo({
  406. url: '/pages/riderMy/order'
  407. })
  408. },
  409. bindapprove() {
  410. uni.navigateTo({
  411. url: '/pages/riderMy/approve/approve'
  412. })
  413. },
  414. bindmy(name) {
  415. console.log(name)
  416. let that = this
  417. if (!that.token) {
  418. uni.navigateTo({
  419. url: '/pages/login/login'
  420. })
  421. return
  422. }
  423. if (name == '资金账户') {
  424. uni.navigateTo({
  425. url: '/pages/riderMy/myAccount/myAccount'
  426. })
  427. } else if (name == '我的订单') {
  428. uni.navigateTo({
  429. url: '/pages/riderMy/order'
  430. })
  431. } else if (name == '我的评价') {
  432. uni.navigateTo({
  433. url: '/pages/riderMy/myComment/myComment'
  434. })
  435. } else if (name == '联系客服') {
  436. uni.navigateTo({
  437. url: '/pages/riderMy/kefu/chat'
  438. })
  439. } else if (name == '用户协议') {
  440. uni.navigateTo({
  441. url: '/pages/riderMy/xieyi'
  442. })
  443. } else if (name == '隐私政策') {
  444. uni.navigateTo({
  445. url: '/pages/riderMy/mimi'
  446. })
  447. } else if (name == '违规申诉') {
  448. uni.navigateTo({
  449. url: '/pages/riderMy/myComplain/myComplain'
  450. })
  451. } else if (name == '培训中心') {
  452. uni.navigateTo({
  453. url: '/pages/riderMy/trainingList'
  454. })
  455. } else if (name == '消息中心') {
  456. uni.navigateTo({
  457. url: '/pages/riderMy/kefu/liaotian'
  458. })
  459. } else if (name == '系统设置') {
  460. uni.navigateTo({
  461. url: '/pages/riderMy/set/set'
  462. })
  463. } else if (name == '意见反馈') {
  464. uni.navigateTo({
  465. url: '/pages/riderMy/set/yijian'
  466. })
  467. }
  468. },
  469. //检测是否登录
  470. checkLogin() {},
  471. // 获取个人信息
  472. getUserInfo(userId) {
  473. this.$Request.getT('/app/tbindent/findUserInfoById').then((res) => {
  474. if (res.code == 0) {
  475. this.$nextTick(function () {
  476. this.avatar = res.data.avatar ? res.data.avatar : '../../static/logo.png'
  477. this.nickName = res.data.nickName
  478. uni.setStorageSync('userName', res.data.userName)
  479. uni.setStorageSync('phone', res.data.phone)
  480. this.checkCertification = res.data.checkCertification
  481. console.log(res,this.checkCertification=='','11c',this.avatar, '实名认证')
  482. this.userId = res.data.userId
  483. })
  484. } else {
  485. this.$queue.logout()
  486. uni.showModal({
  487. showCancel: false,
  488. title: '登录失败',
  489. content: res.msg
  490. })
  491. }
  492. })
  493. },
  494. // 今日收入、订单量
  495. shouru() {
  496. this.$Request.getT('/app/userinfo/findIncome').then((res) => {
  497. if (res.code == 0) {
  498. // this.daySr = res.data.income
  499. // this.orders = res.data.indentCount
  500. this.indent = res.data
  501. }
  502. console.log('res', res)
  503. })
  504. },
  505. // 跳转去登录
  506. goLogin() {
  507. // this.$queue.setData('href', '/pages/my/index');
  508. uni.navigateTo({
  509. url: '/pages/login/login'
  510. })
  511. }
  512. }
  513. }
  514. </script>
  515. <style>
  516. button::after {
  517. border: none;
  518. /* background-color: none; */
  519. }
  520. .u-icon__icon {
  521. font-size: 35rpx !important;
  522. font-weight: bold !important;
  523. }
  524. .u-title {
  525. color: #000000 !important;
  526. }
  527. .u-navbar-fixed {
  528. background: none !important;
  529. }
  530. body {
  531. background: #f5f5f5;
  532. }
  533. .bg {
  534. }
  535. .logins {
  536. border: none;
  537. background: #f8501f;
  538. color: #fff;
  539. width: 200rpx;
  540. margin: 70rpx 20rpx;
  541. height: 70rpx;
  542. line-height: 70rpx;
  543. }
  544. .content {
  545. background: linear-gradient(0deg, #f5f5f5 0%, #fed9ba 100%);
  546. width: 100%;
  547. }
  548. /* 顶部 */
  549. .header {
  550. width: 100%;
  551. height: 200rpx;
  552. display: flex;
  553. }
  554. .head_image {
  555. flex: 1;
  556. display: flex;
  557. justify-content: center;
  558. align-items: center;
  559. }
  560. .head_image image {
  561. width: 90rpx;
  562. height: 90rpx;
  563. }
  564. .head_name {
  565. flex: 4;
  566. position: relative;
  567. margin-left: -14rpx;
  568. }
  569. .name {
  570. position: absolute;
  571. top: 65rpx;
  572. }
  573. .approve {
  574. position: absolute;
  575. top: 100rpx;
  576. font-size: 24rpx;
  577. color: #999999;
  578. }
  579. /* 用户信息 */
  580. .user_box {
  581. display: flex;
  582. height: 210rpx;
  583. position: relative;
  584. top: -15rpx;
  585. padding: 0 20rpx;
  586. }
  587. .box {
  588. flex: 1;
  589. /* margin-left: 40rpx; */
  590. margin-top: 40rpx;
  591. }
  592. .user_price {
  593. font-size: 44rpx;
  594. margin-top: 10rpx;
  595. }
  596. .user_price text {
  597. font-size: 21rpx;
  598. margin-left: 10rpx;
  599. }
  600. .user_tit {
  601. color: #b3b3b3;
  602. font-size: 21rpx;
  603. margin-top: 10rpx;
  604. }
  605. .u-section__title {
  606. font-weight: 500 !important;
  607. color: #333333 !important;
  608. font-size: 14px !important;
  609. padding-left: 10px;
  610. }
  611. /* 我的列表 */
  612. .mylist {
  613. width: 93%;
  614. margin: 0 auto;
  615. background-color: #ffffff;
  616. margin-top: 10rpx;
  617. border-radius: 23rpx;
  618. }
  619. .list_box {
  620. width: 90%;
  621. margin: 0 auto;
  622. display: flex;
  623. height: 95rpx;
  624. }
  625. .list_left {
  626. flex: 1;
  627. display: flex;
  628. justify-content: left;
  629. align-items: center;
  630. }
  631. .list_img {
  632. margin-right: 10rpx;
  633. margin-top: 10rpx;
  634. }
  635. .list_img image {
  636. width: 32rpx;
  637. height: 32rpx;
  638. }
  639. .list_name {
  640. font-size: 25rpx;
  641. letter-spacing: 2rpx;
  642. }
  643. .list_right {
  644. flex: 1;
  645. display: flex;
  646. justify-content: flex-end;
  647. align-items: center;
  648. }
  649. .list_right image {
  650. width: 12rpx;
  651. height: 20rpx;
  652. }
  653. .bott {
  654. background: red;
  655. color: #ffffff;
  656. padding: 5rpx 10rpx;
  657. border-radius: 60%;
  658. font-size: 23rpx;
  659. margin-right: 15rpx;
  660. }
  661. </style>