info.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <template>
  2. <view class="main">
  3. <view class="user-img flex justify-center align-center">
  4. <view class="user-avatar">
  5. <image @click="ChooseImage" :src="imglist" style="width: 100%;height: 100%;" class="cu-avatar round">
  6. </image>
  7. </view>
  8. </view>
  9. <view class="input-container">
  10. <view class="input-border round">
  11. <text class="label">姓名:</text>
  12. <input type="text" @click="VerifyPopup(user.realname)" :disabled="user.realname!=''" v-model="realname"
  13. placeholder="请输入您的姓名" class="input-item" />
  14. </view>
  15. </view>
  16. <view class="input-container">
  17. <view class="input-border round">
  18. <text class="label">手机号:</text>
  19. <input @click="rest(1)" disabled type="text" v-model="phone" placeholder="请输入您的手机号" class="input-item" />
  20. </view>
  21. </view>
  22. <view class="input-container">
  23. <view class="input-border round">
  24. <text class="label">所在地区:</text>
  25. <picker mode="multiSelector" @click="rest(user.city_index)" @change="bindMultiPickerChange"
  26. :disabled="user.city_index!=-1&&user.province_index!=-1" :value="multiIndex"
  27. @columnchange="bindMultiPickerColumnChange" :range="multiArray" range-key="name">
  28. <view class="picker">
  29. <view class="energy">
  30. {{areaname}}
  31. </view>
  32. <view class="energy-img">
  33. <uni-icons :size="30" class="uni-icon-wrapper" color="#F5CC57" type="arrowdown"
  34. style="padding-left:5px" />
  35. </view>
  36. </view>
  37. </picker>
  38. </view>
  39. </view>
  40. <!-- <view class="input-container">
  41. <view class="input-border round">
  42. <text class="label">加盟商:</text>
  43. <picker @change="bindPickerChange" @click="rest(user.partner_index)"
  44. :disabled="user.partner_index!=-1"
  45. :value="partner_index" :range="partners" range-key="company_name">
  46. <view class="picker">
  47. <view class="energy">
  48. {{ company_name}}
  49. </view>
  50. <view class="energy-img">
  51. <uni-icons :size="30" class="uni-icon-wrapper" color="#F5CC57" type="arrowdown"
  52. style="padding-left:5px;" />
  53. </view>
  54. </view>
  55. </picker>
  56. </view>
  57. </view> -->
  58. <view class="input-container">
  59. <view v-if="user.up_id" class="input-border round">
  60. <text class="label">推荐人:</text>
  61. <text class="text-gray">{{user.up_info? user.up_info.realname:'总部'}}</text>
  62. </view>
  63. <view v-else class="input-border round" @click="toSearchUp()">
  64. <text class="label">推荐人:</text>
  65. <input type="text" value="总部" class="input-item" disabled/>
  66. <uni-icons :size="30" class="uni-icon-wrapper" color="#F5CC57" type="search"
  67. style="padding-left:5px;" />
  68. </view>
  69. </view>
  70. <!-- <view class="foot-btn">
  71. <view class="sub" @click="sutmit">提交</view>
  72. <view class="quxiao" @click="cancel">取消</view>
  73. </view> -->
  74. <view class="" style="width: 100%;padding: 0 100rpx;">
  75. <view class="submit" @click="sutmit">立即提交</view>
  76. </view>
  77. <view class="footer">
  78. 信息仅用于身份验证,聚联诚集团保障您的安全
  79. </view>
  80. <!-- 公告框 -->
  81. <view class="cu-modal" :class="modalName == 'VerifyModal' ? 'show' : ''">
  82. <view class="cu-dialog top">
  83. <view class="cu-bar bg-white justify-end">
  84. <view class="content">提示</view>
  85. <view class="action" @tap="hideModal">
  86. <text class="cuIcon-close yellow" />
  87. </view>
  88. </view>
  89. <view class="padding-xl">无法修改,若需修改请联系客服</view>
  90. </view>
  91. </view>
  92. <!-- 提示框 -->
  93. <view class="cu-modal" :class="modalName == 'promptModal' ? 'show' : ''">
  94. <view class="cu-dialog top">
  95. <view class="cu-bar bg-white justify-end">
  96. <view class="content">修改成功</view>
  97. <view class="action" @tap="toHome">
  98. <text class="cuIcon-close yellow" />
  99. </view>
  100. </view>
  101. <view class="padding-xl">
  102. 请前往首页上传征信报告
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import {
  110. mapState,
  111. mapMutations,
  112. mapGetters,
  113. mapActions
  114. } from 'vuex';
  115. import store from '@/store'
  116. export default {
  117. computed: {
  118. ...mapState(['user']),
  119. ...mapGetters({
  120. hasLogin: 'verifyJwt'
  121. })
  122. },
  123. data() {
  124. return {
  125. realname: '',
  126. card_number: '',
  127. phone: '',
  128. multiArray: [
  129. [],
  130. []
  131. ],
  132. multiIndex: [0, 0],
  133. tabindex: 0,
  134. ydindex: 0,
  135. firstid: '0',
  136. secondid: '0',
  137. thirdid: '0',
  138. dengswitchvalue: '',
  139. ktswitchvalue: '',
  140. card_front_img_url: '',
  141. card_back_img_url: '',
  142. partners: [],
  143. partner_index: 0,
  144. modalName: '',
  145. isinit: true,
  146. isshow: false,
  147. nickname: "",
  148. imglist: "",
  149. company_name: "请选择",
  150. areaname: "请选择"
  151. };
  152. },
  153. async onLoad(options) {
  154. await this.getUser(true);
  155. console.log(this.user)
  156. this.realname = this.user.realname;
  157. // this.card_number = this.user.card_number;
  158. this.phone = this.user.phone;
  159. this.partners = this.user.province_id;
  160. // this.card_front_img_url = this.user.card_front_img_url;
  161. // this.card_back_img_url = this.user.card_back_img_url;
  162. this.nickname = this.user.nickname
  163. this.imglist = this.user.avatar
  164. await this.getArea(0);
  165. if(this.multiArray[1][this.multiIndex[1]]){
  166. // 通过城市获取已填写的用户加盟商
  167. // this.gePartners(this.multiArray[1][this.multiIndex[1]].id, 2);
  168. }
  169. },
  170. methods: {
  171. ...mapActions({
  172. getUser: 'getUser' // 将 `this.getUser()` 映射为 `this.$store.dispatch('getUser')`
  173. }),
  174. ...mapMutations({
  175. setJwt: 'setJwt',
  176. login: 'login'
  177. }),
  178. toSearchUp(){
  179. uni.navigateTo({
  180. url: '/pages/login/bindUp'
  181. });
  182. },
  183. rest(index) {
  184. if (index != -1) {
  185. this.modalName = 'VerifyModal'
  186. }
  187. },
  188. toHome: function() {
  189. uni.switchTab({
  190. url: '/pages/index/index'
  191. })
  192. },
  193. VerifyPopup: function(data) {
  194. if (data) {
  195. this.modalName = 'VerifyModal'
  196. }
  197. },
  198. hideModal: function(e) {
  199. this.modalName = null;
  200. },
  201. userPhone: function(e) {
  202. this.phone = uni.getStorageSync('phone')
  203. },
  204. sutmit: function() {
  205. var that = this;
  206. // uni.login({
  207. // success: function(res) {
  208. // if (!res.code) {
  209. // uni.showModal({
  210. // title: '错误信息',
  211. // content: '修改失败',
  212. // showCancel: false
  213. // });
  214. // }
  215. // },
  216. // });
  217. that.requestRegister();
  218. },
  219. requestRegister: async function() {
  220. if (this.$util.isEmpty(this.realname)) {
  221. uni.showModal({
  222. title: '错误信息',
  223. content: '姓名必须填写',
  224. showCancel: false
  225. });
  226. return false;
  227. }
  228. // if (this.$util.isEmpty(this.card_number)) {
  229. // uni.showModal({
  230. // title: '错误信息',
  231. // content: '身份证号码必须填写',
  232. // showCancel: false
  233. // });
  234. // return false;
  235. // }
  236. if (!this.$util.isPhoneNumber(this.phone)) {
  237. uni.showModal({
  238. title: '错误信息',
  239. content: '请输入正确格式的手机号码',
  240. showCancel: false
  241. });
  242. return false;
  243. }
  244. // if (this.company_name == '请选择') {
  245. // uni.showToast({
  246. // title: "请选择合作商",
  247. // icon: "none",
  248. // })
  249. // return false
  250. // }
  251. // if (!this.$util.isIdCard(this.card_number)) {
  252. // uni.showModal({
  253. // title: '错误信息',
  254. // content: '请输入正确格式的身份证号',
  255. // showCancel: false
  256. // });
  257. // return false;
  258. // }
  259. console.log(this.partner_index)
  260. let res = await this.$request.post('/api/user/updateUser', {
  261. avatar: this.imglist,
  262. // nickname: this.nickname,
  263. realname: this.realname,
  264. // card_number: this.card_number,
  265. phone: this.phone,
  266. // card_front_img_url: this.card_front_img_url,
  267. // card_back_img_url: this.card_back_img_url,
  268. area_id: this.multiArray[1][this.multiIndex[1]].id,
  269. // partner_id: this.partners[this.partner_index].id
  270. // up_id: 0
  271. }, true);
  272. if (res.code === 200) {
  273. console.log(res)
  274. // uni.showToast({
  275. // title: '修改成功',
  276. // icon: 'success',
  277. // duration: 1000
  278. // });
  279. // this.setJwt(res.data.token);
  280. // this.getUser(true)
  281. // this.login();
  282. // this.modalName = 'promptModal'
  283. // setTimeout(() => {
  284. // uni.navigateBack({
  285. // delta: 1
  286. // });
  287. // this.modalName = ''
  288. // }, 1000);
  289. uni.reLaunch({
  290. url: './editinfo'
  291. })
  292. } else {
  293. uni.showModal({
  294. title: '错误信息',
  295. content: res.message,
  296. showCancel: false
  297. });
  298. }
  299. },
  300. bindPickerChange: function(e) {
  301. this.isshow = true
  302. this.partner_index = e.target.value;
  303. this.company_name = this.partners[this.partner_index].company_name
  304. },
  305. getArea: async function(parent_id) {
  306. let data = await this.$request.post('/api/common/areaList', {
  307. parent_id: parent_id
  308. });
  309. if (data.code == 200) {
  310. if (parent_id == 0) {
  311. // 默认获取所有省份
  312. this.$set(this.multiArray, 0, data.data);
  313. //console.log('multiArray==',this.multiArray)
  314. if (this.isinit && this.hasLogin && this.user.province_index > -1) {
  315. // 初始化用户省份
  316. this.$set(this.multiIndex, 0, this.user.province_index);
  317. }
  318. // 获取默认城市
  319. await this.getArea(this.multiArray[0][this.multiIndex[0]].id); // 获取城区
  320. } else {
  321. // 城区数组
  322. this.$set(this.multiArray, 1, data.data);
  323. if (this.isinit && this.hasLogin && this.user.city_index > -1) {
  324. // 初始化用户城市
  325. this.$set(this.multiIndex, 1, this.user.city_index);
  326. }
  327. }
  328. if (this.user.city_index != -1 && this.user.province_index != -1) {
  329. this.areaname = this.multiArray[0][this.multiIndex[0]].name + ',' +
  330. (
  331. this.multiArray[1][this.multiIndex[1]] ? this.multiArray[1][this.multiIndex[1]].name : ''
  332. )
  333. }
  334. } else {
  335. uni.showToast({
  336. icon: 'none',
  337. title: data.message
  338. });
  339. }
  340. },
  341. gePartners: async function(area_id, level) {
  342. let data = await this.$request.post('/api/common/partnerList', {
  343. area_id: area_id,
  344. level: 2
  345. });
  346. if (data.code == 200) {
  347. console.log(data)
  348. this.partners = data.data;
  349. if (this.isinit && this.hasLogin && this.user.partner_index > -1) {
  350. this.partner_index = this.user.partner_index;
  351. this.company_name = this.partners[this.partner_index].company_name
  352. this.isinit = false;
  353. }
  354. } else {
  355. uni.showToast({
  356. icon: 'none',
  357. title: data.message
  358. });
  359. }
  360. },
  361. cancel() {
  362. uni.navigateBack()
  363. },
  364. bindMultiPickerChange(e) {
  365. console.log('地区确认==', e)
  366. this.multiIndex = e.detail.value;
  367. this.areaname = this.multiArray[0][this.multiIndex[0]].name + ',' + this.multiArray[1][this.multiIndex[1]]
  368. .name
  369. this.gePartners(this.multiArray[1][this.multiIndex[1]].id, 2);
  370. },
  371. bindMultiPickerColumnChange(e) {
  372. console.log('地区联动==', e)
  373. this.partners = [] // 清空加盟商
  374. this.partner_index = -1 // 改变了地区需要重新选择加盟商
  375. this.company_name = "请选择"
  376. if (e.detail.column == 0) { // 0省份
  377. this.$set(this.multiIndex, 1, 0);
  378. this.$set(this.multiIndex, e.detail.column, e.detail.value);
  379. this.getArea(this.multiArray[0][this.multiIndex[0]].id);
  380. } else { //1城市
  381. this.$set(this.multiIndex, e.detail.column, e.detail.value);
  382. }
  383. },
  384. ChooseImage() {
  385. let me = this;
  386. uni.chooseImage({
  387. sourceType: ['camera', 'album'],
  388. // #ifdef MP-WEIXIN
  389. sizeType: ['original'],
  390. // #endif
  391. count: 1,
  392. success: async function(res) {
  393. let data = await me.$request.upload('api/common/uploadImg', res.tempFilePaths[0], {});
  394. if (data.code == 200) {
  395. me.imglist = data.data.file_url;
  396. } else {
  397. uni.showToast({
  398. icon: 'none',
  399. title: data.message
  400. });
  401. }
  402. }
  403. });
  404. },
  405. // 正面上传
  406. BeforeUpload() {
  407. if (this.card_front_img_url) {
  408. this.modalName = 'VerifyModal'
  409. return;
  410. }
  411. let me = this;
  412. uni.chooseImage({
  413. sourceType: ['camera', 'album'],
  414. // #ifdef MP-WEIXIN
  415. sizeType: ['original'],
  416. // #endif
  417. count: 1,
  418. success: async function(res) {
  419. let data = await me.$request.upload('/api/common/uploadImg', res.tempFilePaths[0], {});
  420. if (data.code == 200) {
  421. me.card_front_img_url = data.data.file_url;
  422. } else {
  423. uni.showToast({
  424. icon: 'none',
  425. title: data.message
  426. });
  427. }
  428. }
  429. });
  430. },
  431. // 反面上传
  432. AfterUpload() {
  433. if (this.card_back_img_url) {
  434. this.modalName = 'VerifyModal'
  435. return;
  436. }
  437. let me = this;
  438. uni.chooseImage({
  439. sourceType: ['camera', 'album'],
  440. // #ifdef MP-WEIXIN
  441. sizeType: ['original'],
  442. // #endif
  443. count: 1,
  444. success: async function(res) {
  445. let data = await me.$request.upload('/api/common/uploadImg', res.tempFilePaths[0], {})
  446. if (data.code == 200) {
  447. me.card_back_img_url = data.data.file_url;
  448. } else {
  449. uni.showToast({
  450. icon: 'none',
  451. title: data.message
  452. });
  453. }
  454. }
  455. });
  456. }
  457. }
  458. };
  459. </script>
  460. <style>
  461. page {
  462. background: #f5f5f5;
  463. }
  464. .main {
  465. width: 100vw;
  466. height: 100vh;
  467. background: #FFFFFF;
  468. }
  469. .user-img {
  470. height: 300rpx;
  471. }
  472. .user-avatar {
  473. width: 200rpx;
  474. height: 200rpx;
  475. border-radius: 50%;
  476. }
  477. .input-container {
  478. width: 100%;
  479. padding: 0 30rpx;
  480. margin: 15px 0;
  481. }
  482. .input-border {
  483. width: 100%;
  484. height: 90rpx;
  485. padding: 0 30rpx 0 40rpx;
  486. box-shadow: 6rpx 6rpx 8rpx rgba(26, 26, 26, 0.2);
  487. display: flex;
  488. align-items: center;
  489. }
  490. .label {
  491. width: 25%;
  492. font-size: 30rpx;
  493. }
  494. .submit {
  495. width: 100%;
  496. height: 70rpx;
  497. line-height: 70rpx;
  498. background: #f5cc57;
  499. color: #fff;
  500. margin-top: 200rpx;
  501. text-align: center;
  502. border-radius: 50rpx;
  503. }
  504. /* */
  505. .line {
  506. width: 100vw;
  507. height: 110rpx;
  508. line-height: 110rpx;
  509. padding: 5px 15px;
  510. border-bottom: 1px solid #eee;
  511. background: #fff;
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. }
  516. .line .name,
  517. .IdCardUpload .name {
  518. width: 27%;
  519. height: 50rpx;
  520. line-height: 50rpx;
  521. font-size: 32rpx;
  522. font-weight: 300;
  523. font-family: PingFangSC-Regular, sans-serif;
  524. color: #555864;
  525. }
  526. .line .input {
  527. width: 72%;
  528. height: 40px;
  529. line-height: 40px;
  530. }
  531. .line .inputs {
  532. display: flex;
  533. justify-content: space-around;
  534. align-items: center;
  535. }
  536. .input-item {
  537. width: 100%;
  538. height: 100%;
  539. font-size: 32rpx;
  540. font-family: PingFangSC-Regular, sans-serif;
  541. font-weight: 300;
  542. color: rgba(143, 143, 144, 1);
  543. }
  544. .yellowBtn {
  545. width: 296rpx;
  546. color: #FFFFFF !important;
  547. background: #f5cc57 !important;
  548. }
  549. picker {
  550. width: 80%;
  551. }
  552. .picker {
  553. width: 100%;
  554. height: auto;
  555. display: flex;
  556. justify-content: space-between;
  557. align-items: center;
  558. flex: 1;
  559. }
  560. .picker .energy {
  561. font-size: 30rpx;
  562. font-family: PingFangSC-Regular, sans-serif;
  563. font-weight: 300;
  564. color: rgba(143, 143, 144, 1);
  565. }
  566. .quxiao,
  567. .sub {
  568. width: auto;
  569. height: 40px;
  570. line-height: 40px;
  571. padding: 0 20px;
  572. float: right;
  573. border-radius: 5px;
  574. }
  575. .foot-btn {
  576. display: flex;
  577. justify-content: center;
  578. align-items: center;
  579. }
  580. .foot-btn .sub {
  581. background: #f5cc57;
  582. color: #fff;
  583. margin: 10px;
  584. }
  585. .foot-btn .quxiao {
  586. border: 1px solid #979797;
  587. color: #979797;
  588. margin: 10px;
  589. }
  590. .footer {
  591. position: absolute;
  592. bottom: 0;
  593. width: 100%;
  594. text-align: center;
  595. font-size: 24rpx;
  596. padding: 30rpx 0;
  597. }
  598. .IdCardUpload {
  599. width: 100vw;
  600. height: 180rpx;
  601. line-height: 180rpx;
  602. padding: 5px 15px;
  603. border-bottom: 1px solid #eee;
  604. background: #fff;
  605. display: flex;
  606. justify-content: space-between;
  607. align-items: center;
  608. }
  609. .IdCardUpload .IdCardImg {
  610. width: 100%;
  611. height: 100%;
  612. display: flex;
  613. justify-content: space-around;
  614. align-items: center;
  615. }
  616. .IdCardUpload .IdCardImg .imgBefore,
  617. .imgAfter {
  618. position: relative;
  619. width: 16.2vh;
  620. height: 8.2vh;
  621. line-height: 8.2vh;
  622. background-color: #f5f5f5;
  623. border: 1px solid #979797;
  624. text-align: center;
  625. font-size: 30px;
  626. border-radius: 8px;
  627. color: #f5cc57;
  628. }
  629. .imgBefore .imgBefore-btn,
  630. .imgAfter .imgAfter-btn {
  631. position: absolute;
  632. top: 12px;
  633. left: 44px;
  634. z-index: 1;
  635. width: 30px;
  636. height: 30px;
  637. border-radius: 50%;
  638. font-size: 20px;
  639. font-weight: 600;
  640. border: 2px solid #f5cc57;
  641. display: flex;
  642. justify-content: center;
  643. align-items: center;
  644. }
  645. .idCardBefore {
  646. position: absolute;
  647. width: 130rpx;
  648. height: 50rpx;
  649. top: 14px;
  650. left: 20px;
  651. }
  652. .idCardAfter {
  653. position: absolute;
  654. width: 130rpx;
  655. height: 50rpx;
  656. top: 14px;
  657. left: 20px;
  658. z-index: 0;
  659. }
  660. .energy {
  661. display: flex;
  662. align-items: center;
  663. }
  664. .yellow {
  665. color: #f5cc57;
  666. }
  667. .yellowBg {
  668. background: #f5cc57 !important;
  669. }
  670. .greyBg {
  671. background: grey !important;
  672. }
  673. .maring-top {
  674. margin-top: 15px;
  675. }
  676. </style>